echarts.js 1.9 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208
  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__(99);
  51. __webpack_require__(133);
  52. __webpack_require__(138);
  53. __webpack_require__(147);
  54. __webpack_require__(151);
  55. __webpack_require__(161);
  56. __webpack_require__(182);
  57. __webpack_require__(194);
  58. __webpack_require__(215);
  59. __webpack_require__(219);
  60. __webpack_require__(223);
  61. __webpack_require__(238);
  62. __webpack_require__(244);
  63. __webpack_require__(251);
  64. __webpack_require__(257);
  65. __webpack_require__(261);
  66. __webpack_require__(269);
  67. __webpack_require__(112);
  68. __webpack_require__(273);
  69. __webpack_require__(279);
  70. __webpack_require__(283);
  71. __webpack_require__(294);
  72. __webpack_require__(224);
  73. __webpack_require__(297);
  74. __webpack_require__(303);
  75. __webpack_require__(315);
  76. __webpack_require__(316);
  77. __webpack_require__(329);
  78. __webpack_require__(344);
  79. __webpack_require__(350);
  80. __webpack_require__(353);
  81. __webpack_require__(356);
  82. __webpack_require__(365);
  83. __webpack_require__(378);
  84. /***/ },
  85. /* 1 */
  86. /***/ function(module, exports, __webpack_require__) {
  87. // Enable DEV mode when using source code without build. which has no __DEV__ variable
  88. // In build process 'typeof __DEV__' will be replace with 'boolean'
  89. // So this code will be removed or disabled anyway after built.
  90. if (false) {
  91. // In browser
  92. if (typeof window !== 'undefined') {
  93. window.__DEV__ = true;
  94. }
  95. // In node
  96. else if (typeof global !== 'undefined') {
  97. global.__DEV__ = true;
  98. }
  99. }
  100. /*!
  101. * ECharts, a javascript interactive chart library.
  102. *
  103. * Copyright (c) 2015, Baidu Inc.
  104. * All rights reserved.
  105. *
  106. * LICENSE
  107. * https://github.com/ecomfe/echarts/blob/master/LICENSE.txt
  108. */
  109. /**
  110. * @module echarts
  111. */
  112. var env = __webpack_require__(2);
  113. var GlobalModel = __webpack_require__(3);
  114. var ExtensionAPI = __webpack_require__(25);
  115. var CoordinateSystemManager = __webpack_require__(26);
  116. var OptionManager = __webpack_require__(27);
  117. var ComponentModel = __webpack_require__(19);
  118. var SeriesModel = __webpack_require__(28);
  119. var ComponentView = __webpack_require__(29);
  120. var ChartView = __webpack_require__(42);
  121. var graphic = __webpack_require__(43);
  122. var zrender = __webpack_require__(81);
  123. var zrUtil = __webpack_require__(4);
  124. var colorTool = __webpack_require__(39);
  125. var Eventful = __webpack_require__(33);
  126. var timsort = __webpack_require__(85);
  127. var each = zrUtil.each;
  128. var PRIORITY_PROCESSOR_FILTER = 1000;
  129. var PRIORITY_PROCESSOR_STATISTIC = 5000;
  130. var PRIORITY_VISUAL_LAYOUT = 1000;
  131. var PRIORITY_VISUAL_GLOBAL = 2000;
  132. var PRIORITY_VISUAL_CHART = 3000;
  133. var PRIORITY_VISUAL_COMPONENT = 4000;
  134. var PRIORITY_VISUAL_BRUSH = 5000;
  135. // Main process have three entries: `setOption`, `dispatchAction` and `resize`,
  136. // where they must not be invoked nestedly, except the only case: invoke
  137. // dispatchAction with updateMethod "none" in main process.
  138. // This flag is used to carry out this rule.
  139. // All events will be triggered out side main process (i.e. when !this[IN_MAIN_PROCESS]).
  140. var IN_MAIN_PROCESS = '__flag_in_main_process';
  141. var HAS_GRADIENT_OR_PATTERN_BG = '_hasGradientOrPatternBg';
  142. function createRegisterEventWithLowercaseName(method) {
  143. return function (eventName, handler, context) {
  144. // Event name is all lowercase
  145. eventName = eventName && eventName.toLowerCase();
  146. Eventful.prototype[method].call(this, eventName, handler, context);
  147. };
  148. }
  149. /**
  150. * @module echarts~MessageCenter
  151. */
  152. function MessageCenter() {
  153. Eventful.call(this);
  154. }
  155. MessageCenter.prototype.on = createRegisterEventWithLowercaseName('on');
  156. MessageCenter.prototype.off = createRegisterEventWithLowercaseName('off');
  157. MessageCenter.prototype.one = createRegisterEventWithLowercaseName('one');
  158. zrUtil.mixin(MessageCenter, Eventful);
  159. /**
  160. * @module echarts~ECharts
  161. */
  162. function ECharts (dom, theme, opts) {
  163. opts = opts || {};
  164. // Get theme by name
  165. if (typeof theme === 'string') {
  166. theme = themeStorage[theme];
  167. }
  168. /**
  169. * @type {string}
  170. */
  171. this.id;
  172. /**
  173. * Group id
  174. * @type {string}
  175. */
  176. this.group;
  177. /**
  178. * @type {HTMLDomElement}
  179. * @private
  180. */
  181. this._dom = dom;
  182. /**
  183. * @type {module:zrender/ZRender}
  184. * @private
  185. */
  186. this._zr = zrender.init(dom, {
  187. renderer: opts.renderer || 'canvas',
  188. devicePixelRatio: opts.devicePixelRatio
  189. });
  190. /**
  191. * @type {Object}
  192. * @private
  193. */
  194. this._theme = zrUtil.clone(theme);
  195. /**
  196. * @type {Array.<module:echarts/view/Chart>}
  197. * @private
  198. */
  199. this._chartsViews = [];
  200. /**
  201. * @type {Object.<string, module:echarts/view/Chart>}
  202. * @private
  203. */
  204. this._chartsMap = {};
  205. /**
  206. * @type {Array.<module:echarts/view/Component>}
  207. * @private
  208. */
  209. this._componentsViews = [];
  210. /**
  211. * @type {Object.<string, module:echarts/view/Component>}
  212. * @private
  213. */
  214. this._componentsMap = {};
  215. /**
  216. * @type {module:echarts/ExtensionAPI}
  217. * @private
  218. */
  219. this._api = new ExtensionAPI(this);
  220. /**
  221. * @type {module:echarts/CoordinateSystem}
  222. * @private
  223. */
  224. this._coordSysMgr = new CoordinateSystemManager();
  225. Eventful.call(this);
  226. /**
  227. * @type {module:echarts~MessageCenter}
  228. * @private
  229. */
  230. this._messageCenter = new MessageCenter();
  231. // Init mouse events
  232. this._initEvents();
  233. // In case some people write `window.onresize = chart.resize`
  234. this.resize = zrUtil.bind(this.resize, this);
  235. // Can't dispatch action during rendering procedure
  236. this._pendingActions = [];
  237. // Sort on demand
  238. function prioritySortFunc(a, b) {
  239. return a.prio - b.prio;
  240. }
  241. timsort(visualFuncs, prioritySortFunc);
  242. timsort(dataProcessorFuncs, prioritySortFunc);
  243. }
  244. var echartsProto = ECharts.prototype;
  245. /**
  246. * @return {HTMLDomElement}
  247. */
  248. echartsProto.getDom = function () {
  249. return this._dom;
  250. };
  251. /**
  252. * @return {module:zrender~ZRender}
  253. */
  254. echartsProto.getZr = function () {
  255. return this._zr;
  256. };
  257. /**
  258. * @param {Object} option
  259. * @param {boolean} notMerge
  260. * @param {boolean} [notRefreshImmediately=false] Useful when setOption frequently.
  261. */
  262. echartsProto.setOption = function (option, notMerge, notRefreshImmediately) {
  263. if (true) {
  264. zrUtil.assert(!this[IN_MAIN_PROCESS], '`setOption` should not be called during main process.');
  265. }
  266. this[IN_MAIN_PROCESS] = true;
  267. if (!this._model || notMerge) {
  268. var optionManager = new OptionManager(this._api);
  269. var theme = this._theme;
  270. var ecModel = this._model = new GlobalModel(null, null, theme, optionManager);
  271. ecModel.init(null, null, theme, optionManager);
  272. }
  273. this._model.setOption(option, optionPreprocessorFuncs);
  274. updateMethods.prepareAndUpdate.call(this);
  275. this[IN_MAIN_PROCESS] = false;
  276. this._flushPendingActions();
  277. !notRefreshImmediately && this._zr.refreshImmediately();
  278. };
  279. /**
  280. * @DEPRECATED
  281. */
  282. echartsProto.setTheme = function () {
  283. console.log('ECharts#setTheme() is DEPRECATED in ECharts 3.0');
  284. };
  285. /**
  286. * @return {module:echarts/model/Global}
  287. */
  288. echartsProto.getModel = function () {
  289. return this._model;
  290. };
  291. /**
  292. * @return {Object}
  293. */
  294. echartsProto.getOption = function () {
  295. return this._model.getOption();
  296. };
  297. /**
  298. * @return {number}
  299. */
  300. echartsProto.getWidth = function () {
  301. return this._zr.getWidth();
  302. };
  303. /**
  304. * @return {number}
  305. */
  306. echartsProto.getHeight = function () {
  307. return this._zr.getHeight();
  308. };
  309. /**
  310. * Get canvas which has all thing rendered
  311. * @param {Object} opts
  312. * @param {string} [opts.backgroundColor]
  313. */
  314. echartsProto.getRenderedCanvas = function (opts) {
  315. if (!env.canvasSupported) {
  316. return;
  317. }
  318. opts = opts || {};
  319. opts.pixelRatio = opts.pixelRatio || 1;
  320. opts.backgroundColor = opts.backgroundColor
  321. || this._model.get('backgroundColor');
  322. var zr = this._zr;
  323. var list = zr.storage.getDisplayList();
  324. // Stop animations
  325. zrUtil.each(list, function (el) {
  326. el.stopAnimation(true);
  327. });
  328. return zr.painter.getRenderedCanvas(opts);
  329. };
  330. /**
  331. * @return {string}
  332. * @param {Object} opts
  333. * @param {string} [opts.type='png']
  334. * @param {string} [opts.pixelRatio=1]
  335. * @param {string} [opts.backgroundColor]
  336. */
  337. echartsProto.getDataURL = function (opts) {
  338. opts = opts || {};
  339. var excludeComponents = opts.excludeComponents;
  340. var ecModel = this._model;
  341. var excludesComponentViews = [];
  342. var self = this;
  343. each(excludeComponents, function (componentType) {
  344. ecModel.eachComponent({
  345. mainType: componentType
  346. }, function (component) {
  347. var view = self._componentsMap[component.__viewId];
  348. if (!view.group.ignore) {
  349. excludesComponentViews.push(view);
  350. view.group.ignore = true;
  351. }
  352. });
  353. });
  354. var url = this.getRenderedCanvas(opts).toDataURL(
  355. 'image/' + (opts && opts.type || 'png')
  356. );
  357. each(excludesComponentViews, function (view) {
  358. view.group.ignore = false;
  359. });
  360. return url;
  361. };
  362. /**
  363. * @return {string}
  364. * @param {Object} opts
  365. * @param {string} [opts.type='png']
  366. * @param {string} [opts.pixelRatio=1]
  367. * @param {string} [opts.backgroundColor]
  368. */
  369. echartsProto.getConnectedDataURL = function (opts) {
  370. if (!env.canvasSupported) {
  371. return;
  372. }
  373. var groupId = this.group;
  374. var mathMin = Math.min;
  375. var mathMax = Math.max;
  376. var MAX_NUMBER = Infinity;
  377. if (connectedGroups[groupId]) {
  378. var left = MAX_NUMBER;
  379. var top = MAX_NUMBER;
  380. var right = -MAX_NUMBER;
  381. var bottom = -MAX_NUMBER;
  382. var canvasList = [];
  383. var dpr = (opts && opts.pixelRatio) || 1;
  384. for (var id in instances) {
  385. var chart = instances[id];
  386. if (chart.group === groupId) {
  387. var canvas = chart.getRenderedCanvas(
  388. zrUtil.clone(opts)
  389. );
  390. var boundingRect = chart.getDom().getBoundingClientRect();
  391. left = mathMin(boundingRect.left, left);
  392. top = mathMin(boundingRect.top, top);
  393. right = mathMax(boundingRect.right, right);
  394. bottom = mathMax(boundingRect.bottom, bottom);
  395. canvasList.push({
  396. dom: canvas,
  397. left: boundingRect.left,
  398. top: boundingRect.top
  399. });
  400. }
  401. }
  402. left *= dpr;
  403. top *= dpr;
  404. right *= dpr;
  405. bottom *= dpr;
  406. var width = right - left;
  407. var height = bottom - top;
  408. var targetCanvas = zrUtil.createCanvas();
  409. targetCanvas.width = width;
  410. targetCanvas.height = height;
  411. var zr = zrender.init(targetCanvas);
  412. each(canvasList, function (item) {
  413. var img = new graphic.Image({
  414. style: {
  415. x: item.left * dpr - left,
  416. y: item.top * dpr - top,
  417. image: item.dom
  418. }
  419. });
  420. zr.add(img);
  421. });
  422. zr.refreshImmediately();
  423. return targetCanvas.toDataURL('image/' + (opts && opts.type || 'png'));
  424. }
  425. else {
  426. return this.getDataURL(opts);
  427. }
  428. };
  429. var updateMethods = {
  430. /**
  431. * @param {Object} payload
  432. * @private
  433. */
  434. update: function (payload) {
  435. // console.time && console.time('update');
  436. var ecModel = this._model;
  437. var api = this._api;
  438. var coordSysMgr = this._coordSysMgr;
  439. var zr = this._zr;
  440. // update before setOption
  441. if (!ecModel) {
  442. return;
  443. }
  444. // Fixme First time update ?
  445. ecModel.restoreData();
  446. // TODO
  447. // Save total ecModel here for undo/redo (after restoring data and before processing data).
  448. // Undo (restoration of total ecModel) can be carried out in 'action' or outside API call.
  449. // Create new coordinate system each update
  450. // In LineView may save the old coordinate system and use it to get the orignal point
  451. coordSysMgr.create(this._model, this._api);
  452. processData.call(this, ecModel, api);
  453. stackSeriesData.call(this, ecModel);
  454. coordSysMgr.update(ecModel, api);
  455. doVisualEncoding.call(this, ecModel, payload);
  456. doRender.call(this, ecModel, payload);
  457. // Set background
  458. var backgroundColor = ecModel.get('backgroundColor') || 'transparent';
  459. var painter = zr.painter;
  460. // TODO all use clearColor ?
  461. if (painter.isSingleCanvas && painter.isSingleCanvas()) {
  462. zr.configLayer(0, {
  463. clearColor: backgroundColor
  464. });
  465. }
  466. else {
  467. // In IE8
  468. if (!env.canvasSupported) {
  469. var colorArr = colorTool.parse(backgroundColor);
  470. backgroundColor = colorTool.stringify(colorArr, 'rgb');
  471. if (colorArr[3] === 0) {
  472. backgroundColor = 'transparent';
  473. }
  474. }
  475. if (backgroundColor.colorStops || backgroundColor.image) {
  476. // Gradient background
  477. // FIXME Fixed layer?
  478. zr.configLayer(0, {
  479. clearColor: backgroundColor
  480. });
  481. this[HAS_GRADIENT_OR_PATTERN_BG] = true;
  482. this._dom.style.background = 'transparent';
  483. }
  484. else {
  485. if (this[HAS_GRADIENT_OR_PATTERN_BG]) {
  486. zr.configLayer(0, {
  487. clearColor: null
  488. });
  489. }
  490. this[HAS_GRADIENT_OR_PATTERN_BG] = false;
  491. this._dom.style.background = backgroundColor;
  492. }
  493. }
  494. // console.time && console.timeEnd('update');
  495. },
  496. // PENDING
  497. /**
  498. * @param {Object} payload
  499. * @private
  500. */
  501. updateView: function (payload) {
  502. var ecModel = this._model;
  503. // update before setOption
  504. if (!ecModel) {
  505. return;
  506. }
  507. ecModel.eachSeries(function (seriesModel) {
  508. seriesModel.getData().clearAllVisual();
  509. });
  510. doVisualEncoding.call(this, ecModel, payload);
  511. invokeUpdateMethod.call(this, 'updateView', ecModel, payload);
  512. },
  513. /**
  514. * @param {Object} payload
  515. * @private
  516. */
  517. updateVisual: function (payload) {
  518. var ecModel = this._model;
  519. // update before setOption
  520. if (!ecModel) {
  521. return;
  522. }
  523. ecModel.eachSeries(function (seriesModel) {
  524. seriesModel.getData().clearAllVisual();
  525. });
  526. doVisualEncoding.call(this, ecModel, payload);
  527. invokeUpdateMethod.call(this, 'updateVisual', ecModel, payload);
  528. },
  529. /**
  530. * @param {Object} payload
  531. * @private
  532. */
  533. updateLayout: function (payload) {
  534. var ecModel = this._model;
  535. // update before setOption
  536. if (!ecModel) {
  537. return;
  538. }
  539. doLayout.call(this, ecModel, payload);
  540. invokeUpdateMethod.call(this, 'updateLayout', ecModel, payload);
  541. },
  542. /**
  543. * @param {Object} payload
  544. * @private
  545. */
  546. highlight: function (payload) {
  547. toggleHighlight.call(this, 'highlight', payload);
  548. },
  549. /**
  550. * @param {Object} payload
  551. * @private
  552. */
  553. downplay: function (payload) {
  554. toggleHighlight.call(this, 'downplay', payload);
  555. },
  556. /**
  557. * @param {Object} payload
  558. * @private
  559. */
  560. prepareAndUpdate: function (payload) {
  561. var ecModel = this._model;
  562. prepareView.call(this, 'component', ecModel);
  563. prepareView.call(this, 'chart', ecModel);
  564. updateMethods.update.call(this, payload);
  565. }
  566. };
  567. /**
  568. * @param {Object} payload
  569. * @private
  570. */
  571. function toggleHighlight(method, payload) {
  572. var ecModel = this._model;
  573. // dispatchAction before setOption
  574. if (!ecModel) {
  575. return;
  576. }
  577. ecModel.eachComponent(
  578. {mainType: 'series', query: payload},
  579. function (seriesModel, index) {
  580. var chartView = this._chartsMap[seriesModel.__viewId];
  581. if (chartView && chartView.__alive) {
  582. chartView[method](
  583. seriesModel, ecModel, this._api, payload
  584. );
  585. }
  586. },
  587. this
  588. );
  589. }
  590. /**
  591. * Resize the chart
  592. */
  593. echartsProto.resize = function () {
  594. if (true) {
  595. zrUtil.assert(!this[IN_MAIN_PROCESS], '`resize` should not be called during main process.');
  596. }
  597. this[IN_MAIN_PROCESS] = true;
  598. this._zr.resize();
  599. var optionChanged = this._model && this._model.resetOption('media');
  600. updateMethods[optionChanged ? 'prepareAndUpdate' : 'update'].call(this);
  601. // Resize loading effect
  602. this._loadingFX && this._loadingFX.resize();
  603. this[IN_MAIN_PROCESS] = false;
  604. this._flushPendingActions();
  605. };
  606. var defaultLoadingEffect = __webpack_require__(93);
  607. /**
  608. * Show loading effect
  609. * @param {string} [name='default']
  610. * @param {Object} [cfg]
  611. */
  612. echartsProto.showLoading = function (name, cfg) {
  613. if (zrUtil.isObject(name)) {
  614. cfg = name;
  615. name = 'default';
  616. }
  617. this.hideLoading();
  618. var el = defaultLoadingEffect(this._api, cfg);
  619. var zr = this._zr;
  620. this._loadingFX = el;
  621. zr.add(el);
  622. };
  623. /**
  624. * Hide loading effect
  625. */
  626. echartsProto.hideLoading = function () {
  627. this._loadingFX && this._zr.remove(this._loadingFX);
  628. this._loadingFX = null;
  629. };
  630. /**
  631. * @param {Object} eventObj
  632. * @return {Object}
  633. */
  634. echartsProto.makeActionFromEvent = function (eventObj) {
  635. var payload = zrUtil.extend({}, eventObj);
  636. payload.type = eventActionMap[eventObj.type];
  637. return payload;
  638. };
  639. /**
  640. * @pubilc
  641. * @param {Object} payload
  642. * @param {string} [payload.type] Action type
  643. * @param {boolean} [silent=false] Whether trigger event.
  644. */
  645. echartsProto.dispatchAction = function (payload, silent) {
  646. var actionWrap = actions[payload.type];
  647. if (!actionWrap) {
  648. return;
  649. }
  650. var actionInfo = actionWrap.actionInfo;
  651. var updateMethod = actionInfo.update || 'update';
  652. // if (__DEV__) {
  653. // zrUtil.assert(
  654. // !this[IN_MAIN_PROCESS],
  655. // '`dispatchAction` should not be called during main process.'
  656. // + 'unless updateMathod is "none".'
  657. // );
  658. // }
  659. // May dispatchAction in rendering procedure
  660. if (this[IN_MAIN_PROCESS]) {
  661. this._pendingActions.push(payload);
  662. return;
  663. }
  664. this[IN_MAIN_PROCESS] = true;
  665. var payloads = [payload];
  666. var batched = false;
  667. // Batch action
  668. if (payload.batch) {
  669. batched = true;
  670. payloads = zrUtil.map(payload.batch, function (item) {
  671. item = zrUtil.defaults(zrUtil.extend({}, item), payload);
  672. item.batch = null;
  673. return item;
  674. });
  675. }
  676. var eventObjBatch = [];
  677. var eventObj;
  678. var isHighlightOrDownplay = payload.type === 'highlight' || payload.type === 'downplay';
  679. for (var i = 0; i < payloads.length; i++) {
  680. var batchItem = payloads[i];
  681. // Action can specify the event by return it.
  682. eventObj = actionWrap.action(batchItem, this._model);
  683. // Emit event outside
  684. eventObj = eventObj || zrUtil.extend({}, batchItem);
  685. // Convert type to eventType
  686. eventObj.type = actionInfo.event || eventObj.type;
  687. eventObjBatch.push(eventObj);
  688. // Highlight and downplay are special.
  689. isHighlightOrDownplay && updateMethods[updateMethod].call(this, batchItem);
  690. }
  691. (updateMethod !== 'none' && !isHighlightOrDownplay)
  692. && updateMethods[updateMethod].call(this, payload);
  693. // Follow the rule of action batch
  694. if (batched) {
  695. eventObj = {
  696. type: actionInfo.event || payload.type,
  697. batch: eventObjBatch
  698. };
  699. }
  700. else {
  701. eventObj = eventObjBatch[0];
  702. }
  703. this[IN_MAIN_PROCESS] = false;
  704. !silent && this._messageCenter.trigger(eventObj.type, eventObj);
  705. this._flushPendingActions();
  706. };
  707. echartsProto._flushPendingActions = function () {
  708. var pendingActions = this._pendingActions;
  709. while (pendingActions.length) {
  710. var payload = pendingActions.shift();
  711. this.dispatchAction(payload);
  712. }
  713. };
  714. /**
  715. * Register event
  716. * @method
  717. */
  718. echartsProto.on = createRegisterEventWithLowercaseName('on');
  719. echartsProto.off = createRegisterEventWithLowercaseName('off');
  720. echartsProto.one = createRegisterEventWithLowercaseName('one');
  721. /**
  722. * @param {string} methodName
  723. * @private
  724. */
  725. function invokeUpdateMethod(methodName, ecModel, payload) {
  726. var api = this._api;
  727. // Update all components
  728. each(this._componentsViews, function (component) {
  729. var componentModel = component.__model;
  730. component[methodName](componentModel, ecModel, api, payload);
  731. updateZ(componentModel, component);
  732. }, this);
  733. // Upate all charts
  734. ecModel.eachSeries(function (seriesModel, idx) {
  735. var chart = this._chartsMap[seriesModel.__viewId];
  736. chart[methodName](seriesModel, ecModel, api, payload);
  737. updateZ(seriesModel, chart);
  738. updateProgressiveAndBlend(seriesModel, chart);
  739. }, this);
  740. // If use hover layer
  741. updateHoverLayerStatus(this._zr, ecModel);
  742. }
  743. /**
  744. * Prepare view instances of charts and components
  745. * @param {module:echarts/model/Global} ecModel
  746. * @private
  747. */
  748. function prepareView(type, ecModel) {
  749. var isComponent = type === 'component';
  750. var viewList = isComponent ? this._componentsViews : this._chartsViews;
  751. var viewMap = isComponent ? this._componentsMap : this._chartsMap;
  752. var zr = this._zr;
  753. for (var i = 0; i < viewList.length; i++) {
  754. viewList[i].__alive = false;
  755. }
  756. ecModel[isComponent ? 'eachComponent' : 'eachSeries'](function (componentType, model) {
  757. if (isComponent) {
  758. if (componentType === 'series') {
  759. return;
  760. }
  761. }
  762. else {
  763. model = componentType;
  764. }
  765. // Consider: id same and type changed.
  766. var viewId = model.id + '_' + model.type;
  767. var view = viewMap[viewId];
  768. if (!view) {
  769. var classType = ComponentModel.parseClassType(model.type);
  770. var Clazz = isComponent
  771. ? ComponentView.getClass(classType.main, classType.sub)
  772. : ChartView.getClass(classType.sub);
  773. if (Clazz) {
  774. view = new Clazz();
  775. view.init(ecModel, this._api);
  776. viewMap[viewId] = view;
  777. viewList.push(view);
  778. zr.add(view.group);
  779. }
  780. else {
  781. // Error
  782. return;
  783. }
  784. }
  785. model.__viewId = viewId;
  786. view.__alive = true;
  787. view.__id = viewId;
  788. view.__model = model;
  789. }, this);
  790. for (var i = 0; i < viewList.length;) {
  791. var view = viewList[i];
  792. if (!view.__alive) {
  793. zr.remove(view.group);
  794. view.dispose(ecModel, this._api);
  795. viewList.splice(i, 1);
  796. delete viewMap[view.__id];
  797. }
  798. else {
  799. i++;
  800. }
  801. }
  802. }
  803. /**
  804. * Processor data in each series
  805. *
  806. * @param {module:echarts/model/Global} ecModel
  807. * @private
  808. */
  809. function processData(ecModel, api) {
  810. each(dataProcessorFuncs, function (process) {
  811. process.func(ecModel, api);
  812. });
  813. }
  814. /**
  815. * @private
  816. */
  817. function stackSeriesData(ecModel) {
  818. var stackedDataMap = {};
  819. ecModel.eachSeries(function (series) {
  820. var stack = series.get('stack');
  821. var data = series.getData();
  822. if (stack && data.type === 'list') {
  823. var previousStack = stackedDataMap[stack];
  824. if (previousStack) {
  825. data.stackedOn = previousStack;
  826. }
  827. stackedDataMap[stack] = data;
  828. }
  829. });
  830. }
  831. /**
  832. * Layout before each chart render there series, special visual encoding stage
  833. *
  834. * @param {module:echarts/model/Global} ecModel
  835. * @private
  836. */
  837. function doLayout(ecModel, payload) {
  838. var api = this._api;
  839. each(visualFuncs, function (visual) {
  840. if (visual.isLayout) {
  841. visual.func(ecModel, api, payload);
  842. }
  843. });
  844. }
  845. /**
  846. * Encode visual infomation from data after data processing
  847. *
  848. * @param {module:echarts/model/Global} ecModel
  849. * @private
  850. */
  851. function doVisualEncoding(ecModel, payload) {
  852. var api = this._api;
  853. ecModel.clearColorPalette();
  854. ecModel.eachSeries(function (seriesModel) {
  855. seriesModel.clearColorPalette();
  856. });
  857. each(visualFuncs, function (visual) {
  858. visual.func(ecModel, api, payload);
  859. });
  860. }
  861. /**
  862. * Render each chart and component
  863. * @private
  864. */
  865. function doRender(ecModel, payload) {
  866. var api = this._api;
  867. // Render all components
  868. each(this._componentsViews, function (componentView) {
  869. var componentModel = componentView.__model;
  870. componentView.render(componentModel, ecModel, api, payload);
  871. updateZ(componentModel, componentView);
  872. }, this);
  873. each(this._chartsViews, function (chart) {
  874. chart.__alive = false;
  875. }, this);
  876. // Render all charts
  877. ecModel.eachSeries(function (seriesModel, idx) {
  878. var chartView = this._chartsMap[seriesModel.__viewId];
  879. chartView.__alive = true;
  880. chartView.render(seriesModel, ecModel, api, payload);
  881. chartView.group.silent = !!seriesModel.get('silent');
  882. updateZ(seriesModel, chartView);
  883. updateProgressiveAndBlend(seriesModel, chartView);
  884. }, this);
  885. // If use hover layer
  886. updateHoverLayerStatus(this._zr, ecModel);
  887. // Remove groups of unrendered charts
  888. each(this._chartsViews, function (chart) {
  889. if (!chart.__alive) {
  890. chart.remove(ecModel, api);
  891. }
  892. }, this);
  893. }
  894. var MOUSE_EVENT_NAMES = [
  895. 'click', 'dblclick', 'mouseover', 'mouseout', 'mousedown', 'mouseup', 'globalout'
  896. ];
  897. /**
  898. * @private
  899. */
  900. echartsProto._initEvents = function () {
  901. each(MOUSE_EVENT_NAMES, function (eveName) {
  902. this._zr.on(eveName, function (e) {
  903. var ecModel = this.getModel();
  904. var el = e.target;
  905. if (el && el.dataIndex != null) {
  906. var dataModel = el.dataModel || ecModel.getSeriesByIndex(el.seriesIndex);
  907. var params = dataModel && dataModel.getDataParams(el.dataIndex, el.dataType) || {};
  908. params.event = e;
  909. params.type = eveName;
  910. this.trigger(eveName, params);
  911. }
  912. // If element has custom eventData of components
  913. else if (el && el.eventData) {
  914. this.trigger(eveName, el.eventData);
  915. }
  916. }, this);
  917. }, this);
  918. each(eventActionMap, function (actionType, eventType) {
  919. this._messageCenter.on(eventType, function (event) {
  920. this.trigger(eventType, event);
  921. }, this);
  922. }, this);
  923. };
  924. /**
  925. * @return {boolean}
  926. */
  927. echartsProto.isDisposed = function () {
  928. return this._disposed;
  929. };
  930. /**
  931. * Clear
  932. */
  933. echartsProto.clear = function () {
  934. this.setOption({}, true);
  935. };
  936. /**
  937. * Dispose instance
  938. */
  939. echartsProto.dispose = function () {
  940. if (this._disposed) {
  941. if (true) {
  942. console.warn('Instance ' + this.id + ' has been disposed');
  943. }
  944. return;
  945. }
  946. this._disposed = true;
  947. var api = this._api;
  948. var ecModel = this._model;
  949. each(this._componentsViews, function (component) {
  950. component.dispose(ecModel, api);
  951. });
  952. each(this._chartsViews, function (chart) {
  953. chart.dispose(ecModel, api);
  954. });
  955. // Dispose after all views disposed
  956. this._zr.dispose();
  957. delete instances[this.id];
  958. };
  959. zrUtil.mixin(ECharts, Eventful);
  960. function updateHoverLayerStatus(zr, ecModel) {
  961. var storage = zr.storage;
  962. var elCount = 0;
  963. storage.traverse(function (el) {
  964. if (!el.isGroup) {
  965. elCount++;
  966. }
  967. });
  968. if (elCount > ecModel.get('hoverLayerThreshold') && !env.node) {
  969. storage.traverse(function (el) {
  970. if (!el.isGroup) {
  971. el.useHoverLayer = true;
  972. }
  973. });
  974. }
  975. }
  976. /**
  977. * Update chart progressive and blend.
  978. * @param {module:echarts/model/Series|module:echarts/model/Component} model
  979. * @param {module:echarts/view/Component|module:echarts/view/Chart} view
  980. */
  981. function updateProgressiveAndBlend(seriesModel, chartView) {
  982. // Progressive configuration
  983. var elCount = 0;
  984. chartView.group.traverse(function (el) {
  985. if (el.type !== 'group' && !el.ignore) {
  986. elCount++;
  987. }
  988. });
  989. var frameDrawNum = +seriesModel.get('progressive');
  990. var needProgressive = elCount > seriesModel.get('progressiveThreshold') && frameDrawNum && !env.node;
  991. if (needProgressive) {
  992. chartView.group.traverse(function (el) {
  993. // FIXME marker and other components
  994. if (!el.isGroup) {
  995. el.progressive = needProgressive ?
  996. Math.floor(elCount++ / frameDrawNum) : -1;
  997. if (needProgressive) {
  998. el.stopAnimation(true);
  999. }
  1000. }
  1001. });
  1002. }
  1003. // Blend configration
  1004. var blendMode = seriesModel.get('blendMode') || null;
  1005. if (true) {
  1006. if (!env.canvasSupported && blendMode && blendMode !== 'source-over') {
  1007. console.warn('Only canvas support blendMode');
  1008. }
  1009. }
  1010. chartView.group.traverse(function (el) {
  1011. // FIXME marker and other components
  1012. if (!el.isGroup) {
  1013. el.setStyle('blend', blendMode);
  1014. }
  1015. });
  1016. }
  1017. /**
  1018. * @param {module:echarts/model/Series|module:echarts/model/Component} model
  1019. * @param {module:echarts/view/Component|module:echarts/view/Chart} view
  1020. */
  1021. function updateZ(model, view) {
  1022. var z = model.get('z');
  1023. var zlevel = model.get('zlevel');
  1024. // Set z and zlevel
  1025. view.group.traverse(function (el) {
  1026. if (el.type !== 'group') {
  1027. z != null && (el.z = z);
  1028. zlevel != null && (el.zlevel = zlevel);
  1029. }
  1030. });
  1031. }
  1032. /**
  1033. * @type {Array.<Function>}
  1034. * @inner
  1035. */
  1036. var actions = [];
  1037. /**
  1038. * Map eventType to actionType
  1039. * @type {Object}
  1040. */
  1041. var eventActionMap = {};
  1042. /**
  1043. * Data processor functions of each stage
  1044. * @type {Array.<Object.<string, Function>>}
  1045. * @inner
  1046. */
  1047. var dataProcessorFuncs = [];
  1048. /**
  1049. * @type {Array.<Function>}
  1050. * @inner
  1051. */
  1052. var optionPreprocessorFuncs = [];
  1053. /**
  1054. * Visual encoding functions of each stage
  1055. * @type {Array.<Object.<string, Function>>}
  1056. * @inner
  1057. */
  1058. var visualFuncs = [];
  1059. /**
  1060. * Theme storage
  1061. * @type {Object.<key, Object>}
  1062. */
  1063. var themeStorage = {};
  1064. var instances = {};
  1065. var connectedGroups = {};
  1066. var idBase = new Date() - 0;
  1067. var groupIdBase = new Date() - 0;
  1068. var DOM_ATTRIBUTE_KEY = '_echarts_instance_';
  1069. /**
  1070. * @alias module:echarts
  1071. */
  1072. var echarts = {
  1073. /**
  1074. * @type {number}
  1075. */
  1076. version: '3.2.2',
  1077. dependencies: {
  1078. zrender: '3.1.2'
  1079. }
  1080. };
  1081. function enableConnect(chart) {
  1082. var STATUS_PENDING = 0;
  1083. var STATUS_UPDATING = 1;
  1084. var STATUS_UPDATED = 2;
  1085. var STATUS_KEY = '__connectUpdateStatus';
  1086. function updateConnectedChartsStatus(charts, status) {
  1087. for (var i = 0; i < charts.length; i++) {
  1088. var otherChart = charts[i];
  1089. otherChart[STATUS_KEY] = status;
  1090. }
  1091. }
  1092. zrUtil.each(eventActionMap, function (actionType, eventType) {
  1093. chart._messageCenter.on(eventType, function (event) {
  1094. if (connectedGroups[chart.group] && chart[STATUS_KEY] !== STATUS_PENDING) {
  1095. var action = chart.makeActionFromEvent(event);
  1096. var otherCharts = [];
  1097. for (var id in instances) {
  1098. var otherChart = instances[id];
  1099. if (otherChart !== chart && otherChart.group === chart.group) {
  1100. otherCharts.push(otherChart);
  1101. }
  1102. }
  1103. updateConnectedChartsStatus(otherCharts, STATUS_PENDING);
  1104. each(otherCharts, function (otherChart) {
  1105. if (otherChart[STATUS_KEY] !== STATUS_UPDATING) {
  1106. otherChart.dispatchAction(action);
  1107. }
  1108. });
  1109. updateConnectedChartsStatus(otherCharts, STATUS_UPDATED);
  1110. }
  1111. });
  1112. });
  1113. }
  1114. /**
  1115. * @param {HTMLDomElement} dom
  1116. * @param {Object} [theme]
  1117. * @param {Object} opts
  1118. */
  1119. echarts.init = function (dom, theme, opts) {
  1120. if (true) {
  1121. // Check version
  1122. if ((zrender.version.replace('.', '') - 0) < (echarts.dependencies.zrender.replace('.', '') - 0)) {
  1123. throw new Error(
  1124. 'ZRender ' + zrender.version
  1125. + ' is too old for ECharts ' + echarts.version
  1126. + '. Current version need ZRender '
  1127. + echarts.dependencies.zrender + '+'
  1128. );
  1129. }
  1130. if (!dom) {
  1131. throw new Error('Initialize failed: invalid dom.');
  1132. }
  1133. if (zrUtil.isDom(dom) && dom.nodeName.toUpperCase() !== 'CANVAS' && (!dom.clientWidth || !dom.clientHeight)) {
  1134. console.warn('Can\'t get dom width or height');
  1135. }
  1136. }
  1137. var chart = new ECharts(dom, theme, opts);
  1138. chart.id = 'ec_' + idBase++;
  1139. instances[chart.id] = chart;
  1140. dom.setAttribute &&
  1141. dom.setAttribute(DOM_ATTRIBUTE_KEY, chart.id);
  1142. enableConnect(chart);
  1143. return chart;
  1144. };
  1145. /**
  1146. * @return {string|Array.<module:echarts~ECharts>} groupId
  1147. */
  1148. echarts.connect = function (groupId) {
  1149. // Is array of charts
  1150. if (zrUtil.isArray(groupId)) {
  1151. var charts = groupId;
  1152. groupId = null;
  1153. // If any chart has group
  1154. zrUtil.each(charts, function (chart) {
  1155. if (chart.group != null) {
  1156. groupId = chart.group;
  1157. }
  1158. });
  1159. groupId = groupId || ('g_' + groupIdBase++);
  1160. zrUtil.each(charts, function (chart) {
  1161. chart.group = groupId;
  1162. });
  1163. }
  1164. connectedGroups[groupId] = true;
  1165. return groupId;
  1166. };
  1167. /**
  1168. * @return {string} groupId
  1169. */
  1170. echarts.disConnect = function (groupId) {
  1171. connectedGroups[groupId] = false;
  1172. };
  1173. /**
  1174. * Dispose a chart instance
  1175. * @param {module:echarts~ECharts|HTMLDomElement|string} chart
  1176. */
  1177. echarts.dispose = function (chart) {
  1178. if (zrUtil.isDom(chart)) {
  1179. chart = echarts.getInstanceByDom(chart);
  1180. }
  1181. else if (typeof chart === 'string') {
  1182. chart = instances[chart];
  1183. }
  1184. if ((chart instanceof ECharts) && !chart.isDisposed()) {
  1185. chart.dispose();
  1186. }
  1187. };
  1188. /**
  1189. * @param {HTMLDomElement} dom
  1190. * @return {echarts~ECharts}
  1191. */
  1192. echarts.getInstanceByDom = function (dom) {
  1193. var key = dom.getAttribute(DOM_ATTRIBUTE_KEY);
  1194. return instances[key];
  1195. };
  1196. /**
  1197. * @param {string} key
  1198. * @return {echarts~ECharts}
  1199. */
  1200. echarts.getInstanceById = function (key) {
  1201. return instances[key];
  1202. };
  1203. /**
  1204. * Register theme
  1205. */
  1206. echarts.registerTheme = function (name, theme) {
  1207. themeStorage[name] = theme;
  1208. };
  1209. /**
  1210. * Register option preprocessor
  1211. * @param {Function} preprocessorFunc
  1212. */
  1213. echarts.registerPreprocessor = function (preprocessorFunc) {
  1214. optionPreprocessorFuncs.push(preprocessorFunc);
  1215. };
  1216. /**
  1217. * @param {number} [priority=1000]
  1218. * @param {Function} processorFunc
  1219. */
  1220. echarts.registerProcessor = function (priority, processorFunc) {
  1221. if (typeof priority === 'function') {
  1222. processorFunc = priority;
  1223. priority = PRIORITY_PROCESSOR_FILTER;
  1224. }
  1225. if (true) {
  1226. if (isNaN(priority)) {
  1227. throw new Error('Unkown processor priority');
  1228. }
  1229. }
  1230. dataProcessorFuncs.push({
  1231. prio: priority,
  1232. func: processorFunc
  1233. });
  1234. };
  1235. /**
  1236. * Usage:
  1237. * registerAction('someAction', 'someEvent', function () { ... });
  1238. * registerAction('someAction', function () { ... });
  1239. * registerAction(
  1240. * {type: 'someAction', event: 'someEvent', update: 'updateView'},
  1241. * function () { ... }
  1242. * );
  1243. *
  1244. * @param {(string|Object)} actionInfo
  1245. * @param {string} actionInfo.type
  1246. * @param {string} [actionInfo.event]
  1247. * @param {string} [actionInfo.update]
  1248. * @param {string} [eventName]
  1249. * @param {Function} action
  1250. */
  1251. echarts.registerAction = function (actionInfo, eventName, action) {
  1252. if (typeof eventName === 'function') {
  1253. action = eventName;
  1254. eventName = '';
  1255. }
  1256. var actionType = zrUtil.isObject(actionInfo)
  1257. ? actionInfo.type
  1258. : ([actionInfo, actionInfo = {
  1259. event: eventName
  1260. }][0]);
  1261. // Event name is all lowercase
  1262. actionInfo.event = (actionInfo.event || actionType).toLowerCase();
  1263. eventName = actionInfo.event;
  1264. if (!actions[actionType]) {
  1265. actions[actionType] = {action: action, actionInfo: actionInfo};
  1266. }
  1267. eventActionMap[eventName] = actionType;
  1268. };
  1269. /**
  1270. * @param {string} type
  1271. * @param {*} CoordinateSystem
  1272. */
  1273. echarts.registerCoordinateSystem = function (type, CoordinateSystem) {
  1274. CoordinateSystemManager.register(type, CoordinateSystem);
  1275. };
  1276. /**
  1277. * Layout is a special stage of visual encoding
  1278. * Most visual encoding like color are common for different chart
  1279. * But each chart has it's own layout algorithm
  1280. *
  1281. * @param {string} [priority=1000]
  1282. * @param {Function} layoutFunc
  1283. */
  1284. echarts.registerLayout = function (priority, layoutFunc) {
  1285. if (typeof priority === 'function') {
  1286. layoutFunc = priority;
  1287. priority = PRIORITY_VISUAL_LAYOUT;
  1288. }
  1289. if (true) {
  1290. if (isNaN(priority)) {
  1291. throw new Error('Unkown layout priority');
  1292. }
  1293. }
  1294. visualFuncs.push({
  1295. prio: priority,
  1296. func: layoutFunc,
  1297. isLayout: true
  1298. });
  1299. };
  1300. /**
  1301. * @param {string} [priority=3000]
  1302. * @param {Function} visualFunc
  1303. */
  1304. echarts.registerVisual = function (priority, visualFunc) {
  1305. if (typeof priority === 'function') {
  1306. visualFunc = priority;
  1307. priority = PRIORITY_VISUAL_CHART;
  1308. }
  1309. if (true) {
  1310. if (isNaN(priority)) {
  1311. throw new Error('Unkown visual priority');
  1312. }
  1313. }
  1314. visualFuncs.push({
  1315. prio: priority,
  1316. func: visualFunc
  1317. });
  1318. };
  1319. var parseClassType = ComponentModel.parseClassType;
  1320. /**
  1321. * @param {Object} opts
  1322. * @param {string} [superClass]
  1323. */
  1324. echarts.extendComponentModel = function (opts, superClass) {
  1325. var Clazz = ComponentModel;
  1326. if (superClass) {
  1327. var classType = parseClassType(superClass);
  1328. Clazz = ComponentModel.getClass(classType.main, classType.sub, true);
  1329. }
  1330. return Clazz.extend(opts);
  1331. };
  1332. /**
  1333. * @param {Object} opts
  1334. * @param {string} [superClass]
  1335. */
  1336. echarts.extendComponentView = function (opts, superClass) {
  1337. var Clazz = ComponentView;
  1338. if (superClass) {
  1339. var classType = parseClassType(superClass);
  1340. Clazz = ComponentView.getClass(classType.main, classType.sub, true);
  1341. }
  1342. return Clazz.extend(opts);
  1343. };
  1344. /**
  1345. * @param {Object} opts
  1346. * @param {string} [superClass]
  1347. */
  1348. echarts.extendSeriesModel = function (opts, superClass) {
  1349. var Clazz = SeriesModel;
  1350. if (superClass) {
  1351. superClass = 'series.' + superClass.replace('series.', '');
  1352. var classType = parseClassType(superClass);
  1353. Clazz = SeriesModel.getClass(classType.main, classType.sub, true);
  1354. }
  1355. return Clazz.extend(opts);
  1356. };
  1357. /**
  1358. * @param {Object} opts
  1359. * @param {string} [superClass]
  1360. */
  1361. echarts.extendChartView = function (opts, superClass) {
  1362. var Clazz = ChartView;
  1363. if (superClass) {
  1364. superClass.replace('series.', '');
  1365. var classType = parseClassType(superClass);
  1366. Clazz = ChartView.getClass(classType.main, true);
  1367. }
  1368. return ChartView.extend(opts);
  1369. };
  1370. /**
  1371. * ZRender need a canvas context to do measureText.
  1372. * But in node environment canvas may be created by node-canvas.
  1373. * So we need to specify how to create a canvas instead of using document.createElement('canvas')
  1374. *
  1375. * Be careful of using it in the browser.
  1376. *
  1377. * @param {Function} creator
  1378. * @example
  1379. * var Canvas = require('canvas');
  1380. * var echarts = require('echarts');
  1381. * echarts.setCanvasCreator(function () {
  1382. * // Small size is enough.
  1383. * return new Canvas(32, 32);
  1384. * });
  1385. */
  1386. echarts.setCanvasCreator = function (creator) {
  1387. zrUtil.createCanvas = creator;
  1388. };
  1389. echarts.registerVisual(PRIORITY_VISUAL_GLOBAL, __webpack_require__(94));
  1390. echarts.registerPreprocessor(__webpack_require__(95));
  1391. // Default action
  1392. echarts.registerAction({
  1393. type: 'highlight',
  1394. event: 'highlight',
  1395. update: 'highlight'
  1396. }, zrUtil.noop);
  1397. echarts.registerAction({
  1398. type: 'downplay',
  1399. event: 'downplay',
  1400. update: 'downplay'
  1401. }, zrUtil.noop);
  1402. // --------
  1403. // Exports
  1404. // --------
  1405. //
  1406. echarts.List = __webpack_require__(97);
  1407. echarts.Model = __webpack_require__(12);
  1408. echarts.graphic = __webpack_require__(43);
  1409. echarts.number = __webpack_require__(7);
  1410. echarts.format = __webpack_require__(6);
  1411. echarts.matrix = __webpack_require__(11);
  1412. echarts.vector = __webpack_require__(10);
  1413. echarts.color = __webpack_require__(39);
  1414. echarts.util = {};
  1415. each([
  1416. 'map', 'each', 'filter', 'indexOf', 'inherits',
  1417. 'reduce', 'filter', 'bind', 'curry', 'isArray',
  1418. 'isString', 'isObject', 'isFunction', 'extend', 'defaults'
  1419. ],
  1420. function (name) {
  1421. echarts.util[name] = zrUtil[name];
  1422. }
  1423. );
  1424. // PRIORITY
  1425. echarts.PRIORITY = {
  1426. PROCESSOR: {
  1427. FILTER: PRIORITY_PROCESSOR_FILTER,
  1428. STATISTIC: PRIORITY_PROCESSOR_STATISTIC
  1429. },
  1430. VISUAL: {
  1431. LAYOUT: PRIORITY_VISUAL_LAYOUT,
  1432. GLOBAL: PRIORITY_VISUAL_GLOBAL,
  1433. CHART: PRIORITY_VISUAL_CHART,
  1434. COMPONENT: PRIORITY_VISUAL_COMPONENT,
  1435. BRUSH: PRIORITY_VISUAL_BRUSH
  1436. }
  1437. };
  1438. module.exports = echarts;
  1439. /***/ },
  1440. /* 2 */
  1441. /***/ function(module, exports) {
  1442. /**
  1443. * echarts设备环境识别
  1444. *
  1445. * @desc echarts基于Canvas,纯Javascript图表库,提供直观,生动,可交互,可个性化定制的数据统计图表。
  1446. * @author firede[firede@firede.us]
  1447. * @desc thanks zepto.
  1448. */
  1449. var env = {};
  1450. if (typeof navigator === 'undefined') {
  1451. // In node
  1452. env = {
  1453. browser: {},
  1454. os: {},
  1455. node: true,
  1456. // Assume canvas is supported
  1457. canvasSupported: true
  1458. };
  1459. }
  1460. else {
  1461. env = detect(navigator.userAgent);
  1462. }
  1463. module.exports = env;
  1464. // Zepto.js
  1465. // (c) 2010-2013 Thomas Fuchs
  1466. // Zepto.js may be freely distributed under the MIT license.
  1467. function detect(ua) {
  1468. var os = {};
  1469. var browser = {};
  1470. // var webkit = ua.match(/Web[kK]it[\/]{0,1}([\d.]+)/);
  1471. // var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/);
  1472. // var ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
  1473. // var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
  1474. // var iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/);
  1475. // var webos = ua.match(/(webOS|hpwOS)[\s\/]([\d.]+)/);
  1476. // var touchpad = webos && ua.match(/TouchPad/);
  1477. // var kindle = ua.match(/Kindle\/([\d.]+)/);
  1478. // var silk = ua.match(/Silk\/([\d._]+)/);
  1479. // var blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/);
  1480. // var bb10 = ua.match(/(BB10).*Version\/([\d.]+)/);
  1481. // var rimtabletos = ua.match(/(RIM\sTablet\sOS)\s([\d.]+)/);
  1482. // var playbook = ua.match(/PlayBook/);
  1483. // var chrome = ua.match(/Chrome\/([\d.]+)/) || ua.match(/CriOS\/([\d.]+)/);
  1484. var firefox = ua.match(/Firefox\/([\d.]+)/);
  1485. // var safari = webkit && ua.match(/Mobile\//) && !chrome;
  1486. // var webview = ua.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/) && !chrome;
  1487. var ie = ua.match(/MSIE\s([\d.]+)/)
  1488. // IE 11 Trident/7.0; rv:11.0
  1489. || ua.match(/Trident\/.+?rv:(([\d.]+))/);
  1490. var edge = ua.match(/Edge\/([\d.]+)/); // IE 12 and 12+
  1491. // Todo: clean this up with a better OS/browser seperation:
  1492. // - discern (more) between multiple browsers on android
  1493. // - decide if kindle fire in silk mode is android or not
  1494. // - Firefox on Android doesn't specify the Android version
  1495. // - possibly devide in os, device and browser hashes
  1496. // if (browser.webkit = !!webkit) browser.version = webkit[1];
  1497. // if (android) os.android = true, os.version = android[2];
  1498. // if (iphone && !ipod) os.ios = os.iphone = true, os.version = iphone[2].replace(/_/g, '.');
  1499. // if (ipad) os.ios = os.ipad = true, os.version = ipad[2].replace(/_/g, '.');
  1500. // if (ipod) os.ios = os.ipod = true, os.version = ipod[3] ? ipod[3].replace(/_/g, '.') : null;
  1501. // if (webos) os.webos = true, os.version = webos[2];
  1502. // if (touchpad) os.touchpad = true;
  1503. // if (blackberry) os.blackberry = true, os.version = blackberry[2];
  1504. // if (bb10) os.bb10 = true, os.version = bb10[2];
  1505. // if (rimtabletos) os.rimtabletos = true, os.version = rimtabletos[2];
  1506. // if (playbook) browser.playbook = true;
  1507. // if (kindle) os.kindle = true, os.version = kindle[1];
  1508. // if (silk) browser.silk = true, browser.version = silk[1];
  1509. // if (!silk && os.android && ua.match(/Kindle Fire/)) browser.silk = true;
  1510. // if (chrome) browser.chrome = true, browser.version = chrome[1];
  1511. if (firefox) browser.firefox = true, browser.version = firefox[1];
  1512. // if (safari && (ua.match(/Safari/) || !!os.ios)) browser.safari = true;
  1513. // if (webview) browser.webview = true;
  1514. if (ie) {
  1515. browser.ie = true; browser.version = ie[1];
  1516. }
  1517. if (ie) {
  1518. browser.ie = true;
  1519. browser.version = ie[1];
  1520. }
  1521. if (edge) {
  1522. browser.edge = true;
  1523. browser.version = edge[1];
  1524. }
  1525. // os.tablet = !!(ipad || playbook || (android && !ua.match(/Mobile/)) ||
  1526. // (firefox && ua.match(/Tablet/)) || (ie && !ua.match(/Phone/) && ua.match(/Touch/)));
  1527. // os.phone = !!(!os.tablet && !os.ipod && (android || iphone || webos ||
  1528. // (chrome && ua.match(/Android/)) || (chrome && ua.match(/CriOS\/([\d.]+)/)) ||
  1529. // (firefox && ua.match(/Mobile/)) || (ie && ua.match(/Touch/))));
  1530. return {
  1531. browser: browser,
  1532. os: os,
  1533. node: false,
  1534. // 原生canvas支持,改极端点了
  1535. // canvasSupported : !(browser.ie && parseFloat(browser.version) < 9)
  1536. canvasSupported : document.createElement('canvas').getContext ? true : false,
  1537. // @see <http://stackoverflow.com/questions/4817029/whats-the-best-way-to-detect-a-touch-screen-device-using-javascript>
  1538. // works on most browsers
  1539. // IE10/11 does not support touch event, and MS Edge supports them but not by
  1540. // default, so we dont check navigator.maxTouchPoints for them here.
  1541. touchEventsSupported: 'ontouchstart' in window && !browser.ie && !browser.edge,
  1542. // <http://caniuse.com/#search=pointer%20event>.
  1543. pointerEventsSupported: 'onpointerdown' in window
  1544. // Firefox supports pointer but not by default,
  1545. // only MS browsers are reliable on pointer events currently.
  1546. && (browser.edge || (browser.ie && browser.version >= 10))
  1547. };
  1548. }
  1549. /***/ },
  1550. /* 3 */
  1551. /***/ function(module, exports, __webpack_require__) {
  1552. /**
  1553. * ECharts global model
  1554. *
  1555. * @module {echarts/model/Global}
  1556. *
  1557. */
  1558. var zrUtil = __webpack_require__(4);
  1559. var modelUtil = __webpack_require__(5);
  1560. var Model = __webpack_require__(12);
  1561. var each = zrUtil.each;
  1562. var filter = zrUtil.filter;
  1563. var map = zrUtil.map;
  1564. var isArray = zrUtil.isArray;
  1565. var indexOf = zrUtil.indexOf;
  1566. var isObject = zrUtil.isObject;
  1567. var ComponentModel = __webpack_require__(19);
  1568. var globalDefault = __webpack_require__(23);
  1569. var OPTION_INNER_KEY = '\0_ec_inner';
  1570. /**
  1571. * @alias module:echarts/model/Global
  1572. *
  1573. * @param {Object} option
  1574. * @param {module:echarts/model/Model} parentModel
  1575. * @param {Object} theme
  1576. */
  1577. var GlobalModel = Model.extend({
  1578. constructor: GlobalModel,
  1579. init: function (option, parentModel, theme, optionManager) {
  1580. theme = theme || {};
  1581. this.option = null; // Mark as not initialized.
  1582. /**
  1583. * @type {module:echarts/model/Model}
  1584. * @private
  1585. */
  1586. this._theme = new Model(theme);
  1587. /**
  1588. * @type {module:echarts/model/OptionManager}
  1589. */
  1590. this._optionManager = optionManager;
  1591. },
  1592. setOption: function (option, optionPreprocessorFuncs) {
  1593. zrUtil.assert(
  1594. !(OPTION_INNER_KEY in option),
  1595. 'please use chart.getOption()'
  1596. );
  1597. this._optionManager.setOption(option, optionPreprocessorFuncs);
  1598. this.resetOption();
  1599. },
  1600. /**
  1601. * @param {string} type null/undefined: reset all.
  1602. * 'recreate': force recreate all.
  1603. * 'timeline': only reset timeline option
  1604. * 'media': only reset media query option
  1605. * @return {boolean} Whether option changed.
  1606. */
  1607. resetOption: function (type) {
  1608. var optionChanged = false;
  1609. var optionManager = this._optionManager;
  1610. if (!type || type === 'recreate') {
  1611. var baseOption = optionManager.mountOption(type === 'recreate');
  1612. if (!this.option || type === 'recreate') {
  1613. initBase.call(this, baseOption);
  1614. }
  1615. else {
  1616. this.restoreData();
  1617. this.mergeOption(baseOption);
  1618. }
  1619. optionChanged = true;
  1620. }
  1621. if (type === 'timeline' || type === 'media') {
  1622. this.restoreData();
  1623. }
  1624. if (!type || type === 'recreate' || type === 'timeline') {
  1625. var timelineOption = optionManager.getTimelineOption(this);
  1626. timelineOption && (this.mergeOption(timelineOption), optionChanged = true);
  1627. }
  1628. if (!type || type === 'recreate' || type === 'media') {
  1629. var mediaOptions = optionManager.getMediaOption(this, this._api);
  1630. if (mediaOptions.length) {
  1631. each(mediaOptions, function (mediaOption) {
  1632. this.mergeOption(mediaOption, optionChanged = true);
  1633. }, this);
  1634. }
  1635. }
  1636. return optionChanged;
  1637. },
  1638. /**
  1639. * @protected
  1640. */
  1641. mergeOption: function (newOption) {
  1642. var option = this.option;
  1643. var componentsMap = this._componentsMap;
  1644. var newCptTypes = [];
  1645. // 如果不存在对应的 component model 则直接 merge
  1646. each(newOption, function (componentOption, mainType) {
  1647. if (componentOption == null) {
  1648. return;
  1649. }
  1650. if (!ComponentModel.hasClass(mainType)) {
  1651. option[mainType] = option[mainType] == null
  1652. ? zrUtil.clone(componentOption)
  1653. : zrUtil.merge(option[mainType], componentOption, true);
  1654. }
  1655. else {
  1656. newCptTypes.push(mainType);
  1657. }
  1658. });
  1659. // FIXME OPTION 同步是否要改回原来的
  1660. ComponentModel.topologicalTravel(
  1661. newCptTypes, ComponentModel.getAllClassMainTypes(), visitComponent, this
  1662. );
  1663. function visitComponent(mainType, dependencies) {
  1664. var newCptOptionList = modelUtil.normalizeToArray(newOption[mainType]);
  1665. var mapResult = modelUtil.mappingToExists(
  1666. componentsMap[mainType], newCptOptionList
  1667. );
  1668. makeKeyInfo(mainType, mapResult);
  1669. var dependentModels = getComponentsByTypes(
  1670. componentsMap, dependencies
  1671. );
  1672. option[mainType] = [];
  1673. componentsMap[mainType] = [];
  1674. each(mapResult, function (resultItem, index) {
  1675. var componentModel = resultItem.exist;
  1676. var newCptOption = resultItem.option;
  1677. zrUtil.assert(
  1678. isObject(newCptOption) || componentModel,
  1679. 'Empty component definition'
  1680. );
  1681. // Consider where is no new option and should be merged using {},
  1682. // see removeEdgeAndAdd in topologicalTravel and
  1683. // ComponentModel.getAllClassMainTypes.
  1684. if (!newCptOption) {
  1685. componentModel.mergeOption({}, this);
  1686. componentModel.optionUpdated({}, false);
  1687. }
  1688. else {
  1689. var ComponentModelClass = ComponentModel.getClass(
  1690. mainType, resultItem.keyInfo.subType, true
  1691. );
  1692. if (componentModel && componentModel instanceof ComponentModelClass) {
  1693. componentModel.mergeOption(newCptOption, this);
  1694. componentModel.optionUpdated(newCptOption, false);
  1695. }
  1696. else {
  1697. // PENDING Global as parent ?
  1698. var extraOpt = zrUtil.extend(
  1699. {
  1700. dependentModels: dependentModels,
  1701. componentIndex: index
  1702. },
  1703. resultItem.keyInfo
  1704. );
  1705. componentModel = new ComponentModelClass(
  1706. newCptOption, this, this, extraOpt
  1707. );
  1708. componentModel.init(newCptOption, this, this, extraOpt);
  1709. // Call optionUpdated after init.
  1710. // newCptOption has been used as componentModel.option
  1711. // and may be merged with theme and default, so pass null
  1712. // to avoid confusion.
  1713. componentModel.optionUpdated(null, true);
  1714. }
  1715. }
  1716. componentsMap[mainType][index] = componentModel;
  1717. option[mainType][index] = componentModel.option;
  1718. }, this);
  1719. // Backup series for filtering.
  1720. if (mainType === 'series') {
  1721. this._seriesIndices = createSeriesIndices(componentsMap.series);
  1722. }
  1723. }
  1724. },
  1725. /**
  1726. * Get option for output (cloned option and inner info removed)
  1727. * @public
  1728. * @return {Object}
  1729. */
  1730. getOption: function () {
  1731. var option = zrUtil.clone(this.option);
  1732. each(option, function (opts, mainType) {
  1733. if (ComponentModel.hasClass(mainType)) {
  1734. var opts = modelUtil.normalizeToArray(opts);
  1735. for (var i = opts.length - 1; i >= 0; i--) {
  1736. // Remove options with inner id.
  1737. if (modelUtil.isIdInner(opts[i])) {
  1738. opts.splice(i, 1);
  1739. }
  1740. }
  1741. option[mainType] = opts;
  1742. }
  1743. });
  1744. delete option[OPTION_INNER_KEY];
  1745. return option;
  1746. },
  1747. /**
  1748. * @return {module:echarts/model/Model}
  1749. */
  1750. getTheme: function () {
  1751. return this._theme;
  1752. },
  1753. /**
  1754. * @param {string} mainType
  1755. * @param {number} [idx=0]
  1756. * @return {module:echarts/model/Component}
  1757. */
  1758. getComponent: function (mainType, idx) {
  1759. var list = this._componentsMap[mainType];
  1760. if (list) {
  1761. return list[idx || 0];
  1762. }
  1763. },
  1764. /**
  1765. * @param {Object} condition
  1766. * @param {string} condition.mainType
  1767. * @param {string} [condition.subType] If ignore, only query by mainType
  1768. * @param {number} [condition.index] Either input index or id or name.
  1769. * @param {string} [condition.id] Either input index or id or name.
  1770. * @param {string} [condition.name] Either input index or id or name.
  1771. * @return {Array.<module:echarts/model/Component>}
  1772. */
  1773. queryComponents: function (condition) {
  1774. var mainType = condition.mainType;
  1775. if (!mainType) {
  1776. return [];
  1777. }
  1778. var index = condition.index;
  1779. var id = condition.id;
  1780. var name = condition.name;
  1781. var cpts = this._componentsMap[mainType];
  1782. if (!cpts || !cpts.length) {
  1783. return [];
  1784. }
  1785. var result;
  1786. if (index != null) {
  1787. if (!isArray(index)) {
  1788. index = [index];
  1789. }
  1790. result = filter(map(index, function (idx) {
  1791. return cpts[idx];
  1792. }), function (val) {
  1793. return !!val;
  1794. });
  1795. }
  1796. else if (id != null) {
  1797. var isIdArray = isArray(id);
  1798. result = filter(cpts, function (cpt) {
  1799. return (isIdArray && indexOf(id, cpt.id) >= 0)
  1800. || (!isIdArray && cpt.id === id);
  1801. });
  1802. }
  1803. else if (name != null) {
  1804. var isNameArray = isArray(name);
  1805. result = filter(cpts, function (cpt) {
  1806. return (isNameArray && indexOf(name, cpt.name) >= 0)
  1807. || (!isNameArray && cpt.name === name);
  1808. });
  1809. }
  1810. return filterBySubType(result, condition);
  1811. },
  1812. /**
  1813. * The interface is different from queryComponents,
  1814. * which is convenient for inner usage.
  1815. *
  1816. * @usage
  1817. * var result = findComponents(
  1818. * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}}
  1819. * );
  1820. * var result = findComponents(
  1821. * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}}
  1822. * );
  1823. * var result = findComponents(
  1824. * {mainType: 'series'},
  1825. * function (model, index) {...}
  1826. * );
  1827. * // result like [component0, componnet1, ...]
  1828. *
  1829. * @param {Object} condition
  1830. * @param {string} condition.mainType Mandatory.
  1831. * @param {string} [condition.subType] Optional.
  1832. * @param {Object} [condition.query] like {xxxIndex, xxxId, xxxName},
  1833. * where xxx is mainType.
  1834. * If query attribute is null/undefined or has no index/id/name,
  1835. * do not filtering by query conditions, which is convenient for
  1836. * no-payload situations or when target of action is global.
  1837. * @param {Function} [condition.filter] parameter: component, return boolean.
  1838. * @return {Array.<module:echarts/model/Component>}
  1839. */
  1840. findComponents: function (condition) {
  1841. var query = condition.query;
  1842. var mainType = condition.mainType;
  1843. var queryCond = getQueryCond(query);
  1844. var result = queryCond
  1845. ? this.queryComponents(queryCond)
  1846. : this._componentsMap[mainType];
  1847. return doFilter(filterBySubType(result, condition));
  1848. function getQueryCond(q) {
  1849. var indexAttr = mainType + 'Index';
  1850. var idAttr = mainType + 'Id';
  1851. var nameAttr = mainType + 'Name';
  1852. return q && (
  1853. q.hasOwnProperty(indexAttr)
  1854. || q.hasOwnProperty(idAttr)
  1855. || q.hasOwnProperty(nameAttr)
  1856. )
  1857. ? {
  1858. mainType: mainType,
  1859. // subType will be filtered finally.
  1860. index: q[indexAttr],
  1861. id: q[idAttr],
  1862. name: q[nameAttr]
  1863. }
  1864. : null;
  1865. }
  1866. function doFilter(res) {
  1867. return condition.filter
  1868. ? filter(res, condition.filter)
  1869. : res;
  1870. }
  1871. },
  1872. /**
  1873. * @usage
  1874. * eachComponent('legend', function (legendModel, index) {
  1875. * ...
  1876. * });
  1877. * eachComponent(function (componentType, model, index) {
  1878. * // componentType does not include subType
  1879. * // (componentType is 'xxx' but not 'xxx.aa')
  1880. * });
  1881. * eachComponent(
  1882. * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}},
  1883. * function (model, index) {...}
  1884. * );
  1885. * eachComponent(
  1886. * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}},
  1887. * function (model, index) {...}
  1888. * );
  1889. *
  1890. * @param {string|Object=} mainType When mainType is object, the definition
  1891. * is the same as the method 'findComponents'.
  1892. * @param {Function} cb
  1893. * @param {*} context
  1894. */
  1895. eachComponent: function (mainType, cb, context) {
  1896. var componentsMap = this._componentsMap;
  1897. if (typeof mainType === 'function') {
  1898. context = cb;
  1899. cb = mainType;
  1900. each(componentsMap, function (components, componentType) {
  1901. each(components, function (component, index) {
  1902. cb.call(context, componentType, component, index);
  1903. });
  1904. });
  1905. }
  1906. else if (zrUtil.isString(mainType)) {
  1907. each(componentsMap[mainType], cb, context);
  1908. }
  1909. else if (isObject(mainType)) {
  1910. var queryResult = this.findComponents(mainType);
  1911. each(queryResult, cb, context);
  1912. }
  1913. },
  1914. /**
  1915. * @param {string} name
  1916. * @return {Array.<module:echarts/model/Series>}
  1917. */
  1918. getSeriesByName: function (name) {
  1919. var series = this._componentsMap.series;
  1920. return filter(series, function (oneSeries) {
  1921. return oneSeries.name === name;
  1922. });
  1923. },
  1924. /**
  1925. * @param {number} seriesIndex
  1926. * @return {module:echarts/model/Series}
  1927. */
  1928. getSeriesByIndex: function (seriesIndex) {
  1929. return this._componentsMap.series[seriesIndex];
  1930. },
  1931. /**
  1932. * @param {string} subType
  1933. * @return {Array.<module:echarts/model/Series>}
  1934. */
  1935. getSeriesByType: function (subType) {
  1936. var series = this._componentsMap.series;
  1937. return filter(series, function (oneSeries) {
  1938. return oneSeries.subType === subType;
  1939. });
  1940. },
  1941. /**
  1942. * @return {Array.<module:echarts/model/Series>}
  1943. */
  1944. getSeries: function () {
  1945. return this._componentsMap.series.slice();
  1946. },
  1947. /**
  1948. * After filtering, series may be different
  1949. * frome raw series.
  1950. *
  1951. * @param {Function} cb
  1952. * @param {*} context
  1953. */
  1954. eachSeries: function (cb, context) {
  1955. assertSeriesInitialized(this);
  1956. each(this._seriesIndices, function (rawSeriesIndex) {
  1957. var series = this._componentsMap.series[rawSeriesIndex];
  1958. cb.call(context, series, rawSeriesIndex);
  1959. }, this);
  1960. },
  1961. /**
  1962. * Iterate raw series before filtered.
  1963. *
  1964. * @param {Function} cb
  1965. * @param {*} context
  1966. */
  1967. eachRawSeries: function (cb, context) {
  1968. each(this._componentsMap.series, cb, context);
  1969. },
  1970. /**
  1971. * After filtering, series may be different.
  1972. * frome raw series.
  1973. *
  1974. * @parma {string} subType
  1975. * @param {Function} cb
  1976. * @param {*} context
  1977. */
  1978. eachSeriesByType: function (subType, cb, context) {
  1979. assertSeriesInitialized(this);
  1980. each(this._seriesIndices, function (rawSeriesIndex) {
  1981. var series = this._componentsMap.series[rawSeriesIndex];
  1982. if (series.subType === subType) {
  1983. cb.call(context, series, rawSeriesIndex);
  1984. }
  1985. }, this);
  1986. },
  1987. /**
  1988. * Iterate raw series before filtered of given type.
  1989. *
  1990. * @parma {string} subType
  1991. * @param {Function} cb
  1992. * @param {*} context
  1993. */
  1994. eachRawSeriesByType: function (subType, cb, context) {
  1995. return each(this.getSeriesByType(subType), cb, context);
  1996. },
  1997. /**
  1998. * @param {module:echarts/model/Series} seriesModel
  1999. */
  2000. isSeriesFiltered: function (seriesModel) {
  2001. assertSeriesInitialized(this);
  2002. return zrUtil.indexOf(this._seriesIndices, seriesModel.componentIndex) < 0;
  2003. },
  2004. /**
  2005. * @param {Function} cb
  2006. * @param {*} context
  2007. */
  2008. filterSeries: function (cb, context) {
  2009. assertSeriesInitialized(this);
  2010. var filteredSeries = filter(
  2011. this._componentsMap.series, cb, context
  2012. );
  2013. this._seriesIndices = createSeriesIndices(filteredSeries);
  2014. },
  2015. restoreData: function () {
  2016. var componentsMap = this._componentsMap;
  2017. this._seriesIndices = createSeriesIndices(componentsMap.series);
  2018. var componentTypes = [];
  2019. each(componentsMap, function (components, componentType) {
  2020. componentTypes.push(componentType);
  2021. });
  2022. ComponentModel.topologicalTravel(
  2023. componentTypes,
  2024. ComponentModel.getAllClassMainTypes(),
  2025. function (componentType, dependencies) {
  2026. each(componentsMap[componentType], function (component) {
  2027. component.restoreData();
  2028. });
  2029. }
  2030. );
  2031. }
  2032. });
  2033. /**
  2034. * @inner
  2035. */
  2036. function mergeTheme(option, theme) {
  2037. for (var name in theme) {
  2038. // 如果有 component model 则把具体的 merge 逻辑交给该 model 处理
  2039. if (!ComponentModel.hasClass(name)) {
  2040. if (typeof theme[name] === 'object') {
  2041. option[name] = !option[name]
  2042. ? zrUtil.clone(theme[name])
  2043. : zrUtil.merge(option[name], theme[name], false);
  2044. }
  2045. else {
  2046. if (option[name] == null) {
  2047. option[name] = theme[name];
  2048. }
  2049. }
  2050. }
  2051. }
  2052. }
  2053. function initBase(baseOption) {
  2054. baseOption = baseOption;
  2055. // Using OPTION_INNER_KEY to mark that this option can not be used outside,
  2056. // i.e. `chart.setOption(chart.getModel().option);` is forbiden.
  2057. this.option = {};
  2058. this.option[OPTION_INNER_KEY] = 1;
  2059. /**
  2060. * @type {Object.<string, Array.<module:echarts/model/Model>>}
  2061. * @private
  2062. */
  2063. this._componentsMap = {};
  2064. /**
  2065. * Mapping between filtered series list and raw series list.
  2066. * key: filtered series indices, value: raw series indices.
  2067. * @type {Array.<nubmer>}
  2068. * @private
  2069. */
  2070. this._seriesIndices = null;
  2071. mergeTheme(baseOption, this._theme.option);
  2072. // TODO Needs clone when merging to the unexisted property
  2073. zrUtil.merge(baseOption, globalDefault, false);
  2074. this.mergeOption(baseOption);
  2075. }
  2076. /**
  2077. * @inner
  2078. * @param {Array.<string>|string} types model types
  2079. * @return {Object} key: {string} type, value: {Array.<Object>} models
  2080. */
  2081. function getComponentsByTypes(componentsMap, types) {
  2082. if (!zrUtil.isArray(types)) {
  2083. types = types ? [types] : [];
  2084. }
  2085. var ret = {};
  2086. each(types, function (type) {
  2087. ret[type] = (componentsMap[type] || []).slice();
  2088. });
  2089. return ret;
  2090. }
  2091. /**
  2092. * @inner
  2093. */
  2094. function makeKeyInfo(mainType, mapResult) {
  2095. // We use this id to hash component models and view instances
  2096. // in echarts. id can be specified by user, or auto generated.
  2097. // The id generation rule ensures new view instance are able
  2098. // to mapped to old instance when setOption are called in
  2099. // no-merge mode. So we generate model id by name and plus
  2100. // type in view id.
  2101. // name can be duplicated among components, which is convenient
  2102. // to specify multi components (like series) by one name.
  2103. // Ensure that each id is distinct.
  2104. var idMap = {};
  2105. each(mapResult, function (item, index) {
  2106. var existCpt = item.exist;
  2107. existCpt && (idMap[existCpt.id] = item);
  2108. });
  2109. each(mapResult, function (item, index) {
  2110. var opt = item.option;
  2111. zrUtil.assert(
  2112. !opt || opt.id == null || !idMap[opt.id] || idMap[opt.id] === item,
  2113. 'id duplicates: ' + (opt && opt.id)
  2114. );
  2115. opt && opt.id != null && (idMap[opt.id] = item);
  2116. // Complete subType
  2117. if (isObject(opt)) {
  2118. var subType = determineSubType(mainType, opt, item.exist);
  2119. item.keyInfo = {mainType: mainType, subType: subType};
  2120. }
  2121. });
  2122. // Make name and id.
  2123. each(mapResult, function (item, index) {
  2124. var existCpt = item.exist;
  2125. var opt = item.option;
  2126. var keyInfo = item.keyInfo;
  2127. if (!isObject(opt)) {
  2128. return;
  2129. }
  2130. // name can be overwitten. Consider case: axis.name = '20km'.
  2131. // But id generated by name will not be changed, which affect
  2132. // only in that case: setOption with 'not merge mode' and view
  2133. // instance will be recreated, which can be accepted.
  2134. keyInfo.name = opt.name != null
  2135. ? opt.name + ''
  2136. : existCpt
  2137. ? existCpt.name
  2138. : '\0-';
  2139. if (existCpt) {
  2140. keyInfo.id = existCpt.id;
  2141. }
  2142. else if (opt.id != null) {
  2143. keyInfo.id = opt.id + '';
  2144. }
  2145. else {
  2146. // Consider this situatoin:
  2147. // optionA: [{name: 'a'}, {name: 'a'}, {..}]
  2148. // optionB [{..}, {name: 'a'}, {name: 'a'}]
  2149. // Series with the same name between optionA and optionB
  2150. // should be mapped.
  2151. var idNum = 0;
  2152. do {
  2153. keyInfo.id = '\0' + keyInfo.name + '\0' + idNum++;
  2154. }
  2155. while (idMap[keyInfo.id]);
  2156. }
  2157. idMap[keyInfo.id] = item;
  2158. });
  2159. }
  2160. /**
  2161. * @inner
  2162. */
  2163. function determineSubType(mainType, newCptOption, existComponent) {
  2164. var subType = newCptOption.type
  2165. ? newCptOption.type
  2166. : existComponent
  2167. ? existComponent.subType
  2168. // Use determineSubType only when there is no existComponent.
  2169. : ComponentModel.determineSubType(mainType, newCptOption);
  2170. // tooltip, markline, markpoint may always has no subType
  2171. return subType;
  2172. }
  2173. /**
  2174. * @inner
  2175. */
  2176. function createSeriesIndices(seriesModels) {
  2177. return map(seriesModels, function (series) {
  2178. return series.componentIndex;
  2179. }) || [];
  2180. }
  2181. /**
  2182. * @inner
  2183. */
  2184. function filterBySubType(components, condition) {
  2185. // Using hasOwnProperty for restrict. Consider
  2186. // subType is undefined in user payload.
  2187. return condition.hasOwnProperty('subType')
  2188. ? filter(components, function (cpt) {
  2189. return cpt.subType === condition.subType;
  2190. })
  2191. : components;
  2192. }
  2193. /**
  2194. * @inner
  2195. */
  2196. function assertSeriesInitialized(ecModel) {
  2197. // Components that use _seriesIndices should depends on series component,
  2198. // which make sure that their initialization is after series.
  2199. if (true) {
  2200. if (!ecModel._seriesIndices) {
  2201. throw new Error('Series has not been initialized yet.');
  2202. }
  2203. }
  2204. }
  2205. zrUtil.mixin(GlobalModel, __webpack_require__(24));
  2206. module.exports = GlobalModel;
  2207. /***/ },
  2208. /* 4 */
  2209. /***/ function(module, exports) {
  2210. /**
  2211. * @module zrender/core/util
  2212. */
  2213. // 用于处理merge时无法遍历Date等对象的问题
  2214. var BUILTIN_OBJECT = {
  2215. '[object Function]': 1,
  2216. '[object RegExp]': 1,
  2217. '[object Date]': 1,
  2218. '[object Error]': 1,
  2219. '[object CanvasGradient]': 1,
  2220. '[object CanvasPattern]': 1,
  2221. // In node-canvas Image can be Canvas.Image
  2222. '[object Image]': 1
  2223. };
  2224. var objToString = Object.prototype.toString;
  2225. var arrayProto = Array.prototype;
  2226. var nativeForEach = arrayProto.forEach;
  2227. var nativeFilter = arrayProto.filter;
  2228. var nativeSlice = arrayProto.slice;
  2229. var nativeMap = arrayProto.map;
  2230. var nativeReduce = arrayProto.reduce;
  2231. /**
  2232. * @param {*} source
  2233. * @return {*} 拷贝后的新对象
  2234. */
  2235. function clone(source) {
  2236. if (typeof source == 'object' && source !== null) {
  2237. var result = source;
  2238. if (source instanceof Array) {
  2239. result = [];
  2240. for (var i = 0, len = source.length; i < len; i++) {
  2241. result[i] = clone(source[i]);
  2242. }
  2243. }
  2244. else if (
  2245. !isBuildInObject(source)
  2246. // 是否为 dom 对象
  2247. && !isDom(source)
  2248. ) {
  2249. result = {};
  2250. for (var key in source) {
  2251. if (source.hasOwnProperty(key)) {
  2252. result[key] = clone(source[key]);
  2253. }
  2254. }
  2255. }
  2256. return result;
  2257. }
  2258. return source;
  2259. }
  2260. /**
  2261. * @memberOf module:zrender/core/util
  2262. * @param {*} target
  2263. * @param {*} source
  2264. * @param {boolean} [overwrite=false]
  2265. */
  2266. function merge(target, source, overwrite) {
  2267. // We should escapse that source is string
  2268. // and enter for ... in ...
  2269. if (!isObject(source) || !isObject(target)) {
  2270. return overwrite ? clone(source) : target;
  2271. }
  2272. for (var key in source) {
  2273. if (source.hasOwnProperty(key)) {
  2274. var targetProp = target[key];
  2275. var sourceProp = source[key];
  2276. if (isObject(sourceProp)
  2277. && isObject(targetProp)
  2278. && !isArray(sourceProp)
  2279. && !isArray(targetProp)
  2280. && !isDom(sourceProp)
  2281. && !isDom(targetProp)
  2282. && !isBuildInObject(sourceProp)
  2283. && !isBuildInObject(targetProp)
  2284. ) {
  2285. // 如果需要递归覆盖,就递归调用merge
  2286. merge(targetProp, sourceProp, overwrite);
  2287. }
  2288. else if (overwrite || !(key in target)) {
  2289. // 否则只处理overwrite为true,或者在目标对象中没有此属性的情况
  2290. // NOTE,在 target[key] 不存在的时候也是直接覆盖
  2291. target[key] = clone(source[key], true);
  2292. }
  2293. }
  2294. }
  2295. return target;
  2296. }
  2297. /**
  2298. * @param {Array} targetAndSources The first item is target, and the rests are source.
  2299. * @param {boolean} [overwrite=false]
  2300. * @return {*} target
  2301. */
  2302. function mergeAll(targetAndSources, overwrite) {
  2303. var result = targetAndSources[0];
  2304. for (var i = 1, len = targetAndSources.length; i < len; i++) {
  2305. result = merge(result, targetAndSources[i], overwrite);
  2306. }
  2307. return result;
  2308. }
  2309. /**
  2310. * @param {*} target
  2311. * @param {*} source
  2312. * @memberOf module:zrender/core/util
  2313. */
  2314. function extend(target, source) {
  2315. for (var key in source) {
  2316. if (source.hasOwnProperty(key)) {
  2317. target[key] = source[key];
  2318. }
  2319. }
  2320. return target;
  2321. }
  2322. /**
  2323. * @param {*} target
  2324. * @param {*} source
  2325. * @param {boolen} [overlay=false]
  2326. * @memberOf module:zrender/core/util
  2327. */
  2328. function defaults(target, source, overlay) {
  2329. for (var key in source) {
  2330. if (source.hasOwnProperty(key)
  2331. && (overlay ? source[key] != null : target[key] == null)
  2332. ) {
  2333. target[key] = source[key];
  2334. }
  2335. }
  2336. return target;
  2337. }
  2338. function createCanvas() {
  2339. return document.createElement('canvas');
  2340. }
  2341. // FIXME
  2342. var _ctx;
  2343. function getContext() {
  2344. if (!_ctx) {
  2345. // Use util.createCanvas instead of createCanvas
  2346. // because createCanvas may be overwritten in different environment
  2347. _ctx = util.createCanvas().getContext('2d');
  2348. }
  2349. return _ctx;
  2350. }
  2351. /**
  2352. * 查询数组中元素的index
  2353. * @memberOf module:zrender/core/util
  2354. */
  2355. function indexOf(array, value) {
  2356. if (array) {
  2357. if (array.indexOf) {
  2358. return array.indexOf(value);
  2359. }
  2360. for (var i = 0, len = array.length; i < len; i++) {
  2361. if (array[i] === value) {
  2362. return i;
  2363. }
  2364. }
  2365. }
  2366. return -1;
  2367. }
  2368. /**
  2369. * 构造类继承关系
  2370. *
  2371. * @memberOf module:zrender/core/util
  2372. * @param {Function} clazz 源类
  2373. * @param {Function} baseClazz 基类
  2374. */
  2375. function inherits(clazz, baseClazz) {
  2376. var clazzPrototype = clazz.prototype;
  2377. function F() {}
  2378. F.prototype = baseClazz.prototype;
  2379. clazz.prototype = new F();
  2380. for (var prop in clazzPrototype) {
  2381. clazz.prototype[prop] = clazzPrototype[prop];
  2382. }
  2383. clazz.prototype.constructor = clazz;
  2384. clazz.superClass = baseClazz;
  2385. }
  2386. /**
  2387. * @memberOf module:zrender/core/util
  2388. * @param {Object|Function} target
  2389. * @param {Object|Function} sorce
  2390. * @param {boolean} overlay
  2391. */
  2392. function mixin(target, source, overlay) {
  2393. target = 'prototype' in target ? target.prototype : target;
  2394. source = 'prototype' in source ? source.prototype : source;
  2395. defaults(target, source, overlay);
  2396. }
  2397. /**
  2398. * @param {Array|TypedArray} data
  2399. */
  2400. function isArrayLike(data) {
  2401. if (! data) {
  2402. return;
  2403. }
  2404. if (typeof data == 'string') {
  2405. return false;
  2406. }
  2407. return typeof data.length == 'number';
  2408. }
  2409. /**
  2410. * 数组或对象遍历
  2411. * @memberOf module:zrender/core/util
  2412. * @param {Object|Array} obj
  2413. * @param {Function} cb
  2414. * @param {*} [context]
  2415. */
  2416. function each(obj, cb, context) {
  2417. if (!(obj && cb)) {
  2418. return;
  2419. }
  2420. if (obj.forEach && obj.forEach === nativeForEach) {
  2421. obj.forEach(cb, context);
  2422. }
  2423. else if (obj.length === +obj.length) {
  2424. for (var i = 0, len = obj.length; i < len; i++) {
  2425. cb.call(context, obj[i], i, obj);
  2426. }
  2427. }
  2428. else {
  2429. for (var key in obj) {
  2430. if (obj.hasOwnProperty(key)) {
  2431. cb.call(context, obj[key], key, obj);
  2432. }
  2433. }
  2434. }
  2435. }
  2436. /**
  2437. * 数组映射
  2438. * @memberOf module:zrender/core/util
  2439. * @param {Array} obj
  2440. * @param {Function} cb
  2441. * @param {*} [context]
  2442. * @return {Array}
  2443. */
  2444. function map(obj, cb, context) {
  2445. if (!(obj && cb)) {
  2446. return;
  2447. }
  2448. if (obj.map && obj.map === nativeMap) {
  2449. return obj.map(cb, context);
  2450. }
  2451. else {
  2452. var result = [];
  2453. for (var i = 0, len = obj.length; i < len; i++) {
  2454. result.push(cb.call(context, obj[i], i, obj));
  2455. }
  2456. return result;
  2457. }
  2458. }
  2459. /**
  2460. * @memberOf module:zrender/core/util
  2461. * @param {Array} obj
  2462. * @param {Function} cb
  2463. * @param {Object} [memo]
  2464. * @param {*} [context]
  2465. * @return {Array}
  2466. */
  2467. function reduce(obj, cb, memo, context) {
  2468. if (!(obj && cb)) {
  2469. return;
  2470. }
  2471. if (obj.reduce && obj.reduce === nativeReduce) {
  2472. return obj.reduce(cb, memo, context);
  2473. }
  2474. else {
  2475. for (var i = 0, len = obj.length; i < len; i++) {
  2476. memo = cb.call(context, memo, obj[i], i, obj);
  2477. }
  2478. return memo;
  2479. }
  2480. }
  2481. /**
  2482. * 数组过滤
  2483. * @memberOf module:zrender/core/util
  2484. * @param {Array} obj
  2485. * @param {Function} cb
  2486. * @param {*} [context]
  2487. * @return {Array}
  2488. */
  2489. function filter(obj, cb, context) {
  2490. if (!(obj && cb)) {
  2491. return;
  2492. }
  2493. if (obj.filter && obj.filter === nativeFilter) {
  2494. return obj.filter(cb, context);
  2495. }
  2496. else {
  2497. var result = [];
  2498. for (var i = 0, len = obj.length; i < len; i++) {
  2499. if (cb.call(context, obj[i], i, obj)) {
  2500. result.push(obj[i]);
  2501. }
  2502. }
  2503. return result;
  2504. }
  2505. }
  2506. /**
  2507. * 数组项查找
  2508. * @memberOf module:zrender/core/util
  2509. * @param {Array} obj
  2510. * @param {Function} cb
  2511. * @param {*} [context]
  2512. * @return {Array}
  2513. */
  2514. function find(obj, cb, context) {
  2515. if (!(obj && cb)) {
  2516. return;
  2517. }
  2518. for (var i = 0, len = obj.length; i < len; i++) {
  2519. if (cb.call(context, obj[i], i, obj)) {
  2520. return obj[i];
  2521. }
  2522. }
  2523. }
  2524. /**
  2525. * @memberOf module:zrender/core/util
  2526. * @param {Function} func
  2527. * @param {*} context
  2528. * @return {Function}
  2529. */
  2530. function bind(func, context) {
  2531. var args = nativeSlice.call(arguments, 2);
  2532. return function () {
  2533. return func.apply(context, args.concat(nativeSlice.call(arguments)));
  2534. };
  2535. }
  2536. /**
  2537. * @memberOf module:zrender/core/util
  2538. * @param {Function} func
  2539. * @return {Function}
  2540. */
  2541. function curry(func) {
  2542. var args = nativeSlice.call(arguments, 1);
  2543. return function () {
  2544. return func.apply(this, args.concat(nativeSlice.call(arguments)));
  2545. };
  2546. }
  2547. /**
  2548. * @memberOf module:zrender/core/util
  2549. * @param {*} value
  2550. * @return {boolean}
  2551. */
  2552. function isArray(value) {
  2553. return objToString.call(value) === '[object Array]';
  2554. }
  2555. /**
  2556. * @memberOf module:zrender/core/util
  2557. * @param {*} value
  2558. * @return {boolean}
  2559. */
  2560. function isFunction(value) {
  2561. return typeof value === 'function';
  2562. }
  2563. /**
  2564. * @memberOf module:zrender/core/util
  2565. * @param {*} value
  2566. * @return {boolean}
  2567. */
  2568. function isString(value) {
  2569. return objToString.call(value) === '[object String]';
  2570. }
  2571. /**
  2572. * @memberOf module:zrender/core/util
  2573. * @param {*} value
  2574. * @return {boolean}
  2575. */
  2576. function isObject(value) {
  2577. // Avoid a V8 JIT bug in Chrome 19-20.
  2578. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  2579. var type = typeof value;
  2580. return type === 'function' || (!!value && type == 'object');
  2581. }
  2582. /**
  2583. * @memberOf module:zrender/core/util
  2584. * @param {*} value
  2585. * @return {boolean}
  2586. */
  2587. function isBuildInObject(value) {
  2588. return !!BUILTIN_OBJECT[objToString.call(value)];
  2589. }
  2590. /**
  2591. * @memberOf module:zrender/core/util
  2592. * @param {*} value
  2593. * @return {boolean}
  2594. */
  2595. function isDom(value) {
  2596. return value && value.nodeType === 1
  2597. && typeof(value.nodeName) == 'string';
  2598. }
  2599. /**
  2600. * If value1 is not null, then return value1, otherwise judget rest of values.
  2601. * @memberOf module:zrender/core/util
  2602. * @return {*} Final value
  2603. */
  2604. function retrieve(values) {
  2605. for (var i = 0, len = arguments.length; i < len; i++) {
  2606. if (arguments[i] != null) {
  2607. return arguments[i];
  2608. }
  2609. }
  2610. }
  2611. /**
  2612. * @memberOf module:zrender/core/util
  2613. * @param {Array} arr
  2614. * @param {number} startIndex
  2615. * @param {number} endIndex
  2616. * @return {Array}
  2617. */
  2618. function slice() {
  2619. return Function.call.apply(nativeSlice, arguments);
  2620. }
  2621. /**
  2622. * @memberOf module:zrender/core/util
  2623. * @param {boolean} condition
  2624. * @param {string} message
  2625. */
  2626. function assert(condition, message) {
  2627. if (!condition) {
  2628. throw new Error(message);
  2629. }
  2630. }
  2631. var util = {
  2632. inherits: inherits,
  2633. mixin: mixin,
  2634. clone: clone,
  2635. merge: merge,
  2636. mergeAll: mergeAll,
  2637. extend: extend,
  2638. defaults: defaults,
  2639. getContext: getContext,
  2640. createCanvas: createCanvas,
  2641. indexOf: indexOf,
  2642. slice: slice,
  2643. find: find,
  2644. isArrayLike: isArrayLike,
  2645. each: each,
  2646. map: map,
  2647. reduce: reduce,
  2648. filter: filter,
  2649. bind: bind,
  2650. curry: curry,
  2651. isArray: isArray,
  2652. isString: isString,
  2653. isObject: isObject,
  2654. isFunction: isFunction,
  2655. isBuildInObject: isBuildInObject,
  2656. isDom: isDom,
  2657. retrieve: retrieve,
  2658. assert: assert,
  2659. noop: function () {}
  2660. };
  2661. module.exports = util;
  2662. /***/ },
  2663. /* 5 */
  2664. /***/ function(module, exports, __webpack_require__) {
  2665. var formatUtil = __webpack_require__(6);
  2666. var nubmerUtil = __webpack_require__(7);
  2667. var Model = __webpack_require__(12);
  2668. var zrUtil = __webpack_require__(4);
  2669. var AXIS_DIMS = ['x', 'y', 'z', 'radius', 'angle'];
  2670. var modelUtil = {};
  2671. /**
  2672. * Create "each" method to iterate names.
  2673. *
  2674. * @pubilc
  2675. * @param {Array.<string>} names
  2676. * @param {Array.<string>=} attrs
  2677. * @return {Function}
  2678. */
  2679. modelUtil.createNameEach = function (names, attrs) {
  2680. names = names.slice();
  2681. var capitalNames = zrUtil.map(names, modelUtil.capitalFirst);
  2682. attrs = (attrs || []).slice();
  2683. var capitalAttrs = zrUtil.map(attrs, modelUtil.capitalFirst);
  2684. return function (callback, context) {
  2685. zrUtil.each(names, function (name, index) {
  2686. var nameObj = {name: name, capital: capitalNames[index]};
  2687. for (var j = 0; j < attrs.length; j++) {
  2688. nameObj[attrs[j]] = name + capitalAttrs[j];
  2689. }
  2690. callback.call(context, nameObj);
  2691. });
  2692. };
  2693. };
  2694. /**
  2695. * @public
  2696. */
  2697. modelUtil.capitalFirst = function (str) {
  2698. return str ? str.charAt(0).toUpperCase() + str.substr(1) : str;
  2699. };
  2700. /**
  2701. * Iterate each dimension name.
  2702. *
  2703. * @public
  2704. * @param {Function} callback The parameter is like:
  2705. * {
  2706. * name: 'angle',
  2707. * capital: 'Angle',
  2708. * axis: 'angleAxis',
  2709. * axisIndex: 'angleAixs',
  2710. * index: 'angleIndex'
  2711. * }
  2712. * @param {Object} context
  2713. */
  2714. modelUtil.eachAxisDim = modelUtil.createNameEach(AXIS_DIMS, ['axisIndex', 'axis', 'index']);
  2715. /**
  2716. * If value is not array, then translate it to array.
  2717. * @param {*} value
  2718. * @return {Array} [value] or value
  2719. */
  2720. modelUtil.normalizeToArray = function (value) {
  2721. return value instanceof Array
  2722. ? value
  2723. : value == null
  2724. ? []
  2725. : [value];
  2726. };
  2727. /**
  2728. * If tow dataZoomModels has the same axis controlled, we say that they are 'linked'.
  2729. * dataZoomModels and 'links' make up one or more graphics.
  2730. * This function finds the graphic where the source dataZoomModel is in.
  2731. *
  2732. * @public
  2733. * @param {Function} forEachNode Node iterator.
  2734. * @param {Function} forEachEdgeType edgeType iterator
  2735. * @param {Function} edgeIdGetter Giving node and edgeType, return an array of edge id.
  2736. * @return {Function} Input: sourceNode, Output: Like {nodes: [], dims: {}}
  2737. */
  2738. modelUtil.createLinkedNodesFinder = function (forEachNode, forEachEdgeType, edgeIdGetter) {
  2739. return function (sourceNode) {
  2740. var result = {
  2741. nodes: [],
  2742. records: {} // key: edgeType.name, value: Object (key: edge id, value: boolean).
  2743. };
  2744. forEachEdgeType(function (edgeType) {
  2745. result.records[edgeType.name] = {};
  2746. });
  2747. if (!sourceNode) {
  2748. return result;
  2749. }
  2750. absorb(sourceNode, result);
  2751. var existsLink;
  2752. do {
  2753. existsLink = false;
  2754. forEachNode(processSingleNode);
  2755. }
  2756. while (existsLink);
  2757. function processSingleNode(node) {
  2758. if (!isNodeAbsorded(node, result) && isLinked(node, result)) {
  2759. absorb(node, result);
  2760. existsLink = true;
  2761. }
  2762. }
  2763. return result;
  2764. };
  2765. function isNodeAbsorded(node, result) {
  2766. return zrUtil.indexOf(result.nodes, node) >= 0;
  2767. }
  2768. function isLinked(node, result) {
  2769. var hasLink = false;
  2770. forEachEdgeType(function (edgeType) {
  2771. zrUtil.each(edgeIdGetter(node, edgeType) || [], function (edgeId) {
  2772. result.records[edgeType.name][edgeId] && (hasLink = true);
  2773. });
  2774. });
  2775. return hasLink;
  2776. }
  2777. function absorb(node, result) {
  2778. result.nodes.push(node);
  2779. forEachEdgeType(function (edgeType) {
  2780. zrUtil.each(edgeIdGetter(node, edgeType) || [], function (edgeId) {
  2781. result.records[edgeType.name][edgeId] = true;
  2782. });
  2783. });
  2784. }
  2785. };
  2786. /**
  2787. * Sync default option between normal and emphasis like `position` and `show`
  2788. * In case some one will write code like
  2789. * label: {
  2790. * normal: {
  2791. * show: false,
  2792. * position: 'outside',
  2793. * textStyle: {
  2794. * fontSize: 18
  2795. * }
  2796. * },
  2797. * emphasis: {
  2798. * show: true
  2799. * }
  2800. * }
  2801. * @param {Object} opt
  2802. * @param {Array.<string>} subOpts
  2803. */
  2804. modelUtil.defaultEmphasis = function (opt, subOpts) {
  2805. if (opt) {
  2806. var emphasisOpt = opt.emphasis = opt.emphasis || {};
  2807. var normalOpt = opt.normal = opt.normal || {};
  2808. // Default emphasis option from normal
  2809. zrUtil.each(subOpts, function (subOptName) {
  2810. var val = zrUtil.retrieve(emphasisOpt[subOptName], normalOpt[subOptName]);
  2811. if (val != null) {
  2812. emphasisOpt[subOptName] = val;
  2813. }
  2814. });
  2815. }
  2816. };
  2817. modelUtil.LABEL_OPTIONS = ['position', 'show', 'textStyle', 'distance', 'formatter'];
  2818. /**
  2819. * data could be [12, 2323, {value: 223}, [1221, 23], {value: [2, 23]}]
  2820. * This helper method retieves value from data.
  2821. * @param {string|number|Date|Array|Object} dataItem
  2822. * @return {number|string|Date|Array.<number|string|Date>}
  2823. */
  2824. modelUtil.getDataItemValue = function (dataItem) {
  2825. // Performance sensitive.
  2826. return dataItem && (dataItem.value == null ? dataItem : dataItem.value);
  2827. };
  2828. /**
  2829. * data could be [12, 2323, {value: 223}, [1221, 23], {value: [2, 23]}]
  2830. * This helper method determine if dataItem has extra option besides value
  2831. * @param {string|number|Date|Array|Object} dataItem
  2832. */
  2833. modelUtil.isDataItemOption = function (dataItem) {
  2834. return zrUtil.isObject(dataItem)
  2835. && !(dataItem instanceof Array);
  2836. // // markLine data can be array
  2837. // && !(dataItem[0] && zrUtil.isObject(dataItem[0]) && !(dataItem[0] instanceof Array));
  2838. };
  2839. /**
  2840. * This helper method convert value in data.
  2841. * @param {string|number|Date} value
  2842. * @param {Object|string} [dimInfo] If string (like 'x'), dimType defaults 'number'.
  2843. */
  2844. modelUtil.converDataValue = function (value, dimInfo) {
  2845. // Performance sensitive.
  2846. var dimType = dimInfo && dimInfo.type;
  2847. if (dimType === 'ordinal') {
  2848. return value;
  2849. }
  2850. if (dimType === 'time' && !isFinite(value) && value != null && value !== '-') {
  2851. value = +nubmerUtil.parseDate(value);
  2852. }
  2853. // dimType defaults 'number'.
  2854. // If dimType is not ordinal and value is null or undefined or NaN or '-',
  2855. // parse to NaN.
  2856. return (value == null || value === '')
  2857. ? NaN : +value; // If string (like '-'), using '+' parse to NaN
  2858. };
  2859. /**
  2860. * Create a model proxy to be used in tooltip for edge data, markLine data, markPoint data.
  2861. * @param {module:echarts/data/List} data
  2862. * @param {Object} opt
  2863. * @param {string} [opt.seriesIndex]
  2864. * @param {Object} [opt.name]
  2865. * @param {Object} [opt.mainType]
  2866. * @param {Object} [opt.subType]
  2867. */
  2868. modelUtil.createDataFormatModel = function (data, opt) {
  2869. var model = new Model();
  2870. zrUtil.mixin(model, modelUtil.dataFormatMixin);
  2871. model.seriesIndex = opt.seriesIndex;
  2872. model.name = opt.name || '';
  2873. model.mainType = opt.mainType;
  2874. model.subType = opt.subType;
  2875. model.getData = function () {
  2876. return data;
  2877. };
  2878. return model;
  2879. };
  2880. // PENDING A little ugly
  2881. modelUtil.dataFormatMixin = {
  2882. /**
  2883. * Get params for formatter
  2884. * @param {number} dataIndex
  2885. * @param {string} [dataType]
  2886. * @return {Object}
  2887. */
  2888. getDataParams: function (dataIndex, dataType) {
  2889. var data = this.getData(dataType);
  2890. var seriesIndex = this.seriesIndex;
  2891. var seriesName = this.name;
  2892. var rawValue = this.getRawValue(dataIndex, dataType);
  2893. var rawDataIndex = data.getRawIndex(dataIndex);
  2894. var name = data.getName(dataIndex, true);
  2895. var itemOpt = data.getRawDataItem(dataIndex);
  2896. return {
  2897. componentType: this.mainType,
  2898. componentSubType: this.subType,
  2899. seriesType: this.mainType === 'series' ? this.subType : null,
  2900. seriesIndex: seriesIndex,
  2901. seriesName: seriesName,
  2902. name: name,
  2903. dataIndex: rawDataIndex,
  2904. data: itemOpt,
  2905. dataType: dataType,
  2906. value: rawValue,
  2907. color: data.getItemVisual(dataIndex, 'color'),
  2908. // Param name list for mapping `a`, `b`, `c`, `d`, `e`
  2909. $vars: ['seriesName', 'name', 'value']
  2910. };
  2911. },
  2912. /**
  2913. * Format label
  2914. * @param {number} dataIndex
  2915. * @param {string} [status='normal'] 'normal' or 'emphasis'
  2916. * @param {string} [dataType]
  2917. * @param {number} [dimIndex]
  2918. * @return {string}
  2919. */
  2920. getFormattedLabel: function (dataIndex, status, dataType, dimIndex) {
  2921. status = status || 'normal';
  2922. var data = this.getData(dataType);
  2923. var itemModel = data.getItemModel(dataIndex);
  2924. var params = this.getDataParams(dataIndex, dataType);
  2925. if (dimIndex != null && (params.value instanceof Array)) {
  2926. params.value = params.value[dimIndex];
  2927. }
  2928. var formatter = itemModel.get(['label', status, 'formatter']);
  2929. if (typeof formatter === 'function') {
  2930. params.status = status;
  2931. return formatter(params);
  2932. }
  2933. else if (typeof formatter === 'string') {
  2934. return formatUtil.formatTpl(formatter, params);
  2935. }
  2936. },
  2937. /**
  2938. * Get raw value in option
  2939. * @param {number} idx
  2940. * @param {string} [dataType]
  2941. * @return {Object}
  2942. */
  2943. getRawValue: function (idx, dataType) {
  2944. var data = this.getData(dataType);
  2945. var dataItem = data.getRawDataItem(idx);
  2946. if (dataItem != null) {
  2947. return (zrUtil.isObject(dataItem) && !(dataItem instanceof Array))
  2948. ? dataItem.value : dataItem;
  2949. }
  2950. },
  2951. /**
  2952. * Should be implemented.
  2953. * @param {number} dataIndex
  2954. * @param {boolean} [multipleSeries=false]
  2955. * @param {number} [dataType]
  2956. * @return {string} tooltip string
  2957. */
  2958. formatTooltip: zrUtil.noop
  2959. };
  2960. /**
  2961. * Mapping to exists for merge.
  2962. *
  2963. * @public
  2964. * @param {Array.<Object>|Array.<module:echarts/model/Component>} exists
  2965. * @param {Object|Array.<Object>} newCptOptions
  2966. * @return {Array.<Object>} Result, like [{exist: ..., option: ...}, {}],
  2967. * which order is the same as exists.
  2968. */
  2969. modelUtil.mappingToExists = function (exists, newCptOptions) {
  2970. // Mapping by the order by original option (but not order of
  2971. // new option) in merge mode. Because we should ensure
  2972. // some specified index (like xAxisIndex) is consistent with
  2973. // original option, which is easy to understand, espatially in
  2974. // media query. And in most case, merge option is used to
  2975. // update partial option but not be expected to change order.
  2976. newCptOptions = (newCptOptions || []).slice();
  2977. var result = zrUtil.map(exists || [], function (obj, index) {
  2978. return {exist: obj};
  2979. });
  2980. // Mapping by id or name if specified.
  2981. zrUtil.each(newCptOptions, function (cptOption, index) {
  2982. if (!zrUtil.isObject(cptOption)) {
  2983. return;
  2984. }
  2985. for (var i = 0; i < result.length; i++) {
  2986. var exist = result[i].exist;
  2987. if (!result[i].option // Consider name: two map to one.
  2988. && (
  2989. // id has highest priority.
  2990. (cptOption.id != null && exist.id === cptOption.id + '')
  2991. || (cptOption.name != null
  2992. && !modelUtil.isIdInner(cptOption)
  2993. && !modelUtil.isIdInner(exist)
  2994. && exist.name === cptOption.name + ''
  2995. )
  2996. )
  2997. ) {
  2998. result[i].option = cptOption;
  2999. newCptOptions[index] = null;
  3000. break;
  3001. }
  3002. }
  3003. });
  3004. // Otherwise mapping by index.
  3005. zrUtil.each(newCptOptions, function (cptOption, index) {
  3006. if (!zrUtil.isObject(cptOption)) {
  3007. return;
  3008. }
  3009. var i = 0;
  3010. for (; i < result.length; i++) {
  3011. var exist = result[i].exist;
  3012. if (!result[i].option
  3013. && !modelUtil.isIdInner(exist)
  3014. // Caution:
  3015. // Do not overwrite id. But name can be overwritten,
  3016. // because axis use name as 'show label text'.
  3017. // 'exist' always has id and name and we dont
  3018. // need to check it.
  3019. && cptOption.id == null
  3020. ) {
  3021. result[i].option = cptOption;
  3022. break;
  3023. }
  3024. }
  3025. if (i >= result.length) {
  3026. result.push({option: cptOption});
  3027. }
  3028. });
  3029. return result;
  3030. };
  3031. /**
  3032. * @public
  3033. * @param {Object} cptOption
  3034. * @return {boolean}
  3035. */
  3036. modelUtil.isIdInner = function (cptOption) {
  3037. return zrUtil.isObject(cptOption)
  3038. && cptOption.id
  3039. && (cptOption.id + '').indexOf('\0_ec_\0') === 0;
  3040. };
  3041. /**
  3042. * A helper for removing duplicate items between batchA and batchB,
  3043. * and in themselves, and categorize by series.
  3044. *
  3045. * @param {Array.<Object>} batchA Like: [{seriesId: 2, dataIndex: [32, 4, 5]}, ...]
  3046. * @param {Array.<Object>} batchB Like: [{seriesId: 2, dataIndex: [32, 4, 5]}, ...]
  3047. * @return {Array.<Array.<Object>, Array.<Object>>} result: [resultBatchA, resultBatchB]
  3048. */
  3049. modelUtil.compressBatches = function (batchA, batchB) {
  3050. var mapA = {};
  3051. var mapB = {};
  3052. makeMap(batchA || [], mapA);
  3053. makeMap(batchB || [], mapB, mapA);
  3054. return [mapToArray(mapA), mapToArray(mapB)];
  3055. function makeMap(sourceBatch, map, otherMap) {
  3056. for (var i = 0, len = sourceBatch.length; i < len; i++) {
  3057. var seriesId = sourceBatch[i].seriesId;
  3058. var dataIndices = modelUtil.normalizeToArray(sourceBatch[i].dataIndex);
  3059. var otherDataIndices = otherMap && otherMap[seriesId];
  3060. for (var j = 0, lenj = dataIndices.length; j < lenj; j++) {
  3061. var dataIndex = dataIndices[j];
  3062. if (otherDataIndices && otherDataIndices[dataIndex]) {
  3063. otherDataIndices[dataIndex] = null;
  3064. }
  3065. else {
  3066. (map[seriesId] || (map[seriesId] = {}))[dataIndex] = 1;
  3067. }
  3068. }
  3069. }
  3070. }
  3071. function mapToArray(map, isData) {
  3072. var result = [];
  3073. for (var i in map) {
  3074. if (map.hasOwnProperty(i) && map[i] != null) {
  3075. if (isData) {
  3076. result.push(+i);
  3077. }
  3078. else {
  3079. var dataIndices = mapToArray(map[i], true);
  3080. dataIndices.length && result.push({seriesId: i, dataIndex: dataIndices});
  3081. }
  3082. }
  3083. }
  3084. return result;
  3085. }
  3086. };
  3087. module.exports = modelUtil;
  3088. /***/ },
  3089. /* 6 */
  3090. /***/ function(module, exports, __webpack_require__) {
  3091. var zrUtil = __webpack_require__(4);
  3092. var numberUtil = __webpack_require__(7);
  3093. var textContain = __webpack_require__(8);
  3094. /**
  3095. * 每三位默认加,格式化
  3096. * @type {string|number} x
  3097. */
  3098. function addCommas(x) {
  3099. if (isNaN(x)) {
  3100. return '-';
  3101. }
  3102. x = (x + '').split('.');
  3103. return x[0].replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g,'$1,')
  3104. + (x.length > 1 ? ('.' + x[1]) : '');
  3105. }
  3106. /**
  3107. * @param {string} str
  3108. * @return {string} str
  3109. */
  3110. function toCamelCase(str) {
  3111. return str.toLowerCase().replace(/-(.)/g, function(match, group1) {
  3112. return group1.toUpperCase();
  3113. });
  3114. }
  3115. /**
  3116. * Normalize css liked array configuration
  3117. * e.g.
  3118. * 3 => [3, 3, 3, 3]
  3119. * [4, 2] => [4, 2, 4, 2]
  3120. * [4, 3, 2] => [4, 3, 2, 3]
  3121. * @param {number|Array.<number>} val
  3122. */
  3123. function normalizeCssArray(val) {
  3124. var len = val.length;
  3125. if (typeof (val) === 'number') {
  3126. return [val, val, val, val];
  3127. }
  3128. else if (len === 2) {
  3129. // vertical | horizontal
  3130. return [val[0], val[1], val[0], val[1]];
  3131. }
  3132. else if (len === 3) {
  3133. // top | horizontal | bottom
  3134. return [val[0], val[1], val[2], val[1]];
  3135. }
  3136. return val;
  3137. }
  3138. function encodeHTML(source) {
  3139. return String(source)
  3140. .replace(/&/g, '&amp;')
  3141. .replace(/</g, '&lt;')
  3142. .replace(/>/g, '&gt;')
  3143. .replace(/"/g, '&quot;')
  3144. .replace(/'/g, '&#39;');
  3145. }
  3146. var TPL_VAR_ALIAS = ['a', 'b', 'c', 'd', 'e', 'f', 'g'];
  3147. function wrapVar(varName, seriesIdx) {
  3148. return '{' + varName + (seriesIdx == null ? '' : seriesIdx) + '}';
  3149. }
  3150. /**
  3151. * Template formatter
  3152. * @param {string} tpl
  3153. * @param {Array.<Object>|Object} paramsList
  3154. * @return {string}
  3155. */
  3156. function formatTpl(tpl, paramsList) {
  3157. if (!zrUtil.isArray(paramsList)) {
  3158. paramsList = [paramsList];
  3159. }
  3160. var seriesLen = paramsList.length;
  3161. if (!seriesLen) {
  3162. return '';
  3163. }
  3164. var $vars = paramsList[0].$vars || [];
  3165. for (var i = 0; i < $vars.length; i++) {
  3166. var alias = TPL_VAR_ALIAS[i];
  3167. tpl = tpl.replace(wrapVar(alias), wrapVar(alias, 0));
  3168. }
  3169. for (var seriesIdx = 0; seriesIdx < seriesLen; seriesIdx++) {
  3170. for (var k = 0; k < $vars.length; k++) {
  3171. tpl = tpl.replace(
  3172. wrapVar(TPL_VAR_ALIAS[k], seriesIdx),
  3173. paramsList[seriesIdx][$vars[k]]
  3174. );
  3175. }
  3176. }
  3177. return tpl;
  3178. }
  3179. /**
  3180. * ISO Date format
  3181. * @param {string} tpl
  3182. * @param {number} value
  3183. * @inner
  3184. */
  3185. function formatTime(tpl, value) {
  3186. if (tpl === 'week'
  3187. || tpl === 'month'
  3188. || tpl === 'quarter'
  3189. || tpl === 'half-year'
  3190. || tpl === 'year'
  3191. ) {
  3192. tpl = 'MM-dd\nyyyy';
  3193. }
  3194. var date = numberUtil.parseDate(value);
  3195. var y = date.getFullYear();
  3196. var M = date.getMonth() + 1;
  3197. var d = date.getDate();
  3198. var h = date.getHours();
  3199. var m = date.getMinutes();
  3200. var s = date.getSeconds();
  3201. tpl = tpl.replace('MM', s2d(M))
  3202. .toLowerCase()
  3203. .replace('yyyy', y)
  3204. .replace('yy', y % 100)
  3205. .replace('dd', s2d(d))
  3206. .replace('d', d)
  3207. .replace('hh', s2d(h))
  3208. .replace('h', h)
  3209. .replace('mm', s2d(m))
  3210. .replace('m', m)
  3211. .replace('ss', s2d(s))
  3212. .replace('s', s);
  3213. return tpl;
  3214. }
  3215. /**
  3216. * @param {string} str
  3217. * @return {string}
  3218. * @inner
  3219. */
  3220. function s2d(str) {
  3221. return str < 10 ? ('0' + str) : str;
  3222. }
  3223. module.exports = {
  3224. normalizeCssArray: normalizeCssArray,
  3225. addCommas: addCommas,
  3226. toCamelCase: toCamelCase,
  3227. encodeHTML: encodeHTML,
  3228. formatTpl: formatTpl,
  3229. formatTime: formatTime,
  3230. truncateText: textContain.truncateText
  3231. };
  3232. /***/ },
  3233. /* 7 */
  3234. /***/ function(module, exports) {
  3235. /**
  3236. * 数值处理模块
  3237. * @module echarts/util/number
  3238. */
  3239. var number = {};
  3240. var RADIAN_EPSILON = 1e-4;
  3241. function _trim(str) {
  3242. return str.replace(/^\s+/, '').replace(/\s+$/, '');
  3243. }
  3244. /**
  3245. * Linear mapping a value from domain to range
  3246. * @memberOf module:echarts/util/number
  3247. * @param {(number|Array.<number>)} val
  3248. * @param {Array.<number>} domain Domain extent domain[0] can be bigger than domain[1]
  3249. * @param {Array.<number>} range Range extent range[0] can be bigger than range[1]
  3250. * @param {boolean} clamp
  3251. * @return {(number|Array.<number>}
  3252. */
  3253. number.linearMap = function (val, domain, range, clamp) {
  3254. var subDomain = domain[1] - domain[0];
  3255. var subRange = range[1] - range[0];
  3256. if (subDomain === 0) {
  3257. return subRange === 0
  3258. ? range[0]
  3259. : (range[0] + range[1]) / 2;
  3260. }
  3261. // Avoid accuracy problem in edge, such as
  3262. // 146.39 - 62.83 === 83.55999999999999.
  3263. // See echarts/test/ut/spec/util/number.js#linearMap#accuracyError
  3264. // It is a little verbose for efficiency considering this method
  3265. // is a hotspot.
  3266. if (clamp) {
  3267. if (subDomain > 0) {
  3268. if (val <= domain[0]) {
  3269. return range[0];
  3270. }
  3271. else if (val >= domain[1]) {
  3272. return range[1];
  3273. }
  3274. }
  3275. else {
  3276. if (val >= domain[0]) {
  3277. return range[0];
  3278. }
  3279. else if (val <= domain[1]) {
  3280. return range[1];
  3281. }
  3282. }
  3283. }
  3284. else {
  3285. if (val === domain[0]) {
  3286. return range[0];
  3287. }
  3288. if (val === domain[1]) {
  3289. return range[1];
  3290. }
  3291. }
  3292. return (val - domain[0]) / subDomain * subRange + range[0];
  3293. };
  3294. /**
  3295. * Convert a percent string to absolute number.
  3296. * Returns NaN if percent is not a valid string or number
  3297. * @memberOf module:echarts/util/number
  3298. * @param {string|number} percent
  3299. * @param {number} all
  3300. * @return {number}
  3301. */
  3302. number.parsePercent = function(percent, all) {
  3303. switch (percent) {
  3304. case 'center':
  3305. case 'middle':
  3306. percent = '50%';
  3307. break;
  3308. case 'left':
  3309. case 'top':
  3310. percent = '0%';
  3311. break;
  3312. case 'right':
  3313. case 'bottom':
  3314. percent = '100%';
  3315. break;
  3316. }
  3317. if (typeof percent === 'string') {
  3318. if (_trim(percent).match(/%$/)) {
  3319. return parseFloat(percent) / 100 * all;
  3320. }
  3321. return parseFloat(percent);
  3322. }
  3323. return percent == null ? NaN : +percent;
  3324. };
  3325. /**
  3326. * Fix rounding error of float numbers
  3327. * @param {number} x
  3328. * @return {number}
  3329. */
  3330. number.round = function (x) {
  3331. // PENDING
  3332. return +(+x).toFixed(10);
  3333. };
  3334. number.asc = function (arr) {
  3335. arr.sort(function (a, b) {
  3336. return a - b;
  3337. });
  3338. return arr;
  3339. };
  3340. /**
  3341. * Get precision
  3342. * @param {number} val
  3343. */
  3344. number.getPrecision = function (val) {
  3345. val = +val;
  3346. if (isNaN(val)) {
  3347. return 0;
  3348. }
  3349. // It is much faster than methods converting number to string as follows
  3350. // var tmp = val.toString();
  3351. // return tmp.length - 1 - tmp.indexOf('.');
  3352. // especially when precision is low
  3353. var e = 1;
  3354. var count = 0;
  3355. while (Math.round(val * e) / e !== val) {
  3356. e *= 10;
  3357. count++;
  3358. }
  3359. return count;
  3360. };
  3361. /**
  3362. * @param {Array.<number>} dataExtent
  3363. * @param {Array.<number>} pixelExtent
  3364. * @return {number} precision
  3365. */
  3366. number.getPixelPrecision = function (dataExtent, pixelExtent) {
  3367. var log = Math.log;
  3368. var LN10 = Math.LN10;
  3369. var dataQuantity = Math.floor(log(dataExtent[1] - dataExtent[0]) / LN10);
  3370. var sizeQuantity = Math.round(log(Math.abs(pixelExtent[1] - pixelExtent[0])) / LN10);
  3371. return Math.max(
  3372. -dataQuantity + sizeQuantity,
  3373. 0
  3374. );
  3375. };
  3376. // Number.MAX_SAFE_INTEGER, ie do not support.
  3377. number.MAX_SAFE_INTEGER = 9007199254740991;
  3378. /**
  3379. * To 0 - 2 * PI, considering negative radian.
  3380. * @param {number} radian
  3381. * @return {number}
  3382. */
  3383. number.remRadian = function (radian) {
  3384. var pi2 = Math.PI * 2;
  3385. return (radian % pi2 + pi2) % pi2;
  3386. };
  3387. /**
  3388. * @param {type} radian
  3389. * @return {boolean}
  3390. */
  3391. number.isRadianAroundZero = function (val) {
  3392. return val > -RADIAN_EPSILON && val < RADIAN_EPSILON;
  3393. };
  3394. /**
  3395. * @param {string|Date|number} value
  3396. * @return {number} timestamp
  3397. */
  3398. number.parseDate = function (value) {
  3399. return value instanceof Date
  3400. ? value
  3401. : new Date(
  3402. typeof value === 'string'
  3403. // FIXME Date.parse('1970-01-01') is UTC, Date.parse('1970/01/01') is local
  3404. ? (new Date(value.replace(/-/g, '/')) - new Date('1970/01/01'))
  3405. : Math.round(value)
  3406. );
  3407. };
  3408. /**
  3409. * Quantity of a number. e.g. 0.1, 1, 10, 100
  3410. * @param {number} val
  3411. * @return {number}
  3412. */
  3413. number.quantity = function (val) {
  3414. return Math.pow(10, Math.floor(Math.log(val) / Math.LN10));
  3415. };
  3416. // "Nice Numbers for Graph Labels" of Graphic Gems
  3417. /**
  3418. * find a “nice” number approximately equal to x. Round the number if round = true, take ceiling if round = false
  3419. * The primary observation is that the “nicest” numbers in decimal are 1, 2, and 5, and all power-of-ten multiples of these numbers.
  3420. * @param {number} val
  3421. * @param {boolean} round
  3422. * @return {number}
  3423. */
  3424. number.nice = function (val, round) {
  3425. var exp10 = number.quantity(val);
  3426. var f = val / exp10; // between 1 and 10
  3427. var nf;
  3428. if (round) {
  3429. if (f < 1.5) { nf = 1; }
  3430. else if (f < 2.5) { nf = 2; }
  3431. else if (f < 4) { nf = 3; }
  3432. else if (f < 7) { nf = 5; }
  3433. else { nf = 10; }
  3434. }
  3435. else {
  3436. if (f < 1) { nf = 1; }
  3437. else if (f < 2) { nf = 2; }
  3438. else if (f < 3) { nf = 3; }
  3439. else if (f < 5) { nf = 5; }
  3440. else { nf = 10; }
  3441. }
  3442. return nf * exp10;
  3443. };
  3444. module.exports = number;
  3445. /***/ },
  3446. /* 8 */
  3447. /***/ function(module, exports, __webpack_require__) {
  3448. var textWidthCache = {};
  3449. var textWidthCacheCounter = 0;
  3450. var TEXT_CACHE_MAX = 5000;
  3451. var util = __webpack_require__(4);
  3452. var BoundingRect = __webpack_require__(9);
  3453. var retrieve = util.retrieve;
  3454. function getTextWidth(text, textFont) {
  3455. var key = text + ':' + textFont;
  3456. if (textWidthCache[key]) {
  3457. return textWidthCache[key];
  3458. }
  3459. var textLines = (text + '').split('\n');
  3460. var width = 0;
  3461. for (var i = 0, l = textLines.length; i < l; i++) {
  3462. // measureText 可以被覆盖以兼容不支持 Canvas 的环境
  3463. width = Math.max(textContain.measureText(textLines[i], textFont).width, width);
  3464. }
  3465. if (textWidthCacheCounter > TEXT_CACHE_MAX) {
  3466. textWidthCacheCounter = 0;
  3467. textWidthCache = {};
  3468. }
  3469. textWidthCacheCounter++;
  3470. textWidthCache[key] = width;
  3471. return width;
  3472. }
  3473. function getTextRect(text, textFont, textAlign, textBaseline) {
  3474. var textLineLen = ((text || '') + '').split('\n').length;
  3475. var width = getTextWidth(text, textFont);
  3476. // FIXME 高度计算比较粗暴
  3477. var lineHeight = getTextWidth('国', textFont);
  3478. var height = textLineLen * lineHeight;
  3479. var rect = new BoundingRect(0, 0, width, height);
  3480. // Text has a special line height property
  3481. rect.lineHeight = lineHeight;
  3482. switch (textBaseline) {
  3483. case 'bottom':
  3484. case 'alphabetic':
  3485. rect.y -= lineHeight;
  3486. break;
  3487. case 'middle':
  3488. rect.y -= lineHeight / 2;
  3489. break;
  3490. // case 'hanging':
  3491. // case 'top':
  3492. }
  3493. // FIXME Right to left language
  3494. switch (textAlign) {
  3495. case 'end':
  3496. case 'right':
  3497. rect.x -= rect.width;
  3498. break;
  3499. case 'center':
  3500. rect.x -= rect.width / 2;
  3501. break;
  3502. // case 'start':
  3503. // case 'left':
  3504. }
  3505. return rect;
  3506. }
  3507. function adjustTextPositionOnRect(textPosition, rect, textRect, distance) {
  3508. var x = rect.x;
  3509. var y = rect.y;
  3510. var height = rect.height;
  3511. var width = rect.width;
  3512. var textHeight = textRect.height;
  3513. var halfHeight = height / 2 - textHeight / 2;
  3514. var textAlign = 'left';
  3515. switch (textPosition) {
  3516. case 'left':
  3517. x -= distance;
  3518. y += halfHeight;
  3519. textAlign = 'right';
  3520. break;
  3521. case 'right':
  3522. x += distance + width;
  3523. y += halfHeight;
  3524. textAlign = 'left';
  3525. break;
  3526. case 'top':
  3527. x += width / 2;
  3528. y -= distance + textHeight;
  3529. textAlign = 'center';
  3530. break;
  3531. case 'bottom':
  3532. x += width / 2;
  3533. y += height + distance;
  3534. textAlign = 'center';
  3535. break;
  3536. case 'inside':
  3537. x += width / 2;
  3538. y += halfHeight;
  3539. textAlign = 'center';
  3540. break;
  3541. case 'insideLeft':
  3542. x += distance;
  3543. y += halfHeight;
  3544. textAlign = 'left';
  3545. break;
  3546. case 'insideRight':
  3547. x += width - distance;
  3548. y += halfHeight;
  3549. textAlign = 'right';
  3550. break;
  3551. case 'insideTop':
  3552. x += width / 2;
  3553. y += distance;
  3554. textAlign = 'center';
  3555. break;
  3556. case 'insideBottom':
  3557. x += width / 2;
  3558. y += height - textHeight - distance;
  3559. textAlign = 'center';
  3560. break;
  3561. case 'insideTopLeft':
  3562. x += distance;
  3563. y += distance;
  3564. textAlign = 'left';
  3565. break;
  3566. case 'insideTopRight':
  3567. x += width - distance;
  3568. y += distance;
  3569. textAlign = 'right';
  3570. break;
  3571. case 'insideBottomLeft':
  3572. x += distance;
  3573. y += height - textHeight - distance;
  3574. break;
  3575. case 'insideBottomRight':
  3576. x += width - distance;
  3577. y += height - textHeight - distance;
  3578. textAlign = 'right';
  3579. break;
  3580. }
  3581. return {
  3582. x: x,
  3583. y: y,
  3584. textAlign: textAlign,
  3585. textBaseline: 'top'
  3586. };
  3587. }
  3588. /**
  3589. * Show ellipsis if overflow.
  3590. *
  3591. * @param {string} text
  3592. * @param {string} containerWidth
  3593. * @param {string} textFont
  3594. * @param {number} [ellipsis='...']
  3595. * @param {Object} [options]
  3596. * @param {number} [options.maxIterations=3]
  3597. * @param {number} [options.minChar=0] If truncate result are less
  3598. * then minChar, ellipsis will not show, which is
  3599. * better for user hint in some cases.
  3600. * @param {number} [options.placeholder=''] When all truncated, use the placeholder.
  3601. * @return {string}
  3602. */
  3603. function truncateText(text, containerWidth, textFont, ellipsis, options) {
  3604. if (!containerWidth) {
  3605. return '';
  3606. }
  3607. options = options || {};
  3608. ellipsis = retrieve(ellipsis, '...');
  3609. var maxIterations = retrieve(options.maxIterations, 2);
  3610. var minChar = retrieve(options.minChar, 0);
  3611. // FIXME
  3612. // Other languages?
  3613. var cnCharWidth = getTextWidth('国', textFont);
  3614. // FIXME
  3615. // Consider proportional font?
  3616. var ascCharWidth = getTextWidth('a', textFont);
  3617. var placeholder = retrieve(options.placeholder, '');
  3618. // Example 1: minChar: 3, text: 'asdfzxcv', truncate result: 'asdf', but not: 'a...'.
  3619. // Example 2: minChar: 3, text: '维度', truncate result: '维', but not: '...'.
  3620. var contentWidth = containerWidth = Math.max(0, containerWidth - 1); // Reserve some gap.
  3621. for (var i = 0; i < minChar && contentWidth >= ascCharWidth; i++) {
  3622. contentWidth -= ascCharWidth;
  3623. }
  3624. var ellipsisWidth = getTextWidth(ellipsis);
  3625. if (ellipsisWidth > contentWidth) {
  3626. ellipsis = '';
  3627. ellipsisWidth = 0;
  3628. }
  3629. contentWidth = containerWidth - ellipsisWidth;
  3630. var textLines = (text + '').split('\n');
  3631. for (var i = 0, len = textLines.length; i < len; i++) {
  3632. var textLine = textLines[i];
  3633. var lineWidth = getTextWidth(textLine, textFont);
  3634. if (lineWidth <= containerWidth) {
  3635. continue;
  3636. }
  3637. for (var j = 0;; j++) {
  3638. if (lineWidth <= contentWidth || j >= maxIterations) {
  3639. textLine += ellipsis;
  3640. break;
  3641. }
  3642. var subLength = j === 0
  3643. ? estimateLength(textLine, contentWidth, ascCharWidth, cnCharWidth)
  3644. : lineWidth > 0
  3645. ? Math.floor(textLine.length * contentWidth / lineWidth)
  3646. : 0;
  3647. textLine = textLine.substr(0, subLength);
  3648. lineWidth = getTextWidth(textLine, textFont);
  3649. }
  3650. if (textLine === '') {
  3651. textLine = placeholder;
  3652. }
  3653. textLines[i] = textLine;
  3654. }
  3655. return textLines.join('\n');
  3656. }
  3657. function estimateLength(text, contentWidth, ascCharWidth, cnCharWidth) {
  3658. var width = 0;
  3659. var i = 0;
  3660. for (var len = text.length; i < len && width < contentWidth; i++) {
  3661. var charCode = text.charCodeAt(i);
  3662. width += (0 <= charCode && charCode <= 127) ? ascCharWidth : cnCharWidth;
  3663. }
  3664. return i;
  3665. }
  3666. var textContain = {
  3667. getWidth: getTextWidth,
  3668. getBoundingRect: getTextRect,
  3669. adjustTextPositionOnRect: adjustTextPositionOnRect,
  3670. truncateText: truncateText,
  3671. measureText: function (text, textFont) {
  3672. var ctx = util.getContext();
  3673. ctx.font = textFont || '12px sans-serif';
  3674. return ctx.measureText(text);
  3675. }
  3676. };
  3677. module.exports = textContain;
  3678. /***/ },
  3679. /* 9 */
  3680. /***/ function(module, exports, __webpack_require__) {
  3681. 'use strict';
  3682. /**
  3683. * @module echarts/core/BoundingRect
  3684. */
  3685. var vec2 = __webpack_require__(10);
  3686. var matrix = __webpack_require__(11);
  3687. var v2ApplyTransform = vec2.applyTransform;
  3688. var mathMin = Math.min;
  3689. var mathAbs = Math.abs;
  3690. var mathMax = Math.max;
  3691. /**
  3692. * @alias module:echarts/core/BoundingRect
  3693. */
  3694. function BoundingRect(x, y, width, height) {
  3695. /**
  3696. * @type {number}
  3697. */
  3698. this.x = x;
  3699. /**
  3700. * @type {number}
  3701. */
  3702. this.y = y;
  3703. /**
  3704. * @type {number}
  3705. */
  3706. this.width = width;
  3707. /**
  3708. * @type {number}
  3709. */
  3710. this.height = height;
  3711. }
  3712. BoundingRect.prototype = {
  3713. constructor: BoundingRect,
  3714. /**
  3715. * @param {module:echarts/core/BoundingRect} other
  3716. */
  3717. union: function (other) {
  3718. var x = mathMin(other.x, this.x);
  3719. var y = mathMin(other.y, this.y);
  3720. this.width = mathMax(
  3721. other.x + other.width,
  3722. this.x + this.width
  3723. ) - x;
  3724. this.height = mathMax(
  3725. other.y + other.height,
  3726. this.y + this.height
  3727. ) - y;
  3728. this.x = x;
  3729. this.y = y;
  3730. },
  3731. /**
  3732. * @param {Array.<number>} m
  3733. * @methods
  3734. */
  3735. applyTransform: (function () {
  3736. var min = [];
  3737. var max = [];
  3738. return function (m) {
  3739. // In case usage like this
  3740. // el.getBoundingRect().applyTransform(el.transform)
  3741. // And element has no transform
  3742. if (!m) {
  3743. return;
  3744. }
  3745. min[0] = this.x;
  3746. min[1] = this.y;
  3747. max[0] = this.x + this.width;
  3748. max[1] = this.y + this.height;
  3749. v2ApplyTransform(min, min, m);
  3750. v2ApplyTransform(max, max, m);
  3751. this.x = mathMin(min[0], max[0]);
  3752. this.y = mathMin(min[1], max[1]);
  3753. this.width = mathAbs(max[0] - min[0]);
  3754. this.height = mathAbs(max[1] - min[1]);
  3755. };
  3756. })(),
  3757. /**
  3758. * Calculate matrix of transforming from self to target rect
  3759. * @param {module:zrender/core/BoundingRect} b
  3760. * @return {Array.<number>}
  3761. */
  3762. calculateTransform: function (b) {
  3763. var a = this;
  3764. var sx = b.width / a.width;
  3765. var sy = b.height / a.height;
  3766. var m = matrix.create();
  3767. // 矩阵右乘
  3768. matrix.translate(m, m, [-a.x, -a.y]);
  3769. matrix.scale(m, m, [sx, sy]);
  3770. matrix.translate(m, m, [b.x, b.y]);
  3771. return m;
  3772. },
  3773. /**
  3774. * @param {(module:echarts/core/BoundingRect|Object)} b
  3775. * @return {boolean}
  3776. */
  3777. intersect: function (b) {
  3778. var a = this;
  3779. var ax0 = a.x;
  3780. var ax1 = a.x + a.width;
  3781. var ay0 = a.y;
  3782. var ay1 = a.y + a.height;
  3783. var bx0 = b.x;
  3784. var bx1 = b.x + b.width;
  3785. var by0 = b.y;
  3786. var by1 = b.y + b.height;
  3787. return ! (ax1 < bx0 || bx1 < ax0 || ay1 < by0 || by1 < ay0);
  3788. },
  3789. contain: function (x, y) {
  3790. var rect = this;
  3791. return x >= rect.x
  3792. && x <= (rect.x + rect.width)
  3793. && y >= rect.y
  3794. && y <= (rect.y + rect.height);
  3795. },
  3796. /**
  3797. * @return {module:echarts/core/BoundingRect}
  3798. */
  3799. clone: function () {
  3800. return new BoundingRect(this.x, this.y, this.width, this.height);
  3801. },
  3802. /**
  3803. * Copy from another rect
  3804. */
  3805. copy: function (other) {
  3806. this.x = other.x;
  3807. this.y = other.y;
  3808. this.width = other.width;
  3809. this.height = other.height;
  3810. }
  3811. };
  3812. module.exports = BoundingRect;
  3813. /***/ },
  3814. /* 10 */
  3815. /***/ function(module, exports) {
  3816. var ArrayCtor = typeof Float32Array === 'undefined'
  3817. ? Array
  3818. : Float32Array;
  3819. /**
  3820. * @typedef {Float32Array|Array.<number>} Vector2
  3821. */
  3822. /**
  3823. * 二维向量类
  3824. * @exports zrender/tool/vector
  3825. */
  3826. var vector = {
  3827. /**
  3828. * 创建一个向量
  3829. * @param {number} [x=0]
  3830. * @param {number} [y=0]
  3831. * @return {Vector2}
  3832. */
  3833. create: function (x, y) {
  3834. var out = new ArrayCtor(2);
  3835. if (x == null) {
  3836. x = 0;
  3837. }
  3838. if (y == null) {
  3839. y = 0;
  3840. }
  3841. out[0] = x;
  3842. out[1] = y;
  3843. return out;
  3844. },
  3845. /**
  3846. * 复制向量数据
  3847. * @param {Vector2} out
  3848. * @param {Vector2} v
  3849. * @return {Vector2}
  3850. */
  3851. copy: function (out, v) {
  3852. out[0] = v[0];
  3853. out[1] = v[1];
  3854. return out;
  3855. },
  3856. /**
  3857. * 克隆一个向量
  3858. * @param {Vector2} v
  3859. * @return {Vector2}
  3860. */
  3861. clone: function (v) {
  3862. var out = new ArrayCtor(2);
  3863. out[0] = v[0];
  3864. out[1] = v[1];
  3865. return out;
  3866. },
  3867. /**
  3868. * 设置向量的两个项
  3869. * @param {Vector2} out
  3870. * @param {number} a
  3871. * @param {number} b
  3872. * @return {Vector2} 结果
  3873. */
  3874. set: function (out, a, b) {
  3875. out[0] = a;
  3876. out[1] = b;
  3877. return out;
  3878. },
  3879. /**
  3880. * 向量相加
  3881. * @param {Vector2} out
  3882. * @param {Vector2} v1
  3883. * @param {Vector2} v2
  3884. */
  3885. add: function (out, v1, v2) {
  3886. out[0] = v1[0] + v2[0];
  3887. out[1] = v1[1] + v2[1];
  3888. return out;
  3889. },
  3890. /**
  3891. * 向量缩放后相加
  3892. * @param {Vector2} out
  3893. * @param {Vector2} v1
  3894. * @param {Vector2} v2
  3895. * @param {number} a
  3896. */
  3897. scaleAndAdd: function (out, v1, v2, a) {
  3898. out[0] = v1[0] + v2[0] * a;
  3899. out[1] = v1[1] + v2[1] * a;
  3900. return out;
  3901. },
  3902. /**
  3903. * 向量相减
  3904. * @param {Vector2} out
  3905. * @param {Vector2} v1
  3906. * @param {Vector2} v2
  3907. */
  3908. sub: function (out, v1, v2) {
  3909. out[0] = v1[0] - v2[0];
  3910. out[1] = v1[1] - v2[1];
  3911. return out;
  3912. },
  3913. /**
  3914. * 向量长度
  3915. * @param {Vector2} v
  3916. * @return {number}
  3917. */
  3918. len: function (v) {
  3919. return Math.sqrt(this.lenSquare(v));
  3920. },
  3921. /**
  3922. * 向量长度平方
  3923. * @param {Vector2} v
  3924. * @return {number}
  3925. */
  3926. lenSquare: function (v) {
  3927. return v[0] * v[0] + v[1] * v[1];
  3928. },
  3929. /**
  3930. * 向量乘法
  3931. * @param {Vector2} out
  3932. * @param {Vector2} v1
  3933. * @param {Vector2} v2
  3934. */
  3935. mul: function (out, v1, v2) {
  3936. out[0] = v1[0] * v2[0];
  3937. out[1] = v1[1] * v2[1];
  3938. return out;
  3939. },
  3940. /**
  3941. * 向量除法
  3942. * @param {Vector2} out
  3943. * @param {Vector2} v1
  3944. * @param {Vector2} v2
  3945. */
  3946. div: function (out, v1, v2) {
  3947. out[0] = v1[0] / v2[0];
  3948. out[1] = v1[1] / v2[1];
  3949. return out;
  3950. },
  3951. /**
  3952. * 向量点乘
  3953. * @param {Vector2} v1
  3954. * @param {Vector2} v2
  3955. * @return {number}
  3956. */
  3957. dot: function (v1, v2) {
  3958. return v1[0] * v2[0] + v1[1] * v2[1];
  3959. },
  3960. /**
  3961. * 向量缩放
  3962. * @param {Vector2} out
  3963. * @param {Vector2} v
  3964. * @param {number} s
  3965. */
  3966. scale: function (out, v, s) {
  3967. out[0] = v[0] * s;
  3968. out[1] = v[1] * s;
  3969. return out;
  3970. },
  3971. /**
  3972. * 向量归一化
  3973. * @param {Vector2} out
  3974. * @param {Vector2} v
  3975. */
  3976. normalize: function (out, v) {
  3977. var d = vector.len(v);
  3978. if (d === 0) {
  3979. out[0] = 0;
  3980. out[1] = 0;
  3981. }
  3982. else {
  3983. out[0] = v[0] / d;
  3984. out[1] = v[1] / d;
  3985. }
  3986. return out;
  3987. },
  3988. /**
  3989. * 计算向量间距离
  3990. * @param {Vector2} v1
  3991. * @param {Vector2} v2
  3992. * @return {number}
  3993. */
  3994. distance: function (v1, v2) {
  3995. return Math.sqrt(
  3996. (v1[0] - v2[0]) * (v1[0] - v2[0])
  3997. + (v1[1] - v2[1]) * (v1[1] - v2[1])
  3998. );
  3999. },
  4000. /**
  4001. * 向量距离平方
  4002. * @param {Vector2} v1
  4003. * @param {Vector2} v2
  4004. * @return {number}
  4005. */
  4006. distanceSquare: function (v1, v2) {
  4007. return (v1[0] - v2[0]) * (v1[0] - v2[0])
  4008. + (v1[1] - v2[1]) * (v1[1] - v2[1]);
  4009. },
  4010. /**
  4011. * 求负向量
  4012. * @param {Vector2} out
  4013. * @param {Vector2} v
  4014. */
  4015. negate: function (out, v) {
  4016. out[0] = -v[0];
  4017. out[1] = -v[1];
  4018. return out;
  4019. },
  4020. /**
  4021. * 插值两个点
  4022. * @param {Vector2} out
  4023. * @param {Vector2} v1
  4024. * @param {Vector2} v2
  4025. * @param {number} t
  4026. */
  4027. lerp: function (out, v1, v2, t) {
  4028. out[0] = v1[0] + t * (v2[0] - v1[0]);
  4029. out[1] = v1[1] + t * (v2[1] - v1[1]);
  4030. return out;
  4031. },
  4032. /**
  4033. * 矩阵左乘向量
  4034. * @param {Vector2} out
  4035. * @param {Vector2} v
  4036. * @param {Vector2} m
  4037. */
  4038. applyTransform: function (out, v, m) {
  4039. var x = v[0];
  4040. var y = v[1];
  4041. out[0] = m[0] * x + m[2] * y + m[4];
  4042. out[1] = m[1] * x + m[3] * y + m[5];
  4043. return out;
  4044. },
  4045. /**
  4046. * 求两个向量最小值
  4047. * @param {Vector2} out
  4048. * @param {Vector2} v1
  4049. * @param {Vector2} v2
  4050. */
  4051. min: function (out, v1, v2) {
  4052. out[0] = Math.min(v1[0], v2[0]);
  4053. out[1] = Math.min(v1[1], v2[1]);
  4054. return out;
  4055. },
  4056. /**
  4057. * 求两个向量最大值
  4058. * @param {Vector2} out
  4059. * @param {Vector2} v1
  4060. * @param {Vector2} v2
  4061. */
  4062. max: function (out, v1, v2) {
  4063. out[0] = Math.max(v1[0], v2[0]);
  4064. out[1] = Math.max(v1[1], v2[1]);
  4065. return out;
  4066. }
  4067. };
  4068. vector.length = vector.len;
  4069. vector.lengthSquare = vector.lenSquare;
  4070. vector.dist = vector.distance;
  4071. vector.distSquare = vector.distanceSquare;
  4072. module.exports = vector;
  4073. /***/ },
  4074. /* 11 */
  4075. /***/ function(module, exports) {
  4076. var ArrayCtor = typeof Float32Array === 'undefined'
  4077. ? Array
  4078. : Float32Array;
  4079. /**
  4080. * 3x2矩阵操作类
  4081. * @exports zrender/tool/matrix
  4082. */
  4083. var matrix = {
  4084. /**
  4085. * 创建一个单位矩阵
  4086. * @return {Float32Array|Array.<number>}
  4087. */
  4088. create : function() {
  4089. var out = new ArrayCtor(6);
  4090. matrix.identity(out);
  4091. return out;
  4092. },
  4093. /**
  4094. * 设置矩阵为单位矩阵
  4095. * @param {Float32Array|Array.<number>} out
  4096. */
  4097. identity : function(out) {
  4098. out[0] = 1;
  4099. out[1] = 0;
  4100. out[2] = 0;
  4101. out[3] = 1;
  4102. out[4] = 0;
  4103. out[5] = 0;
  4104. return out;
  4105. },
  4106. /**
  4107. * 复制矩阵
  4108. * @param {Float32Array|Array.<number>} out
  4109. * @param {Float32Array|Array.<number>} m
  4110. */
  4111. copy: function(out, m) {
  4112. out[0] = m[0];
  4113. out[1] = m[1];
  4114. out[2] = m[2];
  4115. out[3] = m[3];
  4116. out[4] = m[4];
  4117. out[5] = m[5];
  4118. return out;
  4119. },
  4120. /**
  4121. * 矩阵相乘
  4122. * @param {Float32Array|Array.<number>} out
  4123. * @param {Float32Array|Array.<number>} m1
  4124. * @param {Float32Array|Array.<number>} m2
  4125. */
  4126. mul : function (out, m1, m2) {
  4127. // Consider matrix.mul(m, m2, m);
  4128. // where out is the same as m2.
  4129. // So use temp variable to escape error.
  4130. var out0 = m1[0] * m2[0] + m1[2] * m2[1];
  4131. var out1 = m1[1] * m2[0] + m1[3] * m2[1];
  4132. var out2 = m1[0] * m2[2] + m1[2] * m2[3];
  4133. var out3 = m1[1] * m2[2] + m1[3] * m2[3];
  4134. var out4 = m1[0] * m2[4] + m1[2] * m2[5] + m1[4];
  4135. var out5 = m1[1] * m2[4] + m1[3] * m2[5] + m1[5];
  4136. out[0] = out0;
  4137. out[1] = out1;
  4138. out[2] = out2;
  4139. out[3] = out3;
  4140. out[4] = out4;
  4141. out[5] = out5;
  4142. return out;
  4143. },
  4144. /**
  4145. * 平移变换
  4146. * @param {Float32Array|Array.<number>} out
  4147. * @param {Float32Array|Array.<number>} a
  4148. * @param {Float32Array|Array.<number>} v
  4149. */
  4150. translate : function(out, a, v) {
  4151. out[0] = a[0];
  4152. out[1] = a[1];
  4153. out[2] = a[2];
  4154. out[3] = a[3];
  4155. out[4] = a[4] + v[0];
  4156. out[5] = a[5] + v[1];
  4157. return out;
  4158. },
  4159. /**
  4160. * 旋转变换
  4161. * @param {Float32Array|Array.<number>} out
  4162. * @param {Float32Array|Array.<number>} a
  4163. * @param {number} rad
  4164. */
  4165. rotate : function(out, a, rad) {
  4166. var aa = a[0];
  4167. var ac = a[2];
  4168. var atx = a[4];
  4169. var ab = a[1];
  4170. var ad = a[3];
  4171. var aty = a[5];
  4172. var st = Math.sin(rad);
  4173. var ct = Math.cos(rad);
  4174. out[0] = aa * ct + ab * st;
  4175. out[1] = -aa * st + ab * ct;
  4176. out[2] = ac * ct + ad * st;
  4177. out[3] = -ac * st + ct * ad;
  4178. out[4] = ct * atx + st * aty;
  4179. out[5] = ct * aty - st * atx;
  4180. return out;
  4181. },
  4182. /**
  4183. * 缩放变换
  4184. * @param {Float32Array|Array.<number>} out
  4185. * @param {Float32Array|Array.<number>} a
  4186. * @param {Float32Array|Array.<number>} v
  4187. */
  4188. scale : function(out, a, v) {
  4189. var vx = v[0];
  4190. var vy = v[1];
  4191. out[0] = a[0] * vx;
  4192. out[1] = a[1] * vy;
  4193. out[2] = a[2] * vx;
  4194. out[3] = a[3] * vy;
  4195. out[4] = a[4] * vx;
  4196. out[5] = a[5] * vy;
  4197. return out;
  4198. },
  4199. /**
  4200. * 求逆矩阵
  4201. * @param {Float32Array|Array.<number>} out
  4202. * @param {Float32Array|Array.<number>} a
  4203. */
  4204. invert : function(out, a) {
  4205. var aa = a[0];
  4206. var ac = a[2];
  4207. var atx = a[4];
  4208. var ab = a[1];
  4209. var ad = a[3];
  4210. var aty = a[5];
  4211. var det = aa * ad - ab * ac;
  4212. if (!det) {
  4213. return null;
  4214. }
  4215. det = 1.0 / det;
  4216. out[0] = ad * det;
  4217. out[1] = -ab * det;
  4218. out[2] = -ac * det;
  4219. out[3] = aa * det;
  4220. out[4] = (ac * aty - ad * atx) * det;
  4221. out[5] = (ab * atx - aa * aty) * det;
  4222. return out;
  4223. }
  4224. };
  4225. module.exports = matrix;
  4226. /***/ },
  4227. /* 12 */
  4228. /***/ function(module, exports, __webpack_require__) {
  4229. /**
  4230. * @module echarts/model/Model
  4231. */
  4232. var zrUtil = __webpack_require__(4);
  4233. var clazzUtil = __webpack_require__(13);
  4234. /**
  4235. * @alias module:echarts/model/Model
  4236. * @constructor
  4237. * @param {Object} option
  4238. * @param {module:echarts/model/Model} [parentModel]
  4239. * @param {module:echarts/model/Global} [ecModel]
  4240. */
  4241. function Model(option, parentModel, ecModel) {
  4242. /**
  4243. * @type {module:echarts/model/Model}
  4244. * @readOnly
  4245. */
  4246. this.parentModel = parentModel;
  4247. /**
  4248. * @type {module:echarts/model/Global}
  4249. * @readOnly
  4250. */
  4251. this.ecModel = ecModel;
  4252. /**
  4253. * @type {Object}
  4254. * @protected
  4255. */
  4256. this.option = option;
  4257. // Simple optimization
  4258. // if (this.init) {
  4259. // if (arguments.length <= 4) {
  4260. // this.init(option, parentModel, ecModel, extraOpt);
  4261. // }
  4262. // else {
  4263. // this.init.apply(this, arguments);
  4264. // }
  4265. // }
  4266. }
  4267. Model.prototype = {
  4268. constructor: Model,
  4269. /**
  4270. * Model 的初始化函数
  4271. * @param {Object} option
  4272. */
  4273. init: null,
  4274. /**
  4275. * 从新的 Option merge
  4276. */
  4277. mergeOption: function (option) {
  4278. zrUtil.merge(this.option, option, true);
  4279. },
  4280. /**
  4281. * @param {string} path
  4282. * @param {boolean} [ignoreParent=false]
  4283. * @return {*}
  4284. */
  4285. get: function (path, ignoreParent) {
  4286. if (!path) {
  4287. return this.option;
  4288. }
  4289. if (typeof path === 'string') {
  4290. path = path.split('.');
  4291. }
  4292. var obj = this.option;
  4293. var parentModel = this.parentModel;
  4294. for (var i = 0; i < path.length; i++) {
  4295. // Ignore empty
  4296. if (!path[i]) {
  4297. continue;
  4298. }
  4299. // obj could be number/string/... (like 0)
  4300. obj = (obj && typeof obj === 'object') ? obj[path[i]] : null;
  4301. if (obj == null) {
  4302. break;
  4303. }
  4304. }
  4305. if (obj == null && parentModel && !ignoreParent) {
  4306. obj = parentModel.get(path);
  4307. }
  4308. return obj;
  4309. },
  4310. /**
  4311. * @param {string} key
  4312. * @param {boolean} [ignoreParent=false]
  4313. * @return {*}
  4314. */
  4315. getShallow: function (key, ignoreParent) {
  4316. var option = this.option;
  4317. var val = option && option[key];
  4318. var parentModel = this.parentModel;
  4319. if (val == null && parentModel && !ignoreParent) {
  4320. val = parentModel.getShallow(key);
  4321. }
  4322. return val;
  4323. },
  4324. /**
  4325. * @param {string} path
  4326. * @param {module:echarts/model/Model} [parentModel]
  4327. * @return {module:echarts/model/Model}
  4328. */
  4329. getModel: function (path, parentModel) {
  4330. var obj = this.get(path, true);
  4331. var thisParentModel = this.parentModel;
  4332. var model = new Model(
  4333. obj, parentModel || (thisParentModel && thisParentModel.getModel(path)),
  4334. this.ecModel
  4335. );
  4336. return model;
  4337. },
  4338. /**
  4339. * If model has option
  4340. */
  4341. isEmpty: function () {
  4342. return this.option == null;
  4343. },
  4344. restoreData: function () {},
  4345. // Pending
  4346. clone: function () {
  4347. var Ctor = this.constructor;
  4348. return new Ctor(zrUtil.clone(this.option));
  4349. },
  4350. setReadOnly: function (properties) {
  4351. clazzUtil.setReadOnly(this, properties);
  4352. }
  4353. };
  4354. // Enable Model.extend.
  4355. clazzUtil.enableClassExtend(Model);
  4356. var mixin = zrUtil.mixin;
  4357. mixin(Model, __webpack_require__(14));
  4358. mixin(Model, __webpack_require__(16));
  4359. mixin(Model, __webpack_require__(17));
  4360. mixin(Model, __webpack_require__(18));
  4361. module.exports = Model;
  4362. /***/ },
  4363. /* 13 */
  4364. /***/ function(module, exports, __webpack_require__) {
  4365. var zrUtil = __webpack_require__(4);
  4366. var clazz = {};
  4367. var TYPE_DELIMITER = '.';
  4368. var IS_CONTAINER = '___EC__COMPONENT__CONTAINER___';
  4369. /**
  4370. * @public
  4371. */
  4372. var parseClassType = clazz.parseClassType = function (componentType) {
  4373. var ret = {main: '', sub: ''};
  4374. if (componentType) {
  4375. componentType = componentType.split(TYPE_DELIMITER);
  4376. ret.main = componentType[0] || '';
  4377. ret.sub = componentType[1] || '';
  4378. }
  4379. return ret;
  4380. };
  4381. /**
  4382. * @public
  4383. */
  4384. clazz.enableClassExtend = function (RootClass) {
  4385. RootClass.$constructor = RootClass;
  4386. RootClass.extend = function (proto) {
  4387. var superClass = this;
  4388. var ExtendedClass = function () {
  4389. if (!proto.$constructor) {
  4390. superClass.apply(this, arguments);
  4391. }
  4392. else {
  4393. proto.$constructor.apply(this, arguments);
  4394. }
  4395. };
  4396. zrUtil.extend(ExtendedClass.prototype, proto);
  4397. ExtendedClass.extend = this.extend;
  4398. ExtendedClass.superCall = superCall;
  4399. ExtendedClass.superApply = superApply;
  4400. zrUtil.inherits(ExtendedClass, this);
  4401. ExtendedClass.superClass = superClass;
  4402. return ExtendedClass;
  4403. };
  4404. };
  4405. // superCall should have class info, which can not be fetch from 'this'.
  4406. // Consider this case:
  4407. // class A has method f,
  4408. // class B inherits class A, overrides method f, f call superApply('f'),
  4409. // class C inherits class B, do not overrides method f,
  4410. // then when method of class C is called, dead loop occured.
  4411. function superCall(context, methodName) {
  4412. var args = zrUtil.slice(arguments, 2);
  4413. return this.superClass.prototype[methodName].apply(context, args);
  4414. }
  4415. function superApply(context, methodName, args) {
  4416. return this.superClass.prototype[methodName].apply(context, args);
  4417. }
  4418. /**
  4419. * @param {Object} entity
  4420. * @param {Object} options
  4421. * @param {boolean} [options.registerWhenExtend]
  4422. * @public
  4423. */
  4424. clazz.enableClassManagement = function (entity, options) {
  4425. options = options || {};
  4426. /**
  4427. * Component model classes
  4428. * key: componentType,
  4429. * value:
  4430. * componentClass, when componentType is 'xxx'
  4431. * or Object.<subKey, componentClass>, when componentType is 'xxx.yy'
  4432. * @type {Object}
  4433. */
  4434. var storage = {};
  4435. entity.registerClass = function (Clazz, componentType) {
  4436. if (componentType) {
  4437. componentType = parseClassType(componentType);
  4438. if (!componentType.sub) {
  4439. if (true) {
  4440. if (storage[componentType.main]) {
  4441. console.warn(componentType.main + ' exists.');
  4442. }
  4443. }
  4444. storage[componentType.main] = Clazz;
  4445. }
  4446. else if (componentType.sub !== IS_CONTAINER) {
  4447. var container = makeContainer(componentType);
  4448. container[componentType.sub] = Clazz;
  4449. }
  4450. }
  4451. return Clazz;
  4452. };
  4453. entity.getClass = function (componentTypeMain, subType, throwWhenNotFound) {
  4454. var Clazz = storage[componentTypeMain];
  4455. if (Clazz && Clazz[IS_CONTAINER]) {
  4456. Clazz = subType ? Clazz[subType] : null;
  4457. }
  4458. if (throwWhenNotFound && !Clazz) {
  4459. throw new Error(
  4460. 'Component ' + componentTypeMain + '.' + (subType || '') + ' not exists. Load it first.'
  4461. );
  4462. }
  4463. return Clazz;
  4464. };
  4465. entity.getClassesByMainType = function (componentType) {
  4466. componentType = parseClassType(componentType);
  4467. var result = [];
  4468. var obj = storage[componentType.main];
  4469. if (obj && obj[IS_CONTAINER]) {
  4470. zrUtil.each(obj, function (o, type) {
  4471. type !== IS_CONTAINER && result.push(o);
  4472. });
  4473. }
  4474. else {
  4475. result.push(obj);
  4476. }
  4477. return result;
  4478. };
  4479. entity.hasClass = function (componentType) {
  4480. // Just consider componentType.main.
  4481. componentType = parseClassType(componentType);
  4482. return !!storage[componentType.main];
  4483. };
  4484. /**
  4485. * @return {Array.<string>} Like ['aa', 'bb'], but can not be ['aa.xx']
  4486. */
  4487. entity.getAllClassMainTypes = function () {
  4488. var types = [];
  4489. zrUtil.each(storage, function (obj, type) {
  4490. types.push(type);
  4491. });
  4492. return types;
  4493. };
  4494. /**
  4495. * If a main type is container and has sub types
  4496. * @param {string} mainType
  4497. * @return {boolean}
  4498. */
  4499. entity.hasSubTypes = function (componentType) {
  4500. componentType = parseClassType(componentType);
  4501. var obj = storage[componentType.main];
  4502. return obj && obj[IS_CONTAINER];
  4503. };
  4504. entity.parseClassType = parseClassType;
  4505. function makeContainer(componentType) {
  4506. var container = storage[componentType.main];
  4507. if (!container || !container[IS_CONTAINER]) {
  4508. container = storage[componentType.main] = {};
  4509. container[IS_CONTAINER] = true;
  4510. }
  4511. return container;
  4512. }
  4513. if (options.registerWhenExtend) {
  4514. var originalExtend = entity.extend;
  4515. if (originalExtend) {
  4516. entity.extend = function (proto) {
  4517. var ExtendedClass = originalExtend.call(this, proto);
  4518. return entity.registerClass(ExtendedClass, proto.type);
  4519. };
  4520. }
  4521. }
  4522. return entity;
  4523. };
  4524. /**
  4525. * @param {string|Array.<string>} properties
  4526. */
  4527. clazz.setReadOnly = function (obj, properties) {
  4528. // FIXME It seems broken in IE8 simulation of IE11
  4529. // if (!zrUtil.isArray(properties)) {
  4530. // properties = properties != null ? [properties] : [];
  4531. // }
  4532. // zrUtil.each(properties, function (prop) {
  4533. // var value = obj[prop];
  4534. // Object.defineProperty
  4535. // && Object.defineProperty(obj, prop, {
  4536. // value: value, writable: false
  4537. // });
  4538. // zrUtil.isArray(obj[prop])
  4539. // && Object.freeze
  4540. // && Object.freeze(obj[prop]);
  4541. // });
  4542. };
  4543. module.exports = clazz;
  4544. /***/ },
  4545. /* 14 */
  4546. /***/ function(module, exports, __webpack_require__) {
  4547. var getLineStyle = __webpack_require__(15)(
  4548. [
  4549. ['lineWidth', 'width'],
  4550. ['stroke', 'color'],
  4551. ['opacity'],
  4552. ['shadowBlur'],
  4553. ['shadowOffsetX'],
  4554. ['shadowOffsetY'],
  4555. ['shadowColor']
  4556. ]
  4557. );
  4558. module.exports = {
  4559. getLineStyle: function (excludes) {
  4560. var style = getLineStyle.call(this, excludes);
  4561. var lineDash = this.getLineDash();
  4562. lineDash && (style.lineDash = lineDash);
  4563. return style;
  4564. },
  4565. getLineDash: function () {
  4566. var lineType = this.get('type');
  4567. return (lineType === 'solid' || lineType == null) ? null
  4568. : (lineType === 'dashed' ? [5, 5] : [1, 1]);
  4569. }
  4570. };
  4571. /***/ },
  4572. /* 15 */
  4573. /***/ function(module, exports, __webpack_require__) {
  4574. // TODO Parse shadow style
  4575. // TODO Only shallow path support
  4576. var zrUtil = __webpack_require__(4);
  4577. module.exports = function (properties) {
  4578. // Normalize
  4579. for (var i = 0; i < properties.length; i++) {
  4580. if (!properties[i][1]) {
  4581. properties[i][1] = properties[i][0];
  4582. }
  4583. }
  4584. return function (excludes) {
  4585. var style = {};
  4586. for (var i = 0; i < properties.length; i++) {
  4587. var propName = properties[i][1];
  4588. if (excludes && zrUtil.indexOf(excludes, propName) >= 0) {
  4589. continue;
  4590. }
  4591. var val = this.getShallow(propName);
  4592. if (val != null) {
  4593. style[properties[i][0]] = val;
  4594. }
  4595. }
  4596. return style;
  4597. };
  4598. };
  4599. /***/ },
  4600. /* 16 */
  4601. /***/ function(module, exports, __webpack_require__) {
  4602. module.exports = {
  4603. getAreaStyle: __webpack_require__(15)(
  4604. [
  4605. ['fill', 'color'],
  4606. ['shadowBlur'],
  4607. ['shadowOffsetX'],
  4608. ['shadowOffsetY'],
  4609. ['opacity'],
  4610. ['shadowColor']
  4611. ]
  4612. )
  4613. };
  4614. /***/ },
  4615. /* 17 */
  4616. /***/ function(module, exports, __webpack_require__) {
  4617. var textContain = __webpack_require__(8);
  4618. function getShallow(model, path) {
  4619. return model && model.getShallow(path);
  4620. }
  4621. module.exports = {
  4622. /**
  4623. * Get color property or get color from option.textStyle.color
  4624. * @return {string}
  4625. */
  4626. getTextColor: function () {
  4627. var ecModel = this.ecModel;
  4628. return this.getShallow('color')
  4629. || (ecModel && ecModel.get('textStyle.color'));
  4630. },
  4631. /**
  4632. * Create font string from fontStyle, fontWeight, fontSize, fontFamily
  4633. * @return {string}
  4634. */
  4635. getFont: function () {
  4636. var ecModel = this.ecModel;
  4637. var gTextStyleModel = ecModel && ecModel.getModel('textStyle');
  4638. return [
  4639. // FIXME in node-canvas fontWeight is before fontStyle
  4640. this.getShallow('fontStyle') || getShallow(gTextStyleModel, 'fontStyle'),
  4641. this.getShallow('fontWeight') || getShallow(gTextStyleModel, 'fontWeight'),
  4642. (this.getShallow('fontSize') || getShallow(gTextStyleModel, 'fontSize') || 12) + 'px',
  4643. this.getShallow('fontFamily') || getShallow(gTextStyleModel, 'fontFamily') || 'sans-serif'
  4644. ].join(' ');
  4645. },
  4646. getTextRect: function (text) {
  4647. var textStyle = this.get('textStyle') || {};
  4648. return textContain.getBoundingRect(
  4649. text,
  4650. this.getFont(),
  4651. textStyle.align,
  4652. textStyle.baseline
  4653. );
  4654. },
  4655. truncateText: function (text, containerWidth, ellipsis, options) {
  4656. return textContain.truncateText(
  4657. text, containerWidth, this.getFont(), ellipsis, options
  4658. );
  4659. }
  4660. };
  4661. /***/ },
  4662. /* 18 */
  4663. /***/ function(module, exports, __webpack_require__) {
  4664. var getItemStyle = __webpack_require__(15)(
  4665. [
  4666. ['fill', 'color'],
  4667. ['stroke', 'borderColor'],
  4668. ['lineWidth', 'borderWidth'],
  4669. ['opacity'],
  4670. ['shadowBlur'],
  4671. ['shadowOffsetX'],
  4672. ['shadowOffsetY'],
  4673. ['shadowColor']
  4674. ]
  4675. );
  4676. module.exports = {
  4677. getItemStyle: function (excludes) {
  4678. var style = getItemStyle.call(this, excludes);
  4679. var lineDash = this.getBorderLineDash();
  4680. lineDash && (style.lineDash = lineDash);
  4681. return style;
  4682. },
  4683. getBorderLineDash: function () {
  4684. var lineType = this.get('borderType');
  4685. return (lineType === 'solid' || lineType == null) ? null
  4686. : (lineType === 'dashed' ? [5, 5] : [1, 1]);
  4687. }
  4688. };
  4689. /***/ },
  4690. /* 19 */
  4691. /***/ function(module, exports, __webpack_require__) {
  4692. /**
  4693. * Component model
  4694. *
  4695. * @module echarts/model/Component
  4696. */
  4697. var Model = __webpack_require__(12);
  4698. var zrUtil = __webpack_require__(4);
  4699. var arrayPush = Array.prototype.push;
  4700. var componentUtil = __webpack_require__(20);
  4701. var clazzUtil = __webpack_require__(13);
  4702. var layout = __webpack_require__(21);
  4703. /**
  4704. * @alias module:echarts/model/Component
  4705. * @constructor
  4706. * @param {Object} option
  4707. * @param {module:echarts/model/Model} parentModel
  4708. * @param {module:echarts/model/Model} ecModel
  4709. */
  4710. var ComponentModel = Model.extend({
  4711. type: 'component',
  4712. /**
  4713. * @readOnly
  4714. * @type {string}
  4715. */
  4716. id: '',
  4717. /**
  4718. * @readOnly
  4719. */
  4720. name: '',
  4721. /**
  4722. * @readOnly
  4723. * @type {string}
  4724. */
  4725. mainType: '',
  4726. /**
  4727. * @readOnly
  4728. * @type {string}
  4729. */
  4730. subType: '',
  4731. /**
  4732. * @readOnly
  4733. * @type {number}
  4734. */
  4735. componentIndex: 0,
  4736. /**
  4737. * @type {Object}
  4738. * @protected
  4739. */
  4740. defaultOption: null,
  4741. /**
  4742. * @type {module:echarts/model/Global}
  4743. * @readOnly
  4744. */
  4745. ecModel: null,
  4746. /**
  4747. * key: componentType
  4748. * value: Component model list, can not be null.
  4749. * @type {Object.<string, Array.<module:echarts/model/Model>>}
  4750. * @readOnly
  4751. */
  4752. dependentModels: [],
  4753. /**
  4754. * @type {string}
  4755. * @readOnly
  4756. */
  4757. uid: null,
  4758. /**
  4759. * Support merge layout params.
  4760. * Only support 'box' now (left/right/top/bottom/width/height).
  4761. * @type {string|Object} Object can be {ignoreSize: true}
  4762. * @readOnly
  4763. */
  4764. layoutMode: null,
  4765. $constructor: function (option, parentModel, ecModel, extraOpt) {
  4766. Model.call(this, option, parentModel, ecModel, extraOpt);
  4767. // Set dependentModels, componentIndex, name, id, mainType, subType.
  4768. zrUtil.extend(this, extraOpt);
  4769. this.uid = componentUtil.getUID('componentModel');
  4770. },
  4771. init: function (option, parentModel, ecModel, extraOpt) {
  4772. this.mergeDefaultAndTheme(option, ecModel);
  4773. },
  4774. mergeDefaultAndTheme: function (option, ecModel) {
  4775. var layoutMode = this.layoutMode;
  4776. var inputPositionParams = layoutMode
  4777. ? layout.getLayoutParams(option) : {};
  4778. var themeModel = ecModel.getTheme();
  4779. zrUtil.merge(option, themeModel.get(this.mainType));
  4780. zrUtil.merge(option, this.getDefaultOption());
  4781. if (layoutMode) {
  4782. layout.mergeLayoutParam(option, inputPositionParams, layoutMode);
  4783. }
  4784. },
  4785. mergeOption: function (option) {
  4786. zrUtil.merge(this.option, option, true);
  4787. var layoutMode = this.layoutMode;
  4788. if (layoutMode) {
  4789. layout.mergeLayoutParam(this.option, option, layoutMode);
  4790. }
  4791. },
  4792. // Hooker after init or mergeOption
  4793. optionUpdated: function (newCptOption, isInit) {},
  4794. getDefaultOption: function () {
  4795. if (!this.hasOwnProperty('__defaultOption')) {
  4796. var optList = [];
  4797. var Class = this.constructor;
  4798. while (Class) {
  4799. var opt = Class.prototype.defaultOption;
  4800. opt && optList.push(opt);
  4801. Class = Class.superClass;
  4802. }
  4803. var defaultOption = {};
  4804. for (var i = optList.length - 1; i >= 0; i--) {
  4805. defaultOption = zrUtil.merge(defaultOption, optList[i], true);
  4806. }
  4807. this.__defaultOption = defaultOption;
  4808. }
  4809. return this.__defaultOption;
  4810. }
  4811. });
  4812. // Reset ComponentModel.extend, add preConstruct.
  4813. // clazzUtil.enableClassExtend(
  4814. // ComponentModel,
  4815. // function (option, parentModel, ecModel, extraOpt) {
  4816. // // Set dependentModels, componentIndex, name, id, mainType, subType.
  4817. // zrUtil.extend(this, extraOpt);
  4818. // this.uid = componentUtil.getUID('componentModel');
  4819. // // this.setReadOnly([
  4820. // // 'type', 'id', 'uid', 'name', 'mainType', 'subType',
  4821. // // 'dependentModels', 'componentIndex'
  4822. // // ]);
  4823. // }
  4824. // );
  4825. // Add capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on.
  4826. clazzUtil.enableClassManagement(
  4827. ComponentModel, {registerWhenExtend: true}
  4828. );
  4829. componentUtil.enableSubTypeDefaulter(ComponentModel);
  4830. // Add capability of ComponentModel.topologicalTravel.
  4831. componentUtil.enableTopologicalTravel(ComponentModel, getDependencies);
  4832. function getDependencies(componentType) {
  4833. var deps = [];
  4834. zrUtil.each(ComponentModel.getClassesByMainType(componentType), function (Clazz) {
  4835. arrayPush.apply(deps, Clazz.prototype.dependencies || []);
  4836. });
  4837. // Ensure main type
  4838. return zrUtil.map(deps, function (type) {
  4839. return clazzUtil.parseClassType(type).main;
  4840. });
  4841. }
  4842. zrUtil.mixin(ComponentModel, __webpack_require__(22));
  4843. module.exports = ComponentModel;
  4844. /***/ },
  4845. /* 20 */
  4846. /***/ function(module, exports, __webpack_require__) {
  4847. var zrUtil = __webpack_require__(4);
  4848. var clazz = __webpack_require__(13);
  4849. var parseClassType = clazz.parseClassType;
  4850. var base = 0;
  4851. var componentUtil = {};
  4852. var DELIMITER = '_';
  4853. /**
  4854. * @public
  4855. * @param {string} type
  4856. * @return {string}
  4857. */
  4858. componentUtil.getUID = function (type) {
  4859. // Considering the case of crossing js context,
  4860. // use Math.random to make id as unique as possible.
  4861. return [(type || ''), base++, Math.random()].join(DELIMITER);
  4862. };
  4863. /**
  4864. * @inner
  4865. */
  4866. componentUtil.enableSubTypeDefaulter = function (entity) {
  4867. var subTypeDefaulters = {};
  4868. entity.registerSubTypeDefaulter = function (componentType, defaulter) {
  4869. componentType = parseClassType(componentType);
  4870. subTypeDefaulters[componentType.main] = defaulter;
  4871. };
  4872. entity.determineSubType = function (componentType, option) {
  4873. var type = option.type;
  4874. if (!type) {
  4875. var componentTypeMain = parseClassType(componentType).main;
  4876. if (entity.hasSubTypes(componentType) && subTypeDefaulters[componentTypeMain]) {
  4877. type = subTypeDefaulters[componentTypeMain](option);
  4878. }
  4879. }
  4880. return type;
  4881. };
  4882. return entity;
  4883. };
  4884. /**
  4885. * Topological travel on Activity Network (Activity On Vertices).
  4886. * Dependencies is defined in Model.prototype.dependencies, like ['xAxis', 'yAxis'].
  4887. *
  4888. * If 'xAxis' or 'yAxis' is absent in componentTypeList, just ignore it in topology.
  4889. *
  4890. * If there is circle dependencey, Error will be thrown.
  4891. *
  4892. */
  4893. componentUtil.enableTopologicalTravel = function (entity, dependencyGetter) {
  4894. /**
  4895. * @public
  4896. * @param {Array.<string>} targetNameList Target Component type list.
  4897. * Can be ['aa', 'bb', 'aa.xx']
  4898. * @param {Array.<string>} fullNameList By which we can build dependency graph.
  4899. * @param {Function} callback Params: componentType, dependencies.
  4900. * @param {Object} context Scope of callback.
  4901. */
  4902. entity.topologicalTravel = function (targetNameList, fullNameList, callback, context) {
  4903. if (!targetNameList.length) {
  4904. return;
  4905. }
  4906. var result = makeDepndencyGraph(fullNameList);
  4907. var graph = result.graph;
  4908. var stack = result.noEntryList;
  4909. var targetNameSet = {};
  4910. zrUtil.each(targetNameList, function (name) {
  4911. targetNameSet[name] = true;
  4912. });
  4913. while (stack.length) {
  4914. var currComponentType = stack.pop();
  4915. var currVertex = graph[currComponentType];
  4916. var isInTargetNameSet = !!targetNameSet[currComponentType];
  4917. if (isInTargetNameSet) {
  4918. callback.call(context, currComponentType, currVertex.originalDeps.slice());
  4919. delete targetNameSet[currComponentType];
  4920. }
  4921. zrUtil.each(
  4922. currVertex.successor,
  4923. isInTargetNameSet ? removeEdgeAndAdd : removeEdge
  4924. );
  4925. }
  4926. zrUtil.each(targetNameSet, function () {
  4927. throw new Error('Circle dependency may exists');
  4928. });
  4929. function removeEdge(succComponentType) {
  4930. graph[succComponentType].entryCount--;
  4931. if (graph[succComponentType].entryCount === 0) {
  4932. stack.push(succComponentType);
  4933. }
  4934. }
  4935. // Consider this case: legend depends on series, and we call
  4936. // chart.setOption({series: [...]}), where only series is in option.
  4937. // If we do not have 'removeEdgeAndAdd', legendModel.mergeOption will
  4938. // not be called, but only sereis.mergeOption is called. Thus legend
  4939. // have no chance to update its local record about series (like which
  4940. // name of series is available in legend).
  4941. function removeEdgeAndAdd(succComponentType) {
  4942. targetNameSet[succComponentType] = true;
  4943. removeEdge(succComponentType);
  4944. }
  4945. };
  4946. /**
  4947. * DepndencyGraph: {Object}
  4948. * key: conponentType,
  4949. * value: {
  4950. * successor: [conponentTypes...],
  4951. * originalDeps: [conponentTypes...],
  4952. * entryCount: {number}
  4953. * }
  4954. */
  4955. function makeDepndencyGraph(fullNameList) {
  4956. var graph = {};
  4957. var noEntryList = [];
  4958. zrUtil.each(fullNameList, function (name) {
  4959. var thisItem = createDependencyGraphItem(graph, name);
  4960. var originalDeps = thisItem.originalDeps = dependencyGetter(name);
  4961. var availableDeps = getAvailableDependencies(originalDeps, fullNameList);
  4962. thisItem.entryCount = availableDeps.length;
  4963. if (thisItem.entryCount === 0) {
  4964. noEntryList.push(name);
  4965. }
  4966. zrUtil.each(availableDeps, function (dependentName) {
  4967. if (zrUtil.indexOf(thisItem.predecessor, dependentName) < 0) {
  4968. thisItem.predecessor.push(dependentName);
  4969. }
  4970. var thatItem = createDependencyGraphItem(graph, dependentName);
  4971. if (zrUtil.indexOf(thatItem.successor, dependentName) < 0) {
  4972. thatItem.successor.push(name);
  4973. }
  4974. });
  4975. });
  4976. return {graph: graph, noEntryList: noEntryList};
  4977. }
  4978. function createDependencyGraphItem(graph, name) {
  4979. if (!graph[name]) {
  4980. graph[name] = {predecessor: [], successor: []};
  4981. }
  4982. return graph[name];
  4983. }
  4984. function getAvailableDependencies(originalDeps, fullNameList) {
  4985. var availableDeps = [];
  4986. zrUtil.each(originalDeps, function (dep) {
  4987. zrUtil.indexOf(fullNameList, dep) >= 0 && availableDeps.push(dep);
  4988. });
  4989. return availableDeps;
  4990. }
  4991. };
  4992. module.exports = componentUtil;
  4993. /***/ },
  4994. /* 21 */
  4995. /***/ function(module, exports, __webpack_require__) {
  4996. 'use strict';
  4997. // Layout helpers for each component positioning
  4998. var zrUtil = __webpack_require__(4);
  4999. var BoundingRect = __webpack_require__(9);
  5000. var numberUtil = __webpack_require__(7);
  5001. var formatUtil = __webpack_require__(6);
  5002. var parsePercent = numberUtil.parsePercent;
  5003. var each = zrUtil.each;
  5004. var layout = {};
  5005. var LOCATION_PARAMS = ['left', 'right', 'top', 'bottom', 'width', 'height'];
  5006. function boxLayout(orient, group, gap, maxWidth, maxHeight) {
  5007. var x = 0;
  5008. var y = 0;
  5009. if (maxWidth == null) {
  5010. maxWidth = Infinity;
  5011. }
  5012. if (maxHeight == null) {
  5013. maxHeight = Infinity;
  5014. }
  5015. var currentLineMaxSize = 0;
  5016. group.eachChild(function (child, idx) {
  5017. var position = child.position;
  5018. var rect = child.getBoundingRect();
  5019. var nextChild = group.childAt(idx + 1);
  5020. var nextChildRect = nextChild && nextChild.getBoundingRect();
  5021. var nextX;
  5022. var nextY;
  5023. if (orient === 'horizontal') {
  5024. var moveX = rect.width + (nextChildRect ? (-nextChildRect.x + rect.x) : 0);
  5025. nextX = x + moveX;
  5026. // Wrap when width exceeds maxWidth or meet a `newline` group
  5027. if (nextX > maxWidth || child.newline) {
  5028. x = 0;
  5029. nextX = moveX;
  5030. y += currentLineMaxSize + gap;
  5031. currentLineMaxSize = rect.height;
  5032. }
  5033. else {
  5034. currentLineMaxSize = Math.max(currentLineMaxSize, rect.height);
  5035. }
  5036. }
  5037. else {
  5038. var moveY = rect.height + (nextChildRect ? (-nextChildRect.y + rect.y) : 0);
  5039. nextY = y + moveY;
  5040. // Wrap when width exceeds maxHeight or meet a `newline` group
  5041. if (nextY > maxHeight || child.newline) {
  5042. x += currentLineMaxSize + gap;
  5043. y = 0;
  5044. nextY = moveY;
  5045. currentLineMaxSize = rect.width;
  5046. }
  5047. else {
  5048. currentLineMaxSize = Math.max(currentLineMaxSize, rect.width);
  5049. }
  5050. }
  5051. if (child.newline) {
  5052. return;
  5053. }
  5054. position[0] = x;
  5055. position[1] = y;
  5056. orient === 'horizontal'
  5057. ? (x = nextX + gap)
  5058. : (y = nextY + gap);
  5059. });
  5060. }
  5061. /**
  5062. * VBox or HBox layouting
  5063. * @param {string} orient
  5064. * @param {module:zrender/container/Group} group
  5065. * @param {number} gap
  5066. * @param {number} [width=Infinity]
  5067. * @param {number} [height=Infinity]
  5068. */
  5069. layout.box = boxLayout;
  5070. /**
  5071. * VBox layouting
  5072. * @param {module:zrender/container/Group} group
  5073. * @param {number} gap
  5074. * @param {number} [width=Infinity]
  5075. * @param {number} [height=Infinity]
  5076. */
  5077. layout.vbox = zrUtil.curry(boxLayout, 'vertical');
  5078. /**
  5079. * HBox layouting
  5080. * @param {module:zrender/container/Group} group
  5081. * @param {number} gap
  5082. * @param {number} [width=Infinity]
  5083. * @param {number} [height=Infinity]
  5084. */
  5085. layout.hbox = zrUtil.curry(boxLayout, 'horizontal');
  5086. /**
  5087. * If x or x2 is not specified or 'center' 'left' 'right',
  5088. * the width would be as long as possible.
  5089. * If y or y2 is not specified or 'middle' 'top' 'bottom',
  5090. * the height would be as long as possible.
  5091. *
  5092. * @param {Object} positionInfo
  5093. * @param {number|string} [positionInfo.x]
  5094. * @param {number|string} [positionInfo.y]
  5095. * @param {number|string} [positionInfo.x2]
  5096. * @param {number|string} [positionInfo.y2]
  5097. * @param {Object} containerRect
  5098. * @param {string|number} margin
  5099. * @return {Object} {width, height}
  5100. */
  5101. layout.getAvailableSize = function (positionInfo, containerRect, margin) {
  5102. var containerWidth = containerRect.width;
  5103. var containerHeight = containerRect.height;
  5104. var x = parsePercent(positionInfo.x, containerWidth);
  5105. var y = parsePercent(positionInfo.y, containerHeight);
  5106. var x2 = parsePercent(positionInfo.x2, containerWidth);
  5107. var y2 = parsePercent(positionInfo.y2, containerHeight);
  5108. (isNaN(x) || isNaN(parseFloat(positionInfo.x))) && (x = 0);
  5109. (isNaN(x2) || isNaN(parseFloat(positionInfo.x2))) && (x2 = containerWidth);
  5110. (isNaN(y) || isNaN(parseFloat(positionInfo.y))) && (y = 0);
  5111. (isNaN(y2) || isNaN(parseFloat(positionInfo.y2))) && (y2 = containerHeight);
  5112. margin = formatUtil.normalizeCssArray(margin || 0);
  5113. return {
  5114. width: Math.max(x2 - x - margin[1] - margin[3], 0),
  5115. height: Math.max(y2 - y - margin[0] - margin[2], 0)
  5116. };
  5117. };
  5118. /**
  5119. * Parse position info.
  5120. *
  5121. * @param {Object} positionInfo
  5122. * @param {number|string} [positionInfo.left]
  5123. * @param {number|string} [positionInfo.top]
  5124. * @param {number|string} [positionInfo.right]
  5125. * @param {number|string} [positionInfo.bottom]
  5126. * @param {number|string} [positionInfo.width]
  5127. * @param {number|string} [positionInfo.height]
  5128. * @param {number|string} [positionInfo.aspect] Aspect is width / height
  5129. * @param {Object} containerRect
  5130. * @param {string|number} [margin]
  5131. *
  5132. * @return {module:zrender/core/BoundingRect}
  5133. */
  5134. layout.getLayoutRect = function (
  5135. positionInfo, containerRect, margin
  5136. ) {
  5137. margin = formatUtil.normalizeCssArray(margin || 0);
  5138. var containerWidth = containerRect.width;
  5139. var containerHeight = containerRect.height;
  5140. var left = parsePercent(positionInfo.left, containerWidth);
  5141. var top = parsePercent(positionInfo.top, containerHeight);
  5142. var right = parsePercent(positionInfo.right, containerWidth);
  5143. var bottom = parsePercent(positionInfo.bottom, containerHeight);
  5144. var width = parsePercent(positionInfo.width, containerWidth);
  5145. var height = parsePercent(positionInfo.height, containerHeight);
  5146. var verticalMargin = margin[2] + margin[0];
  5147. var horizontalMargin = margin[1] + margin[3];
  5148. var aspect = positionInfo.aspect;
  5149. // If width is not specified, calculate width from left and right
  5150. if (isNaN(width)) {
  5151. width = containerWidth - right - horizontalMargin - left;
  5152. }
  5153. if (isNaN(height)) {
  5154. height = containerHeight - bottom - verticalMargin - top;
  5155. }
  5156. // If width and height are not given
  5157. // 1. Graph should not exceeds the container
  5158. // 2. Aspect must be keeped
  5159. // 3. Graph should take the space as more as possible
  5160. if (isNaN(width) && isNaN(height)) {
  5161. if (aspect > containerWidth / containerHeight) {
  5162. width = containerWidth * 0.8;
  5163. }
  5164. else {
  5165. height = containerHeight * 0.8;
  5166. }
  5167. }
  5168. if (aspect != null) {
  5169. // Calculate width or height with given aspect
  5170. if (isNaN(width)) {
  5171. width = aspect * height;
  5172. }
  5173. if (isNaN(height)) {
  5174. height = width / aspect;
  5175. }
  5176. }
  5177. // If left is not specified, calculate left from right and width
  5178. if (isNaN(left)) {
  5179. left = containerWidth - right - width - horizontalMargin;
  5180. }
  5181. if (isNaN(top)) {
  5182. top = containerHeight - bottom - height - verticalMargin;
  5183. }
  5184. // Align left and top
  5185. switch (positionInfo.left || positionInfo.right) {
  5186. case 'center':
  5187. left = containerWidth / 2 - width / 2 - margin[3];
  5188. break;
  5189. case 'right':
  5190. left = containerWidth - width - horizontalMargin;
  5191. break;
  5192. }
  5193. switch (positionInfo.top || positionInfo.bottom) {
  5194. case 'middle':
  5195. case 'center':
  5196. top = containerHeight / 2 - height / 2 - margin[0];
  5197. break;
  5198. case 'bottom':
  5199. top = containerHeight - height - verticalMargin;
  5200. break;
  5201. }
  5202. // If something is wrong and left, top, width, height are calculated as NaN
  5203. left = left || 0;
  5204. top = top || 0;
  5205. if (isNaN(width)) {
  5206. // Width may be NaN if only one value is given except width
  5207. width = containerWidth - left - (right || 0);
  5208. }
  5209. if (isNaN(height)) {
  5210. // Height may be NaN if only one value is given except height
  5211. height = containerHeight - top - (bottom || 0);
  5212. }
  5213. var rect = new BoundingRect(left + margin[3], top + margin[0], width, height);
  5214. rect.margin = margin;
  5215. return rect;
  5216. };
  5217. /**
  5218. * Position group of component in viewport
  5219. * Group position is specified by either
  5220. * {left, top}, {right, bottom}
  5221. * If all properties exists, right and bottom will be igonred.
  5222. *
  5223. * @param {module:zrender/container/Group} group
  5224. * @param {Object} positionInfo
  5225. * @param {number|string} [positionInfo.left]
  5226. * @param {number|string} [positionInfo.top]
  5227. * @param {number|string} [positionInfo.right]
  5228. * @param {number|string} [positionInfo.bottom]
  5229. * @param {Object} containerRect
  5230. * @param {string|number} margin
  5231. */
  5232. layout.positionGroup = function (
  5233. group, positionInfo, containerRect, margin
  5234. ) {
  5235. var groupRect = group.getBoundingRect();
  5236. positionInfo = zrUtil.extend(zrUtil.clone(positionInfo), {
  5237. width: groupRect.width,
  5238. height: groupRect.height
  5239. });
  5240. positionInfo = layout.getLayoutRect(
  5241. positionInfo, containerRect, margin
  5242. );
  5243. group.attr('position', [
  5244. positionInfo.x - groupRect.x,
  5245. positionInfo.y - groupRect.y
  5246. ]);
  5247. };
  5248. /**
  5249. * Consider Case:
  5250. * When defulat option has {left: 0, width: 100}, and we set {right: 0}
  5251. * through setOption or media query, using normal zrUtil.merge will cause
  5252. * {right: 0} does not take effect.
  5253. *
  5254. * @example
  5255. * ComponentModel.extend({
  5256. * init: function () {
  5257. * ...
  5258. * var inputPositionParams = layout.getLayoutParams(option);
  5259. * this.mergeOption(inputPositionParams);
  5260. * },
  5261. * mergeOption: function (newOption) {
  5262. * newOption && zrUtil.merge(thisOption, newOption, true);
  5263. * layout.mergeLayoutParam(thisOption, newOption);
  5264. * }
  5265. * });
  5266. *
  5267. * @param {Object} targetOption
  5268. * @param {Object} newOption
  5269. * @param {Object|string} [opt]
  5270. * @param {boolean} [opt.ignoreSize=false] Some component must has width and height.
  5271. */
  5272. layout.mergeLayoutParam = function (targetOption, newOption, opt) {
  5273. !zrUtil.isObject(opt) && (opt = {});
  5274. var hNames = ['width', 'left', 'right']; // Order by priority.
  5275. var vNames = ['height', 'top', 'bottom']; // Order by priority.
  5276. var hResult = merge(hNames);
  5277. var vResult = merge(vNames);
  5278. copy(hNames, targetOption, hResult);
  5279. copy(vNames, targetOption, vResult);
  5280. function merge(names) {
  5281. var newParams = {};
  5282. var newValueCount = 0;
  5283. var merged = {};
  5284. var mergedValueCount = 0;
  5285. var enoughParamNumber = opt.ignoreSize ? 1 : 2;
  5286. each(names, function (name) {
  5287. merged[name] = targetOption[name];
  5288. });
  5289. each(names, function (name) {
  5290. // Consider case: newOption.width is null, which is
  5291. // set by user for removing width setting.
  5292. hasProp(newOption, name) && (newParams[name] = merged[name] = newOption[name]);
  5293. hasValue(newParams, name) && newValueCount++;
  5294. hasValue(merged, name) && mergedValueCount++;
  5295. });
  5296. // Case: newOption: {width: ..., right: ...},
  5297. // or targetOption: {right: ...} and newOption: {width: ...},
  5298. // There is no conflict when merged only has params count
  5299. // little than enoughParamNumber.
  5300. if (mergedValueCount === enoughParamNumber || !newValueCount) {
  5301. return merged;
  5302. }
  5303. // Case: newOption: {width: ..., right: ...},
  5304. // Than we can make sure user only want those two, and ignore
  5305. // all origin params in targetOption.
  5306. else if (newValueCount >= enoughParamNumber) {
  5307. return newParams;
  5308. }
  5309. else {
  5310. // Chose another param from targetOption by priority.
  5311. // When 'ignoreSize', enoughParamNumber is 1 and those will not happen.
  5312. for (var i = 0; i < names.length; i++) {
  5313. var name = names[i];
  5314. if (!hasProp(newParams, name) && hasProp(targetOption, name)) {
  5315. newParams[name] = targetOption[name];
  5316. break;
  5317. }
  5318. }
  5319. return newParams;
  5320. }
  5321. }
  5322. function hasProp(obj, name) {
  5323. return obj.hasOwnProperty(name);
  5324. }
  5325. function hasValue(obj, name) {
  5326. return obj[name] != null && obj[name] !== 'auto';
  5327. }
  5328. function copy(names, target, source) {
  5329. each(names, function (name) {
  5330. target[name] = source[name];
  5331. });
  5332. }
  5333. };
  5334. /**
  5335. * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object.
  5336. * @param {Object} source
  5337. * @return {Object} Result contains those props.
  5338. */
  5339. layout.getLayoutParams = function (source) {
  5340. return layout.copyLayoutParams({}, source);
  5341. };
  5342. /**
  5343. * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object.
  5344. * @param {Object} source
  5345. * @return {Object} Result contains those props.
  5346. */
  5347. layout.copyLayoutParams = function (target, source) {
  5348. source && target && each(LOCATION_PARAMS, function (name) {
  5349. source.hasOwnProperty(name) && (target[name] = source[name]);
  5350. });
  5351. return target;
  5352. };
  5353. module.exports = layout;
  5354. /***/ },
  5355. /* 22 */
  5356. /***/ function(module, exports) {
  5357. module.exports = {
  5358. getBoxLayoutParams: function () {
  5359. return {
  5360. left: this.get('left'),
  5361. top: this.get('top'),
  5362. right: this.get('right'),
  5363. bottom: this.get('bottom'),
  5364. width: this.get('width'),
  5365. height: this.get('height')
  5366. };
  5367. }
  5368. };
  5369. /***/ },
  5370. /* 23 */
  5371. /***/ function(module, exports) {
  5372. var platform = '';
  5373. // Navigator not exists in node
  5374. if (typeof navigator !== 'undefined') {
  5375. platform = navigator.platform || '';
  5376. }
  5377. module.exports = {
  5378. // 全图默认背景
  5379. // backgroundColor: 'rgba(0,0,0,0)',
  5380. // https://dribbble.com/shots/1065960-Infographic-Pie-chart-visualization
  5381. // color: ['#5793f3', '#d14a61', '#fd9c35', '#675bba', '#fec42c', '#dd4444', '#d4df5a', '#cd4870'],
  5382. // 浅色
  5383. // color: ['#bcd3bb', '#e88f70', '#edc1a5', '#9dc5c8', '#e1e8c8', '#7b7c68', '#e5b5b5', '#f0b489', '#928ea8', '#bda29a'],
  5384. // color: ['#cc5664', '#9bd6ec', '#ea946e', '#8acaaa', '#f1ec64', '#ee8686', '#a48dc1', '#5da6bc', '#b9dcae'],
  5385. // 深色
  5386. color: ['#c23531','#2f4554', '#61a0a8', '#d48265', '#91c7ae','#749f83', '#ca8622', '#bda29a','#6e7074', '#546570', '#c4ccd3'],
  5387. // 默认需要 Grid 配置项
  5388. grid: {},
  5389. // 主题,主题
  5390. textStyle: {
  5391. // color: '#000',
  5392. // decoration: 'none',
  5393. // PENDING
  5394. fontFamily: platform.match(/^Win/) ? 'Microsoft YaHei' : 'sans-serif',
  5395. // fontFamily: 'Arial, Verdana, sans-serif',
  5396. fontSize: 12,
  5397. fontStyle: 'normal',
  5398. fontWeight: 'normal'
  5399. },
  5400. // http://blogs.adobe.com/webplatform/2014/02/24/using-blend-modes-in-html-canvas/
  5401. // https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
  5402. // Default is source-over
  5403. blendMode: null,
  5404. animation: true,
  5405. animationDuration: 1000,
  5406. animationDurationUpdate: 300,
  5407. animationEasing: 'exponentialOut',
  5408. animationEasingUpdate: 'cubicOut',
  5409. animationThreshold: 2000,
  5410. // Configuration for progressive/incremental rendering
  5411. progressiveThreshold: 3000,
  5412. progressive: 400,
  5413. // Threshold of if use single hover layer to optimize.
  5414. hoverLayerThreshold: 3000
  5415. };
  5416. /***/ },
  5417. /* 24 */
  5418. /***/ function(module, exports) {
  5419. module.exports = {
  5420. clearColorPalette: function () {
  5421. this._colorIdx = 0;
  5422. this._colorNameMap = {};
  5423. },
  5424. getColorFromPalette: function (name, scope) {
  5425. scope = scope || this;
  5426. var colorIdx = scope._colorIdx || 0;
  5427. var colorNameMap = scope._colorNameMap || (scope._colorNameMap = {});
  5428. if (colorNameMap[name]) {
  5429. return colorNameMap[name];
  5430. }
  5431. var colorPalette = this.get('color', true) || [];
  5432. if (!colorPalette.length) {
  5433. return;
  5434. }
  5435. var color = colorPalette[colorIdx];
  5436. if (name) {
  5437. colorNameMap[name] = color;
  5438. }
  5439. scope._colorIdx = (colorIdx + 1) % colorPalette.length;
  5440. return color;
  5441. }
  5442. };
  5443. /***/ },
  5444. /* 25 */
  5445. /***/ function(module, exports, __webpack_require__) {
  5446. 'use strict';
  5447. var zrUtil = __webpack_require__(4);
  5448. var echartsAPIList = [
  5449. 'getDom', 'getZr', 'getWidth', 'getHeight', 'dispatchAction', 'isDisposed',
  5450. 'on', 'off', 'getDataURL', 'getConnectedDataURL', 'getModel', 'getOption'
  5451. ];
  5452. function ExtensionAPI(chartInstance) {
  5453. zrUtil.each(echartsAPIList, function (name) {
  5454. this[name] = zrUtil.bind(chartInstance[name], chartInstance);
  5455. }, this);
  5456. }
  5457. module.exports = ExtensionAPI;
  5458. /***/ },
  5459. /* 26 */
  5460. /***/ function(module, exports) {
  5461. 'use strict';
  5462. var coordinateSystemCreators = {};
  5463. function CoordinateSystemManager() {
  5464. this._coordinateSystems = [];
  5465. }
  5466. CoordinateSystemManager.prototype = {
  5467. constructor: CoordinateSystemManager,
  5468. create: function (ecModel, api) {
  5469. var coordinateSystems = [];
  5470. for (var type in coordinateSystemCreators) {
  5471. var list = coordinateSystemCreators[type].create(ecModel, api);
  5472. list && (coordinateSystems = coordinateSystems.concat(list));
  5473. }
  5474. this._coordinateSystems = coordinateSystems;
  5475. },
  5476. update: function (ecModel, api) {
  5477. var coordinateSystems = this._coordinateSystems;
  5478. for (var i = 0; i < coordinateSystems.length; i++) {
  5479. // FIXME MUST have
  5480. coordinateSystems[i].update && coordinateSystems[i].update(ecModel, api);
  5481. }
  5482. }
  5483. };
  5484. CoordinateSystemManager.register = function (type, coordinateSystemCreator) {
  5485. coordinateSystemCreators[type] = coordinateSystemCreator;
  5486. };
  5487. CoordinateSystemManager.get = function (type) {
  5488. return coordinateSystemCreators[type];
  5489. };
  5490. module.exports = CoordinateSystemManager;
  5491. /***/ },
  5492. /* 27 */
  5493. /***/ function(module, exports, __webpack_require__) {
  5494. /**
  5495. * ECharts option manager
  5496. *
  5497. * @module {echarts/model/OptionManager}
  5498. */
  5499. var zrUtil = __webpack_require__(4);
  5500. var modelUtil = __webpack_require__(5);
  5501. var ComponentModel = __webpack_require__(19);
  5502. var each = zrUtil.each;
  5503. var clone = zrUtil.clone;
  5504. var map = zrUtil.map;
  5505. var merge = zrUtil.merge;
  5506. var QUERY_REG = /^(min|max)?(.+)$/;
  5507. /**
  5508. * TERM EXPLANATIONS:
  5509. *
  5510. * [option]:
  5511. *
  5512. * An object that contains definitions of components. For example:
  5513. * var option = {
  5514. * title: {...},
  5515. * legend: {...},
  5516. * visualMap: {...},
  5517. * series: [
  5518. * {data: [...]},
  5519. * {data: [...]},
  5520. * ...
  5521. * ]
  5522. * };
  5523. *
  5524. * [rawOption]:
  5525. *
  5526. * An object input to echarts.setOption. 'rawOption' may be an
  5527. * 'option', or may be an object contains multi-options. For example:
  5528. * var option = {
  5529. * baseOption: {
  5530. * title: {...},
  5531. * legend: {...},
  5532. * series: [
  5533. * {data: [...]},
  5534. * {data: [...]},
  5535. * ...
  5536. * ]
  5537. * },
  5538. * timeline: {...},
  5539. * options: [
  5540. * {title: {...}, series: {data: [...]}},
  5541. * {title: {...}, series: {data: [...]}},
  5542. * ...
  5543. * ],
  5544. * media: [
  5545. * {
  5546. * query: {maxWidth: 320},
  5547. * option: {series: {x: 20}, visualMap: {show: false}}
  5548. * },
  5549. * {
  5550. * query: {minWidth: 320, maxWidth: 720},
  5551. * option: {series: {x: 500}, visualMap: {show: true}}
  5552. * },
  5553. * {
  5554. * option: {series: {x: 1200}, visualMap: {show: true}}
  5555. * }
  5556. * ]
  5557. * };
  5558. *
  5559. * @alias module:echarts/model/OptionManager
  5560. * @param {module:echarts/ExtensionAPI} api
  5561. */
  5562. function OptionManager(api) {
  5563. /**
  5564. * @private
  5565. * @type {module:echarts/ExtensionAPI}
  5566. */
  5567. this._api = api;
  5568. /**
  5569. * @private
  5570. * @type {Array.<number>}
  5571. */
  5572. this._timelineOptions = [];
  5573. /**
  5574. * @private
  5575. * @type {Array.<Object>}
  5576. */
  5577. this._mediaList = [];
  5578. /**
  5579. * @private
  5580. * @type {Object}
  5581. */
  5582. this._mediaDefault;
  5583. /**
  5584. * -1, means default.
  5585. * empty means no media.
  5586. * @private
  5587. * @type {Array.<number>}
  5588. */
  5589. this._currentMediaIndices = [];
  5590. /**
  5591. * @private
  5592. * @type {Object}
  5593. */
  5594. this._optionBackup;
  5595. /**
  5596. * @private
  5597. * @type {Object}
  5598. */
  5599. this._newBaseOption;
  5600. }
  5601. // timeline.notMerge is not supported in ec3. Firstly there is rearly
  5602. // case that notMerge is needed. Secondly supporting 'notMerge' requires
  5603. // rawOption cloned and backuped when timeline changed, which does no
  5604. // good to performance. What's more, that both timeline and setOption
  5605. // method supply 'notMerge' brings complex and some problems.
  5606. // Consider this case:
  5607. // (step1) chart.setOption({timeline: {notMerge: false}, ...}, false);
  5608. // (step2) chart.setOption({timeline: {notMerge: true}, ...}, false);
  5609. OptionManager.prototype = {
  5610. constructor: OptionManager,
  5611. /**
  5612. * @public
  5613. * @param {Object} rawOption Raw option.
  5614. * @param {module:echarts/model/Global} ecModel
  5615. * @param {Array.<Function>} optionPreprocessorFuncs
  5616. * @return {Object} Init option
  5617. */
  5618. setOption: function (rawOption, optionPreprocessorFuncs) {
  5619. rawOption = clone(rawOption, true);
  5620. // FIXME
  5621. // 如果 timeline options 或者 media 中设置了某个属性,而baseOption中没有设置,则进行警告。
  5622. var oldOptionBackup = this._optionBackup;
  5623. var newParsedOption = parseRawOption.call(
  5624. this, rawOption, optionPreprocessorFuncs, !oldOptionBackup
  5625. );
  5626. this._newBaseOption = newParsedOption.baseOption;
  5627. // For setOption at second time (using merge mode);
  5628. if (oldOptionBackup) {
  5629. // Only baseOption can be merged.
  5630. mergeOption(oldOptionBackup.baseOption, newParsedOption.baseOption);
  5631. // For simplicity, timeline options and media options do not support merge,
  5632. // that is, if you `setOption` twice and both has timeline options, the latter
  5633. // timeline opitons will not be merged to the formers, but just substitude them.
  5634. if (newParsedOption.timelineOptions.length) {
  5635. oldOptionBackup.timelineOptions = newParsedOption.timelineOptions;
  5636. }
  5637. if (newParsedOption.mediaList.length) {
  5638. oldOptionBackup.mediaList = newParsedOption.mediaList;
  5639. }
  5640. if (newParsedOption.mediaDefault) {
  5641. oldOptionBackup.mediaDefault = newParsedOption.mediaDefault;
  5642. }
  5643. }
  5644. else {
  5645. this._optionBackup = newParsedOption;
  5646. }
  5647. },
  5648. /**
  5649. * @param {boolean} isRecreate
  5650. * @return {Object}
  5651. */
  5652. mountOption: function (isRecreate) {
  5653. var optionBackup = this._optionBackup;
  5654. // TODO
  5655. // 如果没有reset功能则不clone。
  5656. this._timelineOptions = map(optionBackup.timelineOptions, clone);
  5657. this._mediaList = map(optionBackup.mediaList, clone);
  5658. this._mediaDefault = clone(optionBackup.mediaDefault);
  5659. this._currentMediaIndices = [];
  5660. return clone(isRecreate
  5661. // this._optionBackup.baseOption, which is created at the first `setOption`
  5662. // called, and is merged into every new option by inner method `mergeOption`
  5663. // each time `setOption` called, can be only used in `isRecreate`, because
  5664. // its reliability is under suspicion. In other cases option merge is
  5665. // proformed by `model.mergeOption`.
  5666. ? optionBackup.baseOption : this._newBaseOption
  5667. );
  5668. },
  5669. /**
  5670. * @param {module:echarts/model/Global} ecModel
  5671. * @return {Object}
  5672. */
  5673. getTimelineOption: function (ecModel) {
  5674. var option;
  5675. var timelineOptions = this._timelineOptions;
  5676. if (timelineOptions.length) {
  5677. // getTimelineOption can only be called after ecModel inited,
  5678. // so we can get currentIndex from timelineModel.
  5679. var timelineModel = ecModel.getComponent('timeline');
  5680. if (timelineModel) {
  5681. option = clone(
  5682. timelineOptions[timelineModel.getCurrentIndex()],
  5683. true
  5684. );
  5685. }
  5686. }
  5687. return option;
  5688. },
  5689. /**
  5690. * @param {module:echarts/model/Global} ecModel
  5691. * @return {Array.<Object>}
  5692. */
  5693. getMediaOption: function (ecModel) {
  5694. var ecWidth = this._api.getWidth();
  5695. var ecHeight = this._api.getHeight();
  5696. var mediaList = this._mediaList;
  5697. var mediaDefault = this._mediaDefault;
  5698. var indices = [];
  5699. var result = [];
  5700. // No media defined.
  5701. if (!mediaList.length && !mediaDefault) {
  5702. return result;
  5703. }
  5704. // Multi media may be applied, the latter defined media has higher priority.
  5705. for (var i = 0, len = mediaList.length; i < len; i++) {
  5706. if (applyMediaQuery(mediaList[i].query, ecWidth, ecHeight)) {
  5707. indices.push(i);
  5708. }
  5709. }
  5710. // FIXME
  5711. // 是否mediaDefault应该强制用户设置,否则可能修改不能回归。
  5712. if (!indices.length && mediaDefault) {
  5713. indices = [-1];
  5714. }
  5715. if (indices.length && !indicesEquals(indices, this._currentMediaIndices)) {
  5716. result = map(indices, function (index) {
  5717. return clone(
  5718. index === -1 ? mediaDefault.option : mediaList[index].option
  5719. );
  5720. });
  5721. }
  5722. // Otherwise return nothing.
  5723. this._currentMediaIndices = indices;
  5724. return result;
  5725. }
  5726. };
  5727. function parseRawOption(rawOption, optionPreprocessorFuncs, isNew) {
  5728. var timelineOptions = [];
  5729. var mediaList = [];
  5730. var mediaDefault;
  5731. var baseOption;
  5732. // Compatible with ec2.
  5733. var timelineOpt = rawOption.timeline;
  5734. if (rawOption.baseOption) {
  5735. baseOption = rawOption.baseOption;
  5736. }
  5737. // For timeline
  5738. if (timelineOpt || rawOption.options) {
  5739. baseOption = baseOption || {};
  5740. timelineOptions = (rawOption.options || []).slice();
  5741. }
  5742. // For media query
  5743. if (rawOption.media) {
  5744. baseOption = baseOption || {};
  5745. var media = rawOption.media;
  5746. each(media, function (singleMedia) {
  5747. if (singleMedia && singleMedia.option) {
  5748. if (singleMedia.query) {
  5749. mediaList.push(singleMedia);
  5750. }
  5751. else if (!mediaDefault) {
  5752. // Use the first media default.
  5753. mediaDefault = singleMedia;
  5754. }
  5755. }
  5756. });
  5757. }
  5758. // For normal option
  5759. if (!baseOption) {
  5760. baseOption = rawOption;
  5761. }
  5762. // Set timelineOpt to baseOption in ec3,
  5763. // which is convenient for merge option.
  5764. if (!baseOption.timeline) {
  5765. baseOption.timeline = timelineOpt;
  5766. }
  5767. // Preprocess.
  5768. each([baseOption].concat(timelineOptions)
  5769. .concat(zrUtil.map(mediaList, function (media) {
  5770. return media.option;
  5771. })),
  5772. function (option) {
  5773. each(optionPreprocessorFuncs, function (preProcess) {
  5774. preProcess(option, isNew);
  5775. });
  5776. }
  5777. );
  5778. return {
  5779. baseOption: baseOption,
  5780. timelineOptions: timelineOptions,
  5781. mediaDefault: mediaDefault,
  5782. mediaList: mediaList
  5783. };
  5784. }
  5785. /**
  5786. * @see <http://www.w3.org/TR/css3-mediaqueries/#media1>
  5787. * Support: width, height, aspectRatio
  5788. * Can use max or min as prefix.
  5789. */
  5790. function applyMediaQuery(query, ecWidth, ecHeight) {
  5791. var realMap = {
  5792. width: ecWidth,
  5793. height: ecHeight,
  5794. aspectratio: ecWidth / ecHeight // lowser case for convenientce.
  5795. };
  5796. var applicatable = true;
  5797. zrUtil.each(query, function (value, attr) {
  5798. var matched = attr.match(QUERY_REG);
  5799. if (!matched || !matched[1] || !matched[2]) {
  5800. return;
  5801. }
  5802. var operator = matched[1];
  5803. var realAttr = matched[2].toLowerCase();
  5804. if (!compare(realMap[realAttr], value, operator)) {
  5805. applicatable = false;
  5806. }
  5807. });
  5808. return applicatable;
  5809. }
  5810. function compare(real, expect, operator) {
  5811. if (operator === 'min') {
  5812. return real >= expect;
  5813. }
  5814. else if (operator === 'max') {
  5815. return real <= expect;
  5816. }
  5817. else { // Equals
  5818. return real === expect;
  5819. }
  5820. }
  5821. function indicesEquals(indices1, indices2) {
  5822. // indices is always order by asc and has only finite number.
  5823. return indices1.join(',') === indices2.join(',');
  5824. }
  5825. /**
  5826. * Consider case:
  5827. * `chart.setOption(opt1);`
  5828. * Then user do some interaction like dataZoom, dataView changing.
  5829. * `chart.setOption(opt2);`
  5830. * Then user press 'reset button' in toolbox.
  5831. *
  5832. * After doing that all of the interaction effects should be reset, the
  5833. * chart should be the same as the result of invoke
  5834. * `chart.setOption(opt1); chart.setOption(opt2);`.
  5835. *
  5836. * Although it is not able ensure that
  5837. * `chart.setOption(opt1); chart.setOption(opt2);` is equivalents to
  5838. * `chart.setOption(merge(opt1, opt2));` exactly,
  5839. * this might be the only simple way to implement that feature.
  5840. *
  5841. * MEMO: We've considered some other approaches:
  5842. * 1. Each model handle its self restoration but not uniform treatment.
  5843. * (Too complex in logic and error-prone)
  5844. * 2. Use a shadow ecModel. (Performace expensive)
  5845. */
  5846. function mergeOption(oldOption, newOption) {
  5847. newOption = newOption || {};
  5848. each(newOption, function (newCptOpt, mainType) {
  5849. if (newCptOpt == null) {
  5850. return;
  5851. }
  5852. var oldCptOpt = oldOption[mainType];
  5853. if (!ComponentModel.hasClass(mainType)) {
  5854. oldOption[mainType] = merge(oldCptOpt, newCptOpt, true);
  5855. }
  5856. else {
  5857. newCptOpt = modelUtil.normalizeToArray(newCptOpt);
  5858. oldCptOpt = modelUtil.normalizeToArray(oldCptOpt);
  5859. var mapResult = modelUtil.mappingToExists(oldCptOpt, newCptOpt);
  5860. oldOption[mainType] = map(mapResult, function (item) {
  5861. return (item.option && item.exist)
  5862. ? merge(item.exist, item.option, true)
  5863. : (item.exist || item.option);
  5864. });
  5865. }
  5866. });
  5867. }
  5868. module.exports = OptionManager;
  5869. /***/ },
  5870. /* 28 */
  5871. /***/ function(module, exports, __webpack_require__) {
  5872. 'use strict';
  5873. var zrUtil = __webpack_require__(4);
  5874. var formatUtil = __webpack_require__(6);
  5875. var modelUtil = __webpack_require__(5);
  5876. var ComponentModel = __webpack_require__(19);
  5877. var colorPaletteMixin = __webpack_require__(24);
  5878. var env = __webpack_require__(2);
  5879. var encodeHTML = formatUtil.encodeHTML;
  5880. var addCommas = formatUtil.addCommas;
  5881. var SeriesModel = ComponentModel.extend({
  5882. type: 'series.__base__',
  5883. /**
  5884. * @readOnly
  5885. */
  5886. seriesIndex: 0,
  5887. // coodinateSystem will be injected in the echarts/CoordinateSystem
  5888. coordinateSystem: null,
  5889. /**
  5890. * @type {Object}
  5891. * @protected
  5892. */
  5893. defaultOption: null,
  5894. /**
  5895. * Data provided for legend
  5896. * @type {Function}
  5897. */
  5898. // PENDING
  5899. legendDataProvider: null,
  5900. /**
  5901. * Access path of color for visual
  5902. */
  5903. visualColorAccessPath: 'itemStyle.normal.color',
  5904. init: function (option, parentModel, ecModel, extraOpt) {
  5905. /**
  5906. * @type {number}
  5907. * @readOnly
  5908. */
  5909. this.seriesIndex = this.componentIndex;
  5910. this.mergeDefaultAndTheme(option, ecModel);
  5911. /**
  5912. * @type {module:echarts/data/List|module:echarts/data/Tree|module:echarts/data/Graph}
  5913. * @private
  5914. */
  5915. this._dataBeforeProcessed = this.getInitialData(option, ecModel);
  5916. // If we reverse the order (make this._data firstly, and then make
  5917. // this._dataBeforeProcessed by cloneShallow), cloneShallow will
  5918. // cause this._data.graph.data !== this._data when using
  5919. // module:echarts/data/Graph or module:echarts/data/Tree.
  5920. // See module:echarts/data/helper/linkList
  5921. this._data = this._dataBeforeProcessed.cloneShallow();
  5922. },
  5923. /**
  5924. * Util for merge default and theme to option
  5925. * @param {Object} option
  5926. * @param {module:echarts/model/Global} ecModel
  5927. */
  5928. mergeDefaultAndTheme: function (option, ecModel) {
  5929. zrUtil.merge(
  5930. option,
  5931. ecModel.getTheme().get(this.subType)
  5932. );
  5933. zrUtil.merge(option, this.getDefaultOption());
  5934. // Default label emphasis `position` and `show`
  5935. // FIXME Set label in mergeOption
  5936. modelUtil.defaultEmphasis(option.label, modelUtil.LABEL_OPTIONS);
  5937. this.fillDataTextStyle(option.data);
  5938. },
  5939. mergeOption: function (newSeriesOption, ecModel) {
  5940. newSeriesOption = zrUtil.merge(this.option, newSeriesOption, true);
  5941. this.fillDataTextStyle(newSeriesOption.data);
  5942. var data = this.getInitialData(newSeriesOption, ecModel);
  5943. // TODO Merge data?
  5944. if (data) {
  5945. this._data = data;
  5946. this._dataBeforeProcessed = data.cloneShallow();
  5947. }
  5948. },
  5949. fillDataTextStyle: function (data) {
  5950. // Default data label emphasis `position` and `show`
  5951. // FIXME Tree structure data ?
  5952. // FIXME Performance ?
  5953. if (data) {
  5954. for (var i = 0; i < data.length; i++) {
  5955. if (data[i] && data[i].label) {
  5956. modelUtil.defaultEmphasis(data[i].label, modelUtil.LABEL_OPTIONS);
  5957. }
  5958. }
  5959. }
  5960. },
  5961. /**
  5962. * Init a data structure from data related option in series
  5963. * Must be overwritten
  5964. */
  5965. getInitialData: function () {},
  5966. /**
  5967. * @param {string} [dataType]
  5968. * @return {module:echarts/data/List}
  5969. */
  5970. getData: function (dataType) {
  5971. return dataType == null ? this._data : this._data.getLinkedData(dataType);
  5972. },
  5973. /**
  5974. * @param {module:echarts/data/List} data
  5975. */
  5976. setData: function (data) {
  5977. this._data = data;
  5978. },
  5979. /**
  5980. * Get data before processed
  5981. * @return {module:echarts/data/List}
  5982. */
  5983. getRawData: function () {
  5984. return this._dataBeforeProcessed;
  5985. },
  5986. /**
  5987. * Coord dimension to data dimension.
  5988. *
  5989. * By default the result is the same as dimensions of series data.
  5990. * But in some series data dimensions are different from coord dimensions (i.e.
  5991. * candlestick and boxplot). Override this method to handle those cases.
  5992. *
  5993. * Coord dimension to data dimension can be one-to-many
  5994. *
  5995. * @param {string} coordDim
  5996. * @return {Array.<string>} dimensions on the axis.
  5997. */
  5998. coordDimToDataDim: function (coordDim) {
  5999. return [coordDim];
  6000. },
  6001. /**
  6002. * Convert data dimension to coord dimension.
  6003. *
  6004. * @param {string|number} dataDim
  6005. * @return {string}
  6006. */
  6007. dataDimToCoordDim: function (dataDim) {
  6008. return dataDim;
  6009. },
  6010. /**
  6011. * Get base axis if has coordinate system and has axis.
  6012. * By default use coordSys.getBaseAxis();
  6013. * Can be overrided for some chart.
  6014. * @return {type} description
  6015. */
  6016. getBaseAxis: function () {
  6017. var coordSys = this.coordinateSystem;
  6018. return coordSys && coordSys.getBaseAxis && coordSys.getBaseAxis();
  6019. },
  6020. // FIXME
  6021. /**
  6022. * Default tooltip formatter
  6023. *
  6024. * @param {number} dataIndex
  6025. * @param {boolean} [multipleSeries=false]
  6026. * @param {number} [dataType]
  6027. */
  6028. formatTooltip: function (dataIndex, multipleSeries, dataType) {
  6029. function formatArrayValue(value) {
  6030. return zrUtil.map(value, function (val, idx) {
  6031. var dimInfo = data.getDimensionInfo(idx);
  6032. var dimType = dimInfo && dimInfo.type;
  6033. if (dimType === 'ordinal') {
  6034. return val;
  6035. }
  6036. else if (dimType === 'time') {
  6037. return multipleSeries ? '' : formatUtil.formatTime('yyyy/mm/dd hh:mm:ss', val);
  6038. }
  6039. else {
  6040. return addCommas(val);
  6041. }
  6042. }).filter(function (val) {
  6043. return !!val;
  6044. }).join(', ');
  6045. }
  6046. var data = this._data;
  6047. var value = this.getRawValue(dataIndex);
  6048. var formattedValue = zrUtil.isArray(value)
  6049. ? formatArrayValue(value) : addCommas(value);
  6050. var name = data.getName(dataIndex);
  6051. var color = data.getItemVisual(dataIndex, 'color');
  6052. var colorEl = '<span style="display:inline-block;margin-right:5px;'
  6053. + 'border-radius:10px;width:9px;height:9px;background-color:' + color + '"></span>';
  6054. var seriesName = this.name;
  6055. // FIXME
  6056. if (seriesName === '\0-') {
  6057. // Not show '-'
  6058. seriesName = '';
  6059. }
  6060. return !multipleSeries
  6061. ? ((seriesName && encodeHTML(seriesName) + '<br />') + colorEl
  6062. + (name
  6063. ? encodeHTML(name) + ' : ' + formattedValue
  6064. : formattedValue)
  6065. )
  6066. : (colorEl + encodeHTML(this.name) + ' : ' + formattedValue);
  6067. },
  6068. /**
  6069. * @return {boolean}
  6070. */
  6071. ifEnableAnimation: function () {
  6072. if (env.node) {
  6073. return false;
  6074. }
  6075. var animationEnabled = this.getShallow('animation');
  6076. if (animationEnabled) {
  6077. if (this.getData().count() > this.getShallow('animationThreshold')) {
  6078. animationEnabled = false;
  6079. }
  6080. }
  6081. return animationEnabled;
  6082. },
  6083. restoreData: function () {
  6084. this._data = this._dataBeforeProcessed.cloneShallow();
  6085. },
  6086. getColorFromPalette: function (name, scope) {
  6087. var ecModel = this.ecModel;
  6088. // PENDING
  6089. var color = colorPaletteMixin.getColorFromPalette.call(this, name, scope);
  6090. if (!color) {
  6091. color = ecModel.getColorFromPalette(name, scope);
  6092. }
  6093. return color;
  6094. },
  6095. getAxisTooltipDataIndex: null
  6096. });
  6097. zrUtil.mixin(SeriesModel, modelUtil.dataFormatMixin);
  6098. zrUtil.mixin(SeriesModel, colorPaletteMixin);
  6099. module.exports = SeriesModel;
  6100. /***/ },
  6101. /* 29 */
  6102. /***/ function(module, exports, __webpack_require__) {
  6103. var Group = __webpack_require__(30);
  6104. var componentUtil = __webpack_require__(20);
  6105. var clazzUtil = __webpack_require__(13);
  6106. var Component = function () {
  6107. /**
  6108. * @type {module:zrender/container/Group}
  6109. * @readOnly
  6110. */
  6111. this.group = new Group();
  6112. /**
  6113. * @type {string}
  6114. * @readOnly
  6115. */
  6116. this.uid = componentUtil.getUID('viewComponent');
  6117. };
  6118. Component.prototype = {
  6119. constructor: Component,
  6120. init: function (ecModel, api) {},
  6121. render: function (componentModel, ecModel, api, payload) {},
  6122. dispose: function () {}
  6123. };
  6124. var componentProto = Component.prototype;
  6125. componentProto.updateView
  6126. = componentProto.updateLayout
  6127. = componentProto.updateVisual
  6128. = function (seriesModel, ecModel, api, payload) {
  6129. // Do nothing;
  6130. };
  6131. // Enable Component.extend.
  6132. clazzUtil.enableClassExtend(Component);
  6133. // Enable capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on.
  6134. clazzUtil.enableClassManagement(Component, {registerWhenExtend: true});
  6135. module.exports = Component;
  6136. /***/ },
  6137. /* 30 */
  6138. /***/ function(module, exports, __webpack_require__) {
  6139. /**
  6140. * Group是一个容器,可以插入子节点,Group的变换也会被应用到子节点上
  6141. * @module zrender/graphic/Group
  6142. * @example
  6143. * var Group = require('zrender/lib/container/Group');
  6144. * var Circle = require('zrender/lib/graphic/shape/Circle');
  6145. * var g = new Group();
  6146. * g.position[0] = 100;
  6147. * g.position[1] = 100;
  6148. * g.add(new Circle({
  6149. * style: {
  6150. * x: 100,
  6151. * y: 100,
  6152. * r: 20,
  6153. * }
  6154. * }));
  6155. * zr.add(g);
  6156. */
  6157. var zrUtil = __webpack_require__(4);
  6158. var Element = __webpack_require__(31);
  6159. var BoundingRect = __webpack_require__(9);
  6160. /**
  6161. * @alias module:zrender/graphic/Group
  6162. * @constructor
  6163. * @extends module:zrender/mixin/Transformable
  6164. * @extends module:zrender/mixin/Eventful
  6165. */
  6166. var Group = function (opts) {
  6167. opts = opts || {};
  6168. Element.call(this, opts);
  6169. for (var key in opts) {
  6170. this[key] = opts[key];
  6171. }
  6172. this._children = [];
  6173. this.__storage = null;
  6174. this.__dirty = true;
  6175. };
  6176. Group.prototype = {
  6177. constructor: Group,
  6178. isGroup: true,
  6179. /**
  6180. * @type {string}
  6181. */
  6182. type: 'group',
  6183. /**
  6184. * 所有子孙元素是否响应鼠标事件
  6185. * @name module:/zrender/container/Group#silent
  6186. * @type {boolean}
  6187. * @default false
  6188. */
  6189. silent: false,
  6190. /**
  6191. * @return {Array.<module:zrender/Element>}
  6192. */
  6193. children: function () {
  6194. return this._children.slice();
  6195. },
  6196. /**
  6197. * 获取指定 index 的儿子节点
  6198. * @param {number} idx
  6199. * @return {module:zrender/Element}
  6200. */
  6201. childAt: function (idx) {
  6202. return this._children[idx];
  6203. },
  6204. /**
  6205. * 获取指定名字的儿子节点
  6206. * @param {string} name
  6207. * @return {module:zrender/Element}
  6208. */
  6209. childOfName: function (name) {
  6210. var children = this._children;
  6211. for (var i = 0; i < children.length; i++) {
  6212. if (children[i].name === name) {
  6213. return children[i];
  6214. }
  6215. }
  6216. },
  6217. /**
  6218. * @return {number}
  6219. */
  6220. childCount: function () {
  6221. return this._children.length;
  6222. },
  6223. /**
  6224. * 添加子节点到最后
  6225. * @param {module:zrender/Element} child
  6226. */
  6227. add: function (child) {
  6228. if (child && child !== this && child.parent !== this) {
  6229. this._children.push(child);
  6230. this._doAdd(child);
  6231. }
  6232. return this;
  6233. },
  6234. /**
  6235. * 添加子节点在 nextSibling 之前
  6236. * @param {module:zrender/Element} child
  6237. * @param {module:zrender/Element} nextSibling
  6238. */
  6239. addBefore: function (child, nextSibling) {
  6240. if (child && child !== this && child.parent !== this
  6241. && nextSibling && nextSibling.parent === this) {
  6242. var children = this._children;
  6243. var idx = children.indexOf(nextSibling);
  6244. if (idx >= 0) {
  6245. children.splice(idx, 0, child);
  6246. this._doAdd(child);
  6247. }
  6248. }
  6249. return this;
  6250. },
  6251. _doAdd: function (child) {
  6252. if (child.parent) {
  6253. child.parent.remove(child);
  6254. }
  6255. child.parent = this;
  6256. var storage = this.__storage;
  6257. var zr = this.__zr;
  6258. if (storage && storage !== child.__storage) {
  6259. storage.addToMap(child);
  6260. if (child instanceof Group) {
  6261. child.addChildrenToStorage(storage);
  6262. }
  6263. }
  6264. zr && zr.refresh();
  6265. },
  6266. /**
  6267. * 移除子节点
  6268. * @param {module:zrender/Element} child
  6269. */
  6270. remove: function (child) {
  6271. var zr = this.__zr;
  6272. var storage = this.__storage;
  6273. var children = this._children;
  6274. var idx = zrUtil.indexOf(children, child);
  6275. if (idx < 0) {
  6276. return this;
  6277. }
  6278. children.splice(idx, 1);
  6279. child.parent = null;
  6280. if (storage) {
  6281. storage.delFromMap(child.id);
  6282. if (child instanceof Group) {
  6283. child.delChildrenFromStorage(storage);
  6284. }
  6285. }
  6286. zr && zr.refresh();
  6287. return this;
  6288. },
  6289. /**
  6290. * 移除所有子节点
  6291. */
  6292. removeAll: function () {
  6293. var children = this._children;
  6294. var storage = this.__storage;
  6295. var child;
  6296. var i;
  6297. for (i = 0; i < children.length; i++) {
  6298. child = children[i];
  6299. if (storage) {
  6300. storage.delFromMap(child.id);
  6301. if (child instanceof Group) {
  6302. child.delChildrenFromStorage(storage);
  6303. }
  6304. }
  6305. child.parent = null;
  6306. }
  6307. children.length = 0;
  6308. return this;
  6309. },
  6310. /**
  6311. * 遍历所有子节点
  6312. * @param {Function} cb
  6313. * @param {} context
  6314. */
  6315. eachChild: function (cb, context) {
  6316. var children = this._children;
  6317. for (var i = 0; i < children.length; i++) {
  6318. var child = children[i];
  6319. cb.call(context, child, i);
  6320. }
  6321. return this;
  6322. },
  6323. /**
  6324. * 深度优先遍历所有子孙节点
  6325. * @param {Function} cb
  6326. * @param {} context
  6327. */
  6328. traverse: function (cb, context) {
  6329. for (var i = 0; i < this._children.length; i++) {
  6330. var child = this._children[i];
  6331. cb.call(context, child);
  6332. if (child.type === 'group') {
  6333. child.traverse(cb, context);
  6334. }
  6335. }
  6336. return this;
  6337. },
  6338. addChildrenToStorage: function (storage) {
  6339. for (var i = 0; i < this._children.length; i++) {
  6340. var child = this._children[i];
  6341. storage.addToMap(child);
  6342. if (child instanceof Group) {
  6343. child.addChildrenToStorage(storage);
  6344. }
  6345. }
  6346. },
  6347. delChildrenFromStorage: function (storage) {
  6348. for (var i = 0; i < this._children.length; i++) {
  6349. var child = this._children[i];
  6350. storage.delFromMap(child.id);
  6351. if (child instanceof Group) {
  6352. child.delChildrenFromStorage(storage);
  6353. }
  6354. }
  6355. },
  6356. dirty: function () {
  6357. this.__dirty = true;
  6358. this.__zr && this.__zr.refresh();
  6359. return this;
  6360. },
  6361. /**
  6362. * @return {module:zrender/core/BoundingRect}
  6363. */
  6364. getBoundingRect: function (includeChildren) {
  6365. // TODO Caching
  6366. // TODO Transform
  6367. var rect = null;
  6368. var tmpRect = new BoundingRect(0, 0, 0, 0);
  6369. var children = includeChildren || this._children;
  6370. var tmpMat = [];
  6371. for (var i = 0; i < children.length; i++) {
  6372. var child = children[i];
  6373. if (child.ignore || child.invisible) {
  6374. continue;
  6375. }
  6376. var childRect = child.getBoundingRect();
  6377. var transform = child.getLocalTransform(tmpMat);
  6378. if (transform) {
  6379. tmpRect.copy(childRect);
  6380. tmpRect.applyTransform(transform);
  6381. rect = rect || tmpRect.clone();
  6382. rect.union(tmpRect);
  6383. }
  6384. else {
  6385. rect = rect || childRect.clone();
  6386. rect.union(childRect);
  6387. }
  6388. }
  6389. return rect || tmpRect;
  6390. }
  6391. };
  6392. zrUtil.inherits(Group, Element);
  6393. module.exports = Group;
  6394. /***/ },
  6395. /* 31 */
  6396. /***/ function(module, exports, __webpack_require__) {
  6397. 'use strict';
  6398. /**
  6399. * @module zrender/Element
  6400. */
  6401. var guid = __webpack_require__(32);
  6402. var Eventful = __webpack_require__(33);
  6403. var Transformable = __webpack_require__(34);
  6404. var Animatable = __webpack_require__(35);
  6405. var zrUtil = __webpack_require__(4);
  6406. /**
  6407. * @alias module:zrender/Element
  6408. * @constructor
  6409. * @extends {module:zrender/mixin/Animatable}
  6410. * @extends {module:zrender/mixin/Transformable}
  6411. * @extends {module:zrender/mixin/Eventful}
  6412. */
  6413. var Element = function (opts) {
  6414. Transformable.call(this, opts);
  6415. Eventful.call(this, opts);
  6416. Animatable.call(this, opts);
  6417. /**
  6418. * 画布元素ID
  6419. * @type {string}
  6420. */
  6421. this.id = opts.id || guid();
  6422. };
  6423. Element.prototype = {
  6424. /**
  6425. * 元素类型
  6426. * Element type
  6427. * @type {string}
  6428. */
  6429. type: 'element',
  6430. /**
  6431. * 元素名字
  6432. * Element name
  6433. * @type {string}
  6434. */
  6435. name: '',
  6436. /**
  6437. * ZRender 实例对象,会在 element 添加到 zrender 实例中后自动赋值
  6438. * ZRender instance will be assigned when element is associated with zrender
  6439. * @name module:/zrender/Element#__zr
  6440. * @type {module:zrender/ZRender}
  6441. */
  6442. __zr: null,
  6443. /**
  6444. * 图形是否忽略,为true时忽略图形的绘制以及事件触发
  6445. * If ignore drawing and events of the element object
  6446. * @name module:/zrender/Element#ignore
  6447. * @type {boolean}
  6448. * @default false
  6449. */
  6450. ignore: false,
  6451. /**
  6452. * 用于裁剪的路径(shape),所有 Group 内的路径在绘制时都会被这个路径裁剪
  6453. * 该路径会继承被裁减对象的变换
  6454. * @type {module:zrender/graphic/Path}
  6455. * @see http://www.w3.org/TR/2dcontext/#clipping-region
  6456. * @readOnly
  6457. */
  6458. clipPath: null,
  6459. /**
  6460. * Drift element
  6461. * @param {number} dx dx on the global space
  6462. * @param {number} dy dy on the global space
  6463. */
  6464. drift: function (dx, dy) {
  6465. switch (this.draggable) {
  6466. case 'horizontal':
  6467. dy = 0;
  6468. break;
  6469. case 'vertical':
  6470. dx = 0;
  6471. break;
  6472. }
  6473. var m = this.transform;
  6474. if (!m) {
  6475. m = this.transform = [1, 0, 0, 1, 0, 0];
  6476. }
  6477. m[4] += dx;
  6478. m[5] += dy;
  6479. this.decomposeTransform();
  6480. this.dirty(false);
  6481. },
  6482. /**
  6483. * Hook before update
  6484. */
  6485. beforeUpdate: function () {},
  6486. /**
  6487. * Hook after update
  6488. */
  6489. afterUpdate: function () {},
  6490. /**
  6491. * Update each frame
  6492. */
  6493. update: function () {
  6494. this.updateTransform();
  6495. },
  6496. /**
  6497. * @param {Function} cb
  6498. * @param {} context
  6499. */
  6500. traverse: function (cb, context) {},
  6501. /**
  6502. * @protected
  6503. */
  6504. attrKV: function (key, value) {
  6505. if (key === 'position' || key === 'scale' || key === 'origin') {
  6506. // Copy the array
  6507. if (value) {
  6508. var target = this[key];
  6509. if (!target) {
  6510. target = this[key] = [];
  6511. }
  6512. target[0] = value[0];
  6513. target[1] = value[1];
  6514. }
  6515. }
  6516. else {
  6517. this[key] = value;
  6518. }
  6519. },
  6520. /**
  6521. * Hide the element
  6522. */
  6523. hide: function () {
  6524. this.ignore = true;
  6525. this.__zr && this.__zr.refresh();
  6526. },
  6527. /**
  6528. * Show the element
  6529. */
  6530. show: function () {
  6531. this.ignore = false;
  6532. this.__zr && this.__zr.refresh();
  6533. },
  6534. /**
  6535. * @param {string|Object} key
  6536. * @param {*} value
  6537. */
  6538. attr: function (key, value) {
  6539. if (typeof key === 'string') {
  6540. this.attrKV(key, value);
  6541. }
  6542. else if (zrUtil.isObject(key)) {
  6543. for (var name in key) {
  6544. if (key.hasOwnProperty(name)) {
  6545. this.attrKV(name, key[name]);
  6546. }
  6547. }
  6548. }
  6549. this.dirty(false);
  6550. return this;
  6551. },
  6552. /**
  6553. * @param {module:zrender/graphic/Path} clipPath
  6554. */
  6555. setClipPath: function (clipPath) {
  6556. var zr = this.__zr;
  6557. if (zr) {
  6558. clipPath.addSelfToZr(zr);
  6559. }
  6560. // Remove previous clip path
  6561. if (this.clipPath && this.clipPath !== clipPath) {
  6562. this.removeClipPath();
  6563. }
  6564. this.clipPath = clipPath;
  6565. clipPath.__zr = zr;
  6566. clipPath.__clipTarget = this;
  6567. this.dirty(false);
  6568. },
  6569. /**
  6570. */
  6571. removeClipPath: function () {
  6572. var clipPath = this.clipPath;
  6573. if (clipPath) {
  6574. if (clipPath.__zr) {
  6575. clipPath.removeSelfFromZr(clipPath.__zr);
  6576. }
  6577. clipPath.__zr = null;
  6578. clipPath.__clipTarget = null;
  6579. this.clipPath = null;
  6580. this.dirty(false);
  6581. }
  6582. },
  6583. /**
  6584. * Add self from zrender instance.
  6585. * Not recursively because it will be invoked when element added to storage.
  6586. * @param {module:zrender/ZRender} zr
  6587. */
  6588. addSelfToZr: function (zr) {
  6589. this.__zr = zr;
  6590. // 添加动画
  6591. var animators = this.animators;
  6592. if (animators) {
  6593. for (var i = 0; i < animators.length; i++) {
  6594. zr.animation.addAnimator(animators[i]);
  6595. }
  6596. }
  6597. if (this.clipPath) {
  6598. this.clipPath.addSelfToZr(zr);
  6599. }
  6600. },
  6601. /**
  6602. * Remove self from zrender instance.
  6603. * Not recursively because it will be invoked when element added to storage.
  6604. * @param {module:zrender/ZRender} zr
  6605. */
  6606. removeSelfFromZr: function (zr) {
  6607. this.__zr = null;
  6608. // 移除动画
  6609. var animators = this.animators;
  6610. if (animators) {
  6611. for (var i = 0; i < animators.length; i++) {
  6612. zr.animation.removeAnimator(animators[i]);
  6613. }
  6614. }
  6615. if (this.clipPath) {
  6616. this.clipPath.removeSelfFromZr(zr);
  6617. }
  6618. }
  6619. };
  6620. zrUtil.mixin(Element, Animatable);
  6621. zrUtil.mixin(Element, Transformable);
  6622. zrUtil.mixin(Element, Eventful);
  6623. module.exports = Element;
  6624. /***/ },
  6625. /* 32 */
  6626. /***/ function(module, exports) {
  6627. /**
  6628. * zrender: 生成唯一id
  6629. *
  6630. * @author errorrik (errorrik@gmail.com)
  6631. */
  6632. var idStart = 0x0907;
  6633. module.exports = function () {
  6634. return idStart++;
  6635. };
  6636. /***/ },
  6637. /* 33 */
  6638. /***/ function(module, exports) {
  6639. /**
  6640. * 事件扩展
  6641. * @module zrender/mixin/Eventful
  6642. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  6643. * pissang (https://www.github.com/pissang)
  6644. */
  6645. var arrySlice = Array.prototype.slice;
  6646. /**
  6647. * 事件分发器
  6648. * @alias module:zrender/mixin/Eventful
  6649. * @constructor
  6650. */
  6651. var Eventful = function () {
  6652. this._$handlers = {};
  6653. };
  6654. Eventful.prototype = {
  6655. constructor: Eventful,
  6656. /**
  6657. * 单次触发绑定,trigger后销毁
  6658. *
  6659. * @param {string} event 事件名
  6660. * @param {Function} handler 响应函数
  6661. * @param {Object} context
  6662. */
  6663. one: function (event, handler, context) {
  6664. var _h = this._$handlers;
  6665. if (!handler || !event) {
  6666. return this;
  6667. }
  6668. if (!_h[event]) {
  6669. _h[event] = [];
  6670. }
  6671. for (var i = 0; i < _h[event].length; i++) {
  6672. if (_h[event][i].h === handler) {
  6673. return this;
  6674. }
  6675. }
  6676. _h[event].push({
  6677. h: handler,
  6678. one: true,
  6679. ctx: context || this
  6680. });
  6681. return this;
  6682. },
  6683. /**
  6684. * 绑定事件
  6685. * @param {string} event 事件名
  6686. * @param {Function} handler 事件处理函数
  6687. * @param {Object} [context]
  6688. */
  6689. on: function (event, handler, context) {
  6690. var _h = this._$handlers;
  6691. if (!handler || !event) {
  6692. return this;
  6693. }
  6694. if (!_h[event]) {
  6695. _h[event] = [];
  6696. }
  6697. for (var i = 0; i < _h[event].length; i++) {
  6698. if (_h[event][i].h === handler) {
  6699. return this;
  6700. }
  6701. }
  6702. _h[event].push({
  6703. h: handler,
  6704. one: false,
  6705. ctx: context || this
  6706. });
  6707. return this;
  6708. },
  6709. /**
  6710. * 是否绑定了事件
  6711. * @param {string} event
  6712. * @return {boolean}
  6713. */
  6714. isSilent: function (event) {
  6715. var _h = this._$handlers;
  6716. return _h[event] && _h[event].length;
  6717. },
  6718. /**
  6719. * 解绑事件
  6720. * @param {string} event 事件名
  6721. * @param {Function} [handler] 事件处理函数
  6722. */
  6723. off: function (event, handler) {
  6724. var _h = this._$handlers;
  6725. if (!event) {
  6726. this._$handlers = {};
  6727. return this;
  6728. }
  6729. if (handler) {
  6730. if (_h[event]) {
  6731. var newList = [];
  6732. for (var i = 0, l = _h[event].length; i < l; i++) {
  6733. if (_h[event][i]['h'] != handler) {
  6734. newList.push(_h[event][i]);
  6735. }
  6736. }
  6737. _h[event] = newList;
  6738. }
  6739. if (_h[event] && _h[event].length === 0) {
  6740. delete _h[event];
  6741. }
  6742. }
  6743. else {
  6744. delete _h[event];
  6745. }
  6746. return this;
  6747. },
  6748. /**
  6749. * 事件分发
  6750. *
  6751. * @param {string} type 事件类型
  6752. */
  6753. trigger: function (type) {
  6754. if (this._$handlers[type]) {
  6755. var args = arguments;
  6756. var argLen = args.length;
  6757. if (argLen > 3) {
  6758. args = arrySlice.call(args, 1);
  6759. }
  6760. var _h = this._$handlers[type];
  6761. var len = _h.length;
  6762. for (var i = 0; i < len;) {
  6763. // Optimize advise from backbone
  6764. switch (argLen) {
  6765. case 1:
  6766. _h[i]['h'].call(_h[i]['ctx']);
  6767. break;
  6768. case 2:
  6769. _h[i]['h'].call(_h[i]['ctx'], args[1]);
  6770. break;
  6771. case 3:
  6772. _h[i]['h'].call(_h[i]['ctx'], args[1], args[2]);
  6773. break;
  6774. default:
  6775. // have more than 2 given arguments
  6776. _h[i]['h'].apply(_h[i]['ctx'], args);
  6777. break;
  6778. }
  6779. if (_h[i]['one']) {
  6780. _h.splice(i, 1);
  6781. len--;
  6782. }
  6783. else {
  6784. i++;
  6785. }
  6786. }
  6787. }
  6788. return this;
  6789. },
  6790. /**
  6791. * 带有context的事件分发, 最后一个参数是事件回调的context
  6792. * @param {string} type 事件类型
  6793. */
  6794. triggerWithContext: function (type) {
  6795. if (this._$handlers[type]) {
  6796. var args = arguments;
  6797. var argLen = args.length;
  6798. if (argLen > 4) {
  6799. args = arrySlice.call(args, 1, args.length - 1);
  6800. }
  6801. var ctx = args[args.length - 1];
  6802. var _h = this._$handlers[type];
  6803. var len = _h.length;
  6804. for (var i = 0; i < len;) {
  6805. // Optimize advise from backbone
  6806. switch (argLen) {
  6807. case 1:
  6808. _h[i]['h'].call(ctx);
  6809. break;
  6810. case 2:
  6811. _h[i]['h'].call(ctx, args[1]);
  6812. break;
  6813. case 3:
  6814. _h[i]['h'].call(ctx, args[1], args[2]);
  6815. break;
  6816. default:
  6817. // have more than 2 given arguments
  6818. _h[i]['h'].apply(ctx, args);
  6819. break;
  6820. }
  6821. if (_h[i]['one']) {
  6822. _h.splice(i, 1);
  6823. len--;
  6824. }
  6825. else {
  6826. i++;
  6827. }
  6828. }
  6829. }
  6830. return this;
  6831. }
  6832. };
  6833. // 对象可以通过 onxxxx 绑定事件
  6834. /**
  6835. * @event module:zrender/mixin/Eventful#onclick
  6836. * @type {Function}
  6837. * @default null
  6838. */
  6839. /**
  6840. * @event module:zrender/mixin/Eventful#onmouseover
  6841. * @type {Function}
  6842. * @default null
  6843. */
  6844. /**
  6845. * @event module:zrender/mixin/Eventful#onmouseout
  6846. * @type {Function}
  6847. * @default null
  6848. */
  6849. /**
  6850. * @event module:zrender/mixin/Eventful#onmousemove
  6851. * @type {Function}
  6852. * @default null
  6853. */
  6854. /**
  6855. * @event module:zrender/mixin/Eventful#onmousewheel
  6856. * @type {Function}
  6857. * @default null
  6858. */
  6859. /**
  6860. * @event module:zrender/mixin/Eventful#onmousedown
  6861. * @type {Function}
  6862. * @default null
  6863. */
  6864. /**
  6865. * @event module:zrender/mixin/Eventful#onmouseup
  6866. * @type {Function}
  6867. * @default null
  6868. */
  6869. /**
  6870. * @event module:zrender/mixin/Eventful#ondragstart
  6871. * @type {Function}
  6872. * @default null
  6873. */
  6874. /**
  6875. * @event module:zrender/mixin/Eventful#ondragend
  6876. * @type {Function}
  6877. * @default null
  6878. */
  6879. /**
  6880. * @event module:zrender/mixin/Eventful#ondragenter
  6881. * @type {Function}
  6882. * @default null
  6883. */
  6884. /**
  6885. * @event module:zrender/mixin/Eventful#ondragleave
  6886. * @type {Function}
  6887. * @default null
  6888. */
  6889. /**
  6890. * @event module:zrender/mixin/Eventful#ondragover
  6891. * @type {Function}
  6892. * @default null
  6893. */
  6894. /**
  6895. * @event module:zrender/mixin/Eventful#ondrop
  6896. * @type {Function}
  6897. * @default null
  6898. */
  6899. module.exports = Eventful;
  6900. /***/ },
  6901. /* 34 */
  6902. /***/ function(module, exports, __webpack_require__) {
  6903. 'use strict';
  6904. /**
  6905. * 提供变换扩展
  6906. * @module zrender/mixin/Transformable
  6907. * @author pissang (https://www.github.com/pissang)
  6908. */
  6909. var matrix = __webpack_require__(11);
  6910. var vector = __webpack_require__(10);
  6911. var mIdentity = matrix.identity;
  6912. var EPSILON = 5e-5;
  6913. function isNotAroundZero(val) {
  6914. return val > EPSILON || val < -EPSILON;
  6915. }
  6916. /**
  6917. * @alias module:zrender/mixin/Transformable
  6918. * @constructor
  6919. */
  6920. var Transformable = function (opts) {
  6921. opts = opts || {};
  6922. // If there are no given position, rotation, scale
  6923. if (!opts.position) {
  6924. /**
  6925. * 平移
  6926. * @type {Array.<number>}
  6927. * @default [0, 0]
  6928. */
  6929. this.position = [0, 0];
  6930. }
  6931. if (opts.rotation == null) {
  6932. /**
  6933. * 旋转
  6934. * @type {Array.<number>}
  6935. * @default 0
  6936. */
  6937. this.rotation = 0;
  6938. }
  6939. if (!opts.scale) {
  6940. /**
  6941. * 缩放
  6942. * @type {Array.<number>}
  6943. * @default [1, 1]
  6944. */
  6945. this.scale = [1, 1];
  6946. }
  6947. /**
  6948. * 旋转和缩放的原点
  6949. * @type {Array.<number>}
  6950. * @default null
  6951. */
  6952. this.origin = this.origin || null;
  6953. };
  6954. var transformableProto = Transformable.prototype;
  6955. transformableProto.transform = null;
  6956. /**
  6957. * 判断是否需要有坐标变换
  6958. * 如果有坐标变换, 则从position, rotation, scale以及父节点的transform计算出自身的transform矩阵
  6959. */
  6960. transformableProto.needLocalTransform = function () {
  6961. return isNotAroundZero(this.rotation)
  6962. || isNotAroundZero(this.position[0])
  6963. || isNotAroundZero(this.position[1])
  6964. || isNotAroundZero(this.scale[0] - 1)
  6965. || isNotAroundZero(this.scale[1] - 1);
  6966. };
  6967. transformableProto.updateTransform = function () {
  6968. var parent = this.parent;
  6969. var parentHasTransform = parent && parent.transform;
  6970. var needLocalTransform = this.needLocalTransform();
  6971. var m = this.transform;
  6972. if (!(needLocalTransform || parentHasTransform)) {
  6973. m && mIdentity(m);
  6974. return;
  6975. }
  6976. m = m || matrix.create();
  6977. if (needLocalTransform) {
  6978. this.getLocalTransform(m);
  6979. }
  6980. else {
  6981. mIdentity(m);
  6982. }
  6983. // 应用父节点变换
  6984. if (parentHasTransform) {
  6985. if (needLocalTransform) {
  6986. matrix.mul(m, parent.transform, m);
  6987. }
  6988. else {
  6989. matrix.copy(m, parent.transform);
  6990. }
  6991. }
  6992. // 保存这个变换矩阵
  6993. this.transform = m;
  6994. this.invTransform = this.invTransform || matrix.create();
  6995. matrix.invert(this.invTransform, m);
  6996. };
  6997. transformableProto.getLocalTransform = function (m) {
  6998. m = m || [];
  6999. mIdentity(m);
  7000. var origin = this.origin;
  7001. var scale = this.scale;
  7002. var rotation = this.rotation;
  7003. var position = this.position;
  7004. if (origin) {
  7005. // Translate to origin
  7006. m[4] -= origin[0];
  7007. m[5] -= origin[1];
  7008. }
  7009. matrix.scale(m, m, scale);
  7010. if (rotation) {
  7011. matrix.rotate(m, m, rotation);
  7012. }
  7013. if (origin) {
  7014. // Translate back from origin
  7015. m[4] += origin[0];
  7016. m[5] += origin[1];
  7017. }
  7018. m[4] += position[0];
  7019. m[5] += position[1];
  7020. return m;
  7021. };
  7022. /**
  7023. * 将自己的transform应用到context上
  7024. * @param {Context2D} ctx
  7025. */
  7026. transformableProto.setTransform = function (ctx) {
  7027. var m = this.transform;
  7028. if (m) {
  7029. ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
  7030. }
  7031. };
  7032. transformableProto.restoreTransform = function (ctx) {
  7033. var m = this.invTransform;
  7034. if (m) {
  7035. ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
  7036. }
  7037. }
  7038. var tmpTransform = [];
  7039. /**
  7040. * 分解`transform`矩阵到`position`, `rotation`, `scale`
  7041. */
  7042. transformableProto.decomposeTransform = function () {
  7043. if (!this.transform) {
  7044. return;
  7045. }
  7046. var parent = this.parent;
  7047. var m = this.transform;
  7048. if (parent && parent.transform) {
  7049. // Get local transform and decompose them to position, scale, rotation
  7050. matrix.mul(tmpTransform, parent.invTransform, m);
  7051. m = tmpTransform;
  7052. }
  7053. var sx = m[0] * m[0] + m[1] * m[1];
  7054. var sy = m[2] * m[2] + m[3] * m[3];
  7055. var position = this.position;
  7056. var scale = this.scale;
  7057. if (isNotAroundZero(sx - 1)) {
  7058. sx = Math.sqrt(sx);
  7059. }
  7060. if (isNotAroundZero(sy - 1)) {
  7061. sy = Math.sqrt(sy);
  7062. }
  7063. if (m[0] < 0) {
  7064. sx = -sx;
  7065. }
  7066. if (m[3] < 0) {
  7067. sy = -sy;
  7068. }
  7069. position[0] = m[4];
  7070. position[1] = m[5];
  7071. scale[0] = sx;
  7072. scale[1] = sy;
  7073. this.rotation = Math.atan2(-m[1] / sy, m[0] / sx);
  7074. };
  7075. /**
  7076. * Get global scale
  7077. * @return {Array.<number>}
  7078. */
  7079. transformableProto.getGlobalScale = function () {
  7080. var m = this.transform;
  7081. if (!m) {
  7082. return [1, 1];
  7083. }
  7084. var sx = Math.sqrt(m[0] * m[0] + m[1] * m[1]);
  7085. var sy = Math.sqrt(m[2] * m[2] + m[3] * m[3]);
  7086. if (m[0] < 0) {
  7087. sx = -sx;
  7088. }
  7089. if (m[3] < 0) {
  7090. sy = -sy;
  7091. }
  7092. return [sx, sy];
  7093. };
  7094. /**
  7095. * 变换坐标位置到 shape 的局部坐标空间
  7096. * @method
  7097. * @param {number} x
  7098. * @param {number} y
  7099. * @return {Array.<number>}
  7100. */
  7101. transformableProto.transformCoordToLocal = function (x, y) {
  7102. var v2 = [x, y];
  7103. var invTransform = this.invTransform;
  7104. if (invTransform) {
  7105. vector.applyTransform(v2, v2, invTransform);
  7106. }
  7107. return v2;
  7108. };
  7109. /**
  7110. * 变换局部坐标位置到全局坐标空间
  7111. * @method
  7112. * @param {number} x
  7113. * @param {number} y
  7114. * @return {Array.<number>}
  7115. */
  7116. transformableProto.transformCoordToGlobal = function (x, y) {
  7117. var v2 = [x, y];
  7118. var transform = this.transform;
  7119. if (transform) {
  7120. vector.applyTransform(v2, v2, transform);
  7121. }
  7122. return v2;
  7123. };
  7124. module.exports = Transformable;
  7125. /***/ },
  7126. /* 35 */
  7127. /***/ function(module, exports, __webpack_require__) {
  7128. 'use strict';
  7129. /**
  7130. * @module zrender/mixin/Animatable
  7131. */
  7132. var Animator = __webpack_require__(36);
  7133. var util = __webpack_require__(4);
  7134. var isString = util.isString;
  7135. var isFunction = util.isFunction;
  7136. var isObject = util.isObject;
  7137. var log = __webpack_require__(40);
  7138. /**
  7139. * @alias modue:zrender/mixin/Animatable
  7140. * @constructor
  7141. */
  7142. var Animatable = function () {
  7143. /**
  7144. * @type {Array.<module:zrender/animation/Animator>}
  7145. * @readOnly
  7146. */
  7147. this.animators = [];
  7148. };
  7149. Animatable.prototype = {
  7150. constructor: Animatable,
  7151. /**
  7152. * 动画
  7153. *
  7154. * @param {string} path 需要添加动画的属性获取路径,可以通过a.b.c来获取深层的属性
  7155. * @param {boolean} [loop] 动画是否循环
  7156. * @return {module:zrender/animation/Animator}
  7157. * @example:
  7158. * el.animate('style', false)
  7159. * .when(1000, {x: 10} )
  7160. * .done(function(){ // Animation done })
  7161. * .start()
  7162. */
  7163. animate: function (path, loop) {
  7164. var target;
  7165. var animatingShape = false;
  7166. var el = this;
  7167. var zr = this.__zr;
  7168. if (path) {
  7169. var pathSplitted = path.split('.');
  7170. var prop = el;
  7171. // If animating shape
  7172. animatingShape = pathSplitted[0] === 'shape';
  7173. for (var i = 0, l = pathSplitted.length; i < l; i++) {
  7174. if (!prop) {
  7175. continue;
  7176. }
  7177. prop = prop[pathSplitted[i]];
  7178. }
  7179. if (prop) {
  7180. target = prop;
  7181. }
  7182. }
  7183. else {
  7184. target = el;
  7185. }
  7186. if (!target) {
  7187. log(
  7188. 'Property "'
  7189. + path
  7190. + '" is not existed in element '
  7191. + el.id
  7192. );
  7193. return;
  7194. }
  7195. var animators = el.animators;
  7196. var animator = new Animator(target, loop);
  7197. animator.during(function (target) {
  7198. el.dirty(animatingShape);
  7199. })
  7200. .done(function () {
  7201. // FIXME Animator will not be removed if use `Animator#stop` to stop animation
  7202. animators.splice(util.indexOf(animators, animator), 1);
  7203. });
  7204. animators.push(animator);
  7205. // If animate after added to the zrender
  7206. if (zr) {
  7207. zr.animation.addAnimator(animator);
  7208. }
  7209. return animator;
  7210. },
  7211. /**
  7212. * 停止动画
  7213. * @param {boolean} forwardToLast If move to last frame before stop
  7214. */
  7215. stopAnimation: function (forwardToLast) {
  7216. var animators = this.animators;
  7217. var len = animators.length;
  7218. for (var i = 0; i < len; i++) {
  7219. animators[i].stop(forwardToLast);
  7220. }
  7221. animators.length = 0;
  7222. return this;
  7223. },
  7224. /**
  7225. * @param {Object} target
  7226. * @param {number} [time=500] Time in ms
  7227. * @param {string} [easing='linear']
  7228. * @param {number} [delay=0]
  7229. * @param {Function} [callback]
  7230. *
  7231. * @example
  7232. * // Animate position
  7233. * el.animateTo({
  7234. * position: [10, 10]
  7235. * }, function () { // done })
  7236. *
  7237. * // Animate shape, style and position in 100ms, delayed 100ms, with cubicOut easing
  7238. * el.animateTo({
  7239. * shape: {
  7240. * width: 500
  7241. * },
  7242. * style: {
  7243. * fill: 'red'
  7244. * }
  7245. * position: [10, 10]
  7246. * }, 100, 100, 'cubicOut', function () { // done })
  7247. */
  7248. // TODO Return animation key
  7249. animateTo: function (target, time, delay, easing, callback) {
  7250. // animateTo(target, time, easing, callback);
  7251. if (isString(delay)) {
  7252. callback = easing;
  7253. easing = delay;
  7254. delay = 0;
  7255. }
  7256. // animateTo(target, time, delay, callback);
  7257. else if (isFunction(easing)) {
  7258. callback = easing;
  7259. easing = 'linear';
  7260. delay = 0;
  7261. }
  7262. // animateTo(target, time, callback);
  7263. else if (isFunction(delay)) {
  7264. callback = delay;
  7265. delay = 0;
  7266. }
  7267. // animateTo(target, callback)
  7268. else if (isFunction(time)) {
  7269. callback = time;
  7270. time = 500;
  7271. }
  7272. // animateTo(target)
  7273. else if (!time) {
  7274. time = 500;
  7275. }
  7276. // Stop all previous animations
  7277. this.stopAnimation();
  7278. this._animateToShallow('', this, target, time, delay, easing, callback);
  7279. // Animators may be removed immediately after start
  7280. // if there is nothing to animate
  7281. var animators = this.animators.slice();
  7282. var count = animators.length;
  7283. function done() {
  7284. count--;
  7285. if (!count) {
  7286. callback && callback();
  7287. }
  7288. }
  7289. // No animators. This should be checked before animators[i].start(),
  7290. // because 'done' may be executed immediately if no need to animate.
  7291. if (!count) {
  7292. callback && callback();
  7293. }
  7294. // Start after all animators created
  7295. // Incase any animator is done immediately when all animation properties are not changed
  7296. for (var i = 0; i < animators.length; i++) {
  7297. animators[i]
  7298. .done(done)
  7299. .start(easing);
  7300. }
  7301. },
  7302. /**
  7303. * @private
  7304. * @param {string} path=''
  7305. * @param {Object} source=this
  7306. * @param {Object} target
  7307. * @param {number} [time=500]
  7308. * @param {number} [delay=0]
  7309. *
  7310. * @example
  7311. * // Animate position
  7312. * el._animateToShallow({
  7313. * position: [10, 10]
  7314. * })
  7315. *
  7316. * // Animate shape, style and position in 100ms, delayed 100ms
  7317. * el._animateToShallow({
  7318. * shape: {
  7319. * width: 500
  7320. * },
  7321. * style: {
  7322. * fill: 'red'
  7323. * }
  7324. * position: [10, 10]
  7325. * }, 100, 100)
  7326. */
  7327. _animateToShallow: function (path, source, target, time, delay) {
  7328. var objShallow = {};
  7329. var propertyCount = 0;
  7330. for (var name in target) {
  7331. if (source[name] != null) {
  7332. if (isObject(target[name]) && !util.isArrayLike(target[name])) {
  7333. this._animateToShallow(
  7334. path ? path + '.' + name : name,
  7335. source[name],
  7336. target[name],
  7337. time,
  7338. delay
  7339. );
  7340. }
  7341. else {
  7342. objShallow[name] = target[name];
  7343. propertyCount++;
  7344. }
  7345. }
  7346. else if (target[name] != null) {
  7347. // Attr directly if not has property
  7348. // FIXME, if some property not needed for element ?
  7349. if (!path) {
  7350. this.attr(name, target[name]);
  7351. }
  7352. else { // Shape or style
  7353. var props = {};
  7354. props[path] = {};
  7355. props[path][name] = target[name];
  7356. this.attr(props);
  7357. }
  7358. }
  7359. }
  7360. if (propertyCount > 0) {
  7361. this.animate(path, false)
  7362. .when(time == null ? 500 : time, objShallow)
  7363. .delay(delay || 0);
  7364. }
  7365. return this;
  7366. }
  7367. };
  7368. module.exports = Animatable;
  7369. /***/ },
  7370. /* 36 */
  7371. /***/ function(module, exports, __webpack_require__) {
  7372. /**
  7373. * @module echarts/animation/Animator
  7374. */
  7375. var Clip = __webpack_require__(37);
  7376. var color = __webpack_require__(39);
  7377. var util = __webpack_require__(4);
  7378. var isArrayLike = util.isArrayLike;
  7379. var arraySlice = Array.prototype.slice;
  7380. function defaultGetter(target, key) {
  7381. return target[key];
  7382. }
  7383. function defaultSetter(target, key, value) {
  7384. target[key] = value;
  7385. }
  7386. /**
  7387. * @param {number} p0
  7388. * @param {number} p1
  7389. * @param {number} percent
  7390. * @return {number}
  7391. */
  7392. function interpolateNumber(p0, p1, percent) {
  7393. return (p1 - p0) * percent + p0;
  7394. }
  7395. /**
  7396. * @param {string} p0
  7397. * @param {string} p1
  7398. * @param {number} percent
  7399. * @return {string}
  7400. */
  7401. function interpolateString(p0, p1, percent) {
  7402. return percent > 0.5 ? p1 : p0;
  7403. }
  7404. /**
  7405. * @param {Array} p0
  7406. * @param {Array} p1
  7407. * @param {number} percent
  7408. * @param {Array} out
  7409. * @param {number} arrDim
  7410. */
  7411. function interpolateArray(p0, p1, percent, out, arrDim) {
  7412. var len = p0.length;
  7413. if (arrDim == 1) {
  7414. for (var i = 0; i < len; i++) {
  7415. out[i] = interpolateNumber(p0[i], p1[i], percent);
  7416. }
  7417. }
  7418. else {
  7419. var len2 = p0[0].length;
  7420. for (var i = 0; i < len; i++) {
  7421. for (var j = 0; j < len2; j++) {
  7422. out[i][j] = interpolateNumber(
  7423. p0[i][j], p1[i][j], percent
  7424. );
  7425. }
  7426. }
  7427. }
  7428. }
  7429. // arr0 is source array, arr1 is target array.
  7430. // Do some preprocess to avoid error happened when interpolating from arr0 to arr1
  7431. function fillArr(arr0, arr1, arrDim) {
  7432. var arr0Len = arr0.length;
  7433. var arr1Len = arr1.length;
  7434. if (arr0Len !== arr1Len) {
  7435. // FIXME Not work for TypedArray
  7436. var isPreviousLarger = arr0Len > arr1Len;
  7437. if (isPreviousLarger) {
  7438. // Cut the previous
  7439. arr0.length = arr1Len;
  7440. }
  7441. else {
  7442. // Fill the previous
  7443. for (var i = arr0Len; i < arr1Len; i++) {
  7444. arr0.push(
  7445. arrDim === 1 ? arr1[i] : arraySlice.call(arr1[i])
  7446. );
  7447. }
  7448. }
  7449. }
  7450. // Handling NaN value
  7451. var len2 = arr0[0] && arr0[0].length;
  7452. for (var i = 0; i < arr0.length; i++) {
  7453. if (arrDim === 1) {
  7454. if (isNaN(arr0[i])) {
  7455. arr0[i] = arr1[i];
  7456. }
  7457. }
  7458. else {
  7459. for (var j = 0; j < len2; j++) {
  7460. if (isNaN(arr0[i][j])) {
  7461. arr0[i][j] = arr1[i][j];
  7462. }
  7463. }
  7464. }
  7465. }
  7466. }
  7467. /**
  7468. * @param {Array} arr0
  7469. * @param {Array} arr1
  7470. * @param {number} arrDim
  7471. * @return {boolean}
  7472. */
  7473. function isArraySame(arr0, arr1, arrDim) {
  7474. if (arr0 === arr1) {
  7475. return true;
  7476. }
  7477. var len = arr0.length;
  7478. if (len !== arr1.length) {
  7479. return false;
  7480. }
  7481. if (arrDim === 1) {
  7482. for (var i = 0; i < len; i++) {
  7483. if (arr0[i] !== arr1[i]) {
  7484. return false;
  7485. }
  7486. }
  7487. }
  7488. else {
  7489. var len2 = arr0[0].length;
  7490. for (var i = 0; i < len; i++) {
  7491. for (var j = 0; j < len2; j++) {
  7492. if (arr0[i][j] !== arr1[i][j]) {
  7493. return false;
  7494. }
  7495. }
  7496. }
  7497. }
  7498. return true;
  7499. }
  7500. /**
  7501. * Catmull Rom interpolate array
  7502. * @param {Array} p0
  7503. * @param {Array} p1
  7504. * @param {Array} p2
  7505. * @param {Array} p3
  7506. * @param {number} t
  7507. * @param {number} t2
  7508. * @param {number} t3
  7509. * @param {Array} out
  7510. * @param {number} arrDim
  7511. */
  7512. function catmullRomInterpolateArray(
  7513. p0, p1, p2, p3, t, t2, t3, out, arrDim
  7514. ) {
  7515. var len = p0.length;
  7516. if (arrDim == 1) {
  7517. for (var i = 0; i < len; i++) {
  7518. out[i] = catmullRomInterpolate(
  7519. p0[i], p1[i], p2[i], p3[i], t, t2, t3
  7520. );
  7521. }
  7522. }
  7523. else {
  7524. var len2 = p0[0].length;
  7525. for (var i = 0; i < len; i++) {
  7526. for (var j = 0; j < len2; j++) {
  7527. out[i][j] = catmullRomInterpolate(
  7528. p0[i][j], p1[i][j], p2[i][j], p3[i][j],
  7529. t, t2, t3
  7530. );
  7531. }
  7532. }
  7533. }
  7534. }
  7535. /**
  7536. * Catmull Rom interpolate number
  7537. * @param {number} p0
  7538. * @param {number} p1
  7539. * @param {number} p2
  7540. * @param {number} p3
  7541. * @param {number} t
  7542. * @param {number} t2
  7543. * @param {number} t3
  7544. * @return {number}
  7545. */
  7546. function catmullRomInterpolate(p0, p1, p2, p3, t, t2, t3) {
  7547. var v0 = (p2 - p0) * 0.5;
  7548. var v1 = (p3 - p1) * 0.5;
  7549. return (2 * (p1 - p2) + v0 + v1) * t3
  7550. + (-3 * (p1 - p2) - 2 * v0 - v1) * t2
  7551. + v0 * t + p1;
  7552. }
  7553. function cloneValue(value) {
  7554. if (isArrayLike(value)) {
  7555. var len = value.length;
  7556. if (isArrayLike(value[0])) {
  7557. var ret = [];
  7558. for (var i = 0; i < len; i++) {
  7559. ret.push(arraySlice.call(value[i]));
  7560. }
  7561. return ret;
  7562. }
  7563. return arraySlice.call(value);
  7564. }
  7565. return value;
  7566. }
  7567. function rgba2String(rgba) {
  7568. rgba[0] = Math.floor(rgba[0]);
  7569. rgba[1] = Math.floor(rgba[1]);
  7570. rgba[2] = Math.floor(rgba[2]);
  7571. return 'rgba(' + rgba.join(',') + ')';
  7572. }
  7573. function createTrackClip (animator, easing, oneTrackDone, keyframes, propName) {
  7574. var getter = animator._getter;
  7575. var setter = animator._setter;
  7576. var useSpline = easing === 'spline';
  7577. var trackLen = keyframes.length;
  7578. if (!trackLen) {
  7579. return;
  7580. }
  7581. // Guess data type
  7582. var firstVal = keyframes[0].value;
  7583. var isValueArray = isArrayLike(firstVal);
  7584. var isValueColor = false;
  7585. var isValueString = false;
  7586. // For vertices morphing
  7587. var arrDim = (
  7588. isValueArray
  7589. && isArrayLike(firstVal[0])
  7590. )
  7591. ? 2 : 1;
  7592. var trackMaxTime;
  7593. // Sort keyframe as ascending
  7594. keyframes.sort(function(a, b) {
  7595. return a.time - b.time;
  7596. });
  7597. trackMaxTime = keyframes[trackLen - 1].time;
  7598. // Percents of each keyframe
  7599. var kfPercents = [];
  7600. // Value of each keyframe
  7601. var kfValues = [];
  7602. var prevValue = keyframes[0].value;
  7603. var isAllValueEqual = true;
  7604. for (var i = 0; i < trackLen; i++) {
  7605. kfPercents.push(keyframes[i].time / trackMaxTime);
  7606. // Assume value is a color when it is a string
  7607. var value = keyframes[i].value;
  7608. // Check if value is equal, deep check if value is array
  7609. if (!((isValueArray && isArraySame(value, prevValue, arrDim))
  7610. || (!isValueArray && value === prevValue))) {
  7611. isAllValueEqual = false;
  7612. }
  7613. prevValue = value;
  7614. // Try converting a string to a color array
  7615. if (typeof value == 'string') {
  7616. var colorArray = color.parse(value);
  7617. if (colorArray) {
  7618. value = colorArray;
  7619. isValueColor = true;
  7620. }
  7621. else {
  7622. isValueString = true;
  7623. }
  7624. }
  7625. kfValues.push(value);
  7626. }
  7627. if (isAllValueEqual) {
  7628. return;
  7629. }
  7630. var lastValue = kfValues[trackLen - 1];
  7631. // Polyfill array and NaN value
  7632. for (var i = 0; i < trackLen - 1; i++) {
  7633. if (isValueArray) {
  7634. fillArr(kfValues[i], lastValue, arrDim);
  7635. }
  7636. else {
  7637. if (isNaN(kfValues[i]) && !isNaN(lastValue) && !isValueString && !isValueColor) {
  7638. kfValues[i] = lastValue;
  7639. }
  7640. }
  7641. }
  7642. isValueArray && fillArr(getter(animator._target, propName), lastValue, arrDim);
  7643. // Cache the key of last frame to speed up when
  7644. // animation playback is sequency
  7645. var lastFrame = 0;
  7646. var lastFramePercent = 0;
  7647. var start;
  7648. var w;
  7649. var p0;
  7650. var p1;
  7651. var p2;
  7652. var p3;
  7653. if (isValueColor) {
  7654. var rgba = [0, 0, 0, 0];
  7655. }
  7656. var onframe = function (target, percent) {
  7657. // Find the range keyframes
  7658. // kf1-----kf2---------current--------kf3
  7659. // find kf2 and kf3 and do interpolation
  7660. var frame;
  7661. if (percent < lastFramePercent) {
  7662. // Start from next key
  7663. // PENDING start from lastFrame ?
  7664. start = Math.min(lastFrame + 1, trackLen - 1);
  7665. for (frame = start; frame >= 0; frame--) {
  7666. if (kfPercents[frame] <= percent) {
  7667. break;
  7668. }
  7669. }
  7670. // PENDING really need to do this ?
  7671. frame = Math.min(frame, trackLen - 2);
  7672. }
  7673. else {
  7674. for (frame = lastFrame; frame < trackLen; frame++) {
  7675. if (kfPercents[frame] > percent) {
  7676. break;
  7677. }
  7678. }
  7679. frame = Math.min(frame - 1, trackLen - 2);
  7680. }
  7681. lastFrame = frame;
  7682. lastFramePercent = percent;
  7683. var range = (kfPercents[frame + 1] - kfPercents[frame]);
  7684. if (range === 0) {
  7685. return;
  7686. }
  7687. else {
  7688. w = (percent - kfPercents[frame]) / range;
  7689. }
  7690. if (useSpline) {
  7691. p1 = kfValues[frame];
  7692. p0 = kfValues[frame === 0 ? frame : frame - 1];
  7693. p2 = kfValues[frame > trackLen - 2 ? trackLen - 1 : frame + 1];
  7694. p3 = kfValues[frame > trackLen - 3 ? trackLen - 1 : frame + 2];
  7695. if (isValueArray) {
  7696. catmullRomInterpolateArray(
  7697. p0, p1, p2, p3, w, w * w, w * w * w,
  7698. getter(target, propName),
  7699. arrDim
  7700. );
  7701. }
  7702. else {
  7703. var value;
  7704. if (isValueColor) {
  7705. value = catmullRomInterpolateArray(
  7706. p0, p1, p2, p3, w, w * w, w * w * w,
  7707. rgba, 1
  7708. );
  7709. value = rgba2String(rgba);
  7710. }
  7711. else if (isValueString) {
  7712. // String is step(0.5)
  7713. return interpolateString(p1, p2, w);
  7714. }
  7715. else {
  7716. value = catmullRomInterpolate(
  7717. p0, p1, p2, p3, w, w * w, w * w * w
  7718. );
  7719. }
  7720. setter(
  7721. target,
  7722. propName,
  7723. value
  7724. );
  7725. }
  7726. }
  7727. else {
  7728. if (isValueArray) {
  7729. interpolateArray(
  7730. kfValues[frame], kfValues[frame + 1], w,
  7731. getter(target, propName),
  7732. arrDim
  7733. );
  7734. }
  7735. else {
  7736. var value;
  7737. if (isValueColor) {
  7738. interpolateArray(
  7739. kfValues[frame], kfValues[frame + 1], w,
  7740. rgba, 1
  7741. );
  7742. value = rgba2String(rgba);
  7743. }
  7744. else if (isValueString) {
  7745. // String is step(0.5)
  7746. return interpolateString(kfValues[frame], kfValues[frame + 1], w);
  7747. }
  7748. else {
  7749. value = interpolateNumber(kfValues[frame], kfValues[frame + 1], w);
  7750. }
  7751. setter(
  7752. target,
  7753. propName,
  7754. value
  7755. );
  7756. }
  7757. }
  7758. };
  7759. var clip = new Clip({
  7760. target: animator._target,
  7761. life: trackMaxTime,
  7762. loop: animator._loop,
  7763. delay: animator._delay,
  7764. onframe: onframe,
  7765. ondestroy: oneTrackDone
  7766. });
  7767. if (easing && easing !== 'spline') {
  7768. clip.easing = easing;
  7769. }
  7770. return clip;
  7771. }
  7772. /**
  7773. * @alias module:zrender/animation/Animator
  7774. * @constructor
  7775. * @param {Object} target
  7776. * @param {boolean} loop
  7777. * @param {Function} getter
  7778. * @param {Function} setter
  7779. */
  7780. var Animator = function(target, loop, getter, setter) {
  7781. this._tracks = {};
  7782. this._target = target;
  7783. this._loop = loop || false;
  7784. this._getter = getter || defaultGetter;
  7785. this._setter = setter || defaultSetter;
  7786. this._clipCount = 0;
  7787. this._delay = 0;
  7788. this._doneList = [];
  7789. this._onframeList = [];
  7790. this._clipList = [];
  7791. };
  7792. Animator.prototype = {
  7793. /**
  7794. * 设置动画关键帧
  7795. * @param {number} time 关键帧时间,单位是ms
  7796. * @param {Object} props 关键帧的属性值,key-value表示
  7797. * @return {module:zrender/animation/Animator}
  7798. */
  7799. when: function(time /* ms */, props) {
  7800. var tracks = this._tracks;
  7801. for (var propName in props) {
  7802. if (!tracks[propName]) {
  7803. tracks[propName] = [];
  7804. // Invalid value
  7805. var value = this._getter(this._target, propName);
  7806. if (value == null) {
  7807. // zrLog('Invalid property ' + propName);
  7808. continue;
  7809. }
  7810. // If time is 0
  7811. // Then props is given initialize value
  7812. // Else
  7813. // Initialize value from current prop value
  7814. if (time !== 0) {
  7815. tracks[propName].push({
  7816. time: 0,
  7817. value: cloneValue(value)
  7818. });
  7819. }
  7820. }
  7821. tracks[propName].push({
  7822. time: time,
  7823. value: props[propName]
  7824. });
  7825. }
  7826. return this;
  7827. },
  7828. /**
  7829. * 添加动画每一帧的回调函数
  7830. * @param {Function} callback
  7831. * @return {module:zrender/animation/Animator}
  7832. */
  7833. during: function (callback) {
  7834. this._onframeList.push(callback);
  7835. return this;
  7836. },
  7837. _doneCallback: function () {
  7838. // Clear all tracks
  7839. this._tracks = {};
  7840. // Clear all clips
  7841. this._clipList.length = 0;
  7842. var doneList = this._doneList;
  7843. var len = doneList.length;
  7844. for (var i = 0; i < len; i++) {
  7845. doneList[i].call(this);
  7846. }
  7847. },
  7848. /**
  7849. * 开始执行动画
  7850. * @param {string|Function} easing
  7851. * 动画缓动函数,详见{@link module:zrender/animation/easing}
  7852. * @return {module:zrender/animation/Animator}
  7853. */
  7854. start: function (easing) {
  7855. var self = this;
  7856. var clipCount = 0;
  7857. var oneTrackDone = function() {
  7858. clipCount--;
  7859. if (!clipCount) {
  7860. self._doneCallback();
  7861. }
  7862. };
  7863. var lastClip;
  7864. for (var propName in this._tracks) {
  7865. var clip = createTrackClip(
  7866. this, easing, oneTrackDone,
  7867. this._tracks[propName], propName
  7868. );
  7869. if (clip) {
  7870. this._clipList.push(clip);
  7871. clipCount++;
  7872. // If start after added to animation
  7873. if (this.animation) {
  7874. this.animation.addClip(clip);
  7875. }
  7876. lastClip = clip;
  7877. }
  7878. }
  7879. // Add during callback on the last clip
  7880. if (lastClip) {
  7881. var oldOnFrame = lastClip.onframe;
  7882. lastClip.onframe = function (target, percent) {
  7883. oldOnFrame(target, percent);
  7884. for (var i = 0; i < self._onframeList.length; i++) {
  7885. self._onframeList[i](target, percent);
  7886. }
  7887. };
  7888. }
  7889. if (!clipCount) {
  7890. this._doneCallback();
  7891. }
  7892. return this;
  7893. },
  7894. /**
  7895. * 停止动画
  7896. * @param {boolean} forwardToLast If move to last frame before stop
  7897. */
  7898. stop: function (forwardToLast) {
  7899. var clipList = this._clipList;
  7900. var animation = this.animation;
  7901. for (var i = 0; i < clipList.length; i++) {
  7902. var clip = clipList[i];
  7903. if (forwardToLast) {
  7904. // Move to last frame before stop
  7905. clip.onframe(this._target, 1);
  7906. }
  7907. animation && animation.removeClip(clip);
  7908. }
  7909. clipList.length = 0;
  7910. },
  7911. /**
  7912. * 设置动画延迟开始的时间
  7913. * @param {number} time 单位ms
  7914. * @return {module:zrender/animation/Animator}
  7915. */
  7916. delay: function (time) {
  7917. this._delay = time;
  7918. return this;
  7919. },
  7920. /**
  7921. * 添加动画结束的回调
  7922. * @param {Function} cb
  7923. * @return {module:zrender/animation/Animator}
  7924. */
  7925. done: function(cb) {
  7926. if (cb) {
  7927. this._doneList.push(cb);
  7928. }
  7929. return this;
  7930. },
  7931. /**
  7932. * @return {Array.<module:zrender/animation/Clip>}
  7933. */
  7934. getClips: function () {
  7935. return this._clipList;
  7936. }
  7937. };
  7938. module.exports = Animator;
  7939. /***/ },
  7940. /* 37 */
  7941. /***/ function(module, exports, __webpack_require__) {
  7942. /**
  7943. * 动画主控制器
  7944. * @config target 动画对象,可以是数组,如果是数组的话会批量分发onframe等事件
  7945. * @config life(1000) 动画时长
  7946. * @config delay(0) 动画延迟时间
  7947. * @config loop(true)
  7948. * @config gap(0) 循环的间隔时间
  7949. * @config onframe
  7950. * @config easing(optional)
  7951. * @config ondestroy(optional)
  7952. * @config onrestart(optional)
  7953. *
  7954. * TODO pause
  7955. */
  7956. var easingFuncs = __webpack_require__(38);
  7957. function Clip(options) {
  7958. this._target = options.target;
  7959. // 生命周期
  7960. this._life = options.life || 1000;
  7961. // 延时
  7962. this._delay = options.delay || 0;
  7963. // 开始时间
  7964. // this._startTime = new Date().getTime() + this._delay;// 单位毫秒
  7965. this._initialized = false;
  7966. // 是否循环
  7967. this.loop = options.loop == null ? false : options.loop;
  7968. this.gap = options.gap || 0;
  7969. this.easing = options.easing || 'Linear';
  7970. this.onframe = options.onframe;
  7971. this.ondestroy = options.ondestroy;
  7972. this.onrestart = options.onrestart;
  7973. }
  7974. Clip.prototype = {
  7975. constructor: Clip,
  7976. step: function (time) {
  7977. // Set startTime on first step, or _startTime may has milleseconds different between clips
  7978. // PENDING
  7979. if (!this._initialized) {
  7980. this._startTime = new Date().getTime() + this._delay;
  7981. this._initialized = true;
  7982. }
  7983. var percent = (time - this._startTime) / this._life;
  7984. // 还没开始
  7985. if (percent < 0) {
  7986. return;
  7987. }
  7988. percent = Math.min(percent, 1);
  7989. var easing = this.easing;
  7990. var easingFunc = typeof easing == 'string' ? easingFuncs[easing] : easing;
  7991. var schedule = typeof easingFunc === 'function'
  7992. ? easingFunc(percent)
  7993. : percent;
  7994. this.fire('frame', schedule);
  7995. // 结束
  7996. if (percent == 1) {
  7997. if (this.loop) {
  7998. this.restart();
  7999. // 重新开始周期
  8000. // 抛出而不是直接调用事件直到 stage.update 后再统一调用这些事件
  8001. return 'restart';
  8002. }
  8003. // 动画完成将这个控制器标识为待删除
  8004. // 在Animation.update中进行批量删除
  8005. this._needsRemove = true;
  8006. return 'destroy';
  8007. }
  8008. return null;
  8009. },
  8010. restart: function() {
  8011. var time = new Date().getTime();
  8012. var remainder = (time - this._startTime) % this._life;
  8013. this._startTime = new Date().getTime() - remainder + this.gap;
  8014. this._needsRemove = false;
  8015. },
  8016. fire: function(eventType, arg) {
  8017. eventType = 'on' + eventType;
  8018. if (this[eventType]) {
  8019. this[eventType](this._target, arg);
  8020. }
  8021. }
  8022. };
  8023. module.exports = Clip;
  8024. /***/ },
  8025. /* 38 */
  8026. /***/ function(module, exports) {
  8027. /**
  8028. * 缓动代码来自 https://github.com/sole/tween.js/blob/master/src/Tween.js
  8029. * @see http://sole.github.io/tween.js/examples/03_graphs.html
  8030. * @exports zrender/animation/easing
  8031. */
  8032. var easing = {
  8033. /**
  8034. * @param {number} k
  8035. * @return {number}
  8036. */
  8037. linear: function (k) {
  8038. return k;
  8039. },
  8040. /**
  8041. * @param {number} k
  8042. * @return {number}
  8043. */
  8044. quadraticIn: function (k) {
  8045. return k * k;
  8046. },
  8047. /**
  8048. * @param {number} k
  8049. * @return {number}
  8050. */
  8051. quadraticOut: function (k) {
  8052. return k * (2 - k);
  8053. },
  8054. /**
  8055. * @param {number} k
  8056. * @return {number}
  8057. */
  8058. quadraticInOut: function (k) {
  8059. if ((k *= 2) < 1) {
  8060. return 0.5 * k * k;
  8061. }
  8062. return -0.5 * (--k * (k - 2) - 1);
  8063. },
  8064. // 三次方的缓动(t^3)
  8065. /**
  8066. * @param {number} k
  8067. * @return {number}
  8068. */
  8069. cubicIn: function (k) {
  8070. return k * k * k;
  8071. },
  8072. /**
  8073. * @param {number} k
  8074. * @return {number}
  8075. */
  8076. cubicOut: function (k) {
  8077. return --k * k * k + 1;
  8078. },
  8079. /**
  8080. * @param {number} k
  8081. * @return {number}
  8082. */
  8083. cubicInOut: function (k) {
  8084. if ((k *= 2) < 1) {
  8085. return 0.5 * k * k * k;
  8086. }
  8087. return 0.5 * ((k -= 2) * k * k + 2);
  8088. },
  8089. // 四次方的缓动(t^4)
  8090. /**
  8091. * @param {number} k
  8092. * @return {number}
  8093. */
  8094. quarticIn: function (k) {
  8095. return k * k * k * k;
  8096. },
  8097. /**
  8098. * @param {number} k
  8099. * @return {number}
  8100. */
  8101. quarticOut: function (k) {
  8102. return 1 - (--k * k * k * k);
  8103. },
  8104. /**
  8105. * @param {number} k
  8106. * @return {number}
  8107. */
  8108. quarticInOut: function (k) {
  8109. if ((k *= 2) < 1) {
  8110. return 0.5 * k * k * k * k;
  8111. }
  8112. return -0.5 * ((k -= 2) * k * k * k - 2);
  8113. },
  8114. // 五次方的缓动(t^5)
  8115. /**
  8116. * @param {number} k
  8117. * @return {number}
  8118. */
  8119. quinticIn: function (k) {
  8120. return k * k * k * k * k;
  8121. },
  8122. /**
  8123. * @param {number} k
  8124. * @return {number}
  8125. */
  8126. quinticOut: function (k) {
  8127. return --k * k * k * k * k + 1;
  8128. },
  8129. /**
  8130. * @param {number} k
  8131. * @return {number}
  8132. */
  8133. quinticInOut: function (k) {
  8134. if ((k *= 2) < 1) {
  8135. return 0.5 * k * k * k * k * k;
  8136. }
  8137. return 0.5 * ((k -= 2) * k * k * k * k + 2);
  8138. },
  8139. // 正弦曲线的缓动(sin(t))
  8140. /**
  8141. * @param {number} k
  8142. * @return {number}
  8143. */
  8144. sinusoidalIn: function (k) {
  8145. return 1 - Math.cos(k * Math.PI / 2);
  8146. },
  8147. /**
  8148. * @param {number} k
  8149. * @return {number}
  8150. */
  8151. sinusoidalOut: function (k) {
  8152. return Math.sin(k * Math.PI / 2);
  8153. },
  8154. /**
  8155. * @param {number} k
  8156. * @return {number}
  8157. */
  8158. sinusoidalInOut: function (k) {
  8159. return 0.5 * (1 - Math.cos(Math.PI * k));
  8160. },
  8161. // 指数曲线的缓动(2^t)
  8162. /**
  8163. * @param {number} k
  8164. * @return {number}
  8165. */
  8166. exponentialIn: function (k) {
  8167. return k === 0 ? 0 : Math.pow(1024, k - 1);
  8168. },
  8169. /**
  8170. * @param {number} k
  8171. * @return {number}
  8172. */
  8173. exponentialOut: function (k) {
  8174. return k === 1 ? 1 : 1 - Math.pow(2, -10 * k);
  8175. },
  8176. /**
  8177. * @param {number} k
  8178. * @return {number}
  8179. */
  8180. exponentialInOut: function (k) {
  8181. if (k === 0) {
  8182. return 0;
  8183. }
  8184. if (k === 1) {
  8185. return 1;
  8186. }
  8187. if ((k *= 2) < 1) {
  8188. return 0.5 * Math.pow(1024, k - 1);
  8189. }
  8190. return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2);
  8191. },
  8192. // 圆形曲线的缓动(sqrt(1-t^2))
  8193. /**
  8194. * @param {number} k
  8195. * @return {number}
  8196. */
  8197. circularIn: function (k) {
  8198. return 1 - Math.sqrt(1 - k * k);
  8199. },
  8200. /**
  8201. * @param {number} k
  8202. * @return {number}
  8203. */
  8204. circularOut: function (k) {
  8205. return Math.sqrt(1 - (--k * k));
  8206. },
  8207. /**
  8208. * @param {number} k
  8209. * @return {number}
  8210. */
  8211. circularInOut: function (k) {
  8212. if ((k *= 2) < 1) {
  8213. return -0.5 * (Math.sqrt(1 - k * k) - 1);
  8214. }
  8215. return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1);
  8216. },
  8217. // 创建类似于弹簧在停止前来回振荡的动画
  8218. /**
  8219. * @param {number} k
  8220. * @return {number}
  8221. */
  8222. elasticIn: function (k) {
  8223. var s;
  8224. var a = 0.1;
  8225. var p = 0.4;
  8226. if (k === 0) {
  8227. return 0;
  8228. }
  8229. if (k === 1) {
  8230. return 1;
  8231. }
  8232. if (!a || a < 1) {
  8233. a = 1; s = p / 4;
  8234. }
  8235. else {
  8236. s = p * Math.asin(1 / a) / (2 * Math.PI);
  8237. }
  8238. return -(a * Math.pow(2, 10 * (k -= 1)) *
  8239. Math.sin((k - s) * (2 * Math.PI) / p));
  8240. },
  8241. /**
  8242. * @param {number} k
  8243. * @return {number}
  8244. */
  8245. elasticOut: function (k) {
  8246. var s;
  8247. var a = 0.1;
  8248. var p = 0.4;
  8249. if (k === 0) {
  8250. return 0;
  8251. }
  8252. if (k === 1) {
  8253. return 1;
  8254. }
  8255. if (!a || a < 1) {
  8256. a = 1; s = p / 4;
  8257. }
  8258. else {
  8259. s = p * Math.asin(1 / a) / (2 * Math.PI);
  8260. }
  8261. return (a * Math.pow(2, -10 * k) *
  8262. Math.sin((k - s) * (2 * Math.PI) / p) + 1);
  8263. },
  8264. /**
  8265. * @param {number} k
  8266. * @return {number}
  8267. */
  8268. elasticInOut: function (k) {
  8269. var s;
  8270. var a = 0.1;
  8271. var p = 0.4;
  8272. if (k === 0) {
  8273. return 0;
  8274. }
  8275. if (k === 1) {
  8276. return 1;
  8277. }
  8278. if (!a || a < 1) {
  8279. a = 1; s = p / 4;
  8280. }
  8281. else {
  8282. s = p * Math.asin(1 / a) / (2 * Math.PI);
  8283. }
  8284. if ((k *= 2) < 1) {
  8285. return -0.5 * (a * Math.pow(2, 10 * (k -= 1))
  8286. * Math.sin((k - s) * (2 * Math.PI) / p));
  8287. }
  8288. return a * Math.pow(2, -10 * (k -= 1))
  8289. * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1;
  8290. },
  8291. // 在某一动画开始沿指示的路径进行动画处理前稍稍收回该动画的移动
  8292. /**
  8293. * @param {number} k
  8294. * @return {number}
  8295. */
  8296. backIn: function (k) {
  8297. var s = 1.70158;
  8298. return k * k * ((s + 1) * k - s);
  8299. },
  8300. /**
  8301. * @param {number} k
  8302. * @return {number}
  8303. */
  8304. backOut: function (k) {
  8305. var s = 1.70158;
  8306. return --k * k * ((s + 1) * k + s) + 1;
  8307. },
  8308. /**
  8309. * @param {number} k
  8310. * @return {number}
  8311. */
  8312. backInOut: function (k) {
  8313. var s = 1.70158 * 1.525;
  8314. if ((k *= 2) < 1) {
  8315. return 0.5 * (k * k * ((s + 1) * k - s));
  8316. }
  8317. return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
  8318. },
  8319. // 创建弹跳效果
  8320. /**
  8321. * @param {number} k
  8322. * @return {number}
  8323. */
  8324. bounceIn: function (k) {
  8325. return 1 - easing.bounceOut(1 - k);
  8326. },
  8327. /**
  8328. * @param {number} k
  8329. * @return {number}
  8330. */
  8331. bounceOut: function (k) {
  8332. if (k < (1 / 2.75)) {
  8333. return 7.5625 * k * k;
  8334. }
  8335. else if (k < (2 / 2.75)) {
  8336. return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75;
  8337. }
  8338. else if (k < (2.5 / 2.75)) {
  8339. return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375;
  8340. }
  8341. else {
  8342. return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375;
  8343. }
  8344. },
  8345. /**
  8346. * @param {number} k
  8347. * @return {number}
  8348. */
  8349. bounceInOut: function (k) {
  8350. if (k < 0.5) {
  8351. return easing.bounceIn(k * 2) * 0.5;
  8352. }
  8353. return easing.bounceOut(k * 2 - 1) * 0.5 + 0.5;
  8354. }
  8355. };
  8356. module.exports = easing;
  8357. /***/ },
  8358. /* 39 */
  8359. /***/ function(module, exports) {
  8360. /**
  8361. * @module zrender/tool/color
  8362. */
  8363. var kCSSColorTable = {
  8364. 'transparent': [0,0,0,0], 'aliceblue': [240,248,255,1],
  8365. 'antiquewhite': [250,235,215,1], 'aqua': [0,255,255,1],
  8366. 'aquamarine': [127,255,212,1], 'azure': [240,255,255,1],
  8367. 'beige': [245,245,220,1], 'bisque': [255,228,196,1],
  8368. 'black': [0,0,0,1], 'blanchedalmond': [255,235,205,1],
  8369. 'blue': [0,0,255,1], 'blueviolet': [138,43,226,1],
  8370. 'brown': [165,42,42,1], 'burlywood': [222,184,135,1],
  8371. 'cadetblue': [95,158,160,1], 'chartreuse': [127,255,0,1],
  8372. 'chocolate': [210,105,30,1], 'coral': [255,127,80,1],
  8373. 'cornflowerblue': [100,149,237,1], 'cornsilk': [255,248,220,1],
  8374. 'crimson': [220,20,60,1], 'cyan': [0,255,255,1],
  8375. 'darkblue': [0,0,139,1], 'darkcyan': [0,139,139,1],
  8376. 'darkgoldenrod': [184,134,11,1], 'darkgray': [169,169,169,1],
  8377. 'darkgreen': [0,100,0,1], 'darkgrey': [169,169,169,1],
  8378. 'darkkhaki': [189,183,107,1], 'darkmagenta': [139,0,139,1],
  8379. 'darkolivegreen': [85,107,47,1], 'darkorange': [255,140,0,1],
  8380. 'darkorchid': [153,50,204,1], 'darkred': [139,0,0,1],
  8381. 'darksalmon': [233,150,122,1], 'darkseagreen': [143,188,143,1],
  8382. 'darkslateblue': [72,61,139,1], 'darkslategray': [47,79,79,1],
  8383. 'darkslategrey': [47,79,79,1], 'darkturquoise': [0,206,209,1],
  8384. 'darkviolet': [148,0,211,1], 'deeppink': [255,20,147,1],
  8385. 'deepskyblue': [0,191,255,1], 'dimgray': [105,105,105,1],
  8386. 'dimgrey': [105,105,105,1], 'dodgerblue': [30,144,255,1],
  8387. 'firebrick': [178,34,34,1], 'floralwhite': [255,250,240,1],
  8388. 'forestgreen': [34,139,34,1], 'fuchsia': [255,0,255,1],
  8389. 'gainsboro': [220,220,220,1], 'ghostwhite': [248,248,255,1],
  8390. 'gold': [255,215,0,1], 'goldenrod': [218,165,32,1],
  8391. 'gray': [128,128,128,1], 'green': [0,128,0,1],
  8392. 'greenyellow': [173,255,47,1], 'grey': [128,128,128,1],
  8393. 'honeydew': [240,255,240,1], 'hotpink': [255,105,180,1],
  8394. 'indianred': [205,92,92,1], 'indigo': [75,0,130,1],
  8395. 'ivory': [255,255,240,1], 'khaki': [240,230,140,1],
  8396. 'lavender': [230,230,250,1], 'lavenderblush': [255,240,245,1],
  8397. 'lawngreen': [124,252,0,1], 'lemonchiffon': [255,250,205,1],
  8398. 'lightblue': [173,216,230,1], 'lightcoral': [240,128,128,1],
  8399. 'lightcyan': [224,255,255,1], 'lightgoldenrodyellow': [250,250,210,1],
  8400. 'lightgray': [211,211,211,1], 'lightgreen': [144,238,144,1],
  8401. 'lightgrey': [211,211,211,1], 'lightpink': [255,182,193,1],
  8402. 'lightsalmon': [255,160,122,1], 'lightseagreen': [32,178,170,1],
  8403. 'lightskyblue': [135,206,250,1], 'lightslategray': [119,136,153,1],
  8404. 'lightslategrey': [119,136,153,1], 'lightsteelblue': [176,196,222,1],
  8405. 'lightyellow': [255,255,224,1], 'lime': [0,255,0,1],
  8406. 'limegreen': [50,205,50,1], 'linen': [250,240,230,1],
  8407. 'magenta': [255,0,255,1], 'maroon': [128,0,0,1],
  8408. 'mediumaquamarine': [102,205,170,1], 'mediumblue': [0,0,205,1],
  8409. 'mediumorchid': [186,85,211,1], 'mediumpurple': [147,112,219,1],
  8410. 'mediumseagreen': [60,179,113,1], 'mediumslateblue': [123,104,238,1],
  8411. 'mediumspringgreen': [0,250,154,1], 'mediumturquoise': [72,209,204,1],
  8412. 'mediumvioletred': [199,21,133,1], 'midnightblue': [25,25,112,1],
  8413. 'mintcream': [245,255,250,1], 'mistyrose': [255,228,225,1],
  8414. 'moccasin': [255,228,181,1], 'navajowhite': [255,222,173,1],
  8415. 'navy': [0,0,128,1], 'oldlace': [253,245,230,1],
  8416. 'olive': [128,128,0,1], 'olivedrab': [107,142,35,1],
  8417. 'orange': [255,165,0,1], 'orangered': [255,69,0,1],
  8418. 'orchid': [218,112,214,1], 'palegoldenrod': [238,232,170,1],
  8419. 'palegreen': [152,251,152,1], 'paleturquoise': [175,238,238,1],
  8420. 'palevioletred': [219,112,147,1], 'papayawhip': [255,239,213,1],
  8421. 'peachpuff': [255,218,185,1], 'peru': [205,133,63,1],
  8422. 'pink': [255,192,203,1], 'plum': [221,160,221,1],
  8423. 'powderblue': [176,224,230,1], 'purple': [128,0,128,1],
  8424. 'red': [255,0,0,1], 'rosybrown': [188,143,143,1],
  8425. 'royalblue': [65,105,225,1], 'saddlebrown': [139,69,19,1],
  8426. 'salmon': [250,128,114,1], 'sandybrown': [244,164,96,1],
  8427. 'seagreen': [46,139,87,1], 'seashell': [255,245,238,1],
  8428. 'sienna': [160,82,45,1], 'silver': [192,192,192,1],
  8429. 'skyblue': [135,206,235,1], 'slateblue': [106,90,205,1],
  8430. 'slategray': [112,128,144,1], 'slategrey': [112,128,144,1],
  8431. 'snow': [255,250,250,1], 'springgreen': [0,255,127,1],
  8432. 'steelblue': [70,130,180,1], 'tan': [210,180,140,1],
  8433. 'teal': [0,128,128,1], 'thistle': [216,191,216,1],
  8434. 'tomato': [255,99,71,1], 'turquoise': [64,224,208,1],
  8435. 'violet': [238,130,238,1], 'wheat': [245,222,179,1],
  8436. 'white': [255,255,255,1], 'whitesmoke': [245,245,245,1],
  8437. 'yellow': [255,255,0,1], 'yellowgreen': [154,205,50,1]
  8438. };
  8439. function clampCssByte(i) { // Clamp to integer 0 .. 255.
  8440. i = Math.round(i); // Seems to be what Chrome does (vs truncation).
  8441. return i < 0 ? 0 : i > 255 ? 255 : i;
  8442. }
  8443. function clampCssAngle(i) { // Clamp to integer 0 .. 360.
  8444. i = Math.round(i); // Seems to be what Chrome does (vs truncation).
  8445. return i < 0 ? 0 : i > 360 ? 360 : i;
  8446. }
  8447. function clampCssFloat(f) { // Clamp to float 0.0 .. 1.0.
  8448. return f < 0 ? 0 : f > 1 ? 1 : f;
  8449. }
  8450. function parseCssInt(str) { // int or percentage.
  8451. if (str.length && str.charAt(str.length - 1) === '%') {
  8452. return clampCssByte(parseFloat(str) / 100 * 255);
  8453. }
  8454. return clampCssByte(parseInt(str, 10));
  8455. }
  8456. function parseCssFloat(str) { // float or percentage.
  8457. if (str.length && str.charAt(str.length - 1) === '%') {
  8458. return clampCssFloat(parseFloat(str) / 100);
  8459. }
  8460. return clampCssFloat(parseFloat(str));
  8461. }
  8462. function cssHueToRgb(m1, m2, h) {
  8463. if (h < 0) {
  8464. h += 1;
  8465. }
  8466. else if (h > 1) {
  8467. h -= 1;
  8468. }
  8469. if (h * 6 < 1) {
  8470. return m1 + (m2 - m1) * h * 6;
  8471. }
  8472. if (h * 2 < 1) {
  8473. return m2;
  8474. }
  8475. if (h * 3 < 2) {
  8476. return m1 + (m2 - m1) * (2/3 - h) * 6;
  8477. }
  8478. return m1;
  8479. }
  8480. function lerp(a, b, p) {
  8481. return a + (b - a) * p;
  8482. }
  8483. /**
  8484. * @param {string} colorStr
  8485. * @return {Array.<number>}
  8486. * @memberOf module:zrender/util/color
  8487. */
  8488. function parse(colorStr) {
  8489. if (!colorStr) {
  8490. return;
  8491. }
  8492. // colorStr may be not string
  8493. colorStr = colorStr + '';
  8494. // Remove all whitespace, not compliant, but should just be more accepting.
  8495. var str = colorStr.replace(/ /g, '').toLowerCase();
  8496. // Color keywords (and transparent) lookup.
  8497. if (str in kCSSColorTable) {
  8498. return kCSSColorTable[str].slice(); // dup.
  8499. }
  8500. // #abc and #abc123 syntax.
  8501. if (str.charAt(0) === '#') {
  8502. if (str.length === 4) {
  8503. var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing.
  8504. if (!(iv >= 0 && iv <= 0xfff)) {
  8505. return; // Covers NaN.
  8506. }
  8507. return [
  8508. ((iv & 0xf00) >> 4) | ((iv & 0xf00) >> 8),
  8509. (iv & 0xf0) | ((iv & 0xf0) >> 4),
  8510. (iv & 0xf) | ((iv & 0xf) << 4),
  8511. 1
  8512. ];
  8513. }
  8514. else if (str.length === 7) {
  8515. var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing.
  8516. if (!(iv >= 0 && iv <= 0xffffff)) {
  8517. return; // Covers NaN.
  8518. }
  8519. return [
  8520. (iv & 0xff0000) >> 16,
  8521. (iv & 0xff00) >> 8,
  8522. iv & 0xff,
  8523. 1
  8524. ];
  8525. }
  8526. return;
  8527. }
  8528. var op = str.indexOf('('), ep = str.indexOf(')');
  8529. if (op !== -1 && ep + 1 === str.length) {
  8530. var fname = str.substr(0, op);
  8531. var params = str.substr(op + 1, ep - (op + 1)).split(',');
  8532. var alpha = 1; // To allow case fallthrough.
  8533. switch (fname) {
  8534. case 'rgba':
  8535. if (params.length !== 4) {
  8536. return;
  8537. }
  8538. alpha = parseCssFloat(params.pop()); // jshint ignore:line
  8539. // Fall through.
  8540. case 'rgb':
  8541. if (params.length !== 3) {
  8542. return;
  8543. }
  8544. return [
  8545. parseCssInt(params[0]),
  8546. parseCssInt(params[1]),
  8547. parseCssInt(params[2]),
  8548. alpha
  8549. ];
  8550. case 'hsla':
  8551. if (params.length !== 4) {
  8552. return;
  8553. }
  8554. params[3] = parseCssFloat(params[3]);
  8555. return hsla2rgba(params);
  8556. case 'hsl':
  8557. if (params.length !== 3) {
  8558. return;
  8559. }
  8560. return hsla2rgba(params);
  8561. default:
  8562. return;
  8563. }
  8564. }
  8565. return;
  8566. }
  8567. /**
  8568. * @param {Array.<number>} hsla
  8569. * @return {Array.<number>} rgba
  8570. */
  8571. function hsla2rgba(hsla) {
  8572. var h = (((parseFloat(hsla[0]) % 360) + 360) % 360) / 360; // 0 .. 1
  8573. // NOTE(deanm): According to the CSS spec s/l should only be
  8574. // percentages, but we don't bother and let float or percentage.
  8575. var s = parseCssFloat(hsla[1]);
  8576. var l = parseCssFloat(hsla[2]);
  8577. var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
  8578. var m1 = l * 2 - m2;
  8579. var rgba = [
  8580. clampCssByte(cssHueToRgb(m1, m2, h + 1 / 3) * 255),
  8581. clampCssByte(cssHueToRgb(m1, m2, h) * 255),
  8582. clampCssByte(cssHueToRgb(m1, m2, h - 1 / 3) * 255)
  8583. ];
  8584. if (hsla.length === 4) {
  8585. rgba[3] = hsla[3];
  8586. }
  8587. return rgba;
  8588. }
  8589. /**
  8590. * @param {Array.<number>} rgba
  8591. * @return {Array.<number>} hsla
  8592. */
  8593. function rgba2hsla(rgba) {
  8594. if (!rgba) {
  8595. return;
  8596. }
  8597. // RGB from 0 to 255
  8598. var R = rgba[0] / 255;
  8599. var G = rgba[1] / 255;
  8600. var B = rgba[2] / 255;
  8601. var vMin = Math.min(R, G, B); // Min. value of RGB
  8602. var vMax = Math.max(R, G, B); // Max. value of RGB
  8603. var delta = vMax - vMin; // Delta RGB value
  8604. var L = (vMax + vMin) / 2;
  8605. var H;
  8606. var S;
  8607. // HSL results from 0 to 1
  8608. if (delta === 0) {
  8609. H = 0;
  8610. S = 0;
  8611. }
  8612. else {
  8613. if (L < 0.5) {
  8614. S = delta / (vMax + vMin);
  8615. }
  8616. else {
  8617. S = delta / (2 - vMax - vMin);
  8618. }
  8619. var deltaR = (((vMax - R) / 6) + (delta / 2)) / delta;
  8620. var deltaG = (((vMax - G) / 6) + (delta / 2)) / delta;
  8621. var deltaB = (((vMax - B) / 6) + (delta / 2)) / delta;
  8622. if (R === vMax) {
  8623. H = deltaB - deltaG;
  8624. }
  8625. else if (G === vMax) {
  8626. H = (1 / 3) + deltaR - deltaB;
  8627. }
  8628. else if (B === vMax) {
  8629. H = (2 / 3) + deltaG - deltaR;
  8630. }
  8631. if (H < 0) {
  8632. H += 1;
  8633. }
  8634. if (H > 1) {
  8635. H -= 1;
  8636. }
  8637. }
  8638. var hsla = [H * 360, S, L];
  8639. if (rgba[3] != null) {
  8640. hsla.push(rgba[3]);
  8641. }
  8642. return hsla;
  8643. }
  8644. /**
  8645. * @param {string} color
  8646. * @param {number} level
  8647. * @return {string}
  8648. * @memberOf module:zrender/util/color
  8649. */
  8650. function lift(color, level) {
  8651. var colorArr = parse(color);
  8652. if (colorArr) {
  8653. for (var i = 0; i < 3; i++) {
  8654. if (level < 0) {
  8655. colorArr[i] = colorArr[i] * (1 - level) | 0;
  8656. }
  8657. else {
  8658. colorArr[i] = ((255 - colorArr[i]) * level + colorArr[i]) | 0;
  8659. }
  8660. }
  8661. return stringify(colorArr, colorArr.length === 4 ? 'rgba' : 'rgb');
  8662. }
  8663. }
  8664. /**
  8665. * @param {string} color
  8666. * @return {string}
  8667. * @memberOf module:zrender/util/color
  8668. */
  8669. function toHex(color, level) {
  8670. var colorArr = parse(color);
  8671. if (colorArr) {
  8672. return ((1 << 24) + (colorArr[0] << 16) + (colorArr[1] << 8) + (+colorArr[2])).toString(16).slice(1);
  8673. }
  8674. }
  8675. /**
  8676. * Map value to color. Faster than mapToColor methods because color is represented by rgba array
  8677. * @param {number} normalizedValue A float between 0 and 1.
  8678. * @param {Array.<Array.<number>>} colors List of rgba color array
  8679. * @param {Array.<number>} [out] Mapped gba color array
  8680. * @return {Array.<number>}
  8681. */
  8682. function fastMapToColor(normalizedValue, colors, out) {
  8683. if (!(colors && colors.length)
  8684. || !(normalizedValue >= 0 && normalizedValue <= 1)
  8685. ) {
  8686. return;
  8687. }
  8688. out = out || [0, 0, 0, 0];
  8689. var value = normalizedValue * (colors.length - 1);
  8690. var leftIndex = Math.floor(value);
  8691. var rightIndex = Math.ceil(value);
  8692. var leftColor = colors[leftIndex];
  8693. var rightColor = colors[rightIndex];
  8694. var dv = value - leftIndex;
  8695. out[0] = clampCssByte(lerp(leftColor[0], rightColor[0], dv));
  8696. out[1] = clampCssByte(lerp(leftColor[1], rightColor[1], dv));
  8697. out[2] = clampCssByte(lerp(leftColor[2], rightColor[2], dv));
  8698. out[3] = clampCssByte(lerp(leftColor[3], rightColor[3], dv));
  8699. return out;
  8700. }
  8701. /**
  8702. * @param {number} normalizedValue A float between 0 and 1.
  8703. * @param {Array.<string>} colors Color list.
  8704. * @param {boolean=} fullOutput Default false.
  8705. * @return {(string|Object)} Result color. If fullOutput,
  8706. * return {color: ..., leftIndex: ..., rightIndex: ..., value: ...},
  8707. * @memberOf module:zrender/util/color
  8708. */
  8709. function mapToColor(normalizedValue, colors, fullOutput) {
  8710. if (!(colors && colors.length)
  8711. || !(normalizedValue >= 0 && normalizedValue <= 1)
  8712. ) {
  8713. return;
  8714. }
  8715. var value = normalizedValue * (colors.length - 1);
  8716. var leftIndex = Math.floor(value);
  8717. var rightIndex = Math.ceil(value);
  8718. var leftColor = parse(colors[leftIndex]);
  8719. var rightColor = parse(colors[rightIndex]);
  8720. var dv = value - leftIndex;
  8721. var color = stringify(
  8722. [
  8723. clampCssByte(lerp(leftColor[0], rightColor[0], dv)),
  8724. clampCssByte(lerp(leftColor[1], rightColor[1], dv)),
  8725. clampCssByte(lerp(leftColor[2], rightColor[2], dv)),
  8726. clampCssFloat(lerp(leftColor[3], rightColor[3], dv))
  8727. ],
  8728. 'rgba'
  8729. );
  8730. return fullOutput
  8731. ? {
  8732. color: color,
  8733. leftIndex: leftIndex,
  8734. rightIndex: rightIndex,
  8735. value: value
  8736. }
  8737. : color;
  8738. }
  8739. /**
  8740. * @param {string} color
  8741. * @param {number=} h 0 ~ 360, ignore when null.
  8742. * @param {number=} s 0 ~ 1, ignore when null.
  8743. * @param {number=} l 0 ~ 1, ignore when null.
  8744. * @return {string} Color string in rgba format.
  8745. * @memberOf module:zrender/util/color
  8746. */
  8747. function modifyHSL(color, h, s, l) {
  8748. color = parse(color);
  8749. if (color) {
  8750. color = rgba2hsla(color);
  8751. h != null && (color[0] = clampCssAngle(h));
  8752. s != null && (color[1] = parseCssFloat(s));
  8753. l != null && (color[2] = parseCssFloat(l));
  8754. return stringify(hsla2rgba(color), 'rgba');
  8755. }
  8756. }
  8757. /**
  8758. * @param {string} color
  8759. * @param {number=} alpha 0 ~ 1
  8760. * @return {string} Color string in rgba format.
  8761. * @memberOf module:zrender/util/color
  8762. */
  8763. function modifyAlpha(color, alpha) {
  8764. color = parse(color);
  8765. if (color && alpha != null) {
  8766. color[3] = clampCssFloat(alpha);
  8767. return stringify(color, 'rgba');
  8768. }
  8769. }
  8770. /**
  8771. * @param {Array.<string>} colors Color list.
  8772. * @param {string} type 'rgba', 'hsva', ...
  8773. * @return {string} Result color.
  8774. */
  8775. function stringify(arrColor, type) {
  8776. var colorStr = arrColor[0] + ',' + arrColor[1] + ',' + arrColor[2];
  8777. if (type === 'rgba' || type === 'hsva' || type === 'hsla') {
  8778. colorStr += ',' + arrColor[3];
  8779. }
  8780. return type + '(' + colorStr + ')';
  8781. }
  8782. module.exports = {
  8783. parse: parse,
  8784. lift: lift,
  8785. toHex: toHex,
  8786. fastMapToColor: fastMapToColor,
  8787. mapToColor: mapToColor,
  8788. modifyHSL: modifyHSL,
  8789. modifyAlpha: modifyAlpha,
  8790. stringify: stringify
  8791. };
  8792. /***/ },
  8793. /* 40 */
  8794. /***/ function(module, exports, __webpack_require__) {
  8795. var config = __webpack_require__(41);
  8796. /**
  8797. * @exports zrender/tool/log
  8798. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  8799. */
  8800. module.exports = function() {
  8801. if (config.debugMode === 0) {
  8802. return;
  8803. }
  8804. else if (config.debugMode == 1) {
  8805. for (var k in arguments) {
  8806. throw new Error(arguments[k]);
  8807. }
  8808. }
  8809. else if (config.debugMode > 1) {
  8810. for (var k in arguments) {
  8811. console.log(arguments[k]);
  8812. }
  8813. }
  8814. };
  8815. /* for debug
  8816. return function(mes) {
  8817. document.getElementById('wrong-message').innerHTML =
  8818. mes + ' ' + (new Date() - 0)
  8819. + '<br/>'
  8820. + document.getElementById('wrong-message').innerHTML;
  8821. };
  8822. */
  8823. /***/ },
  8824. /* 41 */
  8825. /***/ function(module, exports) {
  8826. var dpr = 1;
  8827. // If in browser environment
  8828. if (typeof window !== 'undefined') {
  8829. dpr = Math.max(window.devicePixelRatio || 1, 1);
  8830. }
  8831. /**
  8832. * config默认配置项
  8833. * @exports zrender/config
  8834. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  8835. */
  8836. var config = {
  8837. /**
  8838. * debug日志选项:catchBrushException为true下有效
  8839. * 0 : 不生成debug数据,发布用
  8840. * 1 : 异常抛出,调试用
  8841. * 2 : 控制台输出,调试用
  8842. */
  8843. debugMode: 0,
  8844. // retina 屏幕优化
  8845. devicePixelRatio: dpr
  8846. };
  8847. module.exports = config;
  8848. /***/ },
  8849. /* 42 */
  8850. /***/ function(module, exports, __webpack_require__) {
  8851. var Group = __webpack_require__(30);
  8852. var componentUtil = __webpack_require__(20);
  8853. var clazzUtil = __webpack_require__(13);
  8854. function Chart() {
  8855. /**
  8856. * @type {module:zrender/container/Group}
  8857. * @readOnly
  8858. */
  8859. this.group = new Group();
  8860. /**
  8861. * @type {string}
  8862. * @readOnly
  8863. */
  8864. this.uid = componentUtil.getUID('viewChart');
  8865. }
  8866. Chart.prototype = {
  8867. type: 'chart',
  8868. /**
  8869. * Init the chart
  8870. * @param {module:echarts/model/Global} ecModel
  8871. * @param {module:echarts/ExtensionAPI} api
  8872. */
  8873. init: function (ecModel, api) {},
  8874. /**
  8875. * Render the chart
  8876. * @param {module:echarts/model/Series} seriesModel
  8877. * @param {module:echarts/model/Global} ecModel
  8878. * @param {module:echarts/ExtensionAPI} api
  8879. * @param {Object} payload
  8880. */
  8881. render: function (seriesModel, ecModel, api, payload) {},
  8882. /**
  8883. * Highlight series or specified data item
  8884. * @param {module:echarts/model/Series} seriesModel
  8885. * @param {module:echarts/model/Global} ecModel
  8886. * @param {module:echarts/ExtensionAPI} api
  8887. * @param {Object} payload
  8888. */
  8889. highlight: function (seriesModel, ecModel, api, payload) {
  8890. toggleHighlight(seriesModel.getData(), payload, 'emphasis');
  8891. },
  8892. /**
  8893. * Downplay series or specified data item
  8894. * @param {module:echarts/model/Series} seriesModel
  8895. * @param {module:echarts/model/Global} ecModel
  8896. * @param {module:echarts/ExtensionAPI} api
  8897. * @param {Object} payload
  8898. */
  8899. downplay: function (seriesModel, ecModel, api, payload) {
  8900. toggleHighlight(seriesModel.getData(), payload, 'normal');
  8901. },
  8902. /**
  8903. * Remove self
  8904. * @param {module:echarts/model/Global} ecModel
  8905. * @param {module:echarts/ExtensionAPI} api
  8906. */
  8907. remove: function (ecModel, api) {
  8908. this.group.removeAll();
  8909. },
  8910. /**
  8911. * Dispose self
  8912. * @param {module:echarts/model/Global} ecModel
  8913. * @param {module:echarts/ExtensionAPI} api
  8914. */
  8915. dispose: function () {}
  8916. };
  8917. var chartProto = Chart.prototype;
  8918. chartProto.updateView
  8919. = chartProto.updateLayout
  8920. = chartProto.updateVisual
  8921. = function (seriesModel, ecModel, api, payload) {
  8922. this.render(seriesModel, ecModel, api, payload);
  8923. };
  8924. /**
  8925. * Set state of single element
  8926. * @param {module:zrender/Element} el
  8927. * @param {string} state
  8928. */
  8929. function elSetState(el, state) {
  8930. if (el) {
  8931. el.trigger(state);
  8932. if (el.type === 'group') {
  8933. for (var i = 0; i < el.childCount(); i++) {
  8934. elSetState(el.childAt(i), state);
  8935. }
  8936. }
  8937. }
  8938. }
  8939. /**
  8940. * @param {module:echarts/data/List} data
  8941. * @param {Object} payload
  8942. * @param {string} state 'normal'|'emphasis'
  8943. * @inner
  8944. */
  8945. function toggleHighlight(data, payload, state) {
  8946. var dataIndex = payload && payload.dataIndex;
  8947. var name = payload && payload.name;
  8948. if (dataIndex != null) {
  8949. var dataIndices = dataIndex instanceof Array ? dataIndex : [dataIndex];
  8950. for (var i = 0, len = dataIndices.length; i < len; i++) {
  8951. elSetState(data.getItemGraphicEl(dataIndices[i]), state);
  8952. }
  8953. }
  8954. else if (name) {
  8955. var names = name instanceof Array ? name : [name];
  8956. for (var i = 0, len = names.length; i < len; i++) {
  8957. var dataIndex = data.indexOfName(names[i]);
  8958. elSetState(data.getItemGraphicEl(dataIndex), state);
  8959. }
  8960. }
  8961. else {
  8962. data.eachItemGraphicEl(function (el) {
  8963. elSetState(el, state);
  8964. });
  8965. }
  8966. }
  8967. // Enable Chart.extend.
  8968. clazzUtil.enableClassExtend(Chart);
  8969. // Add capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on.
  8970. clazzUtil.enableClassManagement(Chart, {registerWhenExtend: true});
  8971. module.exports = Chart;
  8972. /***/ },
  8973. /* 43 */
  8974. /***/ function(module, exports, __webpack_require__) {
  8975. 'use strict';
  8976. var zrUtil = __webpack_require__(4);
  8977. var pathTool = __webpack_require__(44);
  8978. var round = Math.round;
  8979. var Path = __webpack_require__(45);
  8980. var colorTool = __webpack_require__(39);
  8981. var matrix = __webpack_require__(11);
  8982. var vector = __webpack_require__(10);
  8983. var Gradient = __webpack_require__(61);
  8984. var graphic = {};
  8985. graphic.Group = __webpack_require__(30);
  8986. graphic.Image = __webpack_require__(62);
  8987. graphic.Text = __webpack_require__(64);
  8988. graphic.Circle = __webpack_require__(65);
  8989. graphic.Sector = __webpack_require__(66);
  8990. graphic.Ring = __webpack_require__(67);
  8991. graphic.Polygon = __webpack_require__(68);
  8992. graphic.Polyline = __webpack_require__(72);
  8993. graphic.Rect = __webpack_require__(73);
  8994. graphic.Line = __webpack_require__(75);
  8995. graphic.BezierCurve = __webpack_require__(76);
  8996. graphic.Arc = __webpack_require__(77);
  8997. graphic.CompoundPath = __webpack_require__(78);
  8998. graphic.LinearGradient = __webpack_require__(79);
  8999. graphic.RadialGradient = __webpack_require__(80);
  9000. graphic.BoundingRect = __webpack_require__(9);
  9001. /**
  9002. * Extend shape with parameters
  9003. */
  9004. graphic.extendShape = function (opts) {
  9005. return Path.extend(opts);
  9006. };
  9007. /**
  9008. * Extend path
  9009. */
  9010. graphic.extendPath = function (pathData, opts) {
  9011. return pathTool.extendFromString(pathData, opts);
  9012. };
  9013. /**
  9014. * Create a path element from path data string
  9015. * @param {string} pathData
  9016. * @param {Object} opts
  9017. * @param {module:zrender/core/BoundingRect} rect
  9018. * @param {string} [layout=cover] 'center' or 'cover'
  9019. */
  9020. graphic.makePath = function (pathData, opts, rect, layout) {
  9021. var path = pathTool.createFromString(pathData, opts);
  9022. var boundingRect = path.getBoundingRect();
  9023. if (rect) {
  9024. var aspect = boundingRect.width / boundingRect.height;
  9025. if (layout === 'center') {
  9026. // Set rect to center, keep width / height ratio.
  9027. var width = rect.height * aspect;
  9028. var height;
  9029. if (width <= rect.width) {
  9030. height = rect.height;
  9031. }
  9032. else {
  9033. width = rect.width;
  9034. height = width / aspect;
  9035. }
  9036. var cx = rect.x + rect.width / 2;
  9037. var cy = rect.y + rect.height / 2;
  9038. rect.x = cx - width / 2;
  9039. rect.y = cy - height / 2;
  9040. rect.width = width;
  9041. rect.height = height;
  9042. }
  9043. this.resizePath(path, rect);
  9044. }
  9045. return path;
  9046. };
  9047. graphic.mergePath = pathTool.mergePath,
  9048. /**
  9049. * Resize a path to fit the rect
  9050. * @param {module:zrender/graphic/Path} path
  9051. * @param {Object} rect
  9052. */
  9053. graphic.resizePath = function (path, rect) {
  9054. if (!path.applyTransform) {
  9055. return;
  9056. }
  9057. var pathRect = path.getBoundingRect();
  9058. var m = pathRect.calculateTransform(rect);
  9059. path.applyTransform(m);
  9060. };
  9061. /**
  9062. * Sub pixel optimize line for canvas
  9063. *
  9064. * @param {Object} param
  9065. * @param {Object} [param.shape]
  9066. * @param {number} [param.shape.x1]
  9067. * @param {number} [param.shape.y1]
  9068. * @param {number} [param.shape.x2]
  9069. * @param {number} [param.shape.y2]
  9070. * @param {Object} [param.style]
  9071. * @param {number} [param.style.lineWidth]
  9072. * @return {Object} Modified param
  9073. */
  9074. graphic.subPixelOptimizeLine = function (param) {
  9075. var subPixelOptimize = graphic.subPixelOptimize;
  9076. var shape = param.shape;
  9077. var lineWidth = param.style.lineWidth;
  9078. if (round(shape.x1 * 2) === round(shape.x2 * 2)) {
  9079. shape.x1 = shape.x2 = subPixelOptimize(shape.x1, lineWidth, true);
  9080. }
  9081. if (round(shape.y1 * 2) === round(shape.y2 * 2)) {
  9082. shape.y1 = shape.y2 = subPixelOptimize(shape.y1, lineWidth, true);
  9083. }
  9084. return param;
  9085. };
  9086. /**
  9087. * Sub pixel optimize rect for canvas
  9088. *
  9089. * @param {Object} param
  9090. * @param {Object} [param.shape]
  9091. * @param {number} [param.shape.x]
  9092. * @param {number} [param.shape.y]
  9093. * @param {number} [param.shape.width]
  9094. * @param {number} [param.shape.height]
  9095. * @param {Object} [param.style]
  9096. * @param {number} [param.style.lineWidth]
  9097. * @return {Object} Modified param
  9098. */
  9099. graphic.subPixelOptimizeRect = function (param) {
  9100. var subPixelOptimize = graphic.subPixelOptimize;
  9101. var shape = param.shape;
  9102. var lineWidth = param.style.lineWidth;
  9103. var originX = shape.x;
  9104. var originY = shape.y;
  9105. var originWidth = shape.width;
  9106. var originHeight = shape.height;
  9107. shape.x = subPixelOptimize(shape.x, lineWidth, true);
  9108. shape.y = subPixelOptimize(shape.y, lineWidth, true);
  9109. shape.width = Math.max(
  9110. subPixelOptimize(originX + originWidth, lineWidth, false) - shape.x,
  9111. originWidth === 0 ? 0 : 1
  9112. );
  9113. shape.height = Math.max(
  9114. subPixelOptimize(originY + originHeight, lineWidth, false) - shape.y,
  9115. originHeight === 0 ? 0 : 1
  9116. );
  9117. return param;
  9118. };
  9119. /**
  9120. * Sub pixel optimize for canvas
  9121. *
  9122. * @param {number} position Coordinate, such as x, y
  9123. * @param {number} lineWidth Should be nonnegative integer.
  9124. * @param {boolean=} positiveOrNegative Default false (negative).
  9125. * @return {number} Optimized position.
  9126. */
  9127. graphic.subPixelOptimize = function (position, lineWidth, positiveOrNegative) {
  9128. // Assure that (position + lineWidth / 2) is near integer edge,
  9129. // otherwise line will be fuzzy in canvas.
  9130. var doubledPosition = round(position * 2);
  9131. return (doubledPosition + round(lineWidth)) % 2 === 0
  9132. ? doubledPosition / 2
  9133. : (doubledPosition + (positiveOrNegative ? 1 : -1)) / 2;
  9134. };
  9135. function hasFillOrStroke(fillOrStroke) {
  9136. return fillOrStroke != null && fillOrStroke != 'none';
  9137. }
  9138. function liftColor(color) {
  9139. return typeof color === 'string' ? colorTool.lift(color, -0.1) : color;
  9140. }
  9141. /**
  9142. * @private
  9143. */
  9144. function cacheElementStl(el) {
  9145. if (el.__hoverStlDirty) {
  9146. var stroke = el.style.stroke;
  9147. var fill = el.style.fill;
  9148. // Create hoverStyle on mouseover
  9149. var hoverStyle = el.__hoverStl;
  9150. hoverStyle.fill = hoverStyle.fill
  9151. || (hasFillOrStroke(fill) ? liftColor(fill) : null);
  9152. hoverStyle.stroke = hoverStyle.stroke
  9153. || (hasFillOrStroke(stroke) ? liftColor(stroke) : null);
  9154. var normalStyle = {};
  9155. for (var name in hoverStyle) {
  9156. if (hoverStyle.hasOwnProperty(name)) {
  9157. normalStyle[name] = el.style[name];
  9158. }
  9159. }
  9160. el.__normalStl = normalStyle;
  9161. el.__hoverStlDirty = false;
  9162. }
  9163. }
  9164. /**
  9165. * @private
  9166. */
  9167. function doSingleEnterHover(el) {
  9168. if (el.__isHover) {
  9169. return;
  9170. }
  9171. cacheElementStl(el);
  9172. if (el.useHoverLayer) {
  9173. el.__zr && el.__zr.addHover(el, el.__hoverStl);
  9174. }
  9175. else {
  9176. el.setStyle(el.__hoverStl);
  9177. el.z2 += 1;
  9178. }
  9179. el.__isHover = true;
  9180. }
  9181. /**
  9182. * @inner
  9183. */
  9184. function doSingleLeaveHover(el) {
  9185. if (!el.__isHover) {
  9186. return;
  9187. }
  9188. var normalStl = el.__normalStl;
  9189. if (el.useHoverLayer) {
  9190. el.__zr && el.__zr.removeHover(el);
  9191. }
  9192. else {
  9193. normalStl && el.setStyle(normalStl);
  9194. el.z2 -= 1;
  9195. }
  9196. el.__isHover = false;
  9197. }
  9198. /**
  9199. * @inner
  9200. */
  9201. function doEnterHover(el) {
  9202. el.type === 'group'
  9203. ? el.traverse(function (child) {
  9204. if (child.type !== 'group') {
  9205. doSingleEnterHover(child);
  9206. }
  9207. })
  9208. : doSingleEnterHover(el);
  9209. }
  9210. function doLeaveHover(el) {
  9211. el.type === 'group'
  9212. ? el.traverse(function (child) {
  9213. if (child.type !== 'group') {
  9214. doSingleLeaveHover(child);
  9215. }
  9216. })
  9217. : doSingleLeaveHover(el);
  9218. }
  9219. /**
  9220. * @inner
  9221. */
  9222. function setElementHoverStl(el, hoverStl) {
  9223. // If element has sepcified hoverStyle, then use it instead of given hoverStyle
  9224. // Often used when item group has a label element and it's hoverStyle is different
  9225. el.__hoverStl = el.hoverStyle || hoverStl || {};
  9226. el.__hoverStlDirty = true;
  9227. if (el.__isHover) {
  9228. cacheElementStl(el);
  9229. }
  9230. }
  9231. /**
  9232. * @inner
  9233. */
  9234. function onElementMouseOver() {
  9235. // Only if element is not in emphasis status
  9236. !this.__isEmphasis && doEnterHover(this);
  9237. }
  9238. /**
  9239. * @inner
  9240. */
  9241. function onElementMouseOut() {
  9242. // Only if element is not in emphasis status
  9243. !this.__isEmphasis && doLeaveHover(this);
  9244. }
  9245. /**
  9246. * @inner
  9247. */
  9248. function enterEmphasis() {
  9249. this.__isEmphasis = true;
  9250. doEnterHover(this);
  9251. }
  9252. /**
  9253. * @inner
  9254. */
  9255. function leaveEmphasis() {
  9256. this.__isEmphasis = false;
  9257. doLeaveHover(this);
  9258. }
  9259. /**
  9260. * Set hover style of element
  9261. * @param {module:zrender/Element} el
  9262. * @param {Object} [hoverStyle]
  9263. */
  9264. graphic.setHoverStyle = function (el, hoverStyle) {
  9265. el.type === 'group'
  9266. ? el.traverse(function (child) {
  9267. if (child.type !== 'group') {
  9268. setElementHoverStl(child, hoverStyle);
  9269. }
  9270. })
  9271. : setElementHoverStl(el, hoverStyle);
  9272. // Remove previous bound handlers
  9273. el.on('mouseover', onElementMouseOver)
  9274. .on('mouseout', onElementMouseOut);
  9275. // Emphasis, normal can be triggered manually
  9276. el.on('emphasis', enterEmphasis)
  9277. .on('normal', leaveEmphasis);
  9278. };
  9279. /**
  9280. * Set text option in the style
  9281. * @param {Object} textStyle
  9282. * @param {module:echarts/model/Model} labelModel
  9283. * @param {string} color
  9284. */
  9285. graphic.setText = function (textStyle, labelModel, color) {
  9286. var labelPosition = labelModel.getShallow('position') || 'inside';
  9287. var labelColor = labelPosition.indexOf('inside') >= 0 ? 'white' : color;
  9288. var textStyleModel = labelModel.getModel('textStyle');
  9289. zrUtil.extend(textStyle, {
  9290. textDistance: labelModel.getShallow('distance') || 5,
  9291. textFont: textStyleModel.getFont(),
  9292. textPosition: labelPosition,
  9293. textFill: textStyleModel.getTextColor() || labelColor
  9294. });
  9295. };
  9296. function animateOrSetProps(isUpdate, el, props, animatableModel, dataIndex, cb) {
  9297. if (typeof dataIndex === 'function') {
  9298. cb = dataIndex;
  9299. dataIndex = null;
  9300. }
  9301. var animationEnabled = animatableModel
  9302. && (
  9303. animatableModel.ifEnableAnimation
  9304. ? animatableModel.ifEnableAnimation()
  9305. // Directly use animation property
  9306. : animatableModel.getShallow('animation')
  9307. );
  9308. if (animationEnabled) {
  9309. var postfix = isUpdate ? 'Update' : '';
  9310. var duration = animatableModel
  9311. && animatableModel.getShallow('animationDuration' + postfix);
  9312. var animationEasing = animatableModel
  9313. && animatableModel.getShallow('animationEasing' + postfix);
  9314. var animationDelay = animatableModel
  9315. && animatableModel.getShallow('animationDelay' + postfix);
  9316. if (typeof animationDelay === 'function') {
  9317. animationDelay = animationDelay(dataIndex);
  9318. }
  9319. duration > 0
  9320. ? el.animateTo(props, duration, animationDelay || 0, animationEasing, cb)
  9321. : (el.attr(props), cb && cb());
  9322. }
  9323. else {
  9324. el.attr(props);
  9325. cb && cb();
  9326. }
  9327. }
  9328. /**
  9329. * Update graphic element properties with or without animation according to the configuration in series
  9330. * @param {module:zrender/Element} el
  9331. * @param {Object} props
  9332. * @param {module:echarts/model/Model} [animatableModel]
  9333. * @param {number} [dataIndex]
  9334. * @param {Function} [cb]
  9335. * @example
  9336. * graphic.updateProps(el, {
  9337. * position: [100, 100]
  9338. * }, seriesModel, dataIndex, function () { console.log('Animation done!'); });
  9339. * // Or
  9340. * graphic.updateProps(el, {
  9341. * position: [100, 100]
  9342. * }, seriesModel, function () { console.log('Animation done!'); });
  9343. */
  9344. graphic.updateProps = function (el, props, animatableModel, dataIndex, cb) {
  9345. animateOrSetProps(true, el, props, animatableModel, dataIndex, cb);
  9346. };
  9347. /**
  9348. * Init graphic element properties with or without animation according to the configuration in series
  9349. * @param {module:zrender/Element} el
  9350. * @param {Object} props
  9351. * @param {module:echarts/model/Model} [animatableModel]
  9352. * @param {number} [dataIndex]
  9353. * @param {Function} cb
  9354. */
  9355. graphic.initProps = function (el, props, animatableModel, dataIndex, cb) {
  9356. animateOrSetProps(false, el, props, animatableModel, dataIndex, cb);
  9357. };
  9358. /**
  9359. * Get transform matrix of target (param target),
  9360. * in coordinate of its ancestor (param ancestor)
  9361. *
  9362. * @param {module:zrender/mixin/Transformable} target
  9363. * @param {module:zrender/mixin/Transformable} [ancestor]
  9364. */
  9365. graphic.getTransform = function (target, ancestor) {
  9366. var mat = matrix.identity([]);
  9367. while (target && target !== ancestor) {
  9368. matrix.mul(mat, target.getLocalTransform(), mat);
  9369. target = target.parent;
  9370. }
  9371. return mat;
  9372. };
  9373. /**
  9374. * Apply transform to an vertex.
  9375. * @param {Array.<number>} vertex [x, y]
  9376. * @param {Array.<number>} transform Transform matrix: like [1, 0, 0, 1, 0, 0]
  9377. * @param {boolean=} invert Whether use invert matrix.
  9378. * @return {Array.<number>} [x, y]
  9379. */
  9380. graphic.applyTransform = function (vertex, transform, invert) {
  9381. if (invert) {
  9382. transform = matrix.invert([], transform);
  9383. }
  9384. return vector.applyTransform([], vertex, transform);
  9385. };
  9386. /**
  9387. * @param {string} direction 'left' 'right' 'top' 'bottom'
  9388. * @param {Array.<number>} transform Transform matrix: like [1, 0, 0, 1, 0, 0]
  9389. * @param {boolean=} invert Whether use invert matrix.
  9390. * @return {string} Transformed direction. 'left' 'right' 'top' 'bottom'
  9391. */
  9392. graphic.transformDirection = function (direction, transform, invert) {
  9393. // Pick a base, ensure that transform result will not be (0, 0).
  9394. var hBase = (transform[4] === 0 || transform[5] === 0 || transform[0] === 0)
  9395. ? 1 : Math.abs(2 * transform[4] / transform[0]);
  9396. var vBase = (transform[4] === 0 || transform[5] === 0 || transform[2] === 0)
  9397. ? 1 : Math.abs(2 * transform[4] / transform[2]);
  9398. var vertex = [
  9399. direction === 'left' ? -hBase : direction === 'right' ? hBase : 0,
  9400. direction === 'top' ? -vBase : direction === 'bottom' ? vBase : 0
  9401. ];
  9402. vertex = graphic.applyTransform(vertex, transform, invert);
  9403. return Math.abs(vertex[0]) > Math.abs(vertex[1])
  9404. ? (vertex[0] > 0 ? 'right' : 'left')
  9405. : (vertex[1] > 0 ? 'bottom' : 'top');
  9406. };
  9407. /**
  9408. * Apply group transition animation from g1 to g2
  9409. */
  9410. graphic.groupTransition = function (g1, g2, animatableModel, cb) {
  9411. if (!g1 || !g2) {
  9412. return;
  9413. }
  9414. function getElMap(g) {
  9415. var elMap = {};
  9416. g.traverse(function (el) {
  9417. if (!el.isGroup && el.anid) {
  9418. elMap[el.anid] = el;
  9419. }
  9420. });
  9421. return elMap;
  9422. }
  9423. function getAnimatableProps(el) {
  9424. var obj = {
  9425. position: vector.clone(el.position),
  9426. rotation: el.rotation
  9427. };
  9428. if (el.shape) {
  9429. obj.shape = zrUtil.extend({}, el.shape);
  9430. }
  9431. return obj;
  9432. }
  9433. var elMap1 = getElMap(g1);
  9434. g2.traverse(function (el) {
  9435. if (!el.isGroup && el.anid) {
  9436. var oldEl = elMap1[el.anid];
  9437. if (oldEl) {
  9438. var newProp = getAnimatableProps(el);
  9439. el.attr(getAnimatableProps(oldEl));
  9440. graphic.updateProps(el, newProp, animatableModel, el.dataIndex);
  9441. }
  9442. // else {
  9443. // if (el.previousProps) {
  9444. // graphic.updateProps
  9445. // }
  9446. // }
  9447. }
  9448. });
  9449. };
  9450. module.exports = graphic;
  9451. /***/ },
  9452. /* 44 */
  9453. /***/ function(module, exports, __webpack_require__) {
  9454. var Path = __webpack_require__(45);
  9455. var PathProxy = __webpack_require__(49);
  9456. var transformPath = __webpack_require__(60);
  9457. var matrix = __webpack_require__(11);
  9458. // command chars
  9459. var cc = [
  9460. 'm', 'M', 'l', 'L', 'v', 'V', 'h', 'H', 'z', 'Z',
  9461. 'c', 'C', 'q', 'Q', 't', 'T', 's', 'S', 'a', 'A'
  9462. ];
  9463. var mathSqrt = Math.sqrt;
  9464. var mathSin = Math.sin;
  9465. var mathCos = Math.cos;
  9466. var PI = Math.PI;
  9467. var vMag = function(v) {
  9468. return Math.sqrt(v[0] * v[0] + v[1] * v[1]);
  9469. };
  9470. var vRatio = function(u, v) {
  9471. return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v));
  9472. };
  9473. var vAngle = function(u, v) {
  9474. return (u[0] * v[1] < u[1] * v[0] ? -1 : 1)
  9475. * Math.acos(vRatio(u, v));
  9476. };
  9477. function processArc(x1, y1, x2, y2, fa, fs, rx, ry, psiDeg, cmd, path) {
  9478. var psi = psiDeg * (PI / 180.0);
  9479. var xp = mathCos(psi) * (x1 - x2) / 2.0
  9480. + mathSin(psi) * (y1 - y2) / 2.0;
  9481. var yp = -1 * mathSin(psi) * (x1 - x2) / 2.0
  9482. + mathCos(psi) * (y1 - y2) / 2.0;
  9483. var lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry);
  9484. if (lambda > 1) {
  9485. rx *= mathSqrt(lambda);
  9486. ry *= mathSqrt(lambda);
  9487. }
  9488. var f = (fa === fs ? -1 : 1)
  9489. * mathSqrt((((rx * rx) * (ry * ry))
  9490. - ((rx * rx) * (yp * yp))
  9491. - ((ry * ry) * (xp * xp))) / ((rx * rx) * (yp * yp)
  9492. + (ry * ry) * (xp * xp))
  9493. ) || 0;
  9494. var cxp = f * rx * yp / ry;
  9495. var cyp = f * -ry * xp / rx;
  9496. var cx = (x1 + x2) / 2.0
  9497. + mathCos(psi) * cxp
  9498. - mathSin(psi) * cyp;
  9499. var cy = (y1 + y2) / 2.0
  9500. + mathSin(psi) * cxp
  9501. + mathCos(psi) * cyp;
  9502. var theta = vAngle([ 1, 0 ], [ (xp - cxp) / rx, (yp - cyp) / ry ]);
  9503. var u = [ (xp - cxp) / rx, (yp - cyp) / ry ];
  9504. var v = [ (-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry ];
  9505. var dTheta = vAngle(u, v);
  9506. if (vRatio(u, v) <= -1) {
  9507. dTheta = PI;
  9508. }
  9509. if (vRatio(u, v) >= 1) {
  9510. dTheta = 0;
  9511. }
  9512. if (fs === 0 && dTheta > 0) {
  9513. dTheta = dTheta - 2 * PI;
  9514. }
  9515. if (fs === 1 && dTheta < 0) {
  9516. dTheta = dTheta + 2 * PI;
  9517. }
  9518. path.addData(cmd, cx, cy, rx, ry, theta, dTheta, psi, fs);
  9519. }
  9520. function createPathProxyFromString(data) {
  9521. if (!data) {
  9522. return [];
  9523. }
  9524. // command string
  9525. var cs = data.replace(/-/g, ' -')
  9526. .replace(/ /g, ' ')
  9527. .replace(/ /g, ',')
  9528. .replace(/,,/g, ',');
  9529. var n;
  9530. // create pipes so that we can split the data
  9531. for (n = 0; n < cc.length; n++) {
  9532. cs = cs.replace(new RegExp(cc[n], 'g'), '|' + cc[n]);
  9533. }
  9534. // create array
  9535. var arr = cs.split('|');
  9536. // init context point
  9537. var cpx = 0;
  9538. var cpy = 0;
  9539. var path = new PathProxy();
  9540. var CMD = PathProxy.CMD;
  9541. var prevCmd;
  9542. for (n = 1; n < arr.length; n++) {
  9543. var str = arr[n];
  9544. var c = str.charAt(0);
  9545. var off = 0;
  9546. var p = str.slice(1).replace(/e,-/g, 'e-').split(',');
  9547. var cmd;
  9548. if (p.length > 0 && p[0] === '') {
  9549. p.shift();
  9550. }
  9551. for (var i = 0; i < p.length; i++) {
  9552. p[i] = parseFloat(p[i]);
  9553. }
  9554. while (off < p.length && !isNaN(p[off])) {
  9555. if (isNaN(p[0])) {
  9556. break;
  9557. }
  9558. var ctlPtx;
  9559. var ctlPty;
  9560. var rx;
  9561. var ry;
  9562. var psi;
  9563. var fa;
  9564. var fs;
  9565. var x1 = cpx;
  9566. var y1 = cpy;
  9567. // convert l, H, h, V, and v to L
  9568. switch (c) {
  9569. case 'l':
  9570. cpx += p[off++];
  9571. cpy += p[off++];
  9572. cmd = CMD.L;
  9573. path.addData(cmd, cpx, cpy);
  9574. break;
  9575. case 'L':
  9576. cpx = p[off++];
  9577. cpy = p[off++];
  9578. cmd = CMD.L;
  9579. path.addData(cmd, cpx, cpy);
  9580. break;
  9581. case 'm':
  9582. cpx += p[off++];
  9583. cpy += p[off++];
  9584. cmd = CMD.M;
  9585. path.addData(cmd, cpx, cpy);
  9586. c = 'l';
  9587. break;
  9588. case 'M':
  9589. cpx = p[off++];
  9590. cpy = p[off++];
  9591. cmd = CMD.M;
  9592. path.addData(cmd, cpx, cpy);
  9593. c = 'L';
  9594. break;
  9595. case 'h':
  9596. cpx += p[off++];
  9597. cmd = CMD.L;
  9598. path.addData(cmd, cpx, cpy);
  9599. break;
  9600. case 'H':
  9601. cpx = p[off++];
  9602. cmd = CMD.L;
  9603. path.addData(cmd, cpx, cpy);
  9604. break;
  9605. case 'v':
  9606. cpy += p[off++];
  9607. cmd = CMD.L;
  9608. path.addData(cmd, cpx, cpy);
  9609. break;
  9610. case 'V':
  9611. cpy = p[off++];
  9612. cmd = CMD.L;
  9613. path.addData(cmd, cpx, cpy);
  9614. break;
  9615. case 'C':
  9616. cmd = CMD.C;
  9617. path.addData(
  9618. cmd, p[off++], p[off++], p[off++], p[off++], p[off++], p[off++]
  9619. );
  9620. cpx = p[off - 2];
  9621. cpy = p[off - 1];
  9622. break;
  9623. case 'c':
  9624. cmd = CMD.C;
  9625. path.addData(
  9626. cmd,
  9627. p[off++] + cpx, p[off++] + cpy,
  9628. p[off++] + cpx, p[off++] + cpy,
  9629. p[off++] + cpx, p[off++] + cpy
  9630. );
  9631. cpx += p[off - 2];
  9632. cpy += p[off - 1];
  9633. break;
  9634. case 'S':
  9635. ctlPtx = cpx;
  9636. ctlPty = cpy;
  9637. var len = path.len();
  9638. var pathData = path.data;
  9639. if (prevCmd === CMD.C) {
  9640. ctlPtx += cpx - pathData[len - 4];
  9641. ctlPty += cpy - pathData[len - 3];
  9642. }
  9643. cmd = CMD.C;
  9644. x1 = p[off++];
  9645. y1 = p[off++];
  9646. cpx = p[off++];
  9647. cpy = p[off++];
  9648. path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy);
  9649. break;
  9650. case 's':
  9651. ctlPtx = cpx;
  9652. ctlPty = cpy;
  9653. var len = path.len();
  9654. var pathData = path.data;
  9655. if (prevCmd === CMD.C) {
  9656. ctlPtx += cpx - pathData[len - 4];
  9657. ctlPty += cpy - pathData[len - 3];
  9658. }
  9659. cmd = CMD.C;
  9660. x1 = cpx + p[off++];
  9661. y1 = cpy + p[off++];
  9662. cpx += p[off++];
  9663. cpy += p[off++];
  9664. path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy);
  9665. break;
  9666. case 'Q':
  9667. x1 = p[off++];
  9668. y1 = p[off++];
  9669. cpx = p[off++];
  9670. cpy = p[off++];
  9671. cmd = CMD.Q;
  9672. path.addData(cmd, x1, y1, cpx, cpy);
  9673. break;
  9674. case 'q':
  9675. x1 = p[off++] + cpx;
  9676. y1 = p[off++] + cpy;
  9677. cpx += p[off++];
  9678. cpy += p[off++];
  9679. cmd = CMD.Q;
  9680. path.addData(cmd, x1, y1, cpx, cpy);
  9681. break;
  9682. case 'T':
  9683. ctlPtx = cpx;
  9684. ctlPty = cpy;
  9685. var len = path.len();
  9686. var pathData = path.data;
  9687. if (prevCmd === CMD.Q) {
  9688. ctlPtx += cpx - pathData[len - 4];
  9689. ctlPty += cpy - pathData[len - 3];
  9690. }
  9691. cpx = p[off++];
  9692. cpy = p[off++];
  9693. cmd = CMD.Q;
  9694. path.addData(cmd, ctlPtx, ctlPty, cpx, cpy);
  9695. break;
  9696. case 't':
  9697. ctlPtx = cpx;
  9698. ctlPty = cpy;
  9699. var len = path.len();
  9700. var pathData = path.data;
  9701. if (prevCmd === CMD.Q) {
  9702. ctlPtx += cpx - pathData[len - 4];
  9703. ctlPty += cpy - pathData[len - 3];
  9704. }
  9705. cpx += p[off++];
  9706. cpy += p[off++];
  9707. cmd = CMD.Q;
  9708. path.addData(cmd, ctlPtx, ctlPty, cpx, cpy);
  9709. break;
  9710. case 'A':
  9711. rx = p[off++];
  9712. ry = p[off++];
  9713. psi = p[off++];
  9714. fa = p[off++];
  9715. fs = p[off++];
  9716. x1 = cpx, y1 = cpy;
  9717. cpx = p[off++];
  9718. cpy = p[off++];
  9719. cmd = CMD.A;
  9720. processArc(
  9721. x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path
  9722. );
  9723. break;
  9724. case 'a':
  9725. rx = p[off++];
  9726. ry = p[off++];
  9727. psi = p[off++];
  9728. fa = p[off++];
  9729. fs = p[off++];
  9730. x1 = cpx, y1 = cpy;
  9731. cpx += p[off++];
  9732. cpy += p[off++];
  9733. cmd = CMD.A;
  9734. processArc(
  9735. x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path
  9736. );
  9737. break;
  9738. }
  9739. }
  9740. if (c === 'z' || c === 'Z') {
  9741. cmd = CMD.Z;
  9742. path.addData(cmd);
  9743. }
  9744. prevCmd = cmd;
  9745. }
  9746. path.toStatic();
  9747. return path;
  9748. }
  9749. // TODO Optimize double memory cost problem
  9750. function createPathOptions(str, opts) {
  9751. var pathProxy = createPathProxyFromString(str);
  9752. var transform;
  9753. opts = opts || {};
  9754. opts.buildPath = function (path) {
  9755. path.setData(pathProxy.data);
  9756. transform && transformPath(path, transform);
  9757. // Svg and vml renderer don't have context
  9758. var ctx = path.getContext();
  9759. if (ctx) {
  9760. path.rebuildPath(ctx);
  9761. }
  9762. };
  9763. opts.applyTransform = function (m) {
  9764. if (!transform) {
  9765. transform = matrix.create();
  9766. }
  9767. matrix.mul(transform, m, transform);
  9768. };
  9769. return opts;
  9770. }
  9771. module.exports = {
  9772. /**
  9773. * Create a Path object from path string data
  9774. * http://www.w3.org/TR/SVG/paths.html#PathData
  9775. * @param {Object} opts Other options
  9776. */
  9777. createFromString: function (str, opts) {
  9778. return new Path(createPathOptions(str, opts));
  9779. },
  9780. /**
  9781. * Create a Path class from path string data
  9782. * @param {string} str
  9783. * @param {Object} opts Other options
  9784. */
  9785. extendFromString: function (str, opts) {
  9786. return Path.extend(createPathOptions(str, opts));
  9787. },
  9788. /**
  9789. * Merge multiple paths
  9790. */
  9791. // TODO Apply transform
  9792. // TODO stroke dash
  9793. // TODO Optimize double memory cost problem
  9794. mergePath: function (pathEls, opts) {
  9795. var pathList = [];
  9796. var len = pathEls.length;
  9797. for (var i = 0; i < len; i++) {
  9798. var pathEl = pathEls[i];
  9799. if (pathEl.__dirty) {
  9800. pathEl.buildPath(pathEl.path, pathEl.shape, true);
  9801. }
  9802. pathList.push(pathEl.path);
  9803. }
  9804. var pathBundle = new Path(opts);
  9805. pathBundle.buildPath = function (path) {
  9806. path.appendPath(pathList);
  9807. // Svg and vml renderer don't have context
  9808. var ctx = path.getContext();
  9809. if (ctx) {
  9810. path.rebuildPath(ctx);
  9811. }
  9812. };
  9813. return pathBundle;
  9814. }
  9815. };
  9816. /***/ },
  9817. /* 45 */
  9818. /***/ function(module, exports, __webpack_require__) {
  9819. /**
  9820. * Path element
  9821. * @module zrender/graphic/Path
  9822. */
  9823. var Displayable = __webpack_require__(46);
  9824. var zrUtil = __webpack_require__(4);
  9825. var PathProxy = __webpack_require__(49);
  9826. var pathContain = __webpack_require__(52);
  9827. var Pattern = __webpack_require__(59);
  9828. var getCanvasPattern = Pattern.prototype.getCanvasPattern;
  9829. var abs = Math.abs;
  9830. /**
  9831. * @alias module:zrender/graphic/Path
  9832. * @extends module:zrender/graphic/Displayable
  9833. * @constructor
  9834. * @param {Object} opts
  9835. */
  9836. function Path(opts) {
  9837. Displayable.call(this, opts);
  9838. /**
  9839. * @type {module:zrender/core/PathProxy}
  9840. * @readOnly
  9841. */
  9842. this.path = new PathProxy();
  9843. }
  9844. Path.prototype = {
  9845. constructor: Path,
  9846. type: 'path',
  9847. __dirtyPath: true,
  9848. strokeContainThreshold: 5,
  9849. brush: function (ctx, prevEl) {
  9850. var style = this.style;
  9851. var path = this.path;
  9852. var hasStroke = style.hasStroke();
  9853. var hasFill = style.hasFill();
  9854. var fill = style.fill;
  9855. var stroke = style.stroke;
  9856. var hasFillGradient = hasFill && !!(fill.colorStops);
  9857. var hasStrokeGradient = hasStroke && !!(stroke.colorStops);
  9858. var hasFillPattern = hasFill && !!(fill.image);
  9859. var hasStrokePattern = hasStroke && !!(stroke.image);
  9860. style.bind(ctx, this, prevEl);
  9861. this.setTransform(ctx);
  9862. if (this.__dirty) {
  9863. var rect = this.getBoundingRect();
  9864. // Update gradient because bounding rect may changed
  9865. if (hasFillGradient) {
  9866. this._fillGradient = style.getGradient(ctx, fill, rect);
  9867. }
  9868. if (hasStrokeGradient) {
  9869. this._strokeGradient = style.getGradient(ctx, stroke, rect);
  9870. }
  9871. }
  9872. // Use the gradient or pattern
  9873. if (hasFillGradient) {
  9874. // PENDING If may have affect the state
  9875. ctx.fillStyle = this._fillGradient;
  9876. }
  9877. else if (hasFillPattern) {
  9878. ctx.fillStyle = getCanvasPattern.call(fill, ctx);
  9879. }
  9880. if (hasStrokeGradient) {
  9881. ctx.strokeStyle = this._strokeGradient;
  9882. }
  9883. else if (hasStrokePattern) {
  9884. ctx.strokeStyle = getCanvasPattern.call(stroke, ctx);
  9885. }
  9886. var lineDash = style.lineDash;
  9887. var lineDashOffset = style.lineDashOffset;
  9888. var ctxLineDash = !!ctx.setLineDash;
  9889. // Update path sx, sy
  9890. var scale = this.getGlobalScale();
  9891. path.setScale(scale[0], scale[1]);
  9892. // Proxy context
  9893. // Rebuild path in following 2 cases
  9894. // 1. Path is dirty
  9895. // 2. Path needs javascript implemented lineDash stroking.
  9896. // In this case, lineDash information will not be saved in PathProxy
  9897. if (this.__dirtyPath || (
  9898. lineDash && !ctxLineDash && hasStroke
  9899. )) {
  9900. path = this.path.beginPath(ctx);
  9901. // Setting line dash before build path
  9902. if (lineDash && !ctxLineDash) {
  9903. path.setLineDash(lineDash);
  9904. path.setLineDashOffset(lineDashOffset);
  9905. }
  9906. this.buildPath(path, this.shape, false);
  9907. // Clear path dirty flag
  9908. this.__dirtyPath = false;
  9909. }
  9910. else {
  9911. // Replay path building
  9912. ctx.beginPath();
  9913. this.path.rebuildPath(ctx);
  9914. }
  9915. hasFill && path.fill(ctx);
  9916. if (lineDash && ctxLineDash) {
  9917. ctx.setLineDash(lineDash);
  9918. ctx.lineDashOffset = lineDashOffset;
  9919. }
  9920. hasStroke && path.stroke(ctx);
  9921. if (lineDash && ctxLineDash) {
  9922. // PENDING
  9923. // Remove lineDash
  9924. ctx.setLineDash([]);
  9925. }
  9926. this.restoreTransform(ctx);
  9927. // Draw rect text
  9928. if (style.text || style.text === 0) {
  9929. // var rect = this.getBoundingRect();
  9930. this.drawRectText(ctx, this.getBoundingRect());
  9931. }
  9932. },
  9933. // When bundling path, some shape may decide if use moveTo to begin a new subpath or closePath
  9934. // Like in circle
  9935. buildPath: function (ctx, shapeCfg, inBundle) {},
  9936. getBoundingRect: function () {
  9937. var rect = this._rect;
  9938. var style = this.style;
  9939. var needsUpdateRect = !rect;
  9940. if (needsUpdateRect) {
  9941. var path = this.path;
  9942. if (this.__dirtyPath) {
  9943. path.beginPath();
  9944. this.buildPath(path, this.shape, false);
  9945. }
  9946. rect = path.getBoundingRect();
  9947. }
  9948. this._rect = rect;
  9949. if (style.hasStroke()) {
  9950. // Needs update rect with stroke lineWidth when
  9951. // 1. Element changes scale or lineWidth
  9952. // 2. Shape is changed
  9953. var rectWithStroke = this._rectWithStroke || (this._rectWithStroke = rect.clone());
  9954. if (this.__dirty || needsUpdateRect) {
  9955. rectWithStroke.copy(rect);
  9956. // FIXME Must after updateTransform
  9957. var w = style.lineWidth;
  9958. // PENDING, Min line width is needed when line is horizontal or vertical
  9959. var lineScale = style.strokeNoScale ? this.getLineScale() : 1;
  9960. // Only add extra hover lineWidth when there are no fill
  9961. if (!style.hasFill()) {
  9962. w = Math.max(w, this.strokeContainThreshold || 4);
  9963. }
  9964. // Consider line width
  9965. // Line scale can't be 0;
  9966. if (lineScale > 1e-10) {
  9967. rectWithStroke.width += w / lineScale;
  9968. rectWithStroke.height += w / lineScale;
  9969. rectWithStroke.x -= w / lineScale / 2;
  9970. rectWithStroke.y -= w / lineScale / 2;
  9971. }
  9972. }
  9973. // Return rect with stroke
  9974. return rectWithStroke;
  9975. }
  9976. return rect;
  9977. },
  9978. contain: function (x, y) {
  9979. var localPos = this.transformCoordToLocal(x, y);
  9980. var rect = this.getBoundingRect();
  9981. var style = this.style;
  9982. x = localPos[0];
  9983. y = localPos[1];
  9984. if (rect.contain(x, y)) {
  9985. var pathData = this.path.data;
  9986. if (style.hasStroke()) {
  9987. var lineWidth = style.lineWidth;
  9988. var lineScale = style.strokeNoScale ? this.getLineScale() : 1;
  9989. // Line scale can't be 0;
  9990. if (lineScale > 1e-10) {
  9991. // Only add extra hover lineWidth when there are no fill
  9992. if (!style.hasFill()) {
  9993. lineWidth = Math.max(lineWidth, this.strokeContainThreshold);
  9994. }
  9995. if (pathContain.containStroke(
  9996. pathData, lineWidth / lineScale, x, y
  9997. )) {
  9998. return true;
  9999. }
  10000. }
  10001. }
  10002. if (style.hasFill()) {
  10003. return pathContain.contain(pathData, x, y);
  10004. }
  10005. }
  10006. return false;
  10007. },
  10008. /**
  10009. * @param {boolean} dirtyPath
  10010. */
  10011. dirty: function (dirtyPath) {
  10012. if (dirtyPath == null) {
  10013. dirtyPath = true;
  10014. }
  10015. // Only mark dirty, not mark clean
  10016. if (dirtyPath) {
  10017. this.__dirtyPath = dirtyPath;
  10018. this._rect = null;
  10019. }
  10020. this.__dirty = true;
  10021. this.__zr && this.__zr.refresh();
  10022. // Used as a clipping path
  10023. if (this.__clipTarget) {
  10024. this.__clipTarget.dirty();
  10025. }
  10026. },
  10027. /**
  10028. * Alias for animate('shape')
  10029. * @param {boolean} loop
  10030. */
  10031. animateShape: function (loop) {
  10032. return this.animate('shape', loop);
  10033. },
  10034. // Overwrite attrKV
  10035. attrKV: function (key, value) {
  10036. // FIXME
  10037. if (key === 'shape') {
  10038. this.setShape(value);
  10039. this.__dirtyPath = true;
  10040. this._rect = null;
  10041. }
  10042. else {
  10043. Displayable.prototype.attrKV.call(this, key, value);
  10044. }
  10045. },
  10046. /**
  10047. * @param {Object|string} key
  10048. * @param {*} value
  10049. */
  10050. setShape: function (key, value) {
  10051. var shape = this.shape;
  10052. // Path from string may not have shape
  10053. if (shape) {
  10054. if (zrUtil.isObject(key)) {
  10055. for (var name in key) {
  10056. shape[name] = key[name];
  10057. }
  10058. }
  10059. else {
  10060. shape[key] = value;
  10061. }
  10062. this.dirty(true);
  10063. }
  10064. return this;
  10065. },
  10066. getLineScale: function () {
  10067. var m = this.transform;
  10068. // Get the line scale.
  10069. // Determinant of `m` means how much the area is enlarged by the
  10070. // transformation. So its square root can be used as a scale factor
  10071. // for width.
  10072. return m && abs(m[0] - 1) > 1e-10 && abs(m[3] - 1) > 1e-10
  10073. ? Math.sqrt(abs(m[0] * m[3] - m[2] * m[1]))
  10074. : 1;
  10075. }
  10076. };
  10077. /**
  10078. * 扩展一个 Path element, 比如星形,圆等。
  10079. * Extend a path element
  10080. * @param {Object} props
  10081. * @param {string} props.type Path type
  10082. * @param {Function} props.init Initialize
  10083. * @param {Function} props.buildPath Overwrite buildPath method
  10084. * @param {Object} [props.style] Extended default style config
  10085. * @param {Object} [props.shape] Extended default shape config
  10086. */
  10087. Path.extend = function (defaults) {
  10088. var Sub = function (opts) {
  10089. Path.call(this, opts);
  10090. if (defaults.style) {
  10091. // Extend default style
  10092. this.style.extendFrom(defaults.style, false);
  10093. }
  10094. // Extend default shape
  10095. var defaultShape = defaults.shape;
  10096. if (defaultShape) {
  10097. this.shape = this.shape || {};
  10098. var thisShape = this.shape;
  10099. for (var name in defaultShape) {
  10100. if (
  10101. ! thisShape.hasOwnProperty(name)
  10102. && defaultShape.hasOwnProperty(name)
  10103. ) {
  10104. thisShape[name] = defaultShape[name];
  10105. }
  10106. }
  10107. }
  10108. defaults.init && defaults.init.call(this, opts);
  10109. };
  10110. zrUtil.inherits(Sub, Path);
  10111. // FIXME 不能 extend position, rotation 等引用对象
  10112. for (var name in defaults) {
  10113. // Extending prototype values and methods
  10114. if (name !== 'style' && name !== 'shape') {
  10115. Sub.prototype[name] = defaults[name];
  10116. }
  10117. }
  10118. return Sub;
  10119. };
  10120. zrUtil.inherits(Path, Displayable);
  10121. module.exports = Path;
  10122. /***/ },
  10123. /* 46 */
  10124. /***/ function(module, exports, __webpack_require__) {
  10125. /**
  10126. * 可绘制的图形基类
  10127. * Base class of all displayable graphic objects
  10128. * @module zrender/graphic/Displayable
  10129. */
  10130. var zrUtil = __webpack_require__(4);
  10131. var Style = __webpack_require__(47);
  10132. var Element = __webpack_require__(31);
  10133. var RectText = __webpack_require__(48);
  10134. // var Stateful = require('./mixin/Stateful');
  10135. /**
  10136. * @alias module:zrender/graphic/Displayable
  10137. * @extends module:zrender/Element
  10138. * @extends module:zrender/graphic/mixin/RectText
  10139. */
  10140. function Displayable(opts) {
  10141. opts = opts || {};
  10142. Element.call(this, opts);
  10143. // Extend properties
  10144. for (var name in opts) {
  10145. if (
  10146. opts.hasOwnProperty(name) &&
  10147. name !== 'style'
  10148. ) {
  10149. this[name] = opts[name];
  10150. }
  10151. }
  10152. /**
  10153. * @type {module:zrender/graphic/Style}
  10154. */
  10155. this.style = new Style(opts.style);
  10156. this._rect = null;
  10157. // Shapes for cascade clipping.
  10158. this.__clipPaths = [];
  10159. // FIXME Stateful must be mixined after style is setted
  10160. // Stateful.call(this, opts);
  10161. }
  10162. Displayable.prototype = {
  10163. constructor: Displayable,
  10164. type: 'displayable',
  10165. /**
  10166. * Displayable 是否为脏,Painter 中会根据该标记判断是否需要是否需要重新绘制
  10167. * Dirty flag. From which painter will determine if this displayable object needs brush
  10168. * @name module:zrender/graphic/Displayable#__dirty
  10169. * @type {boolean}
  10170. */
  10171. __dirty: true,
  10172. /**
  10173. * 图形是否可见,为true时不绘制图形,但是仍能触发鼠标事件
  10174. * If ignore drawing of the displayable object. Mouse event will still be triggered
  10175. * @name module:/zrender/graphic/Displayable#invisible
  10176. * @type {boolean}
  10177. * @default false
  10178. */
  10179. invisible: false,
  10180. /**
  10181. * @name module:/zrender/graphic/Displayable#z
  10182. * @type {number}
  10183. * @default 0
  10184. */
  10185. z: 0,
  10186. /**
  10187. * @name module:/zrender/graphic/Displayable#z
  10188. * @type {number}
  10189. * @default 0
  10190. */
  10191. z2: 0,
  10192. /**
  10193. * z层level,决定绘画在哪层canvas中
  10194. * @name module:/zrender/graphic/Displayable#zlevel
  10195. * @type {number}
  10196. * @default 0
  10197. */
  10198. zlevel: 0,
  10199. /**
  10200. * 是否可拖拽
  10201. * @name module:/zrender/graphic/Displayable#draggable
  10202. * @type {boolean}
  10203. * @default false
  10204. */
  10205. draggable: false,
  10206. /**
  10207. * 是否正在拖拽
  10208. * @name module:/zrender/graphic/Displayable#draggable
  10209. * @type {boolean}
  10210. * @default false
  10211. */
  10212. dragging: false,
  10213. /**
  10214. * 是否相应鼠标事件
  10215. * @name module:/zrender/graphic/Displayable#silent
  10216. * @type {boolean}
  10217. * @default false
  10218. */
  10219. silent: false,
  10220. /**
  10221. * If enable culling
  10222. * @type {boolean}
  10223. * @default false
  10224. */
  10225. culling: false,
  10226. /**
  10227. * Mouse cursor when hovered
  10228. * @name module:/zrender/graphic/Displayable#cursor
  10229. * @type {string}
  10230. */
  10231. cursor: 'pointer',
  10232. /**
  10233. * If hover area is bounding rect
  10234. * @name module:/zrender/graphic/Displayable#rectHover
  10235. * @type {string}
  10236. */
  10237. rectHover: false,
  10238. /**
  10239. * Render the element progressively when the value >= 0,
  10240. * usefull for large data.
  10241. * @type {number}
  10242. */
  10243. progressive: -1,
  10244. beforeBrush: function (ctx) {},
  10245. afterBrush: function (ctx) {},
  10246. /**
  10247. * 图形绘制方法
  10248. * @param {Canvas2DRenderingContext} ctx
  10249. */
  10250. // Interface
  10251. brush: function (ctx, prevEl) {},
  10252. /**
  10253. * 获取最小包围盒
  10254. * @return {module:zrender/core/BoundingRect}
  10255. */
  10256. // Interface
  10257. getBoundingRect: function () {},
  10258. /**
  10259. * 判断坐标 x, y 是否在图形上
  10260. * If displayable element contain coord x, y
  10261. * @param {number} x
  10262. * @param {number} y
  10263. * @return {boolean}
  10264. */
  10265. contain: function (x, y) {
  10266. return this.rectContain(x, y);
  10267. },
  10268. /**
  10269. * @param {Function} cb
  10270. * @param {} context
  10271. */
  10272. traverse: function (cb, context) {
  10273. cb.call(context, this);
  10274. },
  10275. /**
  10276. * 判断坐标 x, y 是否在图形的包围盒上
  10277. * If bounding rect of element contain coord x, y
  10278. * @param {number} x
  10279. * @param {number} y
  10280. * @return {boolean}
  10281. */
  10282. rectContain: function (x, y) {
  10283. var coord = this.transformCoordToLocal(x, y);
  10284. var rect = this.getBoundingRect();
  10285. return rect.contain(coord[0], coord[1]);
  10286. },
  10287. /**
  10288. * 标记图形元素为脏,并且在下一帧重绘
  10289. * Mark displayable element dirty and refresh next frame
  10290. */
  10291. dirty: function () {
  10292. this.__dirty = true;
  10293. this._rect = null;
  10294. this.__zr && this.__zr.refresh();
  10295. },
  10296. /**
  10297. * 图形是否会触发事件
  10298. * If displayable object binded any event
  10299. * @return {boolean}
  10300. */
  10301. // TODO, 通过 bind 绑定的事件
  10302. // isSilent: function () {
  10303. // return !(
  10304. // this.hoverable || this.draggable
  10305. // || this.onmousemove || this.onmouseover || this.onmouseout
  10306. // || this.onmousedown || this.onmouseup || this.onclick
  10307. // || this.ondragenter || this.ondragover || this.ondragleave
  10308. // || this.ondrop
  10309. // );
  10310. // },
  10311. /**
  10312. * Alias for animate('style')
  10313. * @param {boolean} loop
  10314. */
  10315. animateStyle: function (loop) {
  10316. return this.animate('style', loop);
  10317. },
  10318. attrKV: function (key, value) {
  10319. if (key !== 'style') {
  10320. Element.prototype.attrKV.call(this, key, value);
  10321. }
  10322. else {
  10323. this.style.set(value);
  10324. }
  10325. },
  10326. /**
  10327. * @param {Object|string} key
  10328. * @param {*} value
  10329. */
  10330. setStyle: function (key, value) {
  10331. this.style.set(key, value);
  10332. this.dirty(false);
  10333. return this;
  10334. },
  10335. /**
  10336. * Use given style object
  10337. * @param {Object} obj
  10338. */
  10339. useStyle: function (obj) {
  10340. this.style = new Style(obj);
  10341. this.dirty(false);
  10342. return this;
  10343. }
  10344. };
  10345. zrUtil.inherits(Displayable, Element);
  10346. zrUtil.mixin(Displayable, RectText);
  10347. // zrUtil.mixin(Displayable, Stateful);
  10348. module.exports = Displayable;
  10349. /***/ },
  10350. /* 47 */
  10351. /***/ function(module, exports) {
  10352. /**
  10353. * @module zrender/graphic/Style
  10354. */
  10355. var STYLE_COMMON_PROPS = [
  10356. ['shadowBlur', 0], ['shadowOffsetX', 0], ['shadowOffsetY', 0], ['shadowColor', '#000'],
  10357. ['lineCap', 'butt'], ['lineJoin', 'miter'], ['miterLimit', 10]
  10358. ];
  10359. // var SHADOW_PROPS = STYLE_COMMON_PROPS.slice(0, 4);
  10360. // var LINE_PROPS = STYLE_COMMON_PROPS.slice(4);
  10361. var Style = function (opts) {
  10362. this.extendFrom(opts);
  10363. };
  10364. function createLinearGradient(ctx, obj, rect) {
  10365. // var size =
  10366. var x = obj.x;
  10367. var x2 = obj.x2;
  10368. var y = obj.y;
  10369. var y2 = obj.y2;
  10370. if (!obj.global) {
  10371. x = x * rect.width + rect.x;
  10372. x2 = x2 * rect.width + rect.x;
  10373. y = y * rect.height + rect.y;
  10374. y2 = y2 * rect.height + rect.y;
  10375. }
  10376. var canvasGradient = ctx.createLinearGradient(x, y, x2, y2);
  10377. return canvasGradient;
  10378. }
  10379. function createRadialGradient(ctx, obj, rect) {
  10380. var width = rect.width;
  10381. var height = rect.height;
  10382. var min = Math.min(width, height);
  10383. var x = obj.x;
  10384. var y = obj.y;
  10385. var r = obj.r;
  10386. if (!obj.global) {
  10387. x = x * width + rect.x;
  10388. y = y * height + rect.y;
  10389. r = r * min;
  10390. }
  10391. var canvasGradient = ctx.createRadialGradient(x, y, 0, x, y, r);
  10392. return canvasGradient;
  10393. }
  10394. Style.prototype = {
  10395. constructor: Style,
  10396. /**
  10397. * @type {string}
  10398. */
  10399. fill: '#000000',
  10400. /**
  10401. * @type {string}
  10402. */
  10403. stroke: null,
  10404. /**
  10405. * @type {number}
  10406. */
  10407. opacity: 1,
  10408. /**
  10409. * @type {Array.<number>}
  10410. */
  10411. lineDash: null,
  10412. /**
  10413. * @type {number}
  10414. */
  10415. lineDashOffset: 0,
  10416. /**
  10417. * @type {number}
  10418. */
  10419. shadowBlur: 0,
  10420. /**
  10421. * @type {number}
  10422. */
  10423. shadowOffsetX: 0,
  10424. /**
  10425. * @type {number}
  10426. */
  10427. shadowOffsetY: 0,
  10428. /**
  10429. * @type {number}
  10430. */
  10431. lineWidth: 1,
  10432. /**
  10433. * If stroke ignore scale
  10434. * @type {Boolean}
  10435. */
  10436. strokeNoScale: false,
  10437. // Bounding rect text configuration
  10438. // Not affected by element transform
  10439. /**
  10440. * @type {string}
  10441. */
  10442. text: null,
  10443. /**
  10444. * @type {string}
  10445. */
  10446. textFill: '#000',
  10447. /**
  10448. * @type {string}
  10449. */
  10450. textStroke: null,
  10451. /**
  10452. * 'inside', 'left', 'right', 'top', 'bottom'
  10453. * [x, y]
  10454. * @type {string|Array.<number>}
  10455. * @default 'inside'
  10456. */
  10457. textPosition: 'inside',
  10458. /**
  10459. * @type {string}
  10460. */
  10461. textBaseline: null,
  10462. /**
  10463. * @type {string}
  10464. */
  10465. textAlign: null,
  10466. /**
  10467. * @type {string}
  10468. */
  10469. textVerticalAlign: null,
  10470. /**
  10471. * @type {number}
  10472. */
  10473. textDistance: 5,
  10474. /**
  10475. * @type {number}
  10476. */
  10477. textShadowBlur: 0,
  10478. /**
  10479. * @type {number}
  10480. */
  10481. textShadowOffsetX: 0,
  10482. /**
  10483. * @type {number}
  10484. */
  10485. textShadowOffsetY: 0,
  10486. /**
  10487. * @type {string}
  10488. * https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
  10489. */
  10490. blend: null,
  10491. /**
  10492. * @param {CanvasRenderingContext2D} ctx
  10493. */
  10494. bind: function (ctx, el, prevEl) {
  10495. var style = this;
  10496. var prevStyle = prevEl && prevEl.style;
  10497. var firstDraw = !prevStyle;
  10498. for (var i = 0; i < STYLE_COMMON_PROPS.length; i++) {
  10499. var prop = STYLE_COMMON_PROPS[i];
  10500. var styleName = prop[0];
  10501. if (firstDraw || style[styleName] !== prevStyle[styleName]) {
  10502. // FIXME Invalid property value will cause style leak from previous element.
  10503. ctx[styleName] = style[styleName] || prop[1];
  10504. }
  10505. }
  10506. if ((firstDraw || style.fill !== prevStyle.fill)) {
  10507. ctx.fillStyle = style.fill;
  10508. }
  10509. if ((firstDraw || style.stroke !== prevStyle.stroke)) {
  10510. ctx.strokeStyle = style.stroke;
  10511. }
  10512. if ((firstDraw || style.opacity !== prevStyle.opacity)) {
  10513. ctx.globalAlpha = style.opacity == null ? 1 : style.opacity;
  10514. }
  10515. if ((firstDraw || style.blend !== prevStyle.blend)) {
  10516. ctx.globalCompositeOperation = style.blend || 'source-over';
  10517. }
  10518. if (this.hasStroke()) {
  10519. var lineWidth = style.lineWidth;
  10520. ctx.lineWidth = lineWidth / (
  10521. (this.strokeNoScale && el && el.getLineScale) ? el.getLineScale() : 1
  10522. );
  10523. }
  10524. },
  10525. hasFill: function () {
  10526. var fill = this.fill;
  10527. return fill != null && fill !== 'none';
  10528. },
  10529. hasStroke: function () {
  10530. var stroke = this.stroke;
  10531. return stroke != null && stroke !== 'none' && this.lineWidth > 0;
  10532. },
  10533. /**
  10534. * Extend from other style
  10535. * @param {zrender/graphic/Style} otherStyle
  10536. * @param {boolean} overwrite
  10537. */
  10538. extendFrom: function (otherStyle, overwrite) {
  10539. if (otherStyle) {
  10540. var target = this;
  10541. for (var name in otherStyle) {
  10542. if (otherStyle.hasOwnProperty(name)
  10543. && (overwrite || ! target.hasOwnProperty(name))
  10544. ) {
  10545. target[name] = otherStyle[name];
  10546. }
  10547. }
  10548. }
  10549. },
  10550. /**
  10551. * Batch setting style with a given object
  10552. * @param {Object|string} obj
  10553. * @param {*} [obj]
  10554. */
  10555. set: function (obj, value) {
  10556. if (typeof obj === 'string') {
  10557. this[obj] = value;
  10558. }
  10559. else {
  10560. this.extendFrom(obj, true);
  10561. }
  10562. },
  10563. /**
  10564. * Clone
  10565. * @return {zrender/graphic/Style} [description]
  10566. */
  10567. clone: function () {
  10568. var newStyle = new this.constructor();
  10569. newStyle.extendFrom(this, true);
  10570. return newStyle;
  10571. },
  10572. getGradient: function (ctx, obj, rect) {
  10573. var method = obj.type === 'radial' ? createRadialGradient : createLinearGradient;
  10574. var canvasGradient = method(ctx, obj, rect);
  10575. var colorStops = obj.colorStops;
  10576. for (var i = 0; i < colorStops.length; i++) {
  10577. canvasGradient.addColorStop(
  10578. colorStops[i].offset, colorStops[i].color
  10579. );
  10580. }
  10581. return canvasGradient;
  10582. }
  10583. };
  10584. var styleProto = Style.prototype;
  10585. for (var i = 0; i < STYLE_COMMON_PROPS.length; i++) {
  10586. var prop = STYLE_COMMON_PROPS[i];
  10587. if (!(prop[0] in styleProto)) {
  10588. styleProto[prop[0]] = prop[1];
  10589. }
  10590. }
  10591. // Provide for others
  10592. Style.getGradient = styleProto.getGradient;
  10593. module.exports = Style;
  10594. /***/ },
  10595. /* 48 */
  10596. /***/ function(module, exports, __webpack_require__) {
  10597. /**
  10598. * Mixin for drawing text in a element bounding rect
  10599. * @module zrender/mixin/RectText
  10600. */
  10601. var textContain = __webpack_require__(8);
  10602. var BoundingRect = __webpack_require__(9);
  10603. var tmpRect = new BoundingRect();
  10604. var RectText = function () {};
  10605. function parsePercent(value, maxValue) {
  10606. if (typeof value === 'string') {
  10607. if (value.lastIndexOf('%') >= 0) {
  10608. return parseFloat(value) / 100 * maxValue;
  10609. }
  10610. return parseFloat(value);
  10611. }
  10612. return value;
  10613. }
  10614. function setTransform(ctx, m) {
  10615. ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
  10616. }
  10617. RectText.prototype = {
  10618. constructor: RectText,
  10619. /**
  10620. * Draw text in a rect with specified position.
  10621. * @param {CanvasRenderingContext} ctx
  10622. * @param {Object} rect Displayable rect
  10623. * @return {Object} textRect Alternative precalculated text bounding rect
  10624. */
  10625. drawRectText: function (ctx, rect, textRect) {
  10626. var style = this.style;
  10627. var text = style.text;
  10628. // Convert to string
  10629. text != null && (text += '');
  10630. if (!text) {
  10631. return;
  10632. }
  10633. // FIXME
  10634. ctx.save();
  10635. var x;
  10636. var y;
  10637. var textPosition = style.textPosition;
  10638. var distance = style.textDistance;
  10639. var align = style.textAlign;
  10640. var font = style.textFont || style.font;
  10641. var baseline = style.textBaseline;
  10642. var verticalAlign = style.textVerticalAlign;
  10643. textRect = textRect || textContain.getBoundingRect(text, font, align, baseline);
  10644. // Transform rect to view space
  10645. var transform = this.transform;
  10646. if (transform) {
  10647. tmpRect.copy(rect);
  10648. tmpRect.applyTransform(transform);
  10649. rect = tmpRect;
  10650. }
  10651. // Text position represented by coord
  10652. if (textPosition instanceof Array) {
  10653. // Percent
  10654. x = rect.x + parsePercent(textPosition[0], rect.width);
  10655. y = rect.y + parsePercent(textPosition[1], rect.height);
  10656. align = align || 'left';
  10657. baseline = baseline || 'top';
  10658. if (verticalAlign) {
  10659. switch (verticalAlign) {
  10660. case 'middle':
  10661. y -= textRect.height / 2 - textRect.lineHeight / 2;
  10662. break;
  10663. case 'bottom':
  10664. y -= textRect.height - textRect.lineHeight / 2;
  10665. break;
  10666. default:
  10667. y += textRect.lineHeight / 2;
  10668. }
  10669. // Force bseline to be middle
  10670. baseline = 'middle';
  10671. }
  10672. }
  10673. else {
  10674. var res = textContain.adjustTextPositionOnRect(
  10675. textPosition, rect, textRect, distance
  10676. );
  10677. x = res.x;
  10678. y = res.y;
  10679. // Default align and baseline when has textPosition
  10680. align = align || res.textAlign;
  10681. baseline = baseline || res.textBaseline;
  10682. }
  10683. // Use canvas default left textAlign. Giving invalid value will cause state not change
  10684. ctx.textAlign = align || 'left';
  10685. // Use canvas default alphabetic baseline
  10686. ctx.textBaseline = baseline || 'alphabetic';
  10687. var textFill = style.textFill;
  10688. var textStroke = style.textStroke;
  10689. textFill && (ctx.fillStyle = textFill);
  10690. textStroke && (ctx.strokeStyle = textStroke);
  10691. ctx.font = font;
  10692. // Text shadow
  10693. // Always set shadowBlur and shadowOffset to avoid leak from displayable
  10694. ctx.shadowBlur = style.textShadowBlur;
  10695. ctx.shadowColor = style.textShadowColor || 'transparent';
  10696. ctx.shadowOffsetX = style.textShadowOffsetX;
  10697. ctx.shadowOffsetY = style.textShadowOffsetY;
  10698. var textLines = text.split('\n');
  10699. for (var i = 0; i < textLines.length; i++) {
  10700. textFill && ctx.fillText(textLines[i], x, y);
  10701. textStroke && ctx.strokeText(textLines[i], x, y);
  10702. y += textRect.lineHeight;
  10703. }
  10704. ctx.restore();
  10705. }
  10706. };
  10707. module.exports = RectText;
  10708. /***/ },
  10709. /* 49 */
  10710. /***/ function(module, exports, __webpack_require__) {
  10711. 'use strict';
  10712. /**
  10713. * Path 代理,可以在`buildPath`中用于替代`ctx`, 会保存每个path操作的命令到pathCommands属性中
  10714. * 可以用于 isInsidePath 判断以及获取boundingRect
  10715. *
  10716. * @module zrender/core/PathProxy
  10717. * @author Yi Shen (http://www.github.com/pissang)
  10718. */
  10719. // TODO getTotalLength, getPointAtLength
  10720. var curve = __webpack_require__(50);
  10721. var vec2 = __webpack_require__(10);
  10722. var bbox = __webpack_require__(51);
  10723. var BoundingRect = __webpack_require__(9);
  10724. var dpr = __webpack_require__(41).devicePixelRatio;
  10725. var CMD = {
  10726. M: 1,
  10727. L: 2,
  10728. C: 3,
  10729. Q: 4,
  10730. A: 5,
  10731. Z: 6,
  10732. // Rect
  10733. R: 7
  10734. };
  10735. var min = [];
  10736. var max = [];
  10737. var min2 = [];
  10738. var max2 = [];
  10739. var mathMin = Math.min;
  10740. var mathMax = Math.max;
  10741. var mathCos = Math.cos;
  10742. var mathSin = Math.sin;
  10743. var mathSqrt = Math.sqrt;
  10744. var mathAbs = Math.abs;
  10745. var hasTypedArray = typeof Float32Array != 'undefined';
  10746. /**
  10747. * @alias module:zrender/core/PathProxy
  10748. * @constructor
  10749. */
  10750. var PathProxy = function () {
  10751. /**
  10752. * Path data. Stored as flat array
  10753. * @type {Array.<Object>}
  10754. */
  10755. this.data = [];
  10756. this._len = 0;
  10757. this._ctx = null;
  10758. this._xi = 0;
  10759. this._yi = 0;
  10760. this._x0 = 0;
  10761. this._y0 = 0;
  10762. // Unit x, Unit y. Provide for avoiding drawing that too short line segment
  10763. this._ux = 0;
  10764. this._uy = 0;
  10765. };
  10766. /**
  10767. * 快速计算Path包围盒(并不是最小包围盒)
  10768. * @return {Object}
  10769. */
  10770. PathProxy.prototype = {
  10771. constructor: PathProxy,
  10772. _lineDash: null,
  10773. _dashOffset: 0,
  10774. _dashIdx: 0,
  10775. _dashSum: 0,
  10776. /**
  10777. * @readOnly
  10778. */
  10779. setScale: function (sx, sy) {
  10780. this._ux = mathAbs(1 / dpr / sx) || 0;
  10781. this._uy = mathAbs(1 / dpr / sy) || 0;
  10782. },
  10783. getContext: function () {
  10784. return this._ctx;
  10785. },
  10786. /**
  10787. * @param {CanvasRenderingContext2D} ctx
  10788. * @return {module:zrender/core/PathProxy}
  10789. */
  10790. beginPath: function (ctx) {
  10791. this._ctx = ctx;
  10792. ctx && ctx.beginPath();
  10793. // Reset
  10794. this._len = 0;
  10795. if (this._lineDash) {
  10796. this._lineDash = null;
  10797. this._dashOffset = 0;
  10798. }
  10799. return this;
  10800. },
  10801. /**
  10802. * @param {number} x
  10803. * @param {number} y
  10804. * @return {module:zrender/core/PathProxy}
  10805. */
  10806. moveTo: function (x, y) {
  10807. this.addData(CMD.M, x, y);
  10808. this._ctx && this._ctx.moveTo(x, y);
  10809. // x0, y0, xi, yi 是记录在 _dashedXXXXTo 方法中使用
  10810. // xi, yi 记录当前点, x0, y0 在 closePath 的时候回到起始点。
  10811. // 有可能在 beginPath 之后直接调用 lineTo,这时候 x0, y0 需要
  10812. // 在 lineTo 方法中记录,这里先不考虑这种情况,dashed line 也只在 IE10- 中不支持
  10813. this._x0 = x;
  10814. this._y0 = y;
  10815. this._xi = x;
  10816. this._yi = y;
  10817. return this;
  10818. },
  10819. /**
  10820. * @param {number} x
  10821. * @param {number} y
  10822. * @return {module:zrender/core/PathProxy}
  10823. */
  10824. lineTo: function (x, y) {
  10825. var exceedUnit = mathAbs(x - this._xi) > this._ux
  10826. || mathAbs(y - this._yi) > this._uy
  10827. // Force draw the first segment
  10828. || this._len < 5;
  10829. this.addData(CMD.L, x, y);
  10830. if (this._ctx && exceedUnit) {
  10831. this._needsDash() ? this._dashedLineTo(x, y)
  10832. : this._ctx.lineTo(x, y);
  10833. }
  10834. if (exceedUnit) {
  10835. this._xi = x;
  10836. this._yi = y;
  10837. }
  10838. return this;
  10839. },
  10840. /**
  10841. * @param {number} x1
  10842. * @param {number} y1
  10843. * @param {number} x2
  10844. * @param {number} y2
  10845. * @param {number} x3
  10846. * @param {number} y3
  10847. * @return {module:zrender/core/PathProxy}
  10848. */
  10849. bezierCurveTo: function (x1, y1, x2, y2, x3, y3) {
  10850. this.addData(CMD.C, x1, y1, x2, y2, x3, y3);
  10851. if (this._ctx) {
  10852. this._needsDash() ? this._dashedBezierTo(x1, y1, x2, y2, x3, y3)
  10853. : this._ctx.bezierCurveTo(x1, y1, x2, y2, x3, y3);
  10854. }
  10855. this._xi = x3;
  10856. this._yi = y3;
  10857. return this;
  10858. },
  10859. /**
  10860. * @param {number} x1
  10861. * @param {number} y1
  10862. * @param {number} x2
  10863. * @param {number} y2
  10864. * @return {module:zrender/core/PathProxy}
  10865. */
  10866. quadraticCurveTo: function (x1, y1, x2, y2) {
  10867. this.addData(CMD.Q, x1, y1, x2, y2);
  10868. if (this._ctx) {
  10869. this._needsDash() ? this._dashedQuadraticTo(x1, y1, x2, y2)
  10870. : this._ctx.quadraticCurveTo(x1, y1, x2, y2);
  10871. }
  10872. this._xi = x2;
  10873. this._yi = y2;
  10874. return this;
  10875. },
  10876. /**
  10877. * @param {number} cx
  10878. * @param {number} cy
  10879. * @param {number} r
  10880. * @param {number} startAngle
  10881. * @param {number} endAngle
  10882. * @param {boolean} anticlockwise
  10883. * @return {module:zrender/core/PathProxy}
  10884. */
  10885. arc: function (cx, cy, r, startAngle, endAngle, anticlockwise) {
  10886. this.addData(
  10887. CMD.A, cx, cy, r, r, startAngle, endAngle - startAngle, 0, anticlockwise ? 0 : 1
  10888. );
  10889. this._ctx && this._ctx.arc(cx, cy, r, startAngle, endAngle, anticlockwise);
  10890. this._xi = mathCos(endAngle) * r + cx;
  10891. this._xi = mathSin(endAngle) * r + cx;
  10892. return this;
  10893. },
  10894. // TODO
  10895. arcTo: function (x1, y1, x2, y2, radius) {
  10896. if (this._ctx) {
  10897. this._ctx.arcTo(x1, y1, x2, y2, radius);
  10898. }
  10899. return this;
  10900. },
  10901. // TODO
  10902. rect: function (x, y, w, h) {
  10903. this._ctx && this._ctx.rect(x, y, w, h);
  10904. this.addData(CMD.R, x, y, w, h);
  10905. return this;
  10906. },
  10907. /**
  10908. * @return {module:zrender/core/PathProxy}
  10909. */
  10910. closePath: function () {
  10911. this.addData(CMD.Z);
  10912. var ctx = this._ctx;
  10913. var x0 = this._x0;
  10914. var y0 = this._y0;
  10915. if (ctx) {
  10916. this._needsDash() && this._dashedLineTo(x0, y0);
  10917. ctx.closePath();
  10918. }
  10919. this._xi = x0;
  10920. this._yi = y0;
  10921. return this;
  10922. },
  10923. /**
  10924. * Context 从外部传入,因为有可能是 rebuildPath 完之后再 fill。
  10925. * stroke 同样
  10926. * @param {CanvasRenderingContext2D} ctx
  10927. * @return {module:zrender/core/PathProxy}
  10928. */
  10929. fill: function (ctx) {
  10930. ctx && ctx.fill();
  10931. this.toStatic();
  10932. },
  10933. /**
  10934. * @param {CanvasRenderingContext2D} ctx
  10935. * @return {module:zrender/core/PathProxy}
  10936. */
  10937. stroke: function (ctx) {
  10938. ctx && ctx.stroke();
  10939. this.toStatic();
  10940. },
  10941. /**
  10942. * 必须在其它绘制命令前调用
  10943. * Must be invoked before all other path drawing methods
  10944. * @return {module:zrender/core/PathProxy}
  10945. */
  10946. setLineDash: function (lineDash) {
  10947. if (lineDash instanceof Array) {
  10948. this._lineDash = lineDash;
  10949. this._dashIdx = 0;
  10950. var lineDashSum = 0;
  10951. for (var i = 0; i < lineDash.length; i++) {
  10952. lineDashSum += lineDash[i];
  10953. }
  10954. this._dashSum = lineDashSum;
  10955. }
  10956. return this;
  10957. },
  10958. /**
  10959. * 必须在其它绘制命令前调用
  10960. * Must be invoked before all other path drawing methods
  10961. * @return {module:zrender/core/PathProxy}
  10962. */
  10963. setLineDashOffset: function (offset) {
  10964. this._dashOffset = offset;
  10965. return this;
  10966. },
  10967. /**
  10968. *
  10969. * @return {boolean}
  10970. */
  10971. len: function () {
  10972. return this._len;
  10973. },
  10974. /**
  10975. * 直接设置 Path 数据
  10976. */
  10977. setData: function (data) {
  10978. var len = data.length;
  10979. if (! (this.data && this.data.length == len) && hasTypedArray) {
  10980. this.data = new Float32Array(len);
  10981. }
  10982. for (var i = 0; i < len; i++) {
  10983. this.data[i] = data[i];
  10984. }
  10985. this._len = len;
  10986. },
  10987. /**
  10988. * 添加子路径
  10989. * @param {module:zrender/core/PathProxy|Array.<module:zrender/core/PathProxy>} path
  10990. */
  10991. appendPath: function (path) {
  10992. if (!(path instanceof Array)) {
  10993. path = [path];
  10994. }
  10995. var len = path.length;
  10996. var appendSize = 0;
  10997. var offset = this._len;
  10998. for (var i = 0; i < len; i++) {
  10999. appendSize += path[i].len();
  11000. }
  11001. if (hasTypedArray && (this.data instanceof Float32Array)) {
  11002. this.data = new Float32Array(offset + appendSize);
  11003. }
  11004. for (var i = 0; i < len; i++) {
  11005. var appendPathData = path[i].data;
  11006. for (var k = 0; k < appendPathData.length; k++) {
  11007. this.data[offset++] = appendPathData[k];
  11008. }
  11009. }
  11010. this._len = offset;
  11011. },
  11012. /**
  11013. * 填充 Path 数据。
  11014. * 尽量复用而不申明新的数组。大部分图形重绘的指令数据长度都是不变的。
  11015. */
  11016. addData: function (cmd) {
  11017. var data = this.data;
  11018. if (this._len + arguments.length > data.length) {
  11019. // 因为之前的数组已经转换成静态的 Float32Array
  11020. // 所以不够用时需要扩展一个新的动态数组
  11021. this._expandData();
  11022. data = this.data;
  11023. }
  11024. for (var i = 0; i < arguments.length; i++) {
  11025. data[this._len++] = arguments[i];
  11026. }
  11027. this._prevCmd = cmd;
  11028. },
  11029. _expandData: function () {
  11030. // Only if data is Float32Array
  11031. if (!(this.data instanceof Array)) {
  11032. var newData = [];
  11033. for (var i = 0; i < this._len; i++) {
  11034. newData[i] = this.data[i];
  11035. }
  11036. this.data = newData;
  11037. }
  11038. },
  11039. /**
  11040. * If needs js implemented dashed line
  11041. * @return {boolean}
  11042. * @private
  11043. */
  11044. _needsDash: function () {
  11045. return this._lineDash;
  11046. },
  11047. _dashedLineTo: function (x1, y1) {
  11048. var dashSum = this._dashSum;
  11049. var offset = this._dashOffset;
  11050. var lineDash = this._lineDash;
  11051. var ctx = this._ctx;
  11052. var x0 = this._xi;
  11053. var y0 = this._yi;
  11054. var dx = x1 - x0;
  11055. var dy = y1 - y0;
  11056. var dist = mathSqrt(dx * dx + dy * dy);
  11057. var x = x0;
  11058. var y = y0;
  11059. var dash;
  11060. var nDash = lineDash.length;
  11061. var idx;
  11062. dx /= dist;
  11063. dy /= dist;
  11064. if (offset < 0) {
  11065. // Convert to positive offset
  11066. offset = dashSum + offset;
  11067. }
  11068. offset %= dashSum;
  11069. x -= offset * dx;
  11070. y -= offset * dy;
  11071. while ((dx > 0 && x <= x1) || (dx < 0 && x >= x1)
  11072. || (dx == 0 && ((dy > 0 && y <= y1) || (dy < 0 && y >= y1)))) {
  11073. idx = this._dashIdx;
  11074. dash = lineDash[idx];
  11075. x += dx * dash;
  11076. y += dy * dash;
  11077. this._dashIdx = (idx + 1) % nDash;
  11078. // Skip positive offset
  11079. if ((dx > 0 && x < x0) || (dx < 0 && x > x0) || (dy > 0 && y < y0) || (dy < 0 && y > y0)) {
  11080. continue;
  11081. }
  11082. ctx[idx % 2 ? 'moveTo' : 'lineTo'](
  11083. dx >= 0 ? mathMin(x, x1) : mathMax(x, x1),
  11084. dy >= 0 ? mathMin(y, y1) : mathMax(y, y1)
  11085. );
  11086. }
  11087. // Offset for next lineTo
  11088. dx = x - x1;
  11089. dy = y - y1;
  11090. this._dashOffset = -mathSqrt(dx * dx + dy * dy);
  11091. },
  11092. // Not accurate dashed line to
  11093. _dashedBezierTo: function (x1, y1, x2, y2, x3, y3) {
  11094. var dashSum = this._dashSum;
  11095. var offset = this._dashOffset;
  11096. var lineDash = this._lineDash;
  11097. var ctx = this._ctx;
  11098. var x0 = this._xi;
  11099. var y0 = this._yi;
  11100. var t;
  11101. var dx;
  11102. var dy;
  11103. var cubicAt = curve.cubicAt;
  11104. var bezierLen = 0;
  11105. var idx = this._dashIdx;
  11106. var nDash = lineDash.length;
  11107. var x;
  11108. var y;
  11109. var tmpLen = 0;
  11110. if (offset < 0) {
  11111. // Convert to positive offset
  11112. offset = dashSum + offset;
  11113. }
  11114. offset %= dashSum;
  11115. // Bezier approx length
  11116. for (t = 0; t < 1; t += 0.1) {
  11117. dx = cubicAt(x0, x1, x2, x3, t + 0.1)
  11118. - cubicAt(x0, x1, x2, x3, t);
  11119. dy = cubicAt(y0, y1, y2, y3, t + 0.1)
  11120. - cubicAt(y0, y1, y2, y3, t);
  11121. bezierLen += mathSqrt(dx * dx + dy * dy);
  11122. }
  11123. // Find idx after add offset
  11124. for (; idx < nDash; idx++) {
  11125. tmpLen += lineDash[idx];
  11126. if (tmpLen > offset) {
  11127. break;
  11128. }
  11129. }
  11130. t = (tmpLen - offset) / bezierLen;
  11131. while (t <= 1) {
  11132. x = cubicAt(x0, x1, x2, x3, t);
  11133. y = cubicAt(y0, y1, y2, y3, t);
  11134. // Use line to approximate dashed bezier
  11135. // Bad result if dash is long
  11136. idx % 2 ? ctx.moveTo(x, y)
  11137. : ctx.lineTo(x, y);
  11138. t += lineDash[idx] / bezierLen;
  11139. idx = (idx + 1) % nDash;
  11140. }
  11141. // Finish the last segment and calculate the new offset
  11142. (idx % 2 !== 0) && ctx.lineTo(x3, y3);
  11143. dx = x3 - x;
  11144. dy = y3 - y;
  11145. this._dashOffset = -mathSqrt(dx * dx + dy * dy);
  11146. },
  11147. _dashedQuadraticTo: function (x1, y1, x2, y2) {
  11148. // Convert quadratic to cubic using degree elevation
  11149. var x3 = x2;
  11150. var y3 = y2;
  11151. x2 = (x2 + 2 * x1) / 3;
  11152. y2 = (y2 + 2 * y1) / 3;
  11153. x1 = (this._xi + 2 * x1) / 3;
  11154. y1 = (this._yi + 2 * y1) / 3;
  11155. this._dashedBezierTo(x1, y1, x2, y2, x3, y3);
  11156. },
  11157. /**
  11158. * 转成静态的 Float32Array 减少堆内存占用
  11159. * Convert dynamic array to static Float32Array
  11160. */
  11161. toStatic: function () {
  11162. var data = this.data;
  11163. if (data instanceof Array) {
  11164. data.length = this._len;
  11165. if (hasTypedArray) {
  11166. this.data = new Float32Array(data);
  11167. }
  11168. }
  11169. },
  11170. /**
  11171. * @return {module:zrender/core/BoundingRect}
  11172. */
  11173. getBoundingRect: function () {
  11174. min[0] = min[1] = min2[0] = min2[1] = Number.MAX_VALUE;
  11175. max[0] = max[1] = max2[0] = max2[1] = -Number.MAX_VALUE;
  11176. var data = this.data;
  11177. var xi = 0;
  11178. var yi = 0;
  11179. var x0 = 0;
  11180. var y0 = 0;
  11181. for (var i = 0; i < data.length;) {
  11182. var cmd = data[i++];
  11183. if (i == 1) {
  11184. // 如果第一个命令是 L, C, Q
  11185. // 则 previous point 同绘制命令的第一个 point
  11186. //
  11187. // 第一个命令为 Arc 的情况下会在后面特殊处理
  11188. xi = data[i];
  11189. yi = data[i + 1];
  11190. x0 = xi;
  11191. y0 = yi;
  11192. }
  11193. switch (cmd) {
  11194. case CMD.M:
  11195. // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点
  11196. // 在 closePath 的时候使用
  11197. x0 = data[i++];
  11198. y0 = data[i++];
  11199. xi = x0;
  11200. yi = y0;
  11201. min2[0] = x0;
  11202. min2[1] = y0;
  11203. max2[0] = x0;
  11204. max2[1] = y0;
  11205. break;
  11206. case CMD.L:
  11207. bbox.fromLine(xi, yi, data[i], data[i + 1], min2, max2);
  11208. xi = data[i++];
  11209. yi = data[i++];
  11210. break;
  11211. case CMD.C:
  11212. bbox.fromCubic(
  11213. xi, yi, data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1],
  11214. min2, max2
  11215. );
  11216. xi = data[i++];
  11217. yi = data[i++];
  11218. break;
  11219. case CMD.Q:
  11220. bbox.fromQuadratic(
  11221. xi, yi, data[i++], data[i++], data[i], data[i + 1],
  11222. min2, max2
  11223. );
  11224. xi = data[i++];
  11225. yi = data[i++];
  11226. break;
  11227. case CMD.A:
  11228. // TODO Arc 判断的开销比较大
  11229. var cx = data[i++];
  11230. var cy = data[i++];
  11231. var rx = data[i++];
  11232. var ry = data[i++];
  11233. var startAngle = data[i++];
  11234. var endAngle = data[i++] + startAngle;
  11235. // TODO Arc 旋转
  11236. var psi = data[i++];
  11237. var anticlockwise = 1 - data[i++];
  11238. if (i == 1) {
  11239. // 直接使用 arc 命令
  11240. // 第一个命令起点还未定义
  11241. x0 = mathCos(startAngle) * rx + cx;
  11242. y0 = mathSin(startAngle) * ry + cy;
  11243. }
  11244. bbox.fromArc(
  11245. cx, cy, rx, ry, startAngle, endAngle,
  11246. anticlockwise, min2, max2
  11247. );
  11248. xi = mathCos(endAngle) * rx + cx;
  11249. yi = mathSin(endAngle) * ry + cy;
  11250. break;
  11251. case CMD.R:
  11252. x0 = xi = data[i++];
  11253. y0 = yi = data[i++];
  11254. var width = data[i++];
  11255. var height = data[i++];
  11256. // Use fromLine
  11257. bbox.fromLine(x0, y0, x0 + width, y0 + height, min2, max2);
  11258. break;
  11259. case CMD.Z:
  11260. xi = x0;
  11261. yi = y0;
  11262. break;
  11263. }
  11264. // Union
  11265. vec2.min(min, min, min2);
  11266. vec2.max(max, max, max2);
  11267. }
  11268. // No data
  11269. if (i === 0) {
  11270. min[0] = min[1] = max[0] = max[1] = 0;
  11271. }
  11272. return new BoundingRect(
  11273. min[0], min[1], max[0] - min[0], max[1] - min[1]
  11274. );
  11275. },
  11276. /**
  11277. * Rebuild path from current data
  11278. * Rebuild path will not consider javascript implemented line dash.
  11279. * @param {CanvasRenderingContext} ctx
  11280. */
  11281. rebuildPath: function (ctx) {
  11282. var d = this.data;
  11283. var x0, y0;
  11284. var xi, yi;
  11285. var x, y;
  11286. var ux = this._ux;
  11287. var uy = this._uy;
  11288. var len = this._len;
  11289. for (var i = 0; i < len;) {
  11290. var cmd = d[i++];
  11291. if (i == 1) {
  11292. // 如果第一个命令是 L, C, Q
  11293. // 则 previous point 同绘制命令的第一个 point
  11294. //
  11295. // 第一个命令为 Arc 的情况下会在后面特殊处理
  11296. xi = d[i];
  11297. yi = d[i + 1];
  11298. x0 = xi;
  11299. y0 = yi;
  11300. }
  11301. switch (cmd) {
  11302. case CMD.M:
  11303. x0 = xi = d[i++];
  11304. y0 = yi = d[i++];
  11305. ctx.moveTo(xi, yi);
  11306. break;
  11307. case CMD.L:
  11308. x = d[i++];
  11309. y = d[i++];
  11310. // Not draw too small seg between
  11311. if (mathAbs(x - xi) > ux || mathAbs(y - yi) > uy || i === len - 1) {
  11312. ctx.lineTo(x, y);
  11313. xi = x;
  11314. yi = y;
  11315. }
  11316. break;
  11317. case CMD.C:
  11318. ctx.bezierCurveTo(
  11319. d[i++], d[i++], d[i++], d[i++], d[i++], d[i++]
  11320. );
  11321. xi = d[i - 2];
  11322. yi = d[i - 1];
  11323. break;
  11324. case CMD.Q:
  11325. ctx.quadraticCurveTo(d[i++], d[i++], d[i++], d[i++]);
  11326. xi = d[i - 2];
  11327. yi = d[i - 1];
  11328. break;
  11329. case CMD.A:
  11330. var cx = d[i++];
  11331. var cy = d[i++];
  11332. var rx = d[i++];
  11333. var ry = d[i++];
  11334. var theta = d[i++];
  11335. var dTheta = d[i++];
  11336. var psi = d[i++];
  11337. var fs = d[i++];
  11338. var r = (rx > ry) ? rx : ry;
  11339. var scaleX = (rx > ry) ? 1 : rx / ry;
  11340. var scaleY = (rx > ry) ? ry / rx : 1;
  11341. var isEllipse = Math.abs(rx - ry) > 1e-3;
  11342. var endAngle = theta + dTheta;
  11343. if (isEllipse) {
  11344. ctx.translate(cx, cy);
  11345. ctx.rotate(psi);
  11346. ctx.scale(scaleX, scaleY);
  11347. ctx.arc(0, 0, r, theta, endAngle, 1 - fs);
  11348. ctx.scale(1 / scaleX, 1 / scaleY);
  11349. ctx.rotate(-psi);
  11350. ctx.translate(-cx, -cy);
  11351. }
  11352. else {
  11353. ctx.arc(cx, cy, r, theta, endAngle, 1 - fs);
  11354. }
  11355. if (i == 1) {
  11356. // 直接使用 arc 命令
  11357. // 第一个命令起点还未定义
  11358. x0 = mathCos(theta) * rx + cx;
  11359. y0 = mathSin(theta) * ry + cy;
  11360. }
  11361. xi = mathCos(endAngle) * rx + cx;
  11362. yi = mathSin(endAngle) * ry + cy;
  11363. break;
  11364. case CMD.R:
  11365. x0 = xi = d[i];
  11366. y0 = yi = d[i + 1];
  11367. ctx.rect(d[i++], d[i++], d[i++], d[i++]);
  11368. break;
  11369. case CMD.Z:
  11370. ctx.closePath();
  11371. xi = x0;
  11372. yi = y0;
  11373. }
  11374. }
  11375. }
  11376. };
  11377. PathProxy.CMD = CMD;
  11378. module.exports = PathProxy;
  11379. /***/ },
  11380. /* 50 */
  11381. /***/ function(module, exports, __webpack_require__) {
  11382. 'use strict';
  11383. /**
  11384. * 曲线辅助模块
  11385. * @module zrender/core/curve
  11386. * @author pissang(https://www.github.com/pissang)
  11387. */
  11388. var vec2 = __webpack_require__(10);
  11389. var v2Create = vec2.create;
  11390. var v2DistSquare = vec2.distSquare;
  11391. var mathPow = Math.pow;
  11392. var mathSqrt = Math.sqrt;
  11393. var EPSILON = 1e-8;
  11394. var EPSILON_NUMERIC = 1e-4;
  11395. var THREE_SQRT = mathSqrt(3);
  11396. var ONE_THIRD = 1 / 3;
  11397. // 临时变量
  11398. var _v0 = v2Create();
  11399. var _v1 = v2Create();
  11400. var _v2 = v2Create();
  11401. // var _v3 = vec2.create();
  11402. function isAroundZero(val) {
  11403. return val > -EPSILON && val < EPSILON;
  11404. }
  11405. function isNotAroundZero(val) {
  11406. return val > EPSILON || val < -EPSILON;
  11407. }
  11408. /**
  11409. * 计算三次贝塞尔值
  11410. * @memberOf module:zrender/core/curve
  11411. * @param {number} p0
  11412. * @param {number} p1
  11413. * @param {number} p2
  11414. * @param {number} p3
  11415. * @param {number} t
  11416. * @return {number}
  11417. */
  11418. function cubicAt(p0, p1, p2, p3, t) {
  11419. var onet = 1 - t;
  11420. return onet * onet * (onet * p0 + 3 * t * p1)
  11421. + t * t * (t * p3 + 3 * onet * p2);
  11422. }
  11423. /**
  11424. * 计算三次贝塞尔导数值
  11425. * @memberOf module:zrender/core/curve
  11426. * @param {number} p0
  11427. * @param {number} p1
  11428. * @param {number} p2
  11429. * @param {number} p3
  11430. * @param {number} t
  11431. * @return {number}
  11432. */
  11433. function cubicDerivativeAt(p0, p1, p2, p3, t) {
  11434. var onet = 1 - t;
  11435. return 3 * (
  11436. ((p1 - p0) * onet + 2 * (p2 - p1) * t) * onet
  11437. + (p3 - p2) * t * t
  11438. );
  11439. }
  11440. /**
  11441. * 计算三次贝塞尔方程根,使用盛金公式
  11442. * @memberOf module:zrender/core/curve
  11443. * @param {number} p0
  11444. * @param {number} p1
  11445. * @param {number} p2
  11446. * @param {number} p3
  11447. * @param {number} val
  11448. * @param {Array.<number>} roots
  11449. * @return {number} 有效根数目
  11450. */
  11451. function cubicRootAt(p0, p1, p2, p3, val, roots) {
  11452. // Evaluate roots of cubic functions
  11453. var a = p3 + 3 * (p1 - p2) - p0;
  11454. var b = 3 * (p2 - p1 * 2 + p0);
  11455. var c = 3 * (p1 - p0);
  11456. var d = p0 - val;
  11457. var A = b * b - 3 * a * c;
  11458. var B = b * c - 9 * a * d;
  11459. var C = c * c - 3 * b * d;
  11460. var n = 0;
  11461. if (isAroundZero(A) && isAroundZero(B)) {
  11462. if (isAroundZero(b)) {
  11463. roots[0] = 0;
  11464. }
  11465. else {
  11466. var t1 = -c / b; //t1, t2, t3, b is not zero
  11467. if (t1 >= 0 && t1 <= 1) {
  11468. roots[n++] = t1;
  11469. }
  11470. }
  11471. }
  11472. else {
  11473. var disc = B * B - 4 * A * C;
  11474. if (isAroundZero(disc)) {
  11475. var K = B / A;
  11476. var t1 = -b / a + K; // t1, a is not zero
  11477. var t2 = -K / 2; // t2, t3
  11478. if (t1 >= 0 && t1 <= 1) {
  11479. roots[n++] = t1;
  11480. }
  11481. if (t2 >= 0 && t2 <= 1) {
  11482. roots[n++] = t2;
  11483. }
  11484. }
  11485. else if (disc > 0) {
  11486. var discSqrt = mathSqrt(disc);
  11487. var Y1 = A * b + 1.5 * a * (-B + discSqrt);
  11488. var Y2 = A * b + 1.5 * a * (-B - discSqrt);
  11489. if (Y1 < 0) {
  11490. Y1 = -mathPow(-Y1, ONE_THIRD);
  11491. }
  11492. else {
  11493. Y1 = mathPow(Y1, ONE_THIRD);
  11494. }
  11495. if (Y2 < 0) {
  11496. Y2 = -mathPow(-Y2, ONE_THIRD);
  11497. }
  11498. else {
  11499. Y2 = mathPow(Y2, ONE_THIRD);
  11500. }
  11501. var t1 = (-b - (Y1 + Y2)) / (3 * a);
  11502. if (t1 >= 0 && t1 <= 1) {
  11503. roots[n++] = t1;
  11504. }
  11505. }
  11506. else {
  11507. var T = (2 * A * b - 3 * a * B) / (2 * mathSqrt(A * A * A));
  11508. var theta = Math.acos(T) / 3;
  11509. var ASqrt = mathSqrt(A);
  11510. var tmp = Math.cos(theta);
  11511. var t1 = (-b - 2 * ASqrt * tmp) / (3 * a);
  11512. var t2 = (-b + ASqrt * (tmp + THREE_SQRT * Math.sin(theta))) / (3 * a);
  11513. var t3 = (-b + ASqrt * (tmp - THREE_SQRT * Math.sin(theta))) / (3 * a);
  11514. if (t1 >= 0 && t1 <= 1) {
  11515. roots[n++] = t1;
  11516. }
  11517. if (t2 >= 0 && t2 <= 1) {
  11518. roots[n++] = t2;
  11519. }
  11520. if (t3 >= 0 && t3 <= 1) {
  11521. roots[n++] = t3;
  11522. }
  11523. }
  11524. }
  11525. return n;
  11526. }
  11527. /**
  11528. * 计算三次贝塞尔方程极限值的位置
  11529. * @memberOf module:zrender/core/curve
  11530. * @param {number} p0
  11531. * @param {number} p1
  11532. * @param {number} p2
  11533. * @param {number} p3
  11534. * @param {Array.<number>} extrema
  11535. * @return {number} 有效数目
  11536. */
  11537. function cubicExtrema(p0, p1, p2, p3, extrema) {
  11538. var b = 6 * p2 - 12 * p1 + 6 * p0;
  11539. var a = 9 * p1 + 3 * p3 - 3 * p0 - 9 * p2;
  11540. var c = 3 * p1 - 3 * p0;
  11541. var n = 0;
  11542. if (isAroundZero(a)) {
  11543. if (isNotAroundZero(b)) {
  11544. var t1 = -c / b;
  11545. if (t1 >= 0 && t1 <=1) {
  11546. extrema[n++] = t1;
  11547. }
  11548. }
  11549. }
  11550. else {
  11551. var disc = b * b - 4 * a * c;
  11552. if (isAroundZero(disc)) {
  11553. extrema[0] = -b / (2 * a);
  11554. }
  11555. else if (disc > 0) {
  11556. var discSqrt = mathSqrt(disc);
  11557. var t1 = (-b + discSqrt) / (2 * a);
  11558. var t2 = (-b - discSqrt) / (2 * a);
  11559. if (t1 >= 0 && t1 <= 1) {
  11560. extrema[n++] = t1;
  11561. }
  11562. if (t2 >= 0 && t2 <= 1) {
  11563. extrema[n++] = t2;
  11564. }
  11565. }
  11566. }
  11567. return n;
  11568. }
  11569. /**
  11570. * 细分三次贝塞尔曲线
  11571. * @memberOf module:zrender/core/curve
  11572. * @param {number} p0
  11573. * @param {number} p1
  11574. * @param {number} p2
  11575. * @param {number} p3
  11576. * @param {number} t
  11577. * @param {Array.<number>} out
  11578. */
  11579. function cubicSubdivide(p0, p1, p2, p3, t, out) {
  11580. var p01 = (p1 - p0) * t + p0;
  11581. var p12 = (p2 - p1) * t + p1;
  11582. var p23 = (p3 - p2) * t + p2;
  11583. var p012 = (p12 - p01) * t + p01;
  11584. var p123 = (p23 - p12) * t + p12;
  11585. var p0123 = (p123 - p012) * t + p012;
  11586. // Seg0
  11587. out[0] = p0;
  11588. out[1] = p01;
  11589. out[2] = p012;
  11590. out[3] = p0123;
  11591. // Seg1
  11592. out[4] = p0123;
  11593. out[5] = p123;
  11594. out[6] = p23;
  11595. out[7] = p3;
  11596. }
  11597. /**
  11598. * 投射点到三次贝塞尔曲线上,返回投射距离。
  11599. * 投射点有可能会有一个或者多个,这里只返回其中距离最短的一个。
  11600. * @param {number} x0
  11601. * @param {number} y0
  11602. * @param {number} x1
  11603. * @param {number} y1
  11604. * @param {number} x2
  11605. * @param {number} y2
  11606. * @param {number} x3
  11607. * @param {number} y3
  11608. * @param {number} x
  11609. * @param {number} y
  11610. * @param {Array.<number>} [out] 投射点
  11611. * @return {number}
  11612. */
  11613. function cubicProjectPoint(
  11614. x0, y0, x1, y1, x2, y2, x3, y3,
  11615. x, y, out
  11616. ) {
  11617. // http://pomax.github.io/bezierinfo/#projections
  11618. var t;
  11619. var interval = 0.005;
  11620. var d = Infinity;
  11621. var prev;
  11622. var next;
  11623. var d1;
  11624. var d2;
  11625. _v0[0] = x;
  11626. _v0[1] = y;
  11627. // 先粗略估计一下可能的最小距离的 t 值
  11628. // PENDING
  11629. for (var _t = 0; _t < 1; _t += 0.05) {
  11630. _v1[0] = cubicAt(x0, x1, x2, x3, _t);
  11631. _v1[1] = cubicAt(y0, y1, y2, y3, _t);
  11632. d1 = v2DistSquare(_v0, _v1);
  11633. if (d1 < d) {
  11634. t = _t;
  11635. d = d1;
  11636. }
  11637. }
  11638. d = Infinity;
  11639. // At most 32 iteration
  11640. for (var i = 0; i < 32; i++) {
  11641. if (interval < EPSILON_NUMERIC) {
  11642. break;
  11643. }
  11644. prev = t - interval;
  11645. next = t + interval;
  11646. // t - interval
  11647. _v1[0] = cubicAt(x0, x1, x2, x3, prev);
  11648. _v1[1] = cubicAt(y0, y1, y2, y3, prev);
  11649. d1 = v2DistSquare(_v1, _v0);
  11650. if (prev >= 0 && d1 < d) {
  11651. t = prev;
  11652. d = d1;
  11653. }
  11654. else {
  11655. // t + interval
  11656. _v2[0] = cubicAt(x0, x1, x2, x3, next);
  11657. _v2[1] = cubicAt(y0, y1, y2, y3, next);
  11658. d2 = v2DistSquare(_v2, _v0);
  11659. if (next <= 1 && d2 < d) {
  11660. t = next;
  11661. d = d2;
  11662. }
  11663. else {
  11664. interval *= 0.5;
  11665. }
  11666. }
  11667. }
  11668. // t
  11669. if (out) {
  11670. out[0] = cubicAt(x0, x1, x2, x3, t);
  11671. out[1] = cubicAt(y0, y1, y2, y3, t);
  11672. }
  11673. // console.log(interval, i);
  11674. return mathSqrt(d);
  11675. }
  11676. /**
  11677. * 计算二次方贝塞尔值
  11678. * @param {number} p0
  11679. * @param {number} p1
  11680. * @param {number} p2
  11681. * @param {number} t
  11682. * @return {number}
  11683. */
  11684. function quadraticAt(p0, p1, p2, t) {
  11685. var onet = 1 - t;
  11686. return onet * (onet * p0 + 2 * t * p1) + t * t * p2;
  11687. }
  11688. /**
  11689. * 计算二次方贝塞尔导数值
  11690. * @param {number} p0
  11691. * @param {number} p1
  11692. * @param {number} p2
  11693. * @param {number} t
  11694. * @return {number}
  11695. */
  11696. function quadraticDerivativeAt(p0, p1, p2, t) {
  11697. return 2 * ((1 - t) * (p1 - p0) + t * (p2 - p1));
  11698. }
  11699. /**
  11700. * 计算二次方贝塞尔方程根
  11701. * @param {number} p0
  11702. * @param {number} p1
  11703. * @param {number} p2
  11704. * @param {number} t
  11705. * @param {Array.<number>} roots
  11706. * @return {number} 有效根数目
  11707. */
  11708. function quadraticRootAt(p0, p1, p2, val, roots) {
  11709. var a = p0 - 2 * p1 + p2;
  11710. var b = 2 * (p1 - p0);
  11711. var c = p0 - val;
  11712. var n = 0;
  11713. if (isAroundZero(a)) {
  11714. if (isNotAroundZero(b)) {
  11715. var t1 = -c / b;
  11716. if (t1 >= 0 && t1 <= 1) {
  11717. roots[n++] = t1;
  11718. }
  11719. }
  11720. }
  11721. else {
  11722. var disc = b * b - 4 * a * c;
  11723. if (isAroundZero(disc)) {
  11724. var t1 = -b / (2 * a);
  11725. if (t1 >= 0 && t1 <= 1) {
  11726. roots[n++] = t1;
  11727. }
  11728. }
  11729. else if (disc > 0) {
  11730. var discSqrt = mathSqrt(disc);
  11731. var t1 = (-b + discSqrt) / (2 * a);
  11732. var t2 = (-b - discSqrt) / (2 * a);
  11733. if (t1 >= 0 && t1 <= 1) {
  11734. roots[n++] = t1;
  11735. }
  11736. if (t2 >= 0 && t2 <= 1) {
  11737. roots[n++] = t2;
  11738. }
  11739. }
  11740. }
  11741. return n;
  11742. }
  11743. /**
  11744. * 计算二次贝塞尔方程极限值
  11745. * @memberOf module:zrender/core/curve
  11746. * @param {number} p0
  11747. * @param {number} p1
  11748. * @param {number} p2
  11749. * @return {number}
  11750. */
  11751. function quadraticExtremum(p0, p1, p2) {
  11752. var divider = p0 + p2 - 2 * p1;
  11753. if (divider === 0) {
  11754. // p1 is center of p0 and p2
  11755. return 0.5;
  11756. }
  11757. else {
  11758. return (p0 - p1) / divider;
  11759. }
  11760. }
  11761. /**
  11762. * 细分二次贝塞尔曲线
  11763. * @memberOf module:zrender/core/curve
  11764. * @param {number} p0
  11765. * @param {number} p1
  11766. * @param {number} p2
  11767. * @param {number} t
  11768. * @param {Array.<number>} out
  11769. */
  11770. function quadraticSubdivide(p0, p1, p2, t, out) {
  11771. var p01 = (p1 - p0) * t + p0;
  11772. var p12 = (p2 - p1) * t + p1;
  11773. var p012 = (p12 - p01) * t + p01;
  11774. // Seg0
  11775. out[0] = p0;
  11776. out[1] = p01;
  11777. out[2] = p012;
  11778. // Seg1
  11779. out[3] = p012;
  11780. out[4] = p12;
  11781. out[5] = p2;
  11782. }
  11783. /**
  11784. * 投射点到二次贝塞尔曲线上,返回投射距离。
  11785. * 投射点有可能会有一个或者多个,这里只返回其中距离最短的一个。
  11786. * @param {number} x0
  11787. * @param {number} y0
  11788. * @param {number} x1
  11789. * @param {number} y1
  11790. * @param {number} x2
  11791. * @param {number} y2
  11792. * @param {number} x
  11793. * @param {number} y
  11794. * @param {Array.<number>} out 投射点
  11795. * @return {number}
  11796. */
  11797. function quadraticProjectPoint(
  11798. x0, y0, x1, y1, x2, y2,
  11799. x, y, out
  11800. ) {
  11801. // http://pomax.github.io/bezierinfo/#projections
  11802. var t;
  11803. var interval = 0.005;
  11804. var d = Infinity;
  11805. _v0[0] = x;
  11806. _v0[1] = y;
  11807. // 先粗略估计一下可能的最小距离的 t 值
  11808. // PENDING
  11809. for (var _t = 0; _t < 1; _t += 0.05) {
  11810. _v1[0] = quadraticAt(x0, x1, x2, _t);
  11811. _v1[1] = quadraticAt(y0, y1, y2, _t);
  11812. var d1 = v2DistSquare(_v0, _v1);
  11813. if (d1 < d) {
  11814. t = _t;
  11815. d = d1;
  11816. }
  11817. }
  11818. d = Infinity;
  11819. // At most 32 iteration
  11820. for (var i = 0; i < 32; i++) {
  11821. if (interval < EPSILON_NUMERIC) {
  11822. break;
  11823. }
  11824. var prev = t - interval;
  11825. var next = t + interval;
  11826. // t - interval
  11827. _v1[0] = quadraticAt(x0, x1, x2, prev);
  11828. _v1[1] = quadraticAt(y0, y1, y2, prev);
  11829. var d1 = v2DistSquare(_v1, _v0);
  11830. if (prev >= 0 && d1 < d) {
  11831. t = prev;
  11832. d = d1;
  11833. }
  11834. else {
  11835. // t + interval
  11836. _v2[0] = quadraticAt(x0, x1, x2, next);
  11837. _v2[1] = quadraticAt(y0, y1, y2, next);
  11838. var d2 = v2DistSquare(_v2, _v0);
  11839. if (next <= 1 && d2 < d) {
  11840. t = next;
  11841. d = d2;
  11842. }
  11843. else {
  11844. interval *= 0.5;
  11845. }
  11846. }
  11847. }
  11848. // t
  11849. if (out) {
  11850. out[0] = quadraticAt(x0, x1, x2, t);
  11851. out[1] = quadraticAt(y0, y1, y2, t);
  11852. }
  11853. // console.log(interval, i);
  11854. return mathSqrt(d);
  11855. }
  11856. module.exports = {
  11857. cubicAt: cubicAt,
  11858. cubicDerivativeAt: cubicDerivativeAt,
  11859. cubicRootAt: cubicRootAt,
  11860. cubicExtrema: cubicExtrema,
  11861. cubicSubdivide: cubicSubdivide,
  11862. cubicProjectPoint: cubicProjectPoint,
  11863. quadraticAt: quadraticAt,
  11864. quadraticDerivativeAt: quadraticDerivativeAt,
  11865. quadraticRootAt: quadraticRootAt,
  11866. quadraticExtremum: quadraticExtremum,
  11867. quadraticSubdivide: quadraticSubdivide,
  11868. quadraticProjectPoint: quadraticProjectPoint
  11869. };
  11870. /***/ },
  11871. /* 51 */
  11872. /***/ function(module, exports, __webpack_require__) {
  11873. /**
  11874. * @author Yi Shen(https://github.com/pissang)
  11875. */
  11876. var vec2 = __webpack_require__(10);
  11877. var curve = __webpack_require__(50);
  11878. var bbox = {};
  11879. var mathMin = Math.min;
  11880. var mathMax = Math.max;
  11881. var mathSin = Math.sin;
  11882. var mathCos = Math.cos;
  11883. var start = vec2.create();
  11884. var end = vec2.create();
  11885. var extremity = vec2.create();
  11886. var PI2 = Math.PI * 2;
  11887. /**
  11888. * 从顶点数组中计算出最小包围盒,写入`min`和`max`中
  11889. * @module zrender/core/bbox
  11890. * @param {Array<Object>} points 顶点数组
  11891. * @param {number} min
  11892. * @param {number} max
  11893. */
  11894. bbox.fromPoints = function(points, min, max) {
  11895. if (points.length === 0) {
  11896. return;
  11897. }
  11898. var p = points[0];
  11899. var left = p[0];
  11900. var right = p[0];
  11901. var top = p[1];
  11902. var bottom = p[1];
  11903. var i;
  11904. for (i = 1; i < points.length; i++) {
  11905. p = points[i];
  11906. left = mathMin(left, p[0]);
  11907. right = mathMax(right, p[0]);
  11908. top = mathMin(top, p[1]);
  11909. bottom = mathMax(bottom, p[1]);
  11910. }
  11911. min[0] = left;
  11912. min[1] = top;
  11913. max[0] = right;
  11914. max[1] = bottom;
  11915. };
  11916. /**
  11917. * @memberOf module:zrender/core/bbox
  11918. * @param {number} x0
  11919. * @param {number} y0
  11920. * @param {number} x1
  11921. * @param {number} y1
  11922. * @param {Array.<number>} min
  11923. * @param {Array.<number>} max
  11924. */
  11925. bbox.fromLine = function (x0, y0, x1, y1, min, max) {
  11926. min[0] = mathMin(x0, x1);
  11927. min[1] = mathMin(y0, y1);
  11928. max[0] = mathMax(x0, x1);
  11929. max[1] = mathMax(y0, y1);
  11930. };
  11931. var xDim = [];
  11932. var yDim = [];
  11933. /**
  11934. * 从三阶贝塞尔曲线(p0, p1, p2, p3)中计算出最小包围盒,写入`min`和`max`中
  11935. * @memberOf module:zrender/core/bbox
  11936. * @param {number} x0
  11937. * @param {number} y0
  11938. * @param {number} x1
  11939. * @param {number} y1
  11940. * @param {number} x2
  11941. * @param {number} y2
  11942. * @param {number} x3
  11943. * @param {number} y3
  11944. * @param {Array.<number>} min
  11945. * @param {Array.<number>} max
  11946. */
  11947. bbox.fromCubic = function(
  11948. x0, y0, x1, y1, x2, y2, x3, y3, min, max
  11949. ) {
  11950. var cubicExtrema = curve.cubicExtrema;
  11951. var cubicAt = curve.cubicAt;
  11952. var i;
  11953. var n = cubicExtrema(x0, x1, x2, x3, xDim);
  11954. min[0] = Infinity;
  11955. min[1] = Infinity;
  11956. max[0] = -Infinity;
  11957. max[1] = -Infinity;
  11958. for (i = 0; i < n; i++) {
  11959. var x = cubicAt(x0, x1, x2, x3, xDim[i]);
  11960. min[0] = mathMin(x, min[0]);
  11961. max[0] = mathMax(x, max[0]);
  11962. }
  11963. n = cubicExtrema(y0, y1, y2, y3, yDim);
  11964. for (i = 0; i < n; i++) {
  11965. var y = cubicAt(y0, y1, y2, y3, yDim[i]);
  11966. min[1] = mathMin(y, min[1]);
  11967. max[1] = mathMax(y, max[1]);
  11968. }
  11969. min[0] = mathMin(x0, min[0]);
  11970. max[0] = mathMax(x0, max[0]);
  11971. min[0] = mathMin(x3, min[0]);
  11972. max[0] = mathMax(x3, max[0]);
  11973. min[1] = mathMin(y0, min[1]);
  11974. max[1] = mathMax(y0, max[1]);
  11975. min[1] = mathMin(y3, min[1]);
  11976. max[1] = mathMax(y3, max[1]);
  11977. };
  11978. /**
  11979. * 从二阶贝塞尔曲线(p0, p1, p2)中计算出最小包围盒,写入`min`和`max`中
  11980. * @memberOf module:zrender/core/bbox
  11981. * @param {number} x0
  11982. * @param {number} y0
  11983. * @param {number} x1
  11984. * @param {number} y1
  11985. * @param {number} x2
  11986. * @param {number} y2
  11987. * @param {Array.<number>} min
  11988. * @param {Array.<number>} max
  11989. */
  11990. bbox.fromQuadratic = function(x0, y0, x1, y1, x2, y2, min, max) {
  11991. var quadraticExtremum = curve.quadraticExtremum;
  11992. var quadraticAt = curve.quadraticAt;
  11993. // Find extremities, where derivative in x dim or y dim is zero
  11994. var tx =
  11995. mathMax(
  11996. mathMin(quadraticExtremum(x0, x1, x2), 1), 0
  11997. );
  11998. var ty =
  11999. mathMax(
  12000. mathMin(quadraticExtremum(y0, y1, y2), 1), 0
  12001. );
  12002. var x = quadraticAt(x0, x1, x2, tx);
  12003. var y = quadraticAt(y0, y1, y2, ty);
  12004. min[0] = mathMin(x0, x2, x);
  12005. min[1] = mathMin(y0, y2, y);
  12006. max[0] = mathMax(x0, x2, x);
  12007. max[1] = mathMax(y0, y2, y);
  12008. };
  12009. /**
  12010. * 从圆弧中计算出最小包围盒,写入`min`和`max`中
  12011. * @method
  12012. * @memberOf module:zrender/core/bbox
  12013. * @param {number} x
  12014. * @param {number} y
  12015. * @param {number} rx
  12016. * @param {number} ry
  12017. * @param {number} startAngle
  12018. * @param {number} endAngle
  12019. * @param {number} anticlockwise
  12020. * @param {Array.<number>} min
  12021. * @param {Array.<number>} max
  12022. */
  12023. bbox.fromArc = function (
  12024. x, y, rx, ry, startAngle, endAngle, anticlockwise, min, max
  12025. ) {
  12026. var vec2Min = vec2.min;
  12027. var vec2Max = vec2.max;
  12028. var diff = Math.abs(startAngle - endAngle);
  12029. if (diff % PI2 < 1e-4 && diff > 1e-4) {
  12030. // Is a circle
  12031. min[0] = x - rx;
  12032. min[1] = y - ry;
  12033. max[0] = x + rx;
  12034. max[1] = y + ry;
  12035. return;
  12036. }
  12037. start[0] = mathCos(startAngle) * rx + x;
  12038. start[1] = mathSin(startAngle) * ry + y;
  12039. end[0] = mathCos(endAngle) * rx + x;
  12040. end[1] = mathSin(endAngle) * ry + y;
  12041. vec2Min(min, start, end);
  12042. vec2Max(max, start, end);
  12043. // Thresh to [0, Math.PI * 2]
  12044. startAngle = startAngle % (PI2);
  12045. if (startAngle < 0) {
  12046. startAngle = startAngle + PI2;
  12047. }
  12048. endAngle = endAngle % (PI2);
  12049. if (endAngle < 0) {
  12050. endAngle = endAngle + PI2;
  12051. }
  12052. if (startAngle > endAngle && !anticlockwise) {
  12053. endAngle += PI2;
  12054. }
  12055. else if (startAngle < endAngle && anticlockwise) {
  12056. startAngle += PI2;
  12057. }
  12058. if (anticlockwise) {
  12059. var tmp = endAngle;
  12060. endAngle = startAngle;
  12061. startAngle = tmp;
  12062. }
  12063. // var number = 0;
  12064. // var step = (anticlockwise ? -Math.PI : Math.PI) / 2;
  12065. for (var angle = 0; angle < endAngle; angle += Math.PI / 2) {
  12066. if (angle > startAngle) {
  12067. extremity[0] = mathCos(angle) * rx + x;
  12068. extremity[1] = mathSin(angle) * ry + y;
  12069. vec2Min(min, extremity, min);
  12070. vec2Max(max, extremity, max);
  12071. }
  12072. }
  12073. };
  12074. module.exports = bbox;
  12075. /***/ },
  12076. /* 52 */
  12077. /***/ function(module, exports, __webpack_require__) {
  12078. 'use strict';
  12079. var CMD = __webpack_require__(49).CMD;
  12080. var line = __webpack_require__(53);
  12081. var cubic = __webpack_require__(54);
  12082. var quadratic = __webpack_require__(55);
  12083. var arc = __webpack_require__(56);
  12084. var normalizeRadian = __webpack_require__(57).normalizeRadian;
  12085. var curve = __webpack_require__(50);
  12086. var windingLine = __webpack_require__(58);
  12087. var containStroke = line.containStroke;
  12088. var PI2 = Math.PI * 2;
  12089. var EPSILON = 1e-4;
  12090. function isAroundEqual(a, b) {
  12091. return Math.abs(a - b) < EPSILON;
  12092. }
  12093. // 临时数组
  12094. var roots = [-1, -1, -1];
  12095. var extrema = [-1, -1];
  12096. function swapExtrema() {
  12097. var tmp = extrema[0];
  12098. extrema[0] = extrema[1];
  12099. extrema[1] = tmp;
  12100. }
  12101. function windingCubic(x0, y0, x1, y1, x2, y2, x3, y3, x, y) {
  12102. // Quick reject
  12103. if (
  12104. (y > y0 && y > y1 && y > y2 && y > y3)
  12105. || (y < y0 && y < y1 && y < y2 && y < y3)
  12106. ) {
  12107. return 0;
  12108. }
  12109. var nRoots = curve.cubicRootAt(y0, y1, y2, y3, y, roots);
  12110. if (nRoots === 0) {
  12111. return 0;
  12112. }
  12113. else {
  12114. var w = 0;
  12115. var nExtrema = -1;
  12116. var y0_, y1_;
  12117. for (var i = 0; i < nRoots; i++) {
  12118. var t = roots[i];
  12119. // Avoid winding error when intersection point is the connect point of two line of polygon
  12120. var unit = (t === 0 || t === 1) ? 0.5 : 1;
  12121. var x_ = curve.cubicAt(x0, x1, x2, x3, t);
  12122. if (x_ < x) { // Quick reject
  12123. continue;
  12124. }
  12125. if (nExtrema < 0) {
  12126. nExtrema = curve.cubicExtrema(y0, y1, y2, y3, extrema);
  12127. if (extrema[1] < extrema[0] && nExtrema > 1) {
  12128. swapExtrema();
  12129. }
  12130. y0_ = curve.cubicAt(y0, y1, y2, y3, extrema[0]);
  12131. if (nExtrema > 1) {
  12132. y1_ = curve.cubicAt(y0, y1, y2, y3, extrema[1]);
  12133. }
  12134. }
  12135. if (nExtrema == 2) {
  12136. // 分成三段单调函数
  12137. if (t < extrema[0]) {
  12138. w += y0_ < y0 ? unit : -unit;
  12139. }
  12140. else if (t < extrema[1]) {
  12141. w += y1_ < y0_ ? unit : -unit;
  12142. }
  12143. else {
  12144. w += y3 < y1_ ? unit : -unit;
  12145. }
  12146. }
  12147. else {
  12148. // 分成两段单调函数
  12149. if (t < extrema[0]) {
  12150. w += y0_ < y0 ? unit : -unit;
  12151. }
  12152. else {
  12153. w += y3 < y0_ ? unit : -unit;
  12154. }
  12155. }
  12156. }
  12157. return w;
  12158. }
  12159. }
  12160. function windingQuadratic(x0, y0, x1, y1, x2, y2, x, y) {
  12161. // Quick reject
  12162. if (
  12163. (y > y0 && y > y1 && y > y2)
  12164. || (y < y0 && y < y1 && y < y2)
  12165. ) {
  12166. return 0;
  12167. }
  12168. var nRoots = curve.quadraticRootAt(y0, y1, y2, y, roots);
  12169. if (nRoots === 0) {
  12170. return 0;
  12171. }
  12172. else {
  12173. var t = curve.quadraticExtremum(y0, y1, y2);
  12174. if (t >= 0 && t <= 1) {
  12175. var w = 0;
  12176. var y_ = curve.quadraticAt(y0, y1, y2, t);
  12177. for (var i = 0; i < nRoots; i++) {
  12178. // Remove one endpoint.
  12179. var unit = (roots[i] === 0 || roots[i] === 1) ? 0.5 : 1;
  12180. var x_ = curve.quadraticAt(x0, x1, x2, roots[i]);
  12181. if (x_ < x) { // Quick reject
  12182. continue;
  12183. }
  12184. if (roots[i] < t) {
  12185. w += y_ < y0 ? unit : -unit;
  12186. }
  12187. else {
  12188. w += y2 < y_ ? unit : -unit;
  12189. }
  12190. }
  12191. return w;
  12192. }
  12193. else {
  12194. // Remove one endpoint.
  12195. var unit = (roots[0] === 0 || roots[0] === 1) ? 0.5 : 1;
  12196. var x_ = curve.quadraticAt(x0, x1, x2, roots[0]);
  12197. if (x_ < x) { // Quick reject
  12198. return 0;
  12199. }
  12200. return y2 < y0 ? unit : -unit;
  12201. }
  12202. }
  12203. }
  12204. // TODO
  12205. // Arc 旋转
  12206. function windingArc(
  12207. cx, cy, r, startAngle, endAngle, anticlockwise, x, y
  12208. ) {
  12209. y -= cy;
  12210. if (y > r || y < -r) {
  12211. return 0;
  12212. }
  12213. var tmp = Math.sqrt(r * r - y * y);
  12214. roots[0] = -tmp;
  12215. roots[1] = tmp;
  12216. var diff = Math.abs(startAngle - endAngle);
  12217. if (diff < 1e-4) {
  12218. return 0;
  12219. }
  12220. if (diff % PI2 < 1e-4) {
  12221. // Is a circle
  12222. startAngle = 0;
  12223. endAngle = PI2;
  12224. var dir = anticlockwise ? 1 : -1;
  12225. if (x >= roots[0] + cx && x <= roots[1] + cx) {
  12226. return dir;
  12227. } else {
  12228. return 0;
  12229. }
  12230. }
  12231. if (anticlockwise) {
  12232. var tmp = startAngle;
  12233. startAngle = normalizeRadian(endAngle);
  12234. endAngle = normalizeRadian(tmp);
  12235. }
  12236. else {
  12237. startAngle = normalizeRadian(startAngle);
  12238. endAngle = normalizeRadian(endAngle);
  12239. }
  12240. if (startAngle > endAngle) {
  12241. endAngle += PI2;
  12242. }
  12243. var w = 0;
  12244. for (var i = 0; i < 2; i++) {
  12245. var x_ = roots[i];
  12246. if (x_ + cx > x) {
  12247. var angle = Math.atan2(y, x_);
  12248. var dir = anticlockwise ? 1 : -1;
  12249. if (angle < 0) {
  12250. angle = PI2 + angle;
  12251. }
  12252. if (
  12253. (angle >= startAngle && angle <= endAngle)
  12254. || (angle + PI2 >= startAngle && angle + PI2 <= endAngle)
  12255. ) {
  12256. if (angle > Math.PI / 2 && angle < Math.PI * 1.5) {
  12257. dir = -dir;
  12258. }
  12259. w += dir;
  12260. }
  12261. }
  12262. }
  12263. return w;
  12264. }
  12265. function containPath(data, lineWidth, isStroke, x, y) {
  12266. var w = 0;
  12267. var xi = 0;
  12268. var yi = 0;
  12269. var x0 = 0;
  12270. var y0 = 0;
  12271. for (var i = 0; i < data.length;) {
  12272. var cmd = data[i++];
  12273. // Begin a new subpath
  12274. if (cmd === CMD.M && i > 1) {
  12275. // Close previous subpath
  12276. if (!isStroke) {
  12277. w += windingLine(xi, yi, x0, y0, x, y);
  12278. }
  12279. // 如果被任何一个 subpath 包含
  12280. // if (w !== 0) {
  12281. // return true;
  12282. // }
  12283. }
  12284. if (i == 1) {
  12285. // 如果第一个命令是 L, C, Q
  12286. // 则 previous point 同绘制命令的第一个 point
  12287. //
  12288. // 第一个命令为 Arc 的情况下会在后面特殊处理
  12289. xi = data[i];
  12290. yi = data[i + 1];
  12291. x0 = xi;
  12292. y0 = yi;
  12293. }
  12294. switch (cmd) {
  12295. case CMD.M:
  12296. // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点
  12297. // 在 closePath 的时候使用
  12298. x0 = data[i++];
  12299. y0 = data[i++];
  12300. xi = x0;
  12301. yi = y0;
  12302. break;
  12303. case CMD.L:
  12304. if (isStroke) {
  12305. if (containStroke(xi, yi, data[i], data[i + 1], lineWidth, x, y)) {
  12306. return true;
  12307. }
  12308. }
  12309. else {
  12310. // NOTE 在第一个命令为 L, C, Q 的时候会计算出 NaN
  12311. w += windingLine(xi, yi, data[i], data[i + 1], x, y) || 0;
  12312. }
  12313. xi = data[i++];
  12314. yi = data[i++];
  12315. break;
  12316. case CMD.C:
  12317. if (isStroke) {
  12318. if (cubic.containStroke(xi, yi,
  12319. data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1],
  12320. lineWidth, x, y
  12321. )) {
  12322. return true;
  12323. }
  12324. }
  12325. else {
  12326. w += windingCubic(
  12327. xi, yi,
  12328. data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1],
  12329. x, y
  12330. ) || 0;
  12331. }
  12332. xi = data[i++];
  12333. yi = data[i++];
  12334. break;
  12335. case CMD.Q:
  12336. if (isStroke) {
  12337. if (quadratic.containStroke(xi, yi,
  12338. data[i++], data[i++], data[i], data[i + 1],
  12339. lineWidth, x, y
  12340. )) {
  12341. return true;
  12342. }
  12343. }
  12344. else {
  12345. w += windingQuadratic(
  12346. xi, yi,
  12347. data[i++], data[i++], data[i], data[i + 1],
  12348. x, y
  12349. ) || 0;
  12350. }
  12351. xi = data[i++];
  12352. yi = data[i++];
  12353. break;
  12354. case CMD.A:
  12355. // TODO Arc 判断的开销比较大
  12356. var cx = data[i++];
  12357. var cy = data[i++];
  12358. var rx = data[i++];
  12359. var ry = data[i++];
  12360. var theta = data[i++];
  12361. var dTheta = data[i++];
  12362. // TODO Arc 旋转
  12363. var psi = data[i++];
  12364. var anticlockwise = 1 - data[i++];
  12365. var x1 = Math.cos(theta) * rx + cx;
  12366. var y1 = Math.sin(theta) * ry + cy;
  12367. // 不是直接使用 arc 命令
  12368. if (i > 1) {
  12369. w += windingLine(xi, yi, x1, y1, x, y);
  12370. }
  12371. else {
  12372. // 第一个命令起点还未定义
  12373. x0 = x1;
  12374. y0 = y1;
  12375. }
  12376. // zr 使用scale来模拟椭圆, 这里也对x做一定的缩放
  12377. var _x = (x - cx) * ry / rx + cx;
  12378. if (isStroke) {
  12379. if (arc.containStroke(
  12380. cx, cy, ry, theta, theta + dTheta, anticlockwise,
  12381. lineWidth, _x, y
  12382. )) {
  12383. return true;
  12384. }
  12385. }
  12386. else {
  12387. w += windingArc(
  12388. cx, cy, ry, theta, theta + dTheta, anticlockwise,
  12389. _x, y
  12390. );
  12391. }
  12392. xi = Math.cos(theta + dTheta) * rx + cx;
  12393. yi = Math.sin(theta + dTheta) * ry + cy;
  12394. break;
  12395. case CMD.R:
  12396. x0 = xi = data[i++];
  12397. y0 = yi = data[i++];
  12398. var width = data[i++];
  12399. var height = data[i++];
  12400. var x1 = x0 + width;
  12401. var y1 = y0 + height;
  12402. if (isStroke) {
  12403. if (containStroke(x0, y0, x1, y0, lineWidth, x, y)
  12404. || containStroke(x1, y0, x1, y1, lineWidth, x, y)
  12405. || containStroke(x1, y1, x0, y1, lineWidth, x, y)
  12406. || containStroke(x0, y1, x0, y0, lineWidth, x, y)
  12407. ) {
  12408. return true;
  12409. }
  12410. }
  12411. else {
  12412. // FIXME Clockwise ?
  12413. w += windingLine(x1, y0, x1, y1, x, y);
  12414. w += windingLine(x0, y1, x0, y0, x, y);
  12415. }
  12416. break;
  12417. case CMD.Z:
  12418. if (isStroke) {
  12419. if (containStroke(
  12420. xi, yi, x0, y0, lineWidth, x, y
  12421. )) {
  12422. return true;
  12423. }
  12424. }
  12425. else {
  12426. // Close a subpath
  12427. w += windingLine(xi, yi, x0, y0, x, y);
  12428. // 如果被任何一个 subpath 包含
  12429. // FIXME subpaths may overlap
  12430. // if (w !== 0) {
  12431. // return true;
  12432. // }
  12433. }
  12434. xi = x0;
  12435. yi = y0;
  12436. break;
  12437. }
  12438. }
  12439. if (!isStroke && !isAroundEqual(yi, y0)) {
  12440. w += windingLine(xi, yi, x0, y0, x, y) || 0;
  12441. }
  12442. return w !== 0;
  12443. }
  12444. module.exports = {
  12445. contain: function (pathData, x, y) {
  12446. return containPath(pathData, 0, false, x, y);
  12447. },
  12448. containStroke: function (pathData, lineWidth, x, y) {
  12449. return containPath(pathData, lineWidth, true, x, y);
  12450. }
  12451. };
  12452. /***/ },
  12453. /* 53 */
  12454. /***/ function(module, exports) {
  12455. module.exports = {
  12456. /**
  12457. * 线段包含判断
  12458. * @param {number} x0
  12459. * @param {number} y0
  12460. * @param {number} x1
  12461. * @param {number} y1
  12462. * @param {number} lineWidth
  12463. * @param {number} x
  12464. * @param {number} y
  12465. * @return {boolean}
  12466. */
  12467. containStroke: function (x0, y0, x1, y1, lineWidth, x, y) {
  12468. if (lineWidth === 0) {
  12469. return false;
  12470. }
  12471. var _l = lineWidth;
  12472. var _a = 0;
  12473. var _b = x0;
  12474. // Quick reject
  12475. if (
  12476. (y > y0 + _l && y > y1 + _l)
  12477. || (y < y0 - _l && y < y1 - _l)
  12478. || (x > x0 + _l && x > x1 + _l)
  12479. || (x < x0 - _l && x < x1 - _l)
  12480. ) {
  12481. return false;
  12482. }
  12483. if (x0 !== x1) {
  12484. _a = (y0 - y1) / (x0 - x1);
  12485. _b = (x0 * y1 - x1 * y0) / (x0 - x1) ;
  12486. }
  12487. else {
  12488. return Math.abs(x - x0) <= _l / 2;
  12489. }
  12490. var tmp = _a * x - y + _b;
  12491. var _s = tmp * tmp / (_a * _a + 1);
  12492. return _s <= _l / 2 * _l / 2;
  12493. }
  12494. };
  12495. /***/ },
  12496. /* 54 */
  12497. /***/ function(module, exports, __webpack_require__) {
  12498. var curve = __webpack_require__(50);
  12499. module.exports = {
  12500. /**
  12501. * 三次贝塞尔曲线描边包含判断
  12502. * @param {number} x0
  12503. * @param {number} y0
  12504. * @param {number} x1
  12505. * @param {number} y1
  12506. * @param {number} x2
  12507. * @param {number} y2
  12508. * @param {number} x3
  12509. * @param {number} y3
  12510. * @param {number} lineWidth
  12511. * @param {number} x
  12512. * @param {number} y
  12513. * @return {boolean}
  12514. */
  12515. containStroke: function(x0, y0, x1, y1, x2, y2, x3, y3, lineWidth, x, y) {
  12516. if (lineWidth === 0) {
  12517. return false;
  12518. }
  12519. var _l = lineWidth;
  12520. // Quick reject
  12521. if (
  12522. (y > y0 + _l && y > y1 + _l && y > y2 + _l && y > y3 + _l)
  12523. || (y < y0 - _l && y < y1 - _l && y < y2 - _l && y < y3 - _l)
  12524. || (x > x0 + _l && x > x1 + _l && x > x2 + _l && x > x3 + _l)
  12525. || (x < x0 - _l && x < x1 - _l && x < x2 - _l && x < x3 - _l)
  12526. ) {
  12527. return false;
  12528. }
  12529. var d = curve.cubicProjectPoint(
  12530. x0, y0, x1, y1, x2, y2, x3, y3,
  12531. x, y, null
  12532. );
  12533. return d <= _l / 2;
  12534. }
  12535. };
  12536. /***/ },
  12537. /* 55 */
  12538. /***/ function(module, exports, __webpack_require__) {
  12539. var curve = __webpack_require__(50);
  12540. module.exports = {
  12541. /**
  12542. * 二次贝塞尔曲线描边包含判断
  12543. * @param {number} x0
  12544. * @param {number} y0
  12545. * @param {number} x1
  12546. * @param {number} y1
  12547. * @param {number} x2
  12548. * @param {number} y2
  12549. * @param {number} lineWidth
  12550. * @param {number} x
  12551. * @param {number} y
  12552. * @return {boolean}
  12553. */
  12554. containStroke: function (x0, y0, x1, y1, x2, y2, lineWidth, x, y) {
  12555. if (lineWidth === 0) {
  12556. return false;
  12557. }
  12558. var _l = lineWidth;
  12559. // Quick reject
  12560. if (
  12561. (y > y0 + _l && y > y1 + _l && y > y2 + _l)
  12562. || (y < y0 - _l && y < y1 - _l && y < y2 - _l)
  12563. || (x > x0 + _l && x > x1 + _l && x > x2 + _l)
  12564. || (x < x0 - _l && x < x1 - _l && x < x2 - _l)
  12565. ) {
  12566. return false;
  12567. }
  12568. var d = curve.quadraticProjectPoint(
  12569. x0, y0, x1, y1, x2, y2,
  12570. x, y, null
  12571. );
  12572. return d <= _l / 2;
  12573. }
  12574. };
  12575. /***/ },
  12576. /* 56 */
  12577. /***/ function(module, exports, __webpack_require__) {
  12578. var normalizeRadian = __webpack_require__(57).normalizeRadian;
  12579. var PI2 = Math.PI * 2;
  12580. module.exports = {
  12581. /**
  12582. * 圆弧描边包含判断
  12583. * @param {number} cx
  12584. * @param {number} cy
  12585. * @param {number} r
  12586. * @param {number} startAngle
  12587. * @param {number} endAngle
  12588. * @param {boolean} anticlockwise
  12589. * @param {number} lineWidth
  12590. * @param {number} x
  12591. * @param {number} y
  12592. * @return {Boolean}
  12593. */
  12594. containStroke: function (
  12595. cx, cy, r, startAngle, endAngle, anticlockwise,
  12596. lineWidth, x, y
  12597. ) {
  12598. if (lineWidth === 0) {
  12599. return false;
  12600. }
  12601. var _l = lineWidth;
  12602. x -= cx;
  12603. y -= cy;
  12604. var d = Math.sqrt(x * x + y * y);
  12605. if ((d - _l > r) || (d + _l < r)) {
  12606. return false;
  12607. }
  12608. if (Math.abs(startAngle - endAngle) % PI2 < 1e-4) {
  12609. // Is a circle
  12610. return true;
  12611. }
  12612. if (anticlockwise) {
  12613. var tmp = startAngle;
  12614. startAngle = normalizeRadian(endAngle);
  12615. endAngle = normalizeRadian(tmp);
  12616. } else {
  12617. startAngle = normalizeRadian(startAngle);
  12618. endAngle = normalizeRadian(endAngle);
  12619. }
  12620. if (startAngle > endAngle) {
  12621. endAngle += PI2;
  12622. }
  12623. var angle = Math.atan2(y, x);
  12624. if (angle < 0) {
  12625. angle += PI2;
  12626. }
  12627. return (angle >= startAngle && angle <= endAngle)
  12628. || (angle + PI2 >= startAngle && angle + PI2 <= endAngle);
  12629. }
  12630. };
  12631. /***/ },
  12632. /* 57 */
  12633. /***/ function(module, exports) {
  12634. var PI2 = Math.PI * 2;
  12635. module.exports = {
  12636. normalizeRadian: function(angle) {
  12637. angle %= PI2;
  12638. if (angle < 0) {
  12639. angle += PI2;
  12640. }
  12641. return angle;
  12642. }
  12643. };
  12644. /***/ },
  12645. /* 58 */
  12646. /***/ function(module, exports) {
  12647. module.exports = function windingLine(x0, y0, x1, y1, x, y) {
  12648. if ((y > y0 && y > y1) || (y < y0 && y < y1)) {
  12649. return 0;
  12650. }
  12651. // Ignore horizontal line
  12652. if (y1 === y0) {
  12653. return 0;
  12654. }
  12655. var dir = y1 < y0 ? 1 : -1;
  12656. var t = (y - y0) / (y1 - y0);
  12657. // Avoid winding error when intersection point is the connect point of two line of polygon
  12658. if (t === 1 || t === 0) {
  12659. dir = y1 < y0 ? 0.5 : -0.5;
  12660. }
  12661. var x_ = t * (x1 - x0) + x0;
  12662. return x_ > x ? dir : 0;
  12663. };
  12664. /***/ },
  12665. /* 59 */
  12666. /***/ function(module, exports) {
  12667. var Pattern = function (image, repeat) {
  12668. this.image = image;
  12669. this.repeat = repeat;
  12670. // Can be cloned
  12671. this.type = 'pattern';
  12672. };
  12673. Pattern.prototype.getCanvasPattern = function (ctx) {
  12674. return this._canvasPattern
  12675. || (this._canvasPattern = ctx.createPattern(this.image, this.repeat));
  12676. };
  12677. module.exports = Pattern;
  12678. /***/ },
  12679. /* 60 */
  12680. /***/ function(module, exports, __webpack_require__) {
  12681. var CMD = __webpack_require__(49).CMD;
  12682. var vec2 = __webpack_require__(10);
  12683. var v2ApplyTransform = vec2.applyTransform;
  12684. var points = [[], [], []];
  12685. var mathSqrt = Math.sqrt;
  12686. var mathAtan2 = Math.atan2;
  12687. function transformPath(path, m) {
  12688. var data = path.data;
  12689. var cmd;
  12690. var nPoint;
  12691. var i;
  12692. var j;
  12693. var k;
  12694. var p;
  12695. var M = CMD.M;
  12696. var C = CMD.C;
  12697. var L = CMD.L;
  12698. var R = CMD.R;
  12699. var A = CMD.A;
  12700. var Q = CMD.Q;
  12701. for (i = 0, j = 0; i < data.length;) {
  12702. cmd = data[i++];
  12703. j = i;
  12704. nPoint = 0;
  12705. switch (cmd) {
  12706. case M:
  12707. nPoint = 1;
  12708. break;
  12709. case L:
  12710. nPoint = 1;
  12711. break;
  12712. case C:
  12713. nPoint = 3;
  12714. break;
  12715. case Q:
  12716. nPoint = 2;
  12717. break;
  12718. case A:
  12719. var x = m[4];
  12720. var y = m[5];
  12721. var sx = mathSqrt(m[0] * m[0] + m[1] * m[1]);
  12722. var sy = mathSqrt(m[2] * m[2] + m[3] * m[3]);
  12723. var angle = mathAtan2(-m[1] / sy, m[0] / sx);
  12724. // cx
  12725. data[i++] += x;
  12726. // cy
  12727. data[i++] += y;
  12728. // Scale rx and ry
  12729. // FIXME Assume psi is 0 here
  12730. data[i++] *= sx;
  12731. data[i++] *= sy;
  12732. // Start angle
  12733. data[i++] += angle;
  12734. // end angle
  12735. data[i++] += angle;
  12736. // FIXME psi
  12737. i += 2;
  12738. j = i;
  12739. break;
  12740. case R:
  12741. // x0, y0
  12742. p[0] = data[i++];
  12743. p[1] = data[i++];
  12744. v2ApplyTransform(p, p, m);
  12745. data[j++] = p[0];
  12746. data[j++] = p[1];
  12747. // x1, y1
  12748. p[0] += data[i++];
  12749. p[1] += data[i++];
  12750. v2ApplyTransform(p, p, m);
  12751. data[j++] = p[0];
  12752. data[j++] = p[1];
  12753. }
  12754. for (k = 0; k < nPoint; k++) {
  12755. var p = points[k];
  12756. p[0] = data[i++];
  12757. p[1] = data[i++];
  12758. v2ApplyTransform(p, p, m);
  12759. // Write back
  12760. data[j++] = p[0];
  12761. data[j++] = p[1];
  12762. }
  12763. }
  12764. }
  12765. module.exports = transformPath;
  12766. /***/ },
  12767. /* 61 */
  12768. /***/ function(module, exports) {
  12769. /**
  12770. * @param {Array.<Object>} colorStops
  12771. */
  12772. var Gradient = function (colorStops) {
  12773. this.colorStops = colorStops || [];
  12774. };
  12775. Gradient.prototype = {
  12776. constructor: Gradient,
  12777. addColorStop: function (offset, color) {
  12778. this.colorStops.push({
  12779. offset: offset,
  12780. color: color
  12781. });
  12782. }
  12783. };
  12784. module.exports = Gradient;
  12785. /***/ },
  12786. /* 62 */
  12787. /***/ function(module, exports, __webpack_require__) {
  12788. /**
  12789. * Image element
  12790. * @module zrender/graphic/Image
  12791. */
  12792. var Displayable = __webpack_require__(46);
  12793. var BoundingRect = __webpack_require__(9);
  12794. var zrUtil = __webpack_require__(4);
  12795. var LRU = __webpack_require__(63);
  12796. var globalImageCache = new LRU(50);
  12797. /**
  12798. * @alias zrender/graphic/Image
  12799. * @extends module:zrender/graphic/Displayable
  12800. * @constructor
  12801. * @param {Object} opts
  12802. */
  12803. function ZImage(opts) {
  12804. Displayable.call(this, opts);
  12805. }
  12806. ZImage.prototype = {
  12807. constructor: ZImage,
  12808. type: 'image',
  12809. brush: function (ctx, prevEl) {
  12810. var style = this.style;
  12811. var src = style.image;
  12812. var image;
  12813. // Must bind each time
  12814. style.bind(ctx, this, prevEl);
  12815. // style.image is a url string
  12816. if (typeof src === 'string') {
  12817. image = this._image;
  12818. }
  12819. // style.image is an HTMLImageElement or HTMLCanvasElement or Canvas
  12820. else {
  12821. image = src;
  12822. }
  12823. // FIXME Case create many images with src
  12824. if (!image && src) {
  12825. // Try get from global image cache
  12826. var cachedImgObj = globalImageCache.get(src);
  12827. if (!cachedImgObj) {
  12828. // Create a new image
  12829. image = new Image();
  12830. image.onload = function () {
  12831. image.onload = null;
  12832. for (var i = 0; i < cachedImgObj.pending.length; i++) {
  12833. cachedImgObj.pending[i].dirty();
  12834. }
  12835. };
  12836. cachedImgObj = {
  12837. image: image,
  12838. pending: [this]
  12839. };
  12840. image.src = src;
  12841. globalImageCache.put(src, cachedImgObj);
  12842. this._image = image;
  12843. return;
  12844. }
  12845. else {
  12846. image = cachedImgObj.image;
  12847. this._image = image;
  12848. // Image is not complete finish, add to pending list
  12849. if (!image.width || !image.height) {
  12850. cachedImgObj.pending.push(this);
  12851. return;
  12852. }
  12853. }
  12854. }
  12855. if (image) {
  12856. // 图片已经加载完成
  12857. // if (image.nodeName.toUpperCase() == 'IMG') {
  12858. // if (!image.complete) {
  12859. // return;
  12860. // }
  12861. // }
  12862. // Else is canvas
  12863. var width = style.width || image.width;
  12864. var height = style.height || image.height;
  12865. var x = style.x || 0;
  12866. var y = style.y || 0;
  12867. // 图片加载失败
  12868. if (!image.width || !image.height) {
  12869. return;
  12870. }
  12871. // 设置transform
  12872. this.setTransform(ctx);
  12873. if (style.sWidth && style.sHeight) {
  12874. var sx = style.sx || 0;
  12875. var sy = style.sy || 0;
  12876. ctx.drawImage(
  12877. image,
  12878. sx, sy, style.sWidth, style.sHeight,
  12879. x, y, width, height
  12880. );
  12881. }
  12882. else if (style.sx && style.sy) {
  12883. var sx = style.sx;
  12884. var sy = style.sy;
  12885. var sWidth = width - sx;
  12886. var sHeight = height - sy;
  12887. ctx.drawImage(
  12888. image,
  12889. sx, sy, sWidth, sHeight,
  12890. x, y, width, height
  12891. );
  12892. }
  12893. else {
  12894. ctx.drawImage(image, x, y, width, height);
  12895. }
  12896. // 如果没设置宽和高的话自动根据图片宽高设置
  12897. if (style.width == null) {
  12898. style.width = width;
  12899. }
  12900. if (style.height == null) {
  12901. style.height = height;
  12902. }
  12903. this.restoreTransform(ctx);
  12904. // Draw rect text
  12905. if (style.text != null) {
  12906. this.drawRectText(ctx, this.getBoundingRect());
  12907. }
  12908. }
  12909. },
  12910. getBoundingRect: function () {
  12911. var style = this.style;
  12912. if (! this._rect) {
  12913. this._rect = new BoundingRect(
  12914. style.x || 0, style.y || 0, style.width || 0, style.height || 0
  12915. );
  12916. }
  12917. return this._rect;
  12918. }
  12919. };
  12920. zrUtil.inherits(ZImage, Displayable);
  12921. module.exports = ZImage;
  12922. /***/ },
  12923. /* 63 */
  12924. /***/ function(module, exports) {
  12925. // Simple LRU cache use doubly linked list
  12926. // @module zrender/core/LRU
  12927. /**
  12928. * Simple double linked list. Compared with array, it has O(1) remove operation.
  12929. * @constructor
  12930. */
  12931. var LinkedList = function() {
  12932. /**
  12933. * @type {module:zrender/core/LRU~Entry}
  12934. */
  12935. this.head = null;
  12936. /**
  12937. * @type {module:zrender/core/LRU~Entry}
  12938. */
  12939. this.tail = null;
  12940. this._len = 0;
  12941. };
  12942. var linkedListProto = LinkedList.prototype;
  12943. /**
  12944. * Insert a new value at the tail
  12945. * @param {} val
  12946. * @return {module:zrender/core/LRU~Entry}
  12947. */
  12948. linkedListProto.insert = function(val) {
  12949. var entry = new Entry(val);
  12950. this.insertEntry(entry);
  12951. return entry;
  12952. };
  12953. /**
  12954. * Insert an entry at the tail
  12955. * @param {module:zrender/core/LRU~Entry} entry
  12956. */
  12957. linkedListProto.insertEntry = function(entry) {
  12958. if (!this.head) {
  12959. this.head = this.tail = entry;
  12960. }
  12961. else {
  12962. this.tail.next = entry;
  12963. entry.prev = this.tail;
  12964. this.tail = entry;
  12965. }
  12966. this._len++;
  12967. };
  12968. /**
  12969. * Remove entry.
  12970. * @param {module:zrender/core/LRU~Entry} entry
  12971. */
  12972. linkedListProto.remove = function(entry) {
  12973. var prev = entry.prev;
  12974. var next = entry.next;
  12975. if (prev) {
  12976. prev.next = next;
  12977. }
  12978. else {
  12979. // Is head
  12980. this.head = next;
  12981. }
  12982. if (next) {
  12983. next.prev = prev;
  12984. }
  12985. else {
  12986. // Is tail
  12987. this.tail = prev;
  12988. }
  12989. entry.next = entry.prev = null;
  12990. this._len--;
  12991. };
  12992. /**
  12993. * @return {number}
  12994. */
  12995. linkedListProto.len = function() {
  12996. return this._len;
  12997. };
  12998. /**
  12999. * @constructor
  13000. * @param {} val
  13001. */
  13002. var Entry = function(val) {
  13003. /**
  13004. * @type {}
  13005. */
  13006. this.value = val;
  13007. /**
  13008. * @type {module:zrender/core/LRU~Entry}
  13009. */
  13010. this.next;
  13011. /**
  13012. * @type {module:zrender/core/LRU~Entry}
  13013. */
  13014. this.prev;
  13015. };
  13016. /**
  13017. * LRU Cache
  13018. * @constructor
  13019. * @alias module:zrender/core/LRU
  13020. */
  13021. var LRU = function(maxSize) {
  13022. this._list = new LinkedList();
  13023. this._map = {};
  13024. this._maxSize = maxSize || 10;
  13025. };
  13026. var LRUProto = LRU.prototype;
  13027. /**
  13028. * @param {string} key
  13029. * @param {} value
  13030. */
  13031. LRUProto.put = function(key, value) {
  13032. var list = this._list;
  13033. var map = this._map;
  13034. if (map[key] == null) {
  13035. var len = list.len();
  13036. if (len >= this._maxSize && len > 0) {
  13037. // Remove the least recently used
  13038. var leastUsedEntry = list.head;
  13039. list.remove(leastUsedEntry);
  13040. delete map[leastUsedEntry.key];
  13041. }
  13042. var entry = list.insert(value);
  13043. entry.key = key;
  13044. map[key] = entry;
  13045. }
  13046. };
  13047. /**
  13048. * @param {string} key
  13049. * @return {}
  13050. */
  13051. LRUProto.get = function(key) {
  13052. var entry = this._map[key];
  13053. var list = this._list;
  13054. if (entry != null) {
  13055. // Put the latest used entry in the tail
  13056. if (entry !== list.tail) {
  13057. list.remove(entry);
  13058. list.insertEntry(entry);
  13059. }
  13060. return entry.value;
  13061. }
  13062. };
  13063. /**
  13064. * Clear the cache
  13065. */
  13066. LRUProto.clear = function() {
  13067. this._list.clear();
  13068. this._map = {};
  13069. };
  13070. module.exports = LRU;
  13071. /***/ },
  13072. /* 64 */
  13073. /***/ function(module, exports, __webpack_require__) {
  13074. /**
  13075. * Text element
  13076. * @module zrender/graphic/Text
  13077. *
  13078. * TODO Wrapping
  13079. *
  13080. * Text not support gradient
  13081. */
  13082. var Displayable = __webpack_require__(46);
  13083. var zrUtil = __webpack_require__(4);
  13084. var textContain = __webpack_require__(8);
  13085. /**
  13086. * @alias zrender/graphic/Text
  13087. * @extends module:zrender/graphic/Displayable
  13088. * @constructor
  13089. * @param {Object} opts
  13090. */
  13091. var Text = function (opts) {
  13092. Displayable.call(this, opts);
  13093. };
  13094. Text.prototype = {
  13095. constructor: Text,
  13096. type: 'text',
  13097. brush: function (ctx, prevEl) {
  13098. var style = this.style;
  13099. var x = style.x || 0;
  13100. var y = style.y || 0;
  13101. // Convert to string
  13102. var text = style.text;
  13103. // Convert to string
  13104. text != null && (text += '');
  13105. // Always bind style
  13106. style.bind(ctx, this, prevEl);
  13107. if (text) {
  13108. this.setTransform(ctx);
  13109. var textBaseline;
  13110. var textAlign = style.textAlign;
  13111. var font = style.textFont || style.font;
  13112. if (style.textVerticalAlign) {
  13113. var rect = textContain.getBoundingRect(
  13114. text, font, style.textAlign, 'top'
  13115. );
  13116. // Ignore textBaseline
  13117. textBaseline = 'middle';
  13118. switch (style.textVerticalAlign) {
  13119. case 'middle':
  13120. y -= rect.height / 2 - rect.lineHeight / 2;
  13121. break;
  13122. case 'bottom':
  13123. y -= rect.height - rect.lineHeight / 2;
  13124. break;
  13125. default:
  13126. y += rect.lineHeight / 2;
  13127. }
  13128. }
  13129. else {
  13130. textBaseline = style.textBaseline;
  13131. }
  13132. ctx.font = font;
  13133. ctx.textAlign = textAlign || 'left';
  13134. // Use canvas default left textAlign. Giving invalid value will cause state not change
  13135. if (ctx.textAlign !== textAlign) {
  13136. ctx.textAlign = 'left';
  13137. }
  13138. ctx.textBaseline = textBaseline || 'alphabetic';
  13139. // Use canvas default alphabetic baseline
  13140. if (ctx.textBaseline !== textBaseline) {
  13141. ctx.textBaseline = 'alphabetic';
  13142. }
  13143. var lineHeight = textContain.measureText('国', ctx.font).width;
  13144. var textLines = text.split('\n');
  13145. for (var i = 0; i < textLines.length; i++) {
  13146. style.hasFill() && ctx.fillText(textLines[i], x, y);
  13147. style.hasStroke() && ctx.strokeText(textLines[i], x, y);
  13148. y += lineHeight;
  13149. }
  13150. this.restoreTransform(ctx);
  13151. }
  13152. },
  13153. getBoundingRect: function () {
  13154. if (!this._rect) {
  13155. var style = this.style;
  13156. var textVerticalAlign = style.textVerticalAlign;
  13157. var rect = textContain.getBoundingRect(
  13158. style.text + '', style.textFont || style.font, style.textAlign,
  13159. textVerticalAlign ? 'top' : style.textBaseline
  13160. );
  13161. switch (textVerticalAlign) {
  13162. case 'middle':
  13163. rect.y -= rect.height / 2;
  13164. break;
  13165. case 'bottom':
  13166. rect.y -= rect.height;
  13167. break;
  13168. }
  13169. rect.x += style.x || 0;
  13170. rect.y += style.y || 0;
  13171. this._rect = rect;
  13172. }
  13173. return this._rect;
  13174. }
  13175. };
  13176. zrUtil.inherits(Text, Displayable);
  13177. module.exports = Text;
  13178. /***/ },
  13179. /* 65 */
  13180. /***/ function(module, exports, __webpack_require__) {
  13181. 'use strict';
  13182. /**
  13183. * 圆形
  13184. * @module zrender/shape/Circle
  13185. */
  13186. module.exports = __webpack_require__(45).extend({
  13187. type: 'circle',
  13188. shape: {
  13189. cx: 0,
  13190. cy: 0,
  13191. r: 0
  13192. },
  13193. buildPath : function (ctx, shape, inBundle) {
  13194. // Better stroking in ShapeBundle
  13195. // Always do it may have performence issue ( fill may be 2x more cost)
  13196. if (inBundle) {
  13197. ctx.moveTo(shape.cx + shape.r, shape.cy);
  13198. }
  13199. // Better stroking in ShapeBundle
  13200. // ctx.moveTo(shape.cx + shape.r, shape.cy);
  13201. ctx.arc(shape.cx, shape.cy, shape.r, 0, Math.PI * 2, true);
  13202. }
  13203. });
  13204. /***/ },
  13205. /* 66 */
  13206. /***/ function(module, exports, __webpack_require__) {
  13207. /**
  13208. * 扇形
  13209. * @module zrender/graphic/shape/Sector
  13210. */
  13211. // FIXME clockwise seems wrong
  13212. module.exports = __webpack_require__(45).extend({
  13213. type: 'sector',
  13214. shape: {
  13215. cx: 0,
  13216. cy: 0,
  13217. r0: 0,
  13218. r: 0,
  13219. startAngle: 0,
  13220. endAngle: Math.PI * 2,
  13221. clockwise: true
  13222. },
  13223. buildPath: function (ctx, shape) {
  13224. var x = shape.cx;
  13225. var y = shape.cy;
  13226. var r0 = Math.max(shape.r0 || 0, 0);
  13227. var r = Math.max(shape.r, 0);
  13228. var startAngle = shape.startAngle;
  13229. var endAngle = shape.endAngle;
  13230. var clockwise = shape.clockwise;
  13231. var unitX = Math.cos(startAngle);
  13232. var unitY = Math.sin(startAngle);
  13233. ctx.moveTo(unitX * r0 + x, unitY * r0 + y);
  13234. ctx.lineTo(unitX * r + x, unitY * r + y);
  13235. ctx.arc(x, y, r, startAngle, endAngle, !clockwise);
  13236. ctx.lineTo(
  13237. Math.cos(endAngle) * r0 + x,
  13238. Math.sin(endAngle) * r0 + y
  13239. );
  13240. if (r0 !== 0) {
  13241. ctx.arc(x, y, r0, endAngle, startAngle, clockwise);
  13242. }
  13243. ctx.closePath();
  13244. }
  13245. });
  13246. /***/ },
  13247. /* 67 */
  13248. /***/ function(module, exports, __webpack_require__) {
  13249. /**
  13250. * 圆环
  13251. * @module zrender/graphic/shape/Ring
  13252. */
  13253. module.exports = __webpack_require__(45).extend({
  13254. type: 'ring',
  13255. shape: {
  13256. cx: 0,
  13257. cy: 0,
  13258. r: 0,
  13259. r0: 0
  13260. },
  13261. buildPath: function (ctx, shape) {
  13262. var x = shape.cx;
  13263. var y = shape.cy;
  13264. var PI2 = Math.PI * 2;
  13265. ctx.moveTo(x + shape.r, y);
  13266. ctx.arc(x, y, shape.r, 0, PI2, false);
  13267. ctx.moveTo(x + shape.r0, y);
  13268. ctx.arc(x, y, shape.r0, 0, PI2, true);
  13269. }
  13270. });
  13271. /***/ },
  13272. /* 68 */
  13273. /***/ function(module, exports, __webpack_require__) {
  13274. /**
  13275. * 多边形
  13276. * @module zrender/shape/Polygon
  13277. */
  13278. var polyHelper = __webpack_require__(69);
  13279. module.exports = __webpack_require__(45).extend({
  13280. type: 'polygon',
  13281. shape: {
  13282. points: null,
  13283. smooth: false,
  13284. smoothConstraint: null
  13285. },
  13286. buildPath: function (ctx, shape) {
  13287. polyHelper.buildPath(ctx, shape, true);
  13288. }
  13289. });
  13290. /***/ },
  13291. /* 69 */
  13292. /***/ function(module, exports, __webpack_require__) {
  13293. var smoothSpline = __webpack_require__(70);
  13294. var smoothBezier = __webpack_require__(71);
  13295. module.exports = {
  13296. buildPath: function (ctx, shape, closePath) {
  13297. var points = shape.points;
  13298. var smooth = shape.smooth;
  13299. if (points && points.length >= 2) {
  13300. if (smooth && smooth !== 'spline') {
  13301. var controlPoints = smoothBezier(
  13302. points, smooth, closePath, shape.smoothConstraint
  13303. );
  13304. ctx.moveTo(points[0][0], points[0][1]);
  13305. var len = points.length;
  13306. for (var i = 0; i < (closePath ? len : len - 1); i++) {
  13307. var cp1 = controlPoints[i * 2];
  13308. var cp2 = controlPoints[i * 2 + 1];
  13309. var p = points[(i + 1) % len];
  13310. ctx.bezierCurveTo(
  13311. cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1]
  13312. );
  13313. }
  13314. }
  13315. else {
  13316. if (smooth === 'spline') {
  13317. points = smoothSpline(points, closePath);
  13318. }
  13319. ctx.moveTo(points[0][0], points[0][1]);
  13320. for (var i = 1, l = points.length; i < l; i++) {
  13321. ctx.lineTo(points[i][0], points[i][1]);
  13322. }
  13323. }
  13324. closePath && ctx.closePath();
  13325. }
  13326. }
  13327. };
  13328. /***/ },
  13329. /* 70 */
  13330. /***/ function(module, exports, __webpack_require__) {
  13331. /**
  13332. * Catmull-Rom spline 插值折线
  13333. * @module zrender/shape/util/smoothSpline
  13334. * @author pissang (https://www.github.com/pissang)
  13335. * Kener (@Kener-林峰, kener.linfeng@gmail.com)
  13336. * errorrik (errorrik@gmail.com)
  13337. */
  13338. var vec2 = __webpack_require__(10);
  13339. /**
  13340. * @inner
  13341. */
  13342. function interpolate(p0, p1, p2, p3, t, t2, t3) {
  13343. var v0 = (p2 - p0) * 0.5;
  13344. var v1 = (p3 - p1) * 0.5;
  13345. return (2 * (p1 - p2) + v0 + v1) * t3
  13346. + (-3 * (p1 - p2) - 2 * v0 - v1) * t2
  13347. + v0 * t + p1;
  13348. }
  13349. /**
  13350. * @alias module:zrender/shape/util/smoothSpline
  13351. * @param {Array} points 线段顶点数组
  13352. * @param {boolean} isLoop
  13353. * @return {Array}
  13354. */
  13355. module.exports = function (points, isLoop) {
  13356. var len = points.length;
  13357. var ret = [];
  13358. var distance = 0;
  13359. for (var i = 1; i < len; i++) {
  13360. distance += vec2.distance(points[i - 1], points[i]);
  13361. }
  13362. var segs = distance / 2;
  13363. segs = segs < len ? len : segs;
  13364. for (var i = 0; i < segs; i++) {
  13365. var pos = i / (segs - 1) * (isLoop ? len : len - 1);
  13366. var idx = Math.floor(pos);
  13367. var w = pos - idx;
  13368. var p0;
  13369. var p1 = points[idx % len];
  13370. var p2;
  13371. var p3;
  13372. if (!isLoop) {
  13373. p0 = points[idx === 0 ? idx : idx - 1];
  13374. p2 = points[idx > len - 2 ? len - 1 : idx + 1];
  13375. p3 = points[idx > len - 3 ? len - 1 : idx + 2];
  13376. }
  13377. else {
  13378. p0 = points[(idx - 1 + len) % len];
  13379. p2 = points[(idx + 1) % len];
  13380. p3 = points[(idx + 2) % len];
  13381. }
  13382. var w2 = w * w;
  13383. var w3 = w * w2;
  13384. ret.push([
  13385. interpolate(p0[0], p1[0], p2[0], p3[0], w, w2, w3),
  13386. interpolate(p0[1], p1[1], p2[1], p3[1], w, w2, w3)
  13387. ]);
  13388. }
  13389. return ret;
  13390. };
  13391. /***/ },
  13392. /* 71 */
  13393. /***/ function(module, exports, __webpack_require__) {
  13394. /**
  13395. * 贝塞尔平滑曲线
  13396. * @module zrender/shape/util/smoothBezier
  13397. * @author pissang (https://www.github.com/pissang)
  13398. * Kener (@Kener-林峰, kener.linfeng@gmail.com)
  13399. * errorrik (errorrik@gmail.com)
  13400. */
  13401. var vec2 = __webpack_require__(10);
  13402. var v2Min = vec2.min;
  13403. var v2Max = vec2.max;
  13404. var v2Scale = vec2.scale;
  13405. var v2Distance = vec2.distance;
  13406. var v2Add = vec2.add;
  13407. /**
  13408. * 贝塞尔平滑曲线
  13409. * @alias module:zrender/shape/util/smoothBezier
  13410. * @param {Array} points 线段顶点数组
  13411. * @param {number} smooth 平滑等级, 0-1
  13412. * @param {boolean} isLoop
  13413. * @param {Array} constraint 将计算出来的控制点约束在一个包围盒内
  13414. * 比如 [[0, 0], [100, 100]], 这个包围盒会与
  13415. * 整个折线的包围盒做一个并集用来约束控制点。
  13416. * @param {Array} 计算出来的控制点数组
  13417. */
  13418. module.exports = function (points, smooth, isLoop, constraint) {
  13419. var cps = [];
  13420. var v = [];
  13421. var v1 = [];
  13422. var v2 = [];
  13423. var prevPoint;
  13424. var nextPoint;
  13425. var min, max;
  13426. if (constraint) {
  13427. min = [Infinity, Infinity];
  13428. max = [-Infinity, -Infinity];
  13429. for (var i = 0, len = points.length; i < len; i++) {
  13430. v2Min(min, min, points[i]);
  13431. v2Max(max, max, points[i]);
  13432. }
  13433. // 与指定的包围盒做并集
  13434. v2Min(min, min, constraint[0]);
  13435. v2Max(max, max, constraint[1]);
  13436. }
  13437. for (var i = 0, len = points.length; i < len; i++) {
  13438. var point = points[i];
  13439. if (isLoop) {
  13440. prevPoint = points[i ? i - 1 : len - 1];
  13441. nextPoint = points[(i + 1) % len];
  13442. }
  13443. else {
  13444. if (i === 0 || i === len - 1) {
  13445. cps.push(vec2.clone(points[i]));
  13446. continue;
  13447. }
  13448. else {
  13449. prevPoint = points[i - 1];
  13450. nextPoint = points[i + 1];
  13451. }
  13452. }
  13453. vec2.sub(v, nextPoint, prevPoint);
  13454. // use degree to scale the handle length
  13455. v2Scale(v, v, smooth);
  13456. var d0 = v2Distance(point, prevPoint);
  13457. var d1 = v2Distance(point, nextPoint);
  13458. var sum = d0 + d1;
  13459. if (sum !== 0) {
  13460. d0 /= sum;
  13461. d1 /= sum;
  13462. }
  13463. v2Scale(v1, v, -d0);
  13464. v2Scale(v2, v, d1);
  13465. var cp0 = v2Add([], point, v1);
  13466. var cp1 = v2Add([], point, v2);
  13467. if (constraint) {
  13468. v2Max(cp0, cp0, min);
  13469. v2Min(cp0, cp0, max);
  13470. v2Max(cp1, cp1, min);
  13471. v2Min(cp1, cp1, max);
  13472. }
  13473. cps.push(cp0);
  13474. cps.push(cp1);
  13475. }
  13476. if (isLoop) {
  13477. cps.push(cps.shift());
  13478. }
  13479. return cps;
  13480. };
  13481. /***/ },
  13482. /* 72 */
  13483. /***/ function(module, exports, __webpack_require__) {
  13484. /**
  13485. * @module zrender/graphic/shape/Polyline
  13486. */
  13487. var polyHelper = __webpack_require__(69);
  13488. module.exports = __webpack_require__(45).extend({
  13489. type: 'polyline',
  13490. shape: {
  13491. points: null,
  13492. smooth: false,
  13493. smoothConstraint: null
  13494. },
  13495. style: {
  13496. stroke: '#000',
  13497. fill: null
  13498. },
  13499. buildPath: function (ctx, shape) {
  13500. polyHelper.buildPath(ctx, shape, false);
  13501. }
  13502. });
  13503. /***/ },
  13504. /* 73 */
  13505. /***/ function(module, exports, __webpack_require__) {
  13506. /**
  13507. * 矩形
  13508. * @module zrender/graphic/shape/Rect
  13509. */
  13510. var roundRectHelper = __webpack_require__(74);
  13511. module.exports = __webpack_require__(45).extend({
  13512. type: 'rect',
  13513. shape: {
  13514. // 左上、右上、右下、左下角的半径依次为r1、r2、r3、r4
  13515. // r缩写为1 相当于 [1, 1, 1, 1]
  13516. // r缩写为[1] 相当于 [1, 1, 1, 1]
  13517. // r缩写为[1, 2] 相当于 [1, 2, 1, 2]
  13518. // r缩写为[1, 2, 3] 相当于 [1, 2, 3, 2]
  13519. r: 0,
  13520. x: 0,
  13521. y: 0,
  13522. width: 0,
  13523. height: 0
  13524. },
  13525. buildPath: function (ctx, shape) {
  13526. var x = shape.x;
  13527. var y = shape.y;
  13528. var width = shape.width;
  13529. var height = shape.height;
  13530. if (!shape.r) {
  13531. ctx.rect(x, y, width, height);
  13532. }
  13533. else {
  13534. roundRectHelper.buildPath(ctx, shape);
  13535. }
  13536. ctx.closePath();
  13537. return;
  13538. }
  13539. });
  13540. /***/ },
  13541. /* 74 */
  13542. /***/ function(module, exports) {
  13543. module.exports = {
  13544. buildPath: function (ctx, shape) {
  13545. var x = shape.x;
  13546. var y = shape.y;
  13547. var width = shape.width;
  13548. var height = shape.height;
  13549. var r = shape.r;
  13550. var r1;
  13551. var r2;
  13552. var r3;
  13553. var r4;
  13554. // Convert width and height to positive for better borderRadius
  13555. if (width < 0) {
  13556. x = x + width;
  13557. width = -width;
  13558. }
  13559. if (height < 0) {
  13560. y = y + height;
  13561. height = -height;
  13562. }
  13563. if (typeof r === 'number') {
  13564. r1 = r2 = r3 = r4 = r;
  13565. }
  13566. else if (r instanceof Array) {
  13567. if (r.length === 1) {
  13568. r1 = r2 = r3 = r4 = r[0];
  13569. }
  13570. else if (r.length === 2) {
  13571. r1 = r3 = r[0];
  13572. r2 = r4 = r[1];
  13573. }
  13574. else if (r.length === 3) {
  13575. r1 = r[0];
  13576. r2 = r4 = r[1];
  13577. r3 = r[2];
  13578. }
  13579. else {
  13580. r1 = r[0];
  13581. r2 = r[1];
  13582. r3 = r[2];
  13583. r4 = r[3];
  13584. }
  13585. }
  13586. else {
  13587. r1 = r2 = r3 = r4 = 0;
  13588. }
  13589. var total;
  13590. if (r1 + r2 > width) {
  13591. total = r1 + r2;
  13592. r1 *= width / total;
  13593. r2 *= width / total;
  13594. }
  13595. if (r3 + r4 > width) {
  13596. total = r3 + r4;
  13597. r3 *= width / total;
  13598. r4 *= width / total;
  13599. }
  13600. if (r2 + r3 > height) {
  13601. total = r2 + r3;
  13602. r2 *= height / total;
  13603. r3 *= height / total;
  13604. }
  13605. if (r1 + r4 > height) {
  13606. total = r1 + r4;
  13607. r1 *= height / total;
  13608. r4 *= height / total;
  13609. }
  13610. ctx.moveTo(x + r1, y);
  13611. ctx.lineTo(x + width - r2, y);
  13612. r2 !== 0 && ctx.quadraticCurveTo(
  13613. x + width, y, x + width, y + r2
  13614. );
  13615. ctx.lineTo(x + width, y + height - r3);
  13616. r3 !== 0 && ctx.quadraticCurveTo(
  13617. x + width, y + height, x + width - r3, y + height
  13618. );
  13619. ctx.lineTo(x + r4, y + height);
  13620. r4 !== 0 && ctx.quadraticCurveTo(
  13621. x, y + height, x, y + height - r4
  13622. );
  13623. ctx.lineTo(x, y + r1);
  13624. r1 !== 0 && ctx.quadraticCurveTo(x, y, x + r1, y);
  13625. }
  13626. };
  13627. /***/ },
  13628. /* 75 */
  13629. /***/ function(module, exports, __webpack_require__) {
  13630. /**
  13631. * 直线
  13632. * @module zrender/graphic/shape/Line
  13633. */
  13634. module.exports = __webpack_require__(45).extend({
  13635. type: 'line',
  13636. shape: {
  13637. // Start point
  13638. x1: 0,
  13639. y1: 0,
  13640. // End point
  13641. x2: 0,
  13642. y2: 0,
  13643. percent: 1
  13644. },
  13645. style: {
  13646. stroke: '#000',
  13647. fill: null
  13648. },
  13649. buildPath: function (ctx, shape) {
  13650. var x1 = shape.x1;
  13651. var y1 = shape.y1;
  13652. var x2 = shape.x2;
  13653. var y2 = shape.y2;
  13654. var percent = shape.percent;
  13655. if (percent === 0) {
  13656. return;
  13657. }
  13658. ctx.moveTo(x1, y1);
  13659. if (percent < 1) {
  13660. x2 = x1 * (1 - percent) + x2 * percent;
  13661. y2 = y1 * (1 - percent) + y2 * percent;
  13662. }
  13663. ctx.lineTo(x2, y2);
  13664. },
  13665. /**
  13666. * Get point at percent
  13667. * @param {number} percent
  13668. * @return {Array.<number>}
  13669. */
  13670. pointAt: function (p) {
  13671. var shape = this.shape;
  13672. return [
  13673. shape.x1 * (1 - p) + shape.x2 * p,
  13674. shape.y1 * (1 - p) + shape.y2 * p
  13675. ];
  13676. }
  13677. });
  13678. /***/ },
  13679. /* 76 */
  13680. /***/ function(module, exports, __webpack_require__) {
  13681. 'use strict';
  13682. /**
  13683. * 贝塞尔曲线
  13684. * @module zrender/shape/BezierCurve
  13685. */
  13686. var curveTool = __webpack_require__(50);
  13687. var vec2 = __webpack_require__(10);
  13688. var quadraticSubdivide = curveTool.quadraticSubdivide;
  13689. var cubicSubdivide = curveTool.cubicSubdivide;
  13690. var quadraticAt = curveTool.quadraticAt;
  13691. var cubicAt = curveTool.cubicAt;
  13692. var quadraticDerivativeAt = curveTool.quadraticDerivativeAt;
  13693. var cubicDerivativeAt = curveTool.cubicDerivativeAt;
  13694. var out = [];
  13695. function someVectorAt(shape, t, isTangent) {
  13696. var cpx2 = shape.cpx2;
  13697. var cpy2 = shape.cpy2;
  13698. if (cpx2 === null || cpy2 === null) {
  13699. return [
  13700. (isTangent ? cubicDerivativeAt : cubicAt)(shape.x1, shape.cpx1, shape.cpx2, shape.x2, t),
  13701. (isTangent ? cubicDerivativeAt : cubicAt)(shape.y1, shape.cpy1, shape.cpy2, shape.y2, t)
  13702. ];
  13703. }
  13704. else {
  13705. return [
  13706. (isTangent ? quadraticDerivativeAt : quadraticAt)(shape.x1, shape.cpx1, shape.x2, t),
  13707. (isTangent ? quadraticDerivativeAt : quadraticAt)(shape.y1, shape.cpy1, shape.y2, t)
  13708. ];
  13709. }
  13710. }
  13711. module.exports = __webpack_require__(45).extend({
  13712. type: 'bezier-curve',
  13713. shape: {
  13714. x1: 0,
  13715. y1: 0,
  13716. x2: 0,
  13717. y2: 0,
  13718. cpx1: 0,
  13719. cpy1: 0,
  13720. // cpx2: 0,
  13721. // cpy2: 0
  13722. // Curve show percent, for animating
  13723. percent: 1
  13724. },
  13725. style: {
  13726. stroke: '#000',
  13727. fill: null
  13728. },
  13729. buildPath: function (ctx, shape) {
  13730. var x1 = shape.x1;
  13731. var y1 = shape.y1;
  13732. var x2 = shape.x2;
  13733. var y2 = shape.y2;
  13734. var cpx1 = shape.cpx1;
  13735. var cpy1 = shape.cpy1;
  13736. var cpx2 = shape.cpx2;
  13737. var cpy2 = shape.cpy2;
  13738. var percent = shape.percent;
  13739. if (percent === 0) {
  13740. return;
  13741. }
  13742. ctx.moveTo(x1, y1);
  13743. if (cpx2 == null || cpy2 == null) {
  13744. if (percent < 1) {
  13745. quadraticSubdivide(
  13746. x1, cpx1, x2, percent, out
  13747. );
  13748. cpx1 = out[1];
  13749. x2 = out[2];
  13750. quadraticSubdivide(
  13751. y1, cpy1, y2, percent, out
  13752. );
  13753. cpy1 = out[1];
  13754. y2 = out[2];
  13755. }
  13756. ctx.quadraticCurveTo(
  13757. cpx1, cpy1,
  13758. x2, y2
  13759. );
  13760. }
  13761. else {
  13762. if (percent < 1) {
  13763. cubicSubdivide(
  13764. x1, cpx1, cpx2, x2, percent, out
  13765. );
  13766. cpx1 = out[1];
  13767. cpx2 = out[2];
  13768. x2 = out[3];
  13769. cubicSubdivide(
  13770. y1, cpy1, cpy2, y2, percent, out
  13771. );
  13772. cpy1 = out[1];
  13773. cpy2 = out[2];
  13774. y2 = out[3];
  13775. }
  13776. ctx.bezierCurveTo(
  13777. cpx1, cpy1,
  13778. cpx2, cpy2,
  13779. x2, y2
  13780. );
  13781. }
  13782. },
  13783. /**
  13784. * Get point at percent
  13785. * @param {number} t
  13786. * @return {Array.<number>}
  13787. */
  13788. pointAt: function (t) {
  13789. return someVectorAt(this.shape, t, false);
  13790. },
  13791. /**
  13792. * Get tangent at percent
  13793. * @param {number} t
  13794. * @return {Array.<number>}
  13795. */
  13796. tangentAt: function (t) {
  13797. var p = someVectorAt(this.shape, t, true);
  13798. return vec2.normalize(p, p);
  13799. }
  13800. });
  13801. /***/ },
  13802. /* 77 */
  13803. /***/ function(module, exports, __webpack_require__) {
  13804. /**
  13805. * 圆弧
  13806. * @module zrender/graphic/shape/Arc
  13807. */
  13808. module.exports = __webpack_require__(45).extend({
  13809. type: 'arc',
  13810. shape: {
  13811. cx: 0,
  13812. cy: 0,
  13813. r: 0,
  13814. startAngle: 0,
  13815. endAngle: Math.PI * 2,
  13816. clockwise: true
  13817. },
  13818. style: {
  13819. stroke: '#000',
  13820. fill: null
  13821. },
  13822. buildPath: function (ctx, shape) {
  13823. var x = shape.cx;
  13824. var y = shape.cy;
  13825. var r = Math.max(shape.r, 0);
  13826. var startAngle = shape.startAngle;
  13827. var endAngle = shape.endAngle;
  13828. var clockwise = shape.clockwise;
  13829. var unitX = Math.cos(startAngle);
  13830. var unitY = Math.sin(startAngle);
  13831. ctx.moveTo(unitX * r + x, unitY * r + y);
  13832. ctx.arc(x, y, r, startAngle, endAngle, !clockwise);
  13833. }
  13834. });
  13835. /***/ },
  13836. /* 78 */
  13837. /***/ function(module, exports, __webpack_require__) {
  13838. // CompoundPath to improve performance
  13839. var Path = __webpack_require__(45);
  13840. module.exports = Path.extend({
  13841. type: 'compound',
  13842. shape: {
  13843. paths: null
  13844. },
  13845. _updatePathDirty: function () {
  13846. var dirtyPath = this.__dirtyPath;
  13847. var paths = this.shape.paths;
  13848. for (var i = 0; i < paths.length; i++) {
  13849. // Mark as dirty if any subpath is dirty
  13850. dirtyPath = dirtyPath || paths[i].__dirtyPath;
  13851. }
  13852. this.__dirtyPath = dirtyPath;
  13853. this.__dirty = this.__dirty || dirtyPath;
  13854. },
  13855. beforeBrush: function () {
  13856. this._updatePathDirty();
  13857. var paths = this.shape.paths || [];
  13858. var scale = this.getGlobalScale();
  13859. // Update path scale
  13860. for (var i = 0; i < paths.length; i++) {
  13861. paths[i].path.setScale(scale[0], scale[1]);
  13862. }
  13863. },
  13864. buildPath: function (ctx, shape) {
  13865. var paths = shape.paths || [];
  13866. for (var i = 0; i < paths.length; i++) {
  13867. paths[i].buildPath(ctx, paths[i].shape, true);
  13868. }
  13869. },
  13870. afterBrush: function () {
  13871. var paths = this.shape.paths;
  13872. for (var i = 0; i < paths.length; i++) {
  13873. paths[i].__dirtyPath = false;
  13874. }
  13875. },
  13876. getBoundingRect: function () {
  13877. this._updatePathDirty();
  13878. return Path.prototype.getBoundingRect.call(this);
  13879. }
  13880. });
  13881. /***/ },
  13882. /* 79 */
  13883. /***/ function(module, exports, __webpack_require__) {
  13884. 'use strict';
  13885. var zrUtil = __webpack_require__(4);
  13886. var Gradient = __webpack_require__(61);
  13887. /**
  13888. * x, y, x2, y2 are all percent from 0 to 1
  13889. * @param {number} [x=0]
  13890. * @param {number} [y=0]
  13891. * @param {number} [x2=1]
  13892. * @param {number} [y2=0]
  13893. * @param {Array.<Object>} colorStops
  13894. * @param {boolean} [globalCoord=false]
  13895. */
  13896. var LinearGradient = function (x, y, x2, y2, colorStops, globalCoord) {
  13897. this.x = x == null ? 0 : x;
  13898. this.y = y == null ? 0 : y;
  13899. this.x2 = x2 == null ? 1 : x2;
  13900. this.y2 = y2 == null ? 0 : y2;
  13901. // Can be cloned
  13902. this.type = 'linear';
  13903. // If use global coord
  13904. this.global = globalCoord || false;
  13905. Gradient.call(this, colorStops);
  13906. };
  13907. LinearGradient.prototype = {
  13908. constructor: LinearGradient
  13909. };
  13910. zrUtil.inherits(LinearGradient, Gradient);
  13911. module.exports = LinearGradient;
  13912. /***/ },
  13913. /* 80 */
  13914. /***/ function(module, exports, __webpack_require__) {
  13915. 'use strict';
  13916. var zrUtil = __webpack_require__(4);
  13917. var Gradient = __webpack_require__(61);
  13918. /**
  13919. * x, y, r are all percent from 0 to 1
  13920. * @param {number} [x=0.5]
  13921. * @param {number} [y=0.5]
  13922. * @param {number} [r=0.5]
  13923. * @param {Array.<Object>} [colorStops]
  13924. * @param {boolean} [globalCoord=false]
  13925. */
  13926. var RadialGradient = function (x, y, r, colorStops, globalCoord) {
  13927. this.x = x == null ? 0.5 : x;
  13928. this.y = y == null ? 0.5 : y;
  13929. this.r = r == null ? 0.5 : r;
  13930. // Can be cloned
  13931. this.type = 'radial';
  13932. // If use global coord
  13933. this.global = globalCoord || false;
  13934. Gradient.call(this, colorStops);
  13935. };
  13936. RadialGradient.prototype = {
  13937. constructor: RadialGradient
  13938. };
  13939. zrUtil.inherits(RadialGradient, Gradient);
  13940. module.exports = RadialGradient;
  13941. /***/ },
  13942. /* 81 */
  13943. /***/ function(module, exports, __webpack_require__) {
  13944. /*!
  13945. * ZRender, a high performance 2d drawing library.
  13946. *
  13947. * Copyright (c) 2013, Baidu Inc.
  13948. * All rights reserved.
  13949. *
  13950. * LICENSE
  13951. * https://github.com/ecomfe/zrender/blob/master/LICENSE.txt
  13952. */
  13953. // Global defines
  13954. var guid = __webpack_require__(32);
  13955. var env = __webpack_require__(2);
  13956. var Handler = __webpack_require__(82);
  13957. var Storage = __webpack_require__(84);
  13958. var Animation = __webpack_require__(86);
  13959. var HandlerProxy = __webpack_require__(89);
  13960. var useVML = !env.canvasSupported;
  13961. var painterCtors = {
  13962. canvas: __webpack_require__(91)
  13963. };
  13964. var instances = {}; // ZRender实例map索引
  13965. var zrender = {};
  13966. /**
  13967. * @type {string}
  13968. */
  13969. zrender.version = '3.1.2';
  13970. /**
  13971. * Initializing a zrender instance
  13972. * @param {HTMLElement} dom
  13973. * @param {Object} opts
  13974. * @param {string} [opts.renderer='canvas'] 'canvas' or 'svg'
  13975. * @param {number} [opts.devicePixelRatio]
  13976. * @return {module:zrender/ZRender}
  13977. */
  13978. zrender.init = function(dom, opts) {
  13979. var zr = new ZRender(guid(), dom, opts);
  13980. instances[zr.id] = zr;
  13981. return zr;
  13982. };
  13983. /**
  13984. * Dispose zrender instance
  13985. * @param {module:zrender/ZRender} zr
  13986. */
  13987. zrender.dispose = function (zr) {
  13988. if (zr) {
  13989. zr.dispose();
  13990. }
  13991. else {
  13992. for (var key in instances) {
  13993. instances[key].dispose();
  13994. }
  13995. instances = {};
  13996. }
  13997. return zrender;
  13998. };
  13999. /**
  14000. * Get zrender instance by id
  14001. * @param {string} id zrender instance id
  14002. * @return {module:zrender/ZRender}
  14003. */
  14004. zrender.getInstance = function (id) {
  14005. return instances[id];
  14006. };
  14007. zrender.registerPainter = function (name, Ctor) {
  14008. painterCtors[name] = Ctor;
  14009. };
  14010. function delInstance(id) {
  14011. delete instances[id];
  14012. }
  14013. /**
  14014. * @module zrender/ZRender
  14015. */
  14016. /**
  14017. * @constructor
  14018. * @alias module:zrender/ZRender
  14019. * @param {string} id
  14020. * @param {HTMLDomElement} dom
  14021. * @param {Object} opts
  14022. * @param {string} [opts.renderer='canvas'] 'canvas' or 'svg'
  14023. * @param {number} [opts.devicePixelRatio]
  14024. */
  14025. var ZRender = function(id, dom, opts) {
  14026. opts = opts || {};
  14027. /**
  14028. * @type {HTMLDomElement}
  14029. */
  14030. this.dom = dom;
  14031. /**
  14032. * @type {string}
  14033. */
  14034. this.id = id;
  14035. var self = this;
  14036. var storage = new Storage();
  14037. var rendererType = opts.renderer;
  14038. if (useVML) {
  14039. if (!painterCtors.vml) {
  14040. throw new Error('You need to require \'zrender/vml/vml\' to support IE8');
  14041. }
  14042. rendererType = 'vml';
  14043. }
  14044. else if (!rendererType || !painterCtors[rendererType]) {
  14045. rendererType = 'canvas';
  14046. }
  14047. var painter = new painterCtors[rendererType](dom, storage, opts);
  14048. this.storage = storage;
  14049. this.painter = painter;
  14050. var handerProxy = !env.node ? new HandlerProxy(painter.getViewportRoot()) : null;
  14051. this.handler = new Handler(storage, painter, handerProxy);
  14052. /**
  14053. * @type {module:zrender/animation/Animation}
  14054. */
  14055. this.animation = new Animation({
  14056. stage: {
  14057. update: function () {
  14058. if (self._needsRefresh) {
  14059. self.refreshImmediately();
  14060. }
  14061. if (self._needsRefreshHover) {
  14062. self.refreshHoverImmediately();
  14063. }
  14064. }
  14065. }
  14066. });
  14067. this.animation.start();
  14068. /**
  14069. * @type {boolean}
  14070. * @private
  14071. */
  14072. this._needsRefresh;
  14073. // 修改 storage.delFromMap, 每次删除元素之前删除动画
  14074. // FIXME 有点ugly
  14075. var oldDelFromMap = storage.delFromMap;
  14076. var oldAddToMap = storage.addToMap;
  14077. storage.delFromMap = function (elId) {
  14078. var el = storage.get(elId);
  14079. oldDelFromMap.call(storage, elId);
  14080. el && el.removeSelfFromZr(self);
  14081. };
  14082. storage.addToMap = function (el) {
  14083. oldAddToMap.call(storage, el);
  14084. el.addSelfToZr(self);
  14085. };
  14086. };
  14087. ZRender.prototype = {
  14088. constructor: ZRender,
  14089. /**
  14090. * 获取实例唯一标识
  14091. * @return {string}
  14092. */
  14093. getId: function () {
  14094. return this.id;
  14095. },
  14096. /**
  14097. * 添加元素
  14098. * @param {module:zrender/Element} el
  14099. */
  14100. add: function (el) {
  14101. this.storage.addRoot(el);
  14102. this._needsRefresh = true;
  14103. },
  14104. /**
  14105. * 删除元素
  14106. * @param {module:zrender/Element} el
  14107. */
  14108. remove: function (el) {
  14109. this.storage.delRoot(el);
  14110. this._needsRefresh = true;
  14111. },
  14112. /**
  14113. * Change configuration of layer
  14114. * @param {string} zLevel
  14115. * @param {Object} config
  14116. * @param {string} [config.clearColor=0] Clear color
  14117. * @param {string} [config.motionBlur=false] If enable motion blur
  14118. * @param {number} [config.lastFrameAlpha=0.7] Motion blur factor. Larger value cause longer trailer
  14119. */
  14120. configLayer: function (zLevel, config) {
  14121. this.painter.configLayer(zLevel, config);
  14122. this._needsRefresh = true;
  14123. },
  14124. /**
  14125. * Repaint the canvas immediately
  14126. */
  14127. refreshImmediately: function () {
  14128. // Clear needsRefresh ahead to avoid something wrong happens in refresh
  14129. // Or it will cause zrender refreshes again and again.
  14130. this._needsRefresh = false;
  14131. this.painter.refresh();
  14132. /**
  14133. * Avoid trigger zr.refresh in Element#beforeUpdate hook
  14134. */
  14135. this._needsRefresh = false;
  14136. },
  14137. /**
  14138. * Mark and repaint the canvas in the next frame of browser
  14139. */
  14140. refresh: function() {
  14141. this._needsRefresh = true;
  14142. },
  14143. /**
  14144. * Add element to hover layer
  14145. * @param {module:zrender/Element} el
  14146. * @param {Object} style
  14147. */
  14148. addHover: function (el, style) {
  14149. if (this.painter.addHover) {
  14150. this.painter.addHover(el, style);
  14151. this.refreshHover();
  14152. }
  14153. },
  14154. /**
  14155. * Add element from hover layer
  14156. * @param {module:zrender/Element} el
  14157. */
  14158. removeHover: function (el) {
  14159. if (this.painter.removeHover) {
  14160. this.painter.removeHover(el);
  14161. this.refreshHover();
  14162. }
  14163. },
  14164. /**
  14165. * Clear all hover elements in hover layer
  14166. * @param {module:zrender/Element} el
  14167. */
  14168. clearHover: function () {
  14169. if (this.painter.clearHover) {
  14170. this.painter.clearHover();
  14171. this.refreshHover();
  14172. }
  14173. },
  14174. /**
  14175. * Refresh hover in next frame
  14176. */
  14177. refreshHover: function () {
  14178. this._needsRefreshHover = true;
  14179. },
  14180. /**
  14181. * Refresh hover immediately
  14182. */
  14183. refreshHoverImmediately: function () {
  14184. this._needsRefreshHover = false;
  14185. this.painter.refreshHover && this.painter.refreshHover();
  14186. },
  14187. /**
  14188. * Resize the canvas.
  14189. * Should be invoked when container size is changed
  14190. */
  14191. resize: function() {
  14192. this.painter.resize();
  14193. this.handler.resize();
  14194. },
  14195. /**
  14196. * Stop and clear all animation immediately
  14197. */
  14198. clearAnimation: function () {
  14199. this.animation.clear();
  14200. },
  14201. /**
  14202. * Get container width
  14203. */
  14204. getWidth: function() {
  14205. return this.painter.getWidth();
  14206. },
  14207. /**
  14208. * Get container height
  14209. */
  14210. getHeight: function() {
  14211. return this.painter.getHeight();
  14212. },
  14213. /**
  14214. * Export the canvas as Base64 URL
  14215. * @param {string} type
  14216. * @param {string} [backgroundColor='#fff']
  14217. * @return {string} Base64 URL
  14218. */
  14219. // toDataURL: function(type, backgroundColor) {
  14220. // return this.painter.getRenderedCanvas({
  14221. // backgroundColor: backgroundColor
  14222. // }).toDataURL(type);
  14223. // },
  14224. /**
  14225. * Converting a path to image.
  14226. * It has much better performance of drawing image rather than drawing a vector path.
  14227. * @param {module:zrender/graphic/Path} e
  14228. * @param {number} width
  14229. * @param {number} height
  14230. */
  14231. pathToImage: function(e, width, height) {
  14232. var id = guid();
  14233. return this.painter.pathToImage(id, e, width, height);
  14234. },
  14235. /**
  14236. * Set default cursor
  14237. * @param {string} [cursorStyle='default'] 例如 crosshair
  14238. */
  14239. setCursorStyle: function (cursorStyle) {
  14240. this.handler.setCursorStyle(cursorStyle);
  14241. },
  14242. /**
  14243. * Bind event
  14244. *
  14245. * @param {string} eventName Event name
  14246. * @param {Function} eventHandler Handler function
  14247. * @param {Object} [context] Context object
  14248. */
  14249. on: function(eventName, eventHandler, context) {
  14250. this.handler.on(eventName, eventHandler, context);
  14251. },
  14252. /**
  14253. * Unbind event
  14254. * @param {string} eventName Event name
  14255. * @param {Function} [eventHandler] Handler function
  14256. */
  14257. off: function(eventName, eventHandler) {
  14258. this.handler.off(eventName, eventHandler);
  14259. },
  14260. /**
  14261. * Trigger event manually
  14262. *
  14263. * @param {string} eventName Event name
  14264. * @param {event=} event Event object
  14265. */
  14266. trigger: function (eventName, event) {
  14267. this.handler.trigger(eventName, event);
  14268. },
  14269. /**
  14270. * Clear all objects and the canvas.
  14271. */
  14272. clear: function () {
  14273. this.storage.delRoot();
  14274. this.painter.clear();
  14275. },
  14276. /**
  14277. * Dispose self.
  14278. */
  14279. dispose: function () {
  14280. this.animation.stop();
  14281. this.clear();
  14282. this.storage.dispose();
  14283. this.painter.dispose();
  14284. this.handler.dispose();
  14285. this.animation =
  14286. this.storage =
  14287. this.painter =
  14288. this.handler = null;
  14289. delInstance(this.id);
  14290. }
  14291. };
  14292. module.exports = zrender;
  14293. /***/ },
  14294. /* 82 */
  14295. /***/ function(module, exports, __webpack_require__) {
  14296. 'use strict';
  14297. /**
  14298. * Handler
  14299. * @module zrender/Handler
  14300. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  14301. * errorrik (errorrik@gmail.com)
  14302. * pissang (shenyi.914@gmail.com)
  14303. */
  14304. var util = __webpack_require__(4);
  14305. var Draggable = __webpack_require__(83);
  14306. var Eventful = __webpack_require__(33);
  14307. function makeEventPacket(eveType, target, event) {
  14308. return {
  14309. type: eveType,
  14310. event: event,
  14311. target: target,
  14312. cancelBubble: false,
  14313. offsetX: event.zrX,
  14314. offsetY: event.zrY,
  14315. gestureEvent: event.gestureEvent,
  14316. pinchX: event.pinchX,
  14317. pinchY: event.pinchY,
  14318. pinchScale: event.pinchScale,
  14319. wheelDelta: event.zrDelta
  14320. };
  14321. }
  14322. function EmptyProxy () {}
  14323. EmptyProxy.prototype.dispose = function () {};
  14324. var handlerNames = [
  14325. 'click', 'dblclick', 'mousewheel', 'mouseout',
  14326. 'mouseup', 'mousedown', 'mousemove'
  14327. ];
  14328. /**
  14329. * @alias module:zrender/Handler
  14330. * @constructor
  14331. * @extends module:zrender/mixin/Eventful
  14332. * @param {HTMLElement} root Main HTML element for painting.
  14333. * @param {module:zrender/Storage} storage Storage instance.
  14334. * @param {module:zrender/Painter} painter Painter instance.
  14335. */
  14336. var Handler = function(storage, painter, proxy) {
  14337. Eventful.call(this);
  14338. this.storage = storage;
  14339. this.painter = painter;
  14340. proxy = proxy || new EmptyProxy();
  14341. /**
  14342. * Proxy of event. can be Dom, WebGLSurface, etc.
  14343. */
  14344. this.proxy = proxy;
  14345. // Attach handler
  14346. proxy.handler = this;
  14347. /**
  14348. * @private
  14349. * @type {boolean}
  14350. */
  14351. this._hovered;
  14352. /**
  14353. * @private
  14354. * @type {Date}
  14355. */
  14356. this._lastTouchMoment;
  14357. /**
  14358. * @private
  14359. * @type {number}
  14360. */
  14361. this._lastX;
  14362. /**
  14363. * @private
  14364. * @type {number}
  14365. */
  14366. this._lastY;
  14367. Draggable.call(this);
  14368. util.each(handlerNames, function (name) {
  14369. proxy.on && proxy.on(name, this[name], this);
  14370. }, this);
  14371. };
  14372. Handler.prototype = {
  14373. constructor: Handler,
  14374. mousemove: function (event) {
  14375. var x = event.zrX;
  14376. var y = event.zrY;
  14377. var hovered = this.findHover(x, y, null);
  14378. var lastHovered = this._hovered;
  14379. var proxy = this.proxy;
  14380. this._hovered = hovered;
  14381. proxy.setCursor && proxy.setCursor(hovered ? hovered.cursor : 'default');
  14382. // Mouse out on previous hovered element
  14383. if (lastHovered && hovered !== lastHovered && lastHovered.__zr) {
  14384. this.dispatchToElement(lastHovered, 'mouseout', event);
  14385. }
  14386. // Mouse moving on one element
  14387. this.dispatchToElement(hovered, 'mousemove', event);
  14388. // Mouse over on a new element
  14389. if (hovered && hovered !== lastHovered) {
  14390. this.dispatchToElement(hovered, 'mouseover', event);
  14391. }
  14392. },
  14393. mouseout: function (event) {
  14394. this.dispatchToElement(this._hovered, 'mouseout', event);
  14395. this.trigger('globalout', {
  14396. event: event
  14397. });
  14398. },
  14399. /**
  14400. * Resize
  14401. */
  14402. resize: function (event) {
  14403. this._hovered = null;
  14404. },
  14405. /**
  14406. * Dispatch event
  14407. * @param {string} eventName
  14408. * @param {event=} eventArgs
  14409. */
  14410. dispatch: function (eventName, eventArgs) {
  14411. var handler = this[eventName];
  14412. handler && handler.call(this, eventArgs);
  14413. },
  14414. /**
  14415. * Dispose
  14416. */
  14417. dispose: function () {
  14418. this.proxy.dispose();
  14419. this.storage =
  14420. this.proxy =
  14421. this.painter = null;
  14422. },
  14423. /**
  14424. * 设置默认的cursor style
  14425. * @param {string} [cursorStyle='default'] 例如 crosshair
  14426. */
  14427. setCursorStyle: function (cursorStyle) {
  14428. var proxy = this.proxy;
  14429. proxy.setCursor && proxy.setCursor(cursorStyle);
  14430. },
  14431. /**
  14432. * 事件分发代理
  14433. *
  14434. * @private
  14435. * @param {Object} targetEl 目标图形元素
  14436. * @param {string} eventName 事件名称
  14437. * @param {Object} event 事件对象
  14438. */
  14439. dispatchToElement: function (targetEl, eventName, event) {
  14440. var eventHandler = 'on' + eventName;
  14441. var eventPacket = makeEventPacket(eventName, targetEl, event);
  14442. var el = targetEl;
  14443. while (el) {
  14444. el[eventHandler]
  14445. && (eventPacket.cancelBubble = el[eventHandler].call(el, eventPacket));
  14446. el.trigger(eventName, eventPacket);
  14447. el = el.parent;
  14448. if (eventPacket.cancelBubble) {
  14449. break;
  14450. }
  14451. }
  14452. if (!eventPacket.cancelBubble) {
  14453. // 冒泡到顶级 zrender 对象
  14454. this.trigger(eventName, eventPacket);
  14455. // 分发事件到用户自定义层
  14456. // 用户有可能在全局 click 事件中 dispose,所以需要判断下 painter 是否存在
  14457. this.painter && this.painter.eachOtherLayer(function (layer) {
  14458. if (typeof(layer[eventHandler]) == 'function') {
  14459. layer[eventHandler].call(layer, eventPacket);
  14460. }
  14461. if (layer.trigger) {
  14462. layer.trigger(eventName, eventPacket);
  14463. }
  14464. });
  14465. }
  14466. },
  14467. /**
  14468. * @private
  14469. * @param {number} x
  14470. * @param {number} y
  14471. * @param {module:zrender/graphic/Displayable} exclude
  14472. * @method
  14473. */
  14474. findHover: function(x, y, exclude) {
  14475. var list = this.storage.getDisplayList();
  14476. for (var i = list.length - 1; i >= 0 ; i--) {
  14477. if (!list[i].silent
  14478. && list[i] !== exclude
  14479. // getDisplayList may include ignored item in VML mode
  14480. && !list[i].ignore
  14481. && isHover(list[i], x, y)) {
  14482. return list[i];
  14483. }
  14484. }
  14485. }
  14486. };
  14487. // Common handlers
  14488. util.each(['click', 'mousedown', 'mouseup', 'mousewheel', 'dblclick'], function (name) {
  14489. Handler.prototype[name] = function (event) {
  14490. // Find hover again to avoid click event is dispatched manually. Or click is triggered without mouseover
  14491. var hovered = this.findHover(event.zrX, event.zrY, null);
  14492. if (name === 'mousedown') {
  14493. this._downel = hovered;
  14494. // In case click triggered before mouseup
  14495. this._upel = hovered;
  14496. }
  14497. else if (name === 'mosueup') {
  14498. this._upel = hovered;
  14499. }
  14500. else if (name === 'click') {
  14501. if (this._downel !== this._upel) {
  14502. return;
  14503. }
  14504. }
  14505. this.dispatchToElement(hovered, name, event);
  14506. };
  14507. });
  14508. function isHover(displayable, x, y) {
  14509. if (displayable[displayable.rectHover ? 'rectContain' : 'contain'](x, y)) {
  14510. var el = displayable;
  14511. while (el) {
  14512. // If ancestor is silent or clipped by ancestor
  14513. if (el.silent || (el.clipPath && !el.clipPath.contain(x, y))) {
  14514. return false;
  14515. }
  14516. el = el.parent;
  14517. }
  14518. return true;
  14519. }
  14520. return false;
  14521. }
  14522. util.mixin(Handler, Eventful);
  14523. util.mixin(Handler, Draggable);
  14524. module.exports = Handler;
  14525. /***/ },
  14526. /* 83 */
  14527. /***/ function(module, exports) {
  14528. // TODO Draggable for group
  14529. // FIXME Draggable on element which has parent rotation or scale
  14530. function Draggable() {
  14531. this.on('mousedown', this._dragStart, this);
  14532. this.on('mousemove', this._drag, this);
  14533. this.on('mouseup', this._dragEnd, this);
  14534. this.on('globalout', this._dragEnd, this);
  14535. // this._dropTarget = null;
  14536. // this._draggingTarget = null;
  14537. // this._x = 0;
  14538. // this._y = 0;
  14539. }
  14540. Draggable.prototype = {
  14541. constructor: Draggable,
  14542. _dragStart: function (e) {
  14543. var draggingTarget = e.target;
  14544. if (draggingTarget && draggingTarget.draggable) {
  14545. this._draggingTarget = draggingTarget;
  14546. draggingTarget.dragging = true;
  14547. this._x = e.offsetX;
  14548. this._y = e.offsetY;
  14549. this.dispatchToElement(draggingTarget, 'dragstart', e.event);
  14550. }
  14551. },
  14552. _drag: function (e) {
  14553. var draggingTarget = this._draggingTarget;
  14554. if (draggingTarget) {
  14555. var x = e.offsetX;
  14556. var y = e.offsetY;
  14557. var dx = x - this._x;
  14558. var dy = y - this._y;
  14559. this._x = x;
  14560. this._y = y;
  14561. draggingTarget.drift(dx, dy, e);
  14562. this.dispatchToElement(draggingTarget, 'drag', e.event);
  14563. var dropTarget = this.findHover(x, y, draggingTarget);
  14564. var lastDropTarget = this._dropTarget;
  14565. this._dropTarget = dropTarget;
  14566. if (draggingTarget !== dropTarget) {
  14567. if (lastDropTarget && dropTarget !== lastDropTarget) {
  14568. this.dispatchToElement(lastDropTarget, 'dragleave', e.event);
  14569. }
  14570. if (dropTarget && dropTarget !== lastDropTarget) {
  14571. this.dispatchToElement(dropTarget, 'dragenter', e.event);
  14572. }
  14573. }
  14574. }
  14575. },
  14576. _dragEnd: function (e) {
  14577. var draggingTarget = this._draggingTarget;
  14578. if (draggingTarget) {
  14579. draggingTarget.dragging = false;
  14580. }
  14581. this.dispatchToElement(draggingTarget, 'dragend', e.event);
  14582. if (this._dropTarget) {
  14583. this.dispatchToElement(this._dropTarget, 'drop', e.event);
  14584. }
  14585. this._draggingTarget = null;
  14586. this._dropTarget = null;
  14587. }
  14588. };
  14589. module.exports = Draggable;
  14590. /***/ },
  14591. /* 84 */
  14592. /***/ function(module, exports, __webpack_require__) {
  14593. 'use strict';
  14594. /**
  14595. * Storage内容仓库模块
  14596. * @module zrender/Storage
  14597. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  14598. * @author errorrik (errorrik@gmail.com)
  14599. * @author pissang (https://github.com/pissang/)
  14600. */
  14601. var util = __webpack_require__(4);
  14602. var env = __webpack_require__(2);
  14603. var Group = __webpack_require__(30);
  14604. // Use timsort because in most case elements are partially sorted
  14605. // https://jsfiddle.net/pissang/jr4x7mdm/8/
  14606. var timsort = __webpack_require__(85);
  14607. function shapeCompareFunc(a, b) {
  14608. if (a.zlevel === b.zlevel) {
  14609. if (a.z === b.z) {
  14610. // if (a.z2 === b.z2) {
  14611. // // FIXME Slow has renderidx compare
  14612. // // http://stackoverflow.com/questions/20883421/sorting-in-javascript-should-every-compare-function-have-a-return-0-statement
  14613. // // https://github.com/v8/v8/blob/47cce544a31ed5577ffe2963f67acb4144ee0232/src/js/array.js#L1012
  14614. // return a.__renderidx - b.__renderidx;
  14615. // }
  14616. return a.z2 - b.z2;
  14617. }
  14618. return a.z - b.z;
  14619. }
  14620. return a.zlevel - b.zlevel;
  14621. }
  14622. /**
  14623. * 内容仓库 (M)
  14624. * @alias module:zrender/Storage
  14625. * @constructor
  14626. */
  14627. var Storage = function () {
  14628. // 所有常规形状,id索引的map
  14629. this._elements = {};
  14630. this._roots = [];
  14631. this._displayList = [];
  14632. this._displayListLen = 0;
  14633. };
  14634. Storage.prototype = {
  14635. constructor: Storage,
  14636. /**
  14637. * @param {Function} cb
  14638. *
  14639. */
  14640. traverse: function (cb, context) {
  14641. for (var i = 0; i < this._roots.length; i++) {
  14642. this._roots[i].traverse(cb, context);
  14643. }
  14644. },
  14645. /**
  14646. * 返回所有图形的绘制队列
  14647. * @param {boolean} [update=false] 是否在返回前更新该数组
  14648. * @param {boolean} [includeIgnore=false] 是否包含 ignore 的数组, 在 update 为 true 的时候有效
  14649. *
  14650. * 详见{@link module:zrender/graphic/Displayable.prototype.updateDisplayList}
  14651. * @return {Array.<module:zrender/graphic/Displayable>}
  14652. */
  14653. getDisplayList: function (update, includeIgnore) {
  14654. includeIgnore = includeIgnore || false;
  14655. if (update) {
  14656. this.updateDisplayList(includeIgnore);
  14657. }
  14658. return this._displayList;
  14659. },
  14660. /**
  14661. * 更新图形的绘制队列。
  14662. * 每次绘制前都会调用,该方法会先深度优先遍历整个树,更新所有Group和Shape的变换并且把所有可见的Shape保存到数组中,
  14663. * 最后根据绘制的优先级(zlevel > z > 插入顺序)排序得到绘制队列
  14664. * @param {boolean} [includeIgnore=false] 是否包含 ignore 的数组
  14665. */
  14666. updateDisplayList: function (includeIgnore) {
  14667. this._displayListLen = 0;
  14668. var roots = this._roots;
  14669. var displayList = this._displayList;
  14670. for (var i = 0, len = roots.length; i < len; i++) {
  14671. this._updateAndAddDisplayable(roots[i], null, includeIgnore);
  14672. }
  14673. displayList.length = this._displayListLen;
  14674. // for (var i = 0, len = displayList.length; i < len; i++) {
  14675. // displayList[i].__renderidx = i;
  14676. // }
  14677. // displayList.sort(shapeCompareFunc);
  14678. env.canvasSupported && timsort(displayList, shapeCompareFunc);
  14679. },
  14680. _updateAndAddDisplayable: function (el, clipPaths, includeIgnore) {
  14681. if (el.ignore && !includeIgnore) {
  14682. return;
  14683. }
  14684. el.beforeUpdate();
  14685. if (el.__dirty) {
  14686. el.update();
  14687. }
  14688. el.afterUpdate();
  14689. var clipPath = el.clipPath;
  14690. if (clipPath) {
  14691. // clipPath 的变换是基于 group 的变换
  14692. clipPath.parent = el;
  14693. clipPath.updateTransform();
  14694. // FIXME 效率影响
  14695. if (clipPaths) {
  14696. clipPaths = clipPaths.slice();
  14697. clipPaths.push(clipPath);
  14698. }
  14699. else {
  14700. clipPaths = [clipPath];
  14701. }
  14702. }
  14703. if (el.isGroup) {
  14704. var children = el._children;
  14705. for (var i = 0; i < children.length; i++) {
  14706. var child = children[i];
  14707. // Force to mark as dirty if group is dirty
  14708. // FIXME __dirtyPath ?
  14709. if (el.__dirty) {
  14710. child.__dirty = true;
  14711. }
  14712. this._updateAndAddDisplayable(child, clipPaths, includeIgnore);
  14713. }
  14714. // Mark group clean here
  14715. el.__dirty = false;
  14716. }
  14717. else {
  14718. el.__clipPaths = clipPaths;
  14719. this._displayList[this._displayListLen++] = el;
  14720. }
  14721. },
  14722. /**
  14723. * 添加图形(Shape)或者组(Group)到根节点
  14724. * @param {module:zrender/Element} el
  14725. */
  14726. addRoot: function (el) {
  14727. // Element has been added
  14728. if (this._elements[el.id]) {
  14729. return;
  14730. }
  14731. if (el instanceof Group) {
  14732. el.addChildrenToStorage(this);
  14733. }
  14734. this.addToMap(el);
  14735. this._roots.push(el);
  14736. },
  14737. /**
  14738. * 删除指定的图形(Shape)或者组(Group)
  14739. * @param {string|Array.<string>} [elId] 如果为空清空整个Storage
  14740. */
  14741. delRoot: function (elId) {
  14742. if (elId == null) {
  14743. // 不指定elId清空
  14744. for (var i = 0; i < this._roots.length; i++) {
  14745. var root = this._roots[i];
  14746. if (root instanceof Group) {
  14747. root.delChildrenFromStorage(this);
  14748. }
  14749. }
  14750. this._elements = {};
  14751. this._roots = [];
  14752. this._displayList = [];
  14753. this._displayListLen = 0;
  14754. return;
  14755. }
  14756. if (elId instanceof Array) {
  14757. for (var i = 0, l = elId.length; i < l; i++) {
  14758. this.delRoot(elId[i]);
  14759. }
  14760. return;
  14761. }
  14762. var el;
  14763. if (typeof(elId) == 'string') {
  14764. el = this._elements[elId];
  14765. }
  14766. else {
  14767. el = elId;
  14768. }
  14769. var idx = util.indexOf(this._roots, el);
  14770. if (idx >= 0) {
  14771. this.delFromMap(el.id);
  14772. this._roots.splice(idx, 1);
  14773. if (el instanceof Group) {
  14774. el.delChildrenFromStorage(this);
  14775. }
  14776. }
  14777. },
  14778. addToMap: function (el) {
  14779. if (el instanceof Group) {
  14780. el.__storage = this;
  14781. }
  14782. el.dirty();
  14783. this._elements[el.id] = el;
  14784. return this;
  14785. },
  14786. get: function (elId) {
  14787. return this._elements[elId];
  14788. },
  14789. delFromMap: function (elId) {
  14790. var elements = this._elements;
  14791. var el = elements[elId];
  14792. if (el) {
  14793. delete elements[elId];
  14794. if (el instanceof Group) {
  14795. el.__storage = null;
  14796. }
  14797. }
  14798. return this;
  14799. },
  14800. /**
  14801. * 清空并且释放Storage
  14802. */
  14803. dispose: function () {
  14804. this._elements =
  14805. this._renderList =
  14806. this._roots = null;
  14807. },
  14808. displayableSortFunc: shapeCompareFunc
  14809. };
  14810. module.exports = Storage;
  14811. /***/ },
  14812. /* 85 */
  14813. /***/ function(module, exports) {
  14814. // https://github.com/mziccard/node-timsort
  14815. var DEFAULT_MIN_MERGE = 32;
  14816. var DEFAULT_MIN_GALLOPING = 7;
  14817. var DEFAULT_TMP_STORAGE_LENGTH = 256;
  14818. function minRunLength(n) {
  14819. var r = 0;
  14820. while (n >= DEFAULT_MIN_MERGE) {
  14821. r |= n & 1;
  14822. n >>= 1;
  14823. }
  14824. return n + r;
  14825. }
  14826. function makeAscendingRun(array, lo, hi, compare) {
  14827. var runHi = lo + 1;
  14828. if (runHi === hi) {
  14829. return 1;
  14830. }
  14831. if (compare(array[runHi++], array[lo]) < 0) {
  14832. while (runHi < hi && compare(array[runHi], array[runHi - 1]) < 0) {
  14833. runHi++;
  14834. }
  14835. reverseRun(array, lo, runHi);
  14836. }
  14837. else {
  14838. while (runHi < hi && compare(array[runHi], array[runHi - 1]) >= 0) {
  14839. runHi++;
  14840. }
  14841. }
  14842. return runHi - lo;
  14843. }
  14844. function reverseRun(array, lo, hi) {
  14845. hi--;
  14846. while (lo < hi) {
  14847. var t = array[lo];
  14848. array[lo++] = array[hi];
  14849. array[hi--] = t;
  14850. }
  14851. }
  14852. function binaryInsertionSort(array, lo, hi, start, compare) {
  14853. if (start === lo) {
  14854. start++;
  14855. }
  14856. for (; start < hi; start++) {
  14857. var pivot = array[start];
  14858. var left = lo;
  14859. var right = start;
  14860. var mid;
  14861. while (left < right) {
  14862. mid = left + right >>> 1;
  14863. if (compare(pivot, array[mid]) < 0) {
  14864. right = mid;
  14865. }
  14866. else {
  14867. left = mid + 1;
  14868. }
  14869. }
  14870. var n = start - left;
  14871. switch (n) {
  14872. case 3:
  14873. array[left + 3] = array[left + 2];
  14874. case 2:
  14875. array[left + 2] = array[left + 1];
  14876. case 1:
  14877. array[left + 1] = array[left];
  14878. break;
  14879. default:
  14880. while (n > 0) {
  14881. array[left + n] = array[left + n - 1];
  14882. n--;
  14883. }
  14884. }
  14885. array[left] = pivot;
  14886. }
  14887. }
  14888. function gallopLeft(value, array, start, length, hint, compare) {
  14889. var lastOffset = 0;
  14890. var maxOffset = 0;
  14891. var offset = 1;
  14892. if (compare(value, array[start + hint]) > 0) {
  14893. maxOffset = length - hint;
  14894. while (offset < maxOffset && compare(value, array[start + hint + offset]) > 0) {
  14895. lastOffset = offset;
  14896. offset = (offset << 1) + 1;
  14897. if (offset <= 0) {
  14898. offset = maxOffset;
  14899. }
  14900. }
  14901. if (offset > maxOffset) {
  14902. offset = maxOffset;
  14903. }
  14904. lastOffset += hint;
  14905. offset += hint;
  14906. }
  14907. else {
  14908. maxOffset = hint + 1;
  14909. while (offset < maxOffset && compare(value, array[start + hint - offset]) <= 0) {
  14910. lastOffset = offset;
  14911. offset = (offset << 1) + 1;
  14912. if (offset <= 0) {
  14913. offset = maxOffset;
  14914. }
  14915. }
  14916. if (offset > maxOffset) {
  14917. offset = maxOffset;
  14918. }
  14919. var tmp = lastOffset;
  14920. lastOffset = hint - offset;
  14921. offset = hint - tmp;
  14922. }
  14923. lastOffset++;
  14924. while (lastOffset < offset) {
  14925. var m = lastOffset + (offset - lastOffset >>> 1);
  14926. if (compare(value, array[start + m]) > 0) {
  14927. lastOffset = m + 1;
  14928. }
  14929. else {
  14930. offset = m;
  14931. }
  14932. }
  14933. return offset;
  14934. }
  14935. function gallopRight(value, array, start, length, hint, compare) {
  14936. var lastOffset = 0;
  14937. var maxOffset = 0;
  14938. var offset = 1;
  14939. if (compare(value, array[start + hint]) < 0) {
  14940. maxOffset = hint + 1;
  14941. while (offset < maxOffset && compare(value, array[start + hint - offset]) < 0) {
  14942. lastOffset = offset;
  14943. offset = (offset << 1) + 1;
  14944. if (offset <= 0) {
  14945. offset = maxOffset;
  14946. }
  14947. }
  14948. if (offset > maxOffset) {
  14949. offset = maxOffset;
  14950. }
  14951. var tmp = lastOffset;
  14952. lastOffset = hint - offset;
  14953. offset = hint - tmp;
  14954. }
  14955. else {
  14956. maxOffset = length - hint;
  14957. while (offset < maxOffset && compare(value, array[start + hint + offset]) >= 0) {
  14958. lastOffset = offset;
  14959. offset = (offset << 1) + 1;
  14960. if (offset <= 0) {
  14961. offset = maxOffset;
  14962. }
  14963. }
  14964. if (offset > maxOffset) {
  14965. offset = maxOffset;
  14966. }
  14967. lastOffset += hint;
  14968. offset += hint;
  14969. }
  14970. lastOffset++;
  14971. while (lastOffset < offset) {
  14972. var m = lastOffset + (offset - lastOffset >>> 1);
  14973. if (compare(value, array[start + m]) < 0) {
  14974. offset = m;
  14975. }
  14976. else {
  14977. lastOffset = m + 1;
  14978. }
  14979. }
  14980. return offset;
  14981. }
  14982. function TimSort(array, compare) {
  14983. var minGallop = DEFAULT_MIN_GALLOPING;
  14984. var length = 0;
  14985. var tmpStorageLength = DEFAULT_TMP_STORAGE_LENGTH;
  14986. var stackLength = 0;
  14987. var runStart;
  14988. var runLength;
  14989. var stackSize = 0;
  14990. length = array.length;
  14991. if (length < 2 * DEFAULT_TMP_STORAGE_LENGTH) {
  14992. tmpStorageLength = length >>> 1;
  14993. }
  14994. var tmp = [];
  14995. stackLength = length < 120 ? 5 : length < 1542 ? 10 : length < 119151 ? 19 : 40;
  14996. runStart = [];
  14997. runLength = [];
  14998. function pushRun(_runStart, _runLength) {
  14999. runStart[stackSize] = _runStart;
  15000. runLength[stackSize] = _runLength;
  15001. stackSize += 1;
  15002. }
  15003. function mergeRuns() {
  15004. while (stackSize > 1) {
  15005. var n = stackSize - 2;
  15006. if (n >= 1 && runLength[n - 1] <= runLength[n] + runLength[n + 1] || n >= 2 && runLength[n - 2] <= runLength[n] + runLength[n - 1]) {
  15007. if (runLength[n - 1] < runLength[n + 1]) {
  15008. n--;
  15009. }
  15010. }
  15011. else if (runLength[n] > runLength[n + 1]) {
  15012. break;
  15013. }
  15014. mergeAt(n);
  15015. }
  15016. }
  15017. function forceMergeRuns() {
  15018. while (stackSize > 1) {
  15019. var n = stackSize - 2;
  15020. if (n > 0 && runLength[n - 1] < runLength[n + 1]) {
  15021. n--;
  15022. }
  15023. mergeAt(n);
  15024. }
  15025. }
  15026. function mergeAt(i) {
  15027. var start1 = runStart[i];
  15028. var length1 = runLength[i];
  15029. var start2 = runStart[i + 1];
  15030. var length2 = runLength[i + 1];
  15031. runLength[i] = length1 + length2;
  15032. if (i === stackSize - 3) {
  15033. runStart[i + 1] = runStart[i + 2];
  15034. runLength[i + 1] = runLength[i + 2];
  15035. }
  15036. stackSize--;
  15037. var k = gallopRight(array[start2], array, start1, length1, 0, compare);
  15038. start1 += k;
  15039. length1 -= k;
  15040. if (length1 === 0) {
  15041. return;
  15042. }
  15043. length2 = gallopLeft(array[start1 + length1 - 1], array, start2, length2, length2 - 1, compare);
  15044. if (length2 === 0) {
  15045. return;
  15046. }
  15047. if (length1 <= length2) {
  15048. mergeLow(start1, length1, start2, length2);
  15049. }
  15050. else {
  15051. mergeHigh(start1, length1, start2, length2);
  15052. }
  15053. }
  15054. function mergeLow(start1, length1, start2, length2) {
  15055. var i = 0;
  15056. for (i = 0; i < length1; i++) {
  15057. tmp[i] = array[start1 + i];
  15058. }
  15059. var cursor1 = 0;
  15060. var cursor2 = start2;
  15061. var dest = start1;
  15062. array[dest++] = array[cursor2++];
  15063. if (--length2 === 0) {
  15064. for (i = 0; i < length1; i++) {
  15065. array[dest + i] = tmp[cursor1 + i];
  15066. }
  15067. return;
  15068. }
  15069. if (length1 === 1) {
  15070. for (i = 0; i < length2; i++) {
  15071. array[dest + i] = array[cursor2 + i];
  15072. }
  15073. array[dest + length2] = tmp[cursor1];
  15074. return;
  15075. }
  15076. var _minGallop = minGallop;
  15077. var count1, count2, exit;
  15078. while (1) {
  15079. count1 = 0;
  15080. count2 = 0;
  15081. exit = false;
  15082. do {
  15083. if (compare(array[cursor2], tmp[cursor1]) < 0) {
  15084. array[dest++] = array[cursor2++];
  15085. count2++;
  15086. count1 = 0;
  15087. if (--length2 === 0) {
  15088. exit = true;
  15089. break;
  15090. }
  15091. }
  15092. else {
  15093. array[dest++] = tmp[cursor1++];
  15094. count1++;
  15095. count2 = 0;
  15096. if (--length1 === 1) {
  15097. exit = true;
  15098. break;
  15099. }
  15100. }
  15101. } while ((count1 | count2) < _minGallop);
  15102. if (exit) {
  15103. break;
  15104. }
  15105. do {
  15106. count1 = gallopRight(array[cursor2], tmp, cursor1, length1, 0, compare);
  15107. if (count1 !== 0) {
  15108. for (i = 0; i < count1; i++) {
  15109. array[dest + i] = tmp[cursor1 + i];
  15110. }
  15111. dest += count1;
  15112. cursor1 += count1;
  15113. length1 -= count1;
  15114. if (length1 <= 1) {
  15115. exit = true;
  15116. break;
  15117. }
  15118. }
  15119. array[dest++] = array[cursor2++];
  15120. if (--length2 === 0) {
  15121. exit = true;
  15122. break;
  15123. }
  15124. count2 = gallopLeft(tmp[cursor1], array, cursor2, length2, 0, compare);
  15125. if (count2 !== 0) {
  15126. for (i = 0; i < count2; i++) {
  15127. array[dest + i] = array[cursor2 + i];
  15128. }
  15129. dest += count2;
  15130. cursor2 += count2;
  15131. length2 -= count2;
  15132. if (length2 === 0) {
  15133. exit = true;
  15134. break;
  15135. }
  15136. }
  15137. array[dest++] = tmp[cursor1++];
  15138. if (--length1 === 1) {
  15139. exit = true;
  15140. break;
  15141. }
  15142. _minGallop--;
  15143. } while (count1 >= DEFAULT_MIN_GALLOPING || count2 >= DEFAULT_MIN_GALLOPING);
  15144. if (exit) {
  15145. break;
  15146. }
  15147. if (_minGallop < 0) {
  15148. _minGallop = 0;
  15149. }
  15150. _minGallop += 2;
  15151. }
  15152. minGallop = _minGallop;
  15153. minGallop < 1 && (minGallop = 1);
  15154. if (length1 === 1) {
  15155. for (i = 0; i < length2; i++) {
  15156. array[dest + i] = array[cursor2 + i];
  15157. }
  15158. array[dest + length2] = tmp[cursor1];
  15159. }
  15160. else if (length1 === 0) {
  15161. throw new Error();
  15162. // throw new Error('mergeLow preconditions were not respected');
  15163. }
  15164. else {
  15165. for (i = 0; i < length1; i++) {
  15166. array[dest + i] = tmp[cursor1 + i];
  15167. }
  15168. }
  15169. }
  15170. function mergeHigh (start1, length1, start2, length2) {
  15171. var i = 0;
  15172. for (i = 0; i < length2; i++) {
  15173. tmp[i] = array[start2 + i];
  15174. }
  15175. var cursor1 = start1 + length1 - 1;
  15176. var cursor2 = length2 - 1;
  15177. var dest = start2 + length2 - 1;
  15178. var customCursor = 0;
  15179. var customDest = 0;
  15180. array[dest--] = array[cursor1--];
  15181. if (--length1 === 0) {
  15182. customCursor = dest - (length2 - 1);
  15183. for (i = 0; i < length2; i++) {
  15184. array[customCursor + i] = tmp[i];
  15185. }
  15186. return;
  15187. }
  15188. if (length2 === 1) {
  15189. dest -= length1;
  15190. cursor1 -= length1;
  15191. customDest = dest + 1;
  15192. customCursor = cursor1 + 1;
  15193. for (i = length1 - 1; i >= 0; i--) {
  15194. array[customDest + i] = array[customCursor + i];
  15195. }
  15196. array[dest] = tmp[cursor2];
  15197. return;
  15198. }
  15199. var _minGallop = minGallop;
  15200. while (true) {
  15201. var count1 = 0;
  15202. var count2 = 0;
  15203. var exit = false;
  15204. do {
  15205. if (compare(tmp[cursor2], array[cursor1]) < 0) {
  15206. array[dest--] = array[cursor1--];
  15207. count1++;
  15208. count2 = 0;
  15209. if (--length1 === 0) {
  15210. exit = true;
  15211. break;
  15212. }
  15213. }
  15214. else {
  15215. array[dest--] = tmp[cursor2--];
  15216. count2++;
  15217. count1 = 0;
  15218. if (--length2 === 1) {
  15219. exit = true;
  15220. break;
  15221. }
  15222. }
  15223. } while ((count1 | count2) < _minGallop);
  15224. if (exit) {
  15225. break;
  15226. }
  15227. do {
  15228. count1 = length1 - gallopRight(tmp[cursor2], array, start1, length1, length1 - 1, compare);
  15229. if (count1 !== 0) {
  15230. dest -= count1;
  15231. cursor1 -= count1;
  15232. length1 -= count1;
  15233. customDest = dest + 1;
  15234. customCursor = cursor1 + 1;
  15235. for (i = count1 - 1; i >= 0; i--) {
  15236. array[customDest + i] = array[customCursor + i];
  15237. }
  15238. if (length1 === 0) {
  15239. exit = true;
  15240. break;
  15241. }
  15242. }
  15243. array[dest--] = tmp[cursor2--];
  15244. if (--length2 === 1) {
  15245. exit = true;
  15246. break;
  15247. }
  15248. count2 = length2 - gallopLeft(array[cursor1], tmp, 0, length2, length2 - 1, compare);
  15249. if (count2 !== 0) {
  15250. dest -= count2;
  15251. cursor2 -= count2;
  15252. length2 -= count2;
  15253. customDest = dest + 1;
  15254. customCursor = cursor2 + 1;
  15255. for (i = 0; i < count2; i++) {
  15256. array[customDest + i] = tmp[customCursor + i];
  15257. }
  15258. if (length2 <= 1) {
  15259. exit = true;
  15260. break;
  15261. }
  15262. }
  15263. array[dest--] = array[cursor1--];
  15264. if (--length1 === 0) {
  15265. exit = true;
  15266. break;
  15267. }
  15268. _minGallop--;
  15269. } while (count1 >= DEFAULT_MIN_GALLOPING || count2 >= DEFAULT_MIN_GALLOPING);
  15270. if (exit) {
  15271. break;
  15272. }
  15273. if (_minGallop < 0) {
  15274. _minGallop = 0;
  15275. }
  15276. _minGallop += 2;
  15277. }
  15278. minGallop = _minGallop;
  15279. if (minGallop < 1) {
  15280. minGallop = 1;
  15281. }
  15282. if (length2 === 1) {
  15283. dest -= length1;
  15284. cursor1 -= length1;
  15285. customDest = dest + 1;
  15286. customCursor = cursor1 + 1;
  15287. for (i = length1 - 1; i >= 0; i--) {
  15288. array[customDest + i] = array[customCursor + i];
  15289. }
  15290. array[dest] = tmp[cursor2];
  15291. }
  15292. else if (length2 === 0) {
  15293. throw new Error();
  15294. // throw new Error('mergeHigh preconditions were not respected');
  15295. }
  15296. else {
  15297. customCursor = dest - (length2 - 1);
  15298. for (i = 0; i < length2; i++) {
  15299. array[customCursor + i] = tmp[i];
  15300. }
  15301. }
  15302. }
  15303. this.mergeRuns = mergeRuns;
  15304. this.forceMergeRuns = forceMergeRuns;
  15305. this.pushRun = pushRun;
  15306. }
  15307. function sort(array, compare, lo, hi) {
  15308. if (!lo) {
  15309. lo = 0;
  15310. }
  15311. if (!hi) {
  15312. hi = array.length;
  15313. }
  15314. var remaining = hi - lo;
  15315. if (remaining < 2) {
  15316. return;
  15317. }
  15318. var runLength = 0;
  15319. if (remaining < DEFAULT_MIN_MERGE) {
  15320. runLength = makeAscendingRun(array, lo, hi, compare);
  15321. binaryInsertionSort(array, lo, hi, lo + runLength, compare);
  15322. return;
  15323. }
  15324. var ts = new TimSort(array, compare);
  15325. var minRun = minRunLength(remaining);
  15326. do {
  15327. runLength = makeAscendingRun(array, lo, hi, compare);
  15328. if (runLength < minRun) {
  15329. var force = remaining;
  15330. if (force > minRun) {
  15331. force = minRun;
  15332. }
  15333. binaryInsertionSort(array, lo, lo + force, lo + runLength, compare);
  15334. runLength = force;
  15335. }
  15336. ts.pushRun(lo, runLength);
  15337. ts.mergeRuns();
  15338. remaining -= runLength;
  15339. lo += runLength;
  15340. } while (remaining !== 0);
  15341. ts.forceMergeRuns();
  15342. }
  15343. module.exports = sort;
  15344. /***/ },
  15345. /* 86 */
  15346. /***/ function(module, exports, __webpack_require__) {
  15347. 'use strict';
  15348. /**
  15349. * 动画主类, 调度和管理所有动画控制器
  15350. *
  15351. * @module zrender/animation/Animation
  15352. * @author pissang(https://github.com/pissang)
  15353. */
  15354. // TODO Additive animation
  15355. // http://iosoteric.com/additive-animations-animatewithduration-in-ios-8/
  15356. // https://developer.apple.com/videos/wwdc2014/#236
  15357. var util = __webpack_require__(4);
  15358. var Dispatcher = __webpack_require__(87).Dispatcher;
  15359. var requestAnimationFrame = __webpack_require__(88);
  15360. var Animator = __webpack_require__(36);
  15361. /**
  15362. * @typedef {Object} IZRenderStage
  15363. * @property {Function} update
  15364. */
  15365. /**
  15366. * @alias module:zrender/animation/Animation
  15367. * @constructor
  15368. * @param {Object} [options]
  15369. * @param {Function} [options.onframe]
  15370. * @param {IZRenderStage} [options.stage]
  15371. * @example
  15372. * var animation = new Animation();
  15373. * var obj = {
  15374. * x: 100,
  15375. * y: 100
  15376. * };
  15377. * animation.animate(node.position)
  15378. * .when(1000, {
  15379. * x: 500,
  15380. * y: 500
  15381. * })
  15382. * .when(2000, {
  15383. * x: 100,
  15384. * y: 100
  15385. * })
  15386. * .start('spline');
  15387. */
  15388. var Animation = function (options) {
  15389. options = options || {};
  15390. this.stage = options.stage || {};
  15391. this.onframe = options.onframe || function() {};
  15392. // private properties
  15393. this._clips = [];
  15394. this._running = false;
  15395. this._time = 0;
  15396. Dispatcher.call(this);
  15397. };
  15398. Animation.prototype = {
  15399. constructor: Animation,
  15400. /**
  15401. * 添加 clip
  15402. * @param {module:zrender/animation/Clip} clip
  15403. */
  15404. addClip: function (clip) {
  15405. this._clips.push(clip);
  15406. },
  15407. /**
  15408. * 添加 animator
  15409. * @param {module:zrender/animation/Animator} animator
  15410. */
  15411. addAnimator: function (animator) {
  15412. animator.animation = this;
  15413. var clips = animator.getClips();
  15414. for (var i = 0; i < clips.length; i++) {
  15415. this.addClip(clips[i]);
  15416. }
  15417. },
  15418. /**
  15419. * 删除动画片段
  15420. * @param {module:zrender/animation/Clip} clip
  15421. */
  15422. removeClip: function(clip) {
  15423. var idx = util.indexOf(this._clips, clip);
  15424. if (idx >= 0) {
  15425. this._clips.splice(idx, 1);
  15426. }
  15427. },
  15428. /**
  15429. * 删除动画片段
  15430. * @param {module:zrender/animation/Animator} animator
  15431. */
  15432. removeAnimator: function (animator) {
  15433. var clips = animator.getClips();
  15434. for (var i = 0; i < clips.length; i++) {
  15435. this.removeClip(clips[i]);
  15436. }
  15437. animator.animation = null;
  15438. },
  15439. _update: function() {
  15440. var time = new Date().getTime();
  15441. var delta = time - this._time;
  15442. var clips = this._clips;
  15443. var len = clips.length;
  15444. var deferredEvents = [];
  15445. var deferredClips = [];
  15446. for (var i = 0; i < len; i++) {
  15447. var clip = clips[i];
  15448. var e = clip.step(time);
  15449. // Throw out the events need to be called after
  15450. // stage.update, like destroy
  15451. if (e) {
  15452. deferredEvents.push(e);
  15453. deferredClips.push(clip);
  15454. }
  15455. }
  15456. // Remove the finished clip
  15457. for (var i = 0; i < len;) {
  15458. if (clips[i]._needsRemove) {
  15459. clips[i] = clips[len - 1];
  15460. clips.pop();
  15461. len--;
  15462. }
  15463. else {
  15464. i++;
  15465. }
  15466. }
  15467. len = deferredEvents.length;
  15468. for (var i = 0; i < len; i++) {
  15469. deferredClips[i].fire(deferredEvents[i]);
  15470. }
  15471. this._time = time;
  15472. this.onframe(delta);
  15473. this.trigger('frame', delta);
  15474. if (this.stage.update) {
  15475. this.stage.update();
  15476. }
  15477. },
  15478. /**
  15479. * 开始运行动画
  15480. */
  15481. start: function () {
  15482. var self = this;
  15483. this._running = true;
  15484. function step() {
  15485. if (self._running) {
  15486. requestAnimationFrame(step);
  15487. self._update();
  15488. }
  15489. }
  15490. this._time = new Date().getTime();
  15491. requestAnimationFrame(step);
  15492. },
  15493. /**
  15494. * 停止运行动画
  15495. */
  15496. stop: function () {
  15497. this._running = false;
  15498. },
  15499. /**
  15500. * 清除所有动画片段
  15501. */
  15502. clear: function () {
  15503. this._clips = [];
  15504. },
  15505. /**
  15506. * 对一个目标创建一个animator对象,可以指定目标中的属性使用动画
  15507. * @param {Object} target
  15508. * @param {Object} options
  15509. * @param {boolean} [options.loop=false] 是否循环播放动画
  15510. * @param {Function} [options.getter=null]
  15511. * 如果指定getter函数,会通过getter函数取属性值
  15512. * @param {Function} [options.setter=null]
  15513. * 如果指定setter函数,会通过setter函数设置属性值
  15514. * @return {module:zrender/animation/Animation~Animator}
  15515. */
  15516. animate: function (target, options) {
  15517. options = options || {};
  15518. var animator = new Animator(
  15519. target,
  15520. options.loop,
  15521. options.getter,
  15522. options.setter
  15523. );
  15524. return animator;
  15525. }
  15526. };
  15527. util.mixin(Animation, Dispatcher);
  15528. module.exports = Animation;
  15529. /***/ },
  15530. /* 87 */
  15531. /***/ function(module, exports, __webpack_require__) {
  15532. 'use strict';
  15533. /**
  15534. * 事件辅助类
  15535. * @module zrender/core/event
  15536. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  15537. */
  15538. var Eventful = __webpack_require__(33);
  15539. var isDomLevel2 = (typeof window !== 'undefined') && !!window.addEventListener;
  15540. function getBoundingClientRect(el) {
  15541. // BlackBerry 5, iOS 3 (original iPhone) don't have getBoundingRect
  15542. return el.getBoundingClientRect ? el.getBoundingClientRect() : {left: 0, top: 0};
  15543. }
  15544. function clientToLocal(el, e, out) {
  15545. // clientX/clientY is according to view port.
  15546. var box = getBoundingClientRect(el);
  15547. out = out || {};
  15548. out.zrX = e.clientX - box.left;
  15549. out.zrY = e.clientY - box.top;
  15550. return out;
  15551. }
  15552. /**
  15553. * 如果存在第三方嵌入的一些dom触发的事件,或touch事件,需要转换一下事件坐标
  15554. */
  15555. function normalizeEvent(el, e) {
  15556. e = e || window.event;
  15557. if (e.zrX != null) {
  15558. return e;
  15559. }
  15560. var eventType = e.type;
  15561. var isTouch = eventType && eventType.indexOf('touch') >= 0;
  15562. if (!isTouch) {
  15563. clientToLocal(el, e, e);
  15564. e.zrDelta = (e.wheelDelta) ? e.wheelDelta / 120 : -(e.detail || 0) / 3;
  15565. }
  15566. else {
  15567. var touch = eventType != 'touchend'
  15568. ? e.targetTouches[0]
  15569. : e.changedTouches[0];
  15570. touch && clientToLocal(el, touch, e);
  15571. }
  15572. return e;
  15573. }
  15574. function addEventListener(el, name, handler) {
  15575. if (isDomLevel2) {
  15576. el.addEventListener(name, handler);
  15577. }
  15578. else {
  15579. el.attachEvent('on' + name, handler);
  15580. }
  15581. }
  15582. function removeEventListener(el, name, handler) {
  15583. if (isDomLevel2) {
  15584. el.removeEventListener(name, handler);
  15585. }
  15586. else {
  15587. el.detachEvent('on' + name, handler);
  15588. }
  15589. }
  15590. /**
  15591. * 停止冒泡和阻止默认行为
  15592. * @memberOf module:zrender/core/event
  15593. * @method
  15594. * @param {Event} e : event对象
  15595. */
  15596. var stop = isDomLevel2
  15597. ? function (e) {
  15598. e.preventDefault();
  15599. e.stopPropagation();
  15600. e.cancelBubble = true;
  15601. }
  15602. : function (e) {
  15603. e.returnValue = false;
  15604. e.cancelBubble = true;
  15605. };
  15606. module.exports = {
  15607. clientToLocal: clientToLocal,
  15608. normalizeEvent: normalizeEvent,
  15609. addEventListener: addEventListener,
  15610. removeEventListener: removeEventListener,
  15611. stop: stop,
  15612. // 做向上兼容
  15613. Dispatcher: Eventful
  15614. };
  15615. /***/ },
  15616. /* 88 */
  15617. /***/ function(module, exports) {
  15618. module.exports = (typeof window !== 'undefined' &&
  15619. (window.requestAnimationFrame
  15620. || window.msRequestAnimationFrame
  15621. || window.mozRequestAnimationFrame
  15622. || window.webkitRequestAnimationFrame))
  15623. || function (func) {
  15624. setTimeout(func, 16);
  15625. };
  15626. /***/ },
  15627. /* 89 */
  15628. /***/ function(module, exports, __webpack_require__) {
  15629. var eventTool = __webpack_require__(87);
  15630. var zrUtil = __webpack_require__(4);
  15631. var Eventful = __webpack_require__(33);
  15632. var env = __webpack_require__(2);
  15633. var GestureMgr = __webpack_require__(90);
  15634. var addEventListener = eventTool.addEventListener;
  15635. var removeEventListener = eventTool.removeEventListener;
  15636. var normalizeEvent = eventTool.normalizeEvent;
  15637. var TOUCH_CLICK_DELAY = 300;
  15638. var mouseHandlerNames = [
  15639. 'click', 'dblclick', 'mousewheel', 'mouseout',
  15640. 'mouseup', 'mousedown', 'mousemove'
  15641. ];
  15642. var touchHandlerNames = [
  15643. 'touchstart', 'touchend', 'touchmove'
  15644. ];
  15645. function eventNameFix(name) {
  15646. return (name === 'mousewheel' && env.browser.firefox) ? 'DOMMouseScroll' : name;
  15647. }
  15648. function processGesture(proxy, event, stage) {
  15649. var gestureMgr = proxy._gestureMgr;
  15650. stage === 'start' && gestureMgr.clear();
  15651. var gestureInfo = gestureMgr.recognize(
  15652. event,
  15653. proxy.handler.findHover(event.zrX, event.zrY, null),
  15654. proxy.dom
  15655. );
  15656. stage === 'end' && gestureMgr.clear();
  15657. if (gestureInfo) {
  15658. // eventTool.stop(event);
  15659. var type = gestureInfo.type;
  15660. event.gestureEvent = type;
  15661. proxy.handler.dispatchToElement(gestureInfo.target, type, gestureInfo.event);
  15662. }
  15663. }
  15664. /**
  15665. * Prevent mouse event from being dispatched after Touch Events action
  15666. * @see <https://github.com/deltakosh/handjs/blob/master/src/hand.base.js>
  15667. * 1. Mobile browsers dispatch mouse events 300ms after touchend.
  15668. * 2. Chrome for Android dispatch mousedown for long-touch about 650ms
  15669. * Result: Blocking Mouse Events for 700ms.
  15670. */
  15671. function setTouchTimer(instance) {
  15672. instance._touching = true;
  15673. clearTimeout(instance._touchTimer);
  15674. instance._touchTimer = setTimeout(function () {
  15675. instance._touching = false;
  15676. }, 700);
  15677. }
  15678. function useTouchEvent() {
  15679. return env.touchEventsSupported;
  15680. }
  15681. var domHandlers = {
  15682. /**
  15683. * Mouse move handler
  15684. * @inner
  15685. * @param {Event} event
  15686. */
  15687. mousemove: function (event) {
  15688. event = normalizeEvent(this.dom, event);
  15689. this.trigger('mousemove', event);
  15690. },
  15691. /**
  15692. * Mouse out handler
  15693. * @inner
  15694. * @param {Event} event
  15695. */
  15696. mouseout: function (event) {
  15697. event = normalizeEvent(this.dom, event);
  15698. var element = event.toElement || event.relatedTarget;
  15699. if (element != this.dom) {
  15700. while (element && element.nodeType != 9) {
  15701. // 忽略包含在root中的dom引起的mouseOut
  15702. if (element === this.dom) {
  15703. return;
  15704. }
  15705. element = element.parentNode;
  15706. }
  15707. }
  15708. this.trigger('mouseout', event);
  15709. },
  15710. /**
  15711. * Touch开始响应函数
  15712. * @inner
  15713. * @param {Event} event
  15714. */
  15715. touchstart: function (event) {
  15716. // Default mouse behaviour should not be disabled here.
  15717. // For example, page may needs to be slided.
  15718. event = normalizeEvent(this.dom, event);
  15719. this._lastTouchMoment = new Date();
  15720. processGesture(this, event, 'start');
  15721. // 平板补充一次findHover
  15722. // this._mobileFindFixed(event);
  15723. // Trigger mousemove and mousedown
  15724. domHandlers.mousemove.call(this, event);
  15725. domHandlers.mousedown.call(this, event);
  15726. setTouchTimer(this);
  15727. },
  15728. /**
  15729. * Touch移动响应函数
  15730. * @inner
  15731. * @param {Event} event
  15732. */
  15733. touchmove: function (event) {
  15734. event = normalizeEvent(this.dom, event);
  15735. processGesture(this, event, 'change');
  15736. // Mouse move should always be triggered no matter whether
  15737. // there is gestrue event, because mouse move and pinch may
  15738. // be used at the same time.
  15739. domHandlers.mousemove.call(this, event);
  15740. setTouchTimer(this);
  15741. },
  15742. /**
  15743. * Touch结束响应函数
  15744. * @inner
  15745. * @param {Event} event
  15746. */
  15747. touchend: function (event) {
  15748. event = normalizeEvent(this.dom, event);
  15749. processGesture(this, event, 'end');
  15750. domHandlers.mouseup.call(this, event);
  15751. // click event should always be triggered no matter whether
  15752. // there is gestrue event. System click can not be prevented.
  15753. if (+new Date() - this._lastTouchMoment < TOUCH_CLICK_DELAY) {
  15754. domHandlers.click.call(this, event);
  15755. }
  15756. setTouchTimer(this);
  15757. }
  15758. };
  15759. // Common handlers
  15760. zrUtil.each(['click', 'mousedown', 'mouseup', 'mousewheel', 'dblclick'], function (name) {
  15761. domHandlers[name] = function (event) {
  15762. event = normalizeEvent(this.dom, event);
  15763. this.trigger(name, event);
  15764. };
  15765. });
  15766. /**
  15767. * 为控制类实例初始化dom 事件处理函数
  15768. *
  15769. * @inner
  15770. * @param {module:zrender/Handler} instance 控制类实例
  15771. */
  15772. function initDomHandler(instance) {
  15773. for (var i = 0; i < touchHandlerNames.length; i++) {
  15774. var name = touchHandlerNames[i];
  15775. instance._handlers[name] = zrUtil.bind(domHandlers[name], instance);
  15776. }
  15777. for (var i = 0; i < mouseHandlerNames.length; i++) {
  15778. var name = mouseHandlerNames[i];
  15779. instance._handlers[name] = makeMouseHandler(domHandlers[name], instance);
  15780. }
  15781. function makeMouseHandler(fn, instance) {
  15782. return function () {
  15783. if (instance._touching) {
  15784. return;
  15785. }
  15786. return fn.apply(instance, arguments);
  15787. };
  15788. }
  15789. }
  15790. function HandlerDomProxy(dom) {
  15791. Eventful.call(this);
  15792. this.dom = dom;
  15793. /**
  15794. * @private
  15795. * @type {boolean}
  15796. */
  15797. this._touching = false;
  15798. /**
  15799. * @private
  15800. * @type {number}
  15801. */
  15802. this._touchTimer;
  15803. /**
  15804. * @private
  15805. * @type {module:zrender/core/GestureMgr}
  15806. */
  15807. this._gestureMgr = new GestureMgr();
  15808. this._handlers = {};
  15809. initDomHandler(this);
  15810. if (useTouchEvent()) {
  15811. mountHandlers(touchHandlerNames, this);
  15812. // Handler of 'mouseout' event is needed in touch mode, which will be mounted below.
  15813. // addEventListener(root, 'mouseout', this._mouseoutHandler);
  15814. }
  15815. // Considering some devices that both enable touch and mouse event (like MS Surface
  15816. // and lenovo X240, @see #2350), we make mouse event be always listened, otherwise
  15817. // mouse event can not be handle in those devices.
  15818. mountHandlers(mouseHandlerNames, this);
  15819. function mountHandlers(handlerNames, instance) {
  15820. zrUtil.each(handlerNames, function (name) {
  15821. addEventListener(dom, eventNameFix(name), instance._handlers[name]);
  15822. }, instance);
  15823. }
  15824. }
  15825. var handlerDomProxyProto = HandlerDomProxy.prototype;
  15826. handlerDomProxyProto.dispose = function () {
  15827. var handlerNames = mouseHandlerNames.concat(touchHandlerNames);
  15828. for (var i = 0; i < handlerNames.length; i++) {
  15829. var name = handlerNames[i];
  15830. removeEventListener(this.dom, eventNameFix(name), this._handlers[name]);
  15831. }
  15832. };
  15833. handlerDomProxyProto.setCursor = function (cursorStyle) {
  15834. this.dom.style.cursor = cursorStyle || 'default';
  15835. };
  15836. zrUtil.mixin(HandlerDomProxy, Eventful);
  15837. module.exports = HandlerDomProxy;
  15838. /***/ },
  15839. /* 90 */
  15840. /***/ function(module, exports, __webpack_require__) {
  15841. 'use strict';
  15842. /**
  15843. * Only implements needed gestures for mobile.
  15844. */
  15845. var eventUtil = __webpack_require__(87);
  15846. var GestureMgr = function () {
  15847. /**
  15848. * @private
  15849. * @type {Array.<Object>}
  15850. */
  15851. this._track = [];
  15852. };
  15853. GestureMgr.prototype = {
  15854. constructor: GestureMgr,
  15855. recognize: function (event, target, root) {
  15856. this._doTrack(event, target, root);
  15857. return this._recognize(event);
  15858. },
  15859. clear: function () {
  15860. this._track.length = 0;
  15861. return this;
  15862. },
  15863. _doTrack: function (event, target, root) {
  15864. var touches = event.touches;
  15865. if (!touches) {
  15866. return;
  15867. }
  15868. var trackItem = {
  15869. points: [],
  15870. touches: [],
  15871. target: target,
  15872. event: event
  15873. };
  15874. for (var i = 0, len = touches.length; i < len; i++) {
  15875. var touch = touches[i];
  15876. var pos = eventUtil.clientToLocal(root, touch);
  15877. trackItem.points.push([pos.zrX, pos.zrY]);
  15878. trackItem.touches.push(touch);
  15879. }
  15880. this._track.push(trackItem);
  15881. },
  15882. _recognize: function (event) {
  15883. for (var eventName in recognizers) {
  15884. if (recognizers.hasOwnProperty(eventName)) {
  15885. var gestureInfo = recognizers[eventName](this._track, event);
  15886. if (gestureInfo) {
  15887. return gestureInfo;
  15888. }
  15889. }
  15890. }
  15891. }
  15892. };
  15893. function dist(pointPair) {
  15894. var dx = pointPair[1][0] - pointPair[0][0];
  15895. var dy = pointPair[1][1] - pointPair[0][1];
  15896. return Math.sqrt(dx * dx + dy * dy);
  15897. }
  15898. function center(pointPair) {
  15899. return [
  15900. (pointPair[0][0] + pointPair[1][0]) / 2,
  15901. (pointPair[0][1] + pointPair[1][1]) / 2
  15902. ];
  15903. }
  15904. var recognizers = {
  15905. pinch: function (track, event) {
  15906. var trackLen = track.length;
  15907. if (!trackLen) {
  15908. return;
  15909. }
  15910. var pinchEnd = (track[trackLen - 1] || {}).points;
  15911. var pinchPre = (track[trackLen - 2] || {}).points || pinchEnd;
  15912. if (pinchPre
  15913. && pinchPre.length > 1
  15914. && pinchEnd
  15915. && pinchEnd.length > 1
  15916. ) {
  15917. var pinchScale = dist(pinchEnd) / dist(pinchPre);
  15918. !isFinite(pinchScale) && (pinchScale = 1);
  15919. event.pinchScale = pinchScale;
  15920. var pinchCenter = center(pinchEnd);
  15921. event.pinchX = pinchCenter[0];
  15922. event.pinchY = pinchCenter[1];
  15923. return {
  15924. type: 'pinch',
  15925. target: track[0].target,
  15926. event: event
  15927. };
  15928. }
  15929. }
  15930. // Only pinch currently.
  15931. };
  15932. module.exports = GestureMgr;
  15933. /***/ },
  15934. /* 91 */
  15935. /***/ function(module, exports, __webpack_require__) {
  15936. 'use strict';
  15937. /**
  15938. * Default canvas painter
  15939. * @module zrender/Painter
  15940. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  15941. * errorrik (errorrik@gmail.com)
  15942. * pissang (https://www.github.com/pissang)
  15943. */
  15944. var config = __webpack_require__(41);
  15945. var util = __webpack_require__(4);
  15946. var log = __webpack_require__(40);
  15947. var BoundingRect = __webpack_require__(9);
  15948. var timsort = __webpack_require__(85);
  15949. var Layer = __webpack_require__(92);
  15950. var requestAnimationFrame = __webpack_require__(88);
  15951. // PENDIGN
  15952. // Layer exceeds MAX_PROGRESSIVE_LAYER_NUMBER may have some problem when flush directly second time.
  15953. //
  15954. // Maximum progressive layer. When exceeding this number. All elements will be drawed in the last layer.
  15955. var MAX_PROGRESSIVE_LAYER_NUMBER = 5;
  15956. function parseInt10(val) {
  15957. return parseInt(val, 10);
  15958. }
  15959. function isLayerValid(layer) {
  15960. if (!layer) {
  15961. return false;
  15962. }
  15963. if (layer.isBuildin) {
  15964. return true;
  15965. }
  15966. if (typeof(layer.resize) !== 'function'
  15967. || typeof(layer.refresh) !== 'function'
  15968. ) {
  15969. return false;
  15970. }
  15971. return true;
  15972. }
  15973. function preProcessLayer(layer) {
  15974. layer.__unusedCount++;
  15975. }
  15976. function postProcessLayer(layer) {
  15977. if (layer.__unusedCount == 1) {
  15978. layer.clear();
  15979. }
  15980. }
  15981. var tmpRect = new BoundingRect(0, 0, 0, 0);
  15982. var viewRect = new BoundingRect(0, 0, 0, 0);
  15983. function isDisplayableCulled(el, width, height) {
  15984. tmpRect.copy(el.getBoundingRect());
  15985. if (el.transform) {
  15986. tmpRect.applyTransform(el.transform);
  15987. }
  15988. viewRect.width = width;
  15989. viewRect.height = height;
  15990. return !tmpRect.intersect(viewRect);
  15991. }
  15992. function isClipPathChanged(clipPaths, prevClipPaths) {
  15993. if (clipPaths == prevClipPaths) { // Can both be null or undefined
  15994. return false;
  15995. }
  15996. if (!clipPaths || !prevClipPaths || (clipPaths.length !== prevClipPaths.length)) {
  15997. return true;
  15998. }
  15999. for (var i = 0; i < clipPaths.length; i++) {
  16000. if (clipPaths[i] !== prevClipPaths[i]) {
  16001. return true;
  16002. }
  16003. }
  16004. }
  16005. function doClip(clipPaths, ctx) {
  16006. for (var i = 0; i < clipPaths.length; i++) {
  16007. var clipPath = clipPaths[i];
  16008. var m;
  16009. if (clipPath.transform) {
  16010. m = clipPath.transform;
  16011. ctx.transform(
  16012. m[0], m[1],
  16013. m[2], m[3],
  16014. m[4], m[5]
  16015. );
  16016. }
  16017. var path = clipPath.path;
  16018. path.beginPath(ctx);
  16019. clipPath.buildPath(path, clipPath.shape);
  16020. ctx.clip();
  16021. // Transform back
  16022. if (clipPath.transform) {
  16023. m = clipPath.invTransform;
  16024. ctx.transform(
  16025. m[0], m[1],
  16026. m[2], m[3],
  16027. m[4], m[5]
  16028. );
  16029. }
  16030. }
  16031. }
  16032. function createRoot(width, height) {
  16033. var domRoot = document.createElement('div');
  16034. var domRootStyle = domRoot.style;
  16035. // domRoot.onselectstart = returnFalse; // 避免页面选中的尴尬
  16036. domRootStyle.position = 'relative';
  16037. domRootStyle.overflow = 'hidden';
  16038. domRootStyle.width = width + 'px';
  16039. domRootStyle.height = height + 'px';
  16040. return domRoot;
  16041. }
  16042. /**
  16043. * @alias module:zrender/Painter
  16044. * @constructor
  16045. * @param {HTMLElement} root 绘图容器
  16046. * @param {module:zrender/Storage} storage
  16047. * @param {Ojbect} opts
  16048. */
  16049. var Painter = function (root, storage, opts) {
  16050. // In node environment using node-canvas
  16051. var singleCanvas = !root.nodeName // In node ?
  16052. || root.nodeName.toUpperCase() === 'CANVAS';
  16053. opts = opts || {};
  16054. /**
  16055. * @type {number}
  16056. */
  16057. this.dpr = opts.devicePixelRatio || config.devicePixelRatio;
  16058. /**
  16059. * @type {boolean}
  16060. * @private
  16061. */
  16062. this._singleCanvas = singleCanvas;
  16063. /**
  16064. * 绘图容器
  16065. * @type {HTMLElement}
  16066. */
  16067. this.root = root;
  16068. var rootStyle = root.style;
  16069. if (rootStyle) {
  16070. rootStyle['-webkit-tap-highlight-color'] = 'transparent';
  16071. rootStyle['-webkit-user-select'] =
  16072. rootStyle['user-select'] =
  16073. rootStyle['-webkit-touch-callout'] = 'none';
  16074. root.innerHTML = '';
  16075. }
  16076. /**
  16077. * @type {module:zrender/Storage}
  16078. */
  16079. this.storage = storage;
  16080. /**
  16081. * @type {Array.<number>}
  16082. * @private
  16083. */
  16084. var zlevelList = this._zlevelList = [];
  16085. /**
  16086. * @type {Object.<string, module:zrender/Layer>}
  16087. * @private
  16088. */
  16089. var layers = this._layers = {};
  16090. /**
  16091. * @type {Object.<string, Object>}
  16092. * @type {private}
  16093. */
  16094. this._layerConfig = {};
  16095. if (!singleCanvas) {
  16096. this._width = this._getWidth();
  16097. this._height = this._getHeight();
  16098. var domRoot = this._domRoot = createRoot(
  16099. this._width, this._height
  16100. );
  16101. root.appendChild(domRoot);
  16102. }
  16103. else {
  16104. // Use canvas width and height directly
  16105. var width = root.width;
  16106. var height = root.height;
  16107. this._width = width;
  16108. this._height = height;
  16109. // Create layer if only one given canvas
  16110. // Device pixel ratio is fixed to 1 because given canvas has its specified width and height
  16111. var mainLayer = new Layer(root, this, 1);
  16112. mainLayer.initContext();
  16113. // FIXME Use canvas width and height
  16114. // mainLayer.resize(width, height);
  16115. layers[0] = mainLayer;
  16116. zlevelList.push(0);
  16117. }
  16118. this.pathToImage = this._createPathToImage();
  16119. // Layers for progressive rendering
  16120. this._progressiveLayers = [];
  16121. /**
  16122. * @type {module:zrender/Layer}
  16123. * @private
  16124. */
  16125. this._hoverlayer;
  16126. this._hoverElements = [];
  16127. };
  16128. Painter.prototype = {
  16129. constructor: Painter,
  16130. /**
  16131. * If painter use a single canvas
  16132. * @return {boolean}
  16133. */
  16134. isSingleCanvas: function () {
  16135. return this._singleCanvas;
  16136. },
  16137. /**
  16138. * @return {HTMLDivElement}
  16139. */
  16140. getViewportRoot: function () {
  16141. return this._singleCanvas ? this._layers[0].dom : this._domRoot;
  16142. },
  16143. /**
  16144. * 刷新
  16145. * @param {boolean} [paintAll=false] 强制绘制所有displayable
  16146. */
  16147. refresh: function (paintAll) {
  16148. var list = this.storage.getDisplayList(true);
  16149. var zlevelList = this._zlevelList;
  16150. this._paintList(list, paintAll);
  16151. // Paint custum layers
  16152. for (var i = 0; i < zlevelList.length; i++) {
  16153. var z = zlevelList[i];
  16154. var layer = this._layers[z];
  16155. if (!layer.isBuildin && layer.refresh) {
  16156. layer.refresh();
  16157. }
  16158. }
  16159. this.refreshHover();
  16160. if (this._progressiveLayers.length) {
  16161. this._startProgessive();
  16162. }
  16163. return this;
  16164. },
  16165. addHover: function (el, hoverStyle) {
  16166. if (el.__hoverMir) {
  16167. return;
  16168. }
  16169. var elMirror = new el.constructor({
  16170. style: el.style,
  16171. shape: el.shape
  16172. });
  16173. elMirror.__from = el;
  16174. el.__hoverMir = elMirror;
  16175. elMirror.setStyle(hoverStyle);
  16176. this._hoverElements.push(elMirror);
  16177. },
  16178. removeHover: function (el) {
  16179. var elMirror = el.__hoverMir;
  16180. var hoverElements = this._hoverElements;
  16181. var idx = util.indexOf(hoverElements, elMirror);
  16182. if (idx >= 0) {
  16183. hoverElements.splice(idx, 1);
  16184. }
  16185. el.__hoverMir = null;
  16186. },
  16187. clearHover: function (el) {
  16188. var hoverElements = this._hoverElements;
  16189. for (var i = 0; i < hoverElements.length; i++) {
  16190. var from = hoverElements[i].__from;
  16191. if (from) {
  16192. from.__hoverMir = null;
  16193. }
  16194. }
  16195. hoverElements.length = 0;
  16196. },
  16197. refreshHover: function () {
  16198. var hoverElements = this._hoverElements;
  16199. var len = hoverElements.length;
  16200. var hoverLayer = this._hoverlayer;
  16201. hoverLayer && hoverLayer.clear();
  16202. if (!len) {
  16203. return;
  16204. }
  16205. timsort(hoverElements, this.storage.displayableSortFunc);
  16206. // Use a extream large zlevel
  16207. // FIXME?
  16208. if (!hoverLayer) {
  16209. hoverLayer = this._hoverlayer = this.getLayer(1e5);
  16210. }
  16211. var scope = {};
  16212. hoverLayer.ctx.save();
  16213. for (var i = 0; i < len;) {
  16214. var el = hoverElements[i];
  16215. var originalEl = el.__from;
  16216. // Original el is removed
  16217. // PENDING
  16218. if (!(originalEl && originalEl.__zr)) {
  16219. hoverElements.splice(i, 1);
  16220. originalEl.__hoverMir = null;
  16221. len--;
  16222. continue;
  16223. }
  16224. i++;
  16225. // Use transform
  16226. // FIXME style and shape ?
  16227. if (!originalEl.invisible) {
  16228. el.transform = originalEl.transform;
  16229. el.invTransform = originalEl.invTransform;
  16230. el.__clipPaths = originalEl.__clipPaths;
  16231. // el.
  16232. this._doPaintEl(el, hoverLayer, true, scope);
  16233. }
  16234. }
  16235. hoverLayer.ctx.restore();
  16236. },
  16237. _startProgessive: function () {
  16238. var self = this;
  16239. if (!self._furtherProgressive) {
  16240. return;
  16241. }
  16242. // Use a token to stop progress steps triggered by
  16243. // previous zr.refresh calling.
  16244. var token = self._progressiveToken = +new Date();
  16245. self._progress++;
  16246. requestAnimationFrame(step);
  16247. function step() {
  16248. // In case refreshed or disposed
  16249. if (token === self._progressiveToken && self.storage) {
  16250. self._doPaintList(self.storage.getDisplayList());
  16251. if (self._furtherProgressive) {
  16252. self._progress++;
  16253. requestAnimationFrame(step);
  16254. }
  16255. else {
  16256. self._progressiveToken = -1;
  16257. }
  16258. }
  16259. }
  16260. },
  16261. _clearProgressive: function () {
  16262. this._progressiveToken = -1;
  16263. this._progress = 0;
  16264. util.each(this._progressiveLayers, function (layer) {
  16265. layer.__dirty && layer.clear();
  16266. });
  16267. },
  16268. _paintList: function (list, paintAll) {
  16269. if (paintAll == null) {
  16270. paintAll = false;
  16271. }
  16272. this._updateLayerStatus(list);
  16273. this._clearProgressive();
  16274. this.eachBuildinLayer(preProcessLayer);
  16275. this._doPaintList(list, paintAll);
  16276. this.eachBuildinLayer(postProcessLayer);
  16277. },
  16278. _doPaintList: function (list, paintAll) {
  16279. var currentLayer;
  16280. var currentZLevel;
  16281. var ctx;
  16282. // var invTransform = [];
  16283. var scope;
  16284. var progressiveLayerIdx = 0;
  16285. var currentProgressiveLayer;
  16286. var width = this._width;
  16287. var height = this._height;
  16288. var layerProgress;
  16289. var frame = this._progress;
  16290. function flushProgressiveLayer(layer) {
  16291. ctx.save();
  16292. ctx.globalAlpha = 1;
  16293. ctx.shadowBlur = 0;
  16294. // Avoid layer don't clear in next progressive frame
  16295. currentLayer.__dirty = true;
  16296. ctx.drawImage(layer.dom, 0, 0, width, height);
  16297. ctx.restore();
  16298. currentLayer.ctx.restore();
  16299. }
  16300. for (var i = 0, l = list.length; i < l; i++) {
  16301. var el = list[i];
  16302. var elZLevel = this._singleCanvas ? 0 : el.zlevel;
  16303. var elFrame = el.__frame;
  16304. // Flush at current context
  16305. // PENDING
  16306. if (elFrame < 0 && currentProgressiveLayer) {
  16307. flushProgressiveLayer(currentProgressiveLayer);
  16308. currentProgressiveLayer = null;
  16309. }
  16310. // Change draw layer
  16311. if (currentZLevel !== elZLevel) {
  16312. if (ctx) {
  16313. ctx.restore();
  16314. }
  16315. // Reset scope
  16316. scope = {};
  16317. // Only 0 zlevel if only has one canvas
  16318. currentZLevel = elZLevel;
  16319. currentLayer = this.getLayer(currentZLevel);
  16320. if (!currentLayer.isBuildin) {
  16321. log(
  16322. 'ZLevel ' + currentZLevel
  16323. + ' has been used by unkown layer ' + currentLayer.id
  16324. );
  16325. }
  16326. ctx = currentLayer.ctx;
  16327. ctx.save();
  16328. // Reset the count
  16329. currentLayer.__unusedCount = 0;
  16330. if (currentLayer.__dirty || paintAll) {
  16331. currentLayer.clear();
  16332. }
  16333. }
  16334. if (!(currentLayer.__dirty || paintAll)) {
  16335. continue;
  16336. }
  16337. if (elFrame >= 0) {
  16338. // Progressive layer changed
  16339. if (!currentProgressiveLayer) {
  16340. currentProgressiveLayer = this._progressiveLayers[
  16341. Math.min(progressiveLayerIdx++, MAX_PROGRESSIVE_LAYER_NUMBER - 1)
  16342. ];
  16343. currentProgressiveLayer.ctx.save();
  16344. currentProgressiveLayer.renderScope = {};
  16345. if (currentProgressiveLayer
  16346. && (currentProgressiveLayer.__progress > currentProgressiveLayer.__maxProgress)
  16347. ) {
  16348. // flushProgressiveLayer(currentProgressiveLayer);
  16349. // Quick jump all progressive elements
  16350. // All progressive element are not dirty, jump over and flush directly
  16351. i = currentProgressiveLayer.__nextIdxNotProg - 1;
  16352. // currentProgressiveLayer = null;
  16353. continue;
  16354. }
  16355. layerProgress = currentProgressiveLayer.__progress;
  16356. if (!currentProgressiveLayer.__dirty) {
  16357. // Keep rendering
  16358. frame = layerProgress;
  16359. }
  16360. currentProgressiveLayer.__progress = frame + 1;
  16361. }
  16362. if (elFrame === frame) {
  16363. this._doPaintEl(el, currentProgressiveLayer, true, currentProgressiveLayer.renderScope);
  16364. }
  16365. }
  16366. else {
  16367. this._doPaintEl(el, currentLayer, paintAll, scope);
  16368. }
  16369. el.__dirty = false;
  16370. }
  16371. if (currentProgressiveLayer) {
  16372. flushProgressiveLayer(currentProgressiveLayer);
  16373. }
  16374. // Restore the lastLayer ctx
  16375. ctx && ctx.restore();
  16376. // If still has clipping state
  16377. // if (scope.prevElClipPaths) {
  16378. // ctx.restore();
  16379. // }
  16380. this._furtherProgressive = false;
  16381. util.each(this._progressiveLayers, function (layer) {
  16382. if (layer.__maxProgress >= layer.__progress) {
  16383. this._furtherProgressive = true;
  16384. }
  16385. }, this);
  16386. },
  16387. _doPaintEl: function (el, currentLayer, forcePaint, scope) {
  16388. var ctx = currentLayer.ctx;
  16389. if (
  16390. (currentLayer.__dirty || forcePaint)
  16391. // Ignore invisible element
  16392. && !el.invisible
  16393. // Ignore transparent element
  16394. && el.style.opacity !== 0
  16395. // Ignore scale 0 element, in some environment like node-canvas
  16396. // Draw a scale 0 element can cause all following draw wrong
  16397. && el.scale[0] && el.scale[1]
  16398. // Ignore culled element
  16399. && !(el.culling && isDisplayableCulled(el, this._width, this._height))
  16400. ) {
  16401. var clipPaths = el.__clipPaths;
  16402. // Optimize when clipping on group with several elements
  16403. if (scope.prevClipLayer !== currentLayer
  16404. || isClipPathChanged(clipPaths, scope.prevElClipPaths)
  16405. ) {
  16406. // If has previous clipping state, restore from it
  16407. if (scope.prevElClipPaths) {
  16408. scope.prevClipLayer.ctx.restore();
  16409. scope.prevClipLayer = scope.prevElClipPaths = null;
  16410. // Reset prevEl since context has been restored
  16411. scope.prevEl = null;
  16412. }
  16413. // New clipping state
  16414. if (clipPaths) {
  16415. ctx.save();
  16416. doClip(clipPaths, ctx);
  16417. scope.prevClipLayer = currentLayer;
  16418. scope.prevElClipPaths = clipPaths;
  16419. }
  16420. }
  16421. el.beforeBrush && el.beforeBrush(ctx);
  16422. el.brush(ctx, scope.prevEl || null);
  16423. scope.prevEl = el;
  16424. el.afterBrush && el.afterBrush(ctx);
  16425. }
  16426. },
  16427. /**
  16428. * 获取 zlevel 所在层,如果不存在则会创建一个新的层
  16429. * @param {number} zlevel
  16430. * @return {module:zrender/Layer}
  16431. */
  16432. getLayer: function (zlevel) {
  16433. if (this._singleCanvas) {
  16434. return this._layers[0];
  16435. }
  16436. var layer = this._layers[zlevel];
  16437. if (!layer) {
  16438. // Create a new layer
  16439. layer = new Layer('zr_' + zlevel, this, this.dpr);
  16440. layer.isBuildin = true;
  16441. if (this._layerConfig[zlevel]) {
  16442. util.merge(layer, this._layerConfig[zlevel], true);
  16443. }
  16444. this.insertLayer(zlevel, layer);
  16445. // Context is created after dom inserted to document
  16446. // Or excanvas will get 0px clientWidth and clientHeight
  16447. layer.initContext();
  16448. }
  16449. return layer;
  16450. },
  16451. insertLayer: function (zlevel, layer) {
  16452. var layersMap = this._layers;
  16453. var zlevelList = this._zlevelList;
  16454. var len = zlevelList.length;
  16455. var prevLayer = null;
  16456. var i = -1;
  16457. var domRoot = this._domRoot;
  16458. if (layersMap[zlevel]) {
  16459. log('ZLevel ' + zlevel + ' has been used already');
  16460. return;
  16461. }
  16462. // Check if is a valid layer
  16463. if (!isLayerValid(layer)) {
  16464. log('Layer of zlevel ' + zlevel + ' is not valid');
  16465. return;
  16466. }
  16467. if (len > 0 && zlevel > zlevelList[0]) {
  16468. for (i = 0; i < len - 1; i++) {
  16469. if (
  16470. zlevelList[i] < zlevel
  16471. && zlevelList[i + 1] > zlevel
  16472. ) {
  16473. break;
  16474. }
  16475. }
  16476. prevLayer = layersMap[zlevelList[i]];
  16477. }
  16478. zlevelList.splice(i + 1, 0, zlevel);
  16479. if (prevLayer) {
  16480. var prevDom = prevLayer.dom;
  16481. if (prevDom.nextSibling) {
  16482. domRoot.insertBefore(
  16483. layer.dom,
  16484. prevDom.nextSibling
  16485. );
  16486. }
  16487. else {
  16488. domRoot.appendChild(layer.dom);
  16489. }
  16490. }
  16491. else {
  16492. if (domRoot.firstChild) {
  16493. domRoot.insertBefore(layer.dom, domRoot.firstChild);
  16494. }
  16495. else {
  16496. domRoot.appendChild(layer.dom);
  16497. }
  16498. }
  16499. layersMap[zlevel] = layer;
  16500. },
  16501. // Iterate each layer
  16502. eachLayer: function (cb, context) {
  16503. var zlevelList = this._zlevelList;
  16504. var z;
  16505. var i;
  16506. for (i = 0; i < zlevelList.length; i++) {
  16507. z = zlevelList[i];
  16508. cb.call(context, this._layers[z], z);
  16509. }
  16510. },
  16511. // Iterate each buildin layer
  16512. eachBuildinLayer: function (cb, context) {
  16513. var zlevelList = this._zlevelList;
  16514. var layer;
  16515. var z;
  16516. var i;
  16517. for (i = 0; i < zlevelList.length; i++) {
  16518. z = zlevelList[i];
  16519. layer = this._layers[z];
  16520. if (layer.isBuildin) {
  16521. cb.call(context, layer, z);
  16522. }
  16523. }
  16524. },
  16525. // Iterate each other layer except buildin layer
  16526. eachOtherLayer: function (cb, context) {
  16527. var zlevelList = this._zlevelList;
  16528. var layer;
  16529. var z;
  16530. var i;
  16531. for (i = 0; i < zlevelList.length; i++) {
  16532. z = zlevelList[i];
  16533. layer = this._layers[z];
  16534. if (! layer.isBuildin) {
  16535. cb.call(context, layer, z);
  16536. }
  16537. }
  16538. },
  16539. /**
  16540. * 获取所有已创建的层
  16541. * @param {Array.<module:zrender/Layer>} [prevLayer]
  16542. */
  16543. getLayers: function () {
  16544. return this._layers;
  16545. },
  16546. _updateLayerStatus: function (list) {
  16547. var layers = this._layers;
  16548. var progressiveLayers = this._progressiveLayers;
  16549. var elCountsLastFrame = {};
  16550. var progressiveElCountsLastFrame = {};
  16551. this.eachBuildinLayer(function (layer, z) {
  16552. elCountsLastFrame[z] = layer.elCount;
  16553. layer.elCount = 0;
  16554. layer.__dirty = false;
  16555. });
  16556. util.each(progressiveLayers, function (layer, idx) {
  16557. progressiveElCountsLastFrame[idx] = layer.elCount;
  16558. layer.elCount = 0;
  16559. layer.__dirty = false;
  16560. });
  16561. var progressiveLayerCount = 0;
  16562. var currentProgressiveLayer;
  16563. var lastProgressiveKey;
  16564. var frameCount = 0;
  16565. for (var i = 0, l = list.length; i < l; i++) {
  16566. var el = list[i];
  16567. var zlevel = this._singleCanvas ? 0 : el.zlevel;
  16568. var layer = layers[zlevel];
  16569. var elProgress = el.progressive;
  16570. if (layer) {
  16571. layer.elCount++;
  16572. layer.__dirty = layer.__dirty || el.__dirty;
  16573. }
  16574. /////// Update progressive
  16575. if (elProgress >= 0) {
  16576. // Fix wrong progressive sequence problem.
  16577. if (lastProgressiveKey !== elProgress) {
  16578. lastProgressiveKey = elProgress;
  16579. frameCount++;
  16580. }
  16581. var elFrame = el.__frame = frameCount - 1;
  16582. if (!currentProgressiveLayer) {
  16583. var idx = Math.min(progressiveLayerCount, MAX_PROGRESSIVE_LAYER_NUMBER - 1);
  16584. currentProgressiveLayer = progressiveLayers[idx];
  16585. if (!currentProgressiveLayer) {
  16586. currentProgressiveLayer = progressiveLayers[idx] = new Layer(
  16587. 'progressive', this, this.dpr
  16588. );
  16589. currentProgressiveLayer.initContext();
  16590. }
  16591. currentProgressiveLayer.__maxProgress = 0;
  16592. }
  16593. currentProgressiveLayer.__dirty = currentProgressiveLayer.__dirty || el.__dirty;
  16594. currentProgressiveLayer.elCount++;
  16595. currentProgressiveLayer.__maxProgress = Math.max(
  16596. currentProgressiveLayer.__maxProgress, elFrame
  16597. );
  16598. if (currentProgressiveLayer.__maxProgress >= currentProgressiveLayer.__progress) {
  16599. // Should keep rendering this layer because progressive rendering is not finished yet
  16600. layer.__dirty = true;
  16601. }
  16602. }
  16603. else {
  16604. el.__frame = -1;
  16605. if (currentProgressiveLayer) {
  16606. currentProgressiveLayer.__nextIdxNotProg = i;
  16607. progressiveLayerCount++;
  16608. currentProgressiveLayer = null;
  16609. }
  16610. }
  16611. }
  16612. if (currentProgressiveLayer) {
  16613. progressiveLayerCount++;
  16614. currentProgressiveLayer.__nextIdxNotProg = i;
  16615. }
  16616. // 层中的元素数量有发生变化
  16617. this.eachBuildinLayer(function (layer, z) {
  16618. if (elCountsLastFrame[z] !== layer.elCount) {
  16619. layer.__dirty = true;
  16620. }
  16621. });
  16622. progressiveLayers.length = Math.min(progressiveLayerCount, MAX_PROGRESSIVE_LAYER_NUMBER);
  16623. util.each(progressiveLayers, function (layer, idx) {
  16624. if (progressiveElCountsLastFrame[idx] !== layer.elCount) {
  16625. el.__dirty = true;
  16626. }
  16627. if (layer.__dirty) {
  16628. layer.__progress = 0;
  16629. }
  16630. });
  16631. },
  16632. /**
  16633. * 清除hover层外所有内容
  16634. */
  16635. clear: function () {
  16636. this.eachBuildinLayer(this._clearLayer);
  16637. return this;
  16638. },
  16639. _clearLayer: function (layer) {
  16640. layer.clear();
  16641. },
  16642. /**
  16643. * 修改指定zlevel的绘制参数
  16644. *
  16645. * @param {string} zlevel
  16646. * @param {Object} config 配置对象
  16647. * @param {string} [config.clearColor=0] 每次清空画布的颜色
  16648. * @param {string} [config.motionBlur=false] 是否开启动态模糊
  16649. * @param {number} [config.lastFrameAlpha=0.7]
  16650. * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显
  16651. */
  16652. configLayer: function (zlevel, config) {
  16653. if (config) {
  16654. var layerConfig = this._layerConfig;
  16655. if (!layerConfig[zlevel]) {
  16656. layerConfig[zlevel] = config;
  16657. }
  16658. else {
  16659. util.merge(layerConfig[zlevel], config, true);
  16660. }
  16661. var layer = this._layers[zlevel];
  16662. if (layer) {
  16663. util.merge(layer, layerConfig[zlevel], true);
  16664. }
  16665. }
  16666. },
  16667. /**
  16668. * 删除指定层
  16669. * @param {number} zlevel 层所在的zlevel
  16670. */
  16671. delLayer: function (zlevel) {
  16672. var layers = this._layers;
  16673. var zlevelList = this._zlevelList;
  16674. var layer = layers[zlevel];
  16675. if (!layer) {
  16676. return;
  16677. }
  16678. layer.dom.parentNode.removeChild(layer.dom);
  16679. delete layers[zlevel];
  16680. zlevelList.splice(util.indexOf(zlevelList, zlevel), 1);
  16681. },
  16682. /**
  16683. * 区域大小变化后重绘
  16684. */
  16685. resize: function (width, height) {
  16686. var domRoot = this._domRoot;
  16687. // FIXME Why ?
  16688. domRoot.style.display = 'none';
  16689. width = width || this._getWidth();
  16690. height = height || this._getHeight();
  16691. domRoot.style.display = '';
  16692. // 优化没有实际改变的resize
  16693. if (this._width != width || height != this._height) {
  16694. domRoot.style.width = width + 'px';
  16695. domRoot.style.height = height + 'px';
  16696. for (var id in this._layers) {
  16697. this._layers[id].resize(width, height);
  16698. }
  16699. this.refresh(true);
  16700. }
  16701. this._width = width;
  16702. this._height = height;
  16703. return this;
  16704. },
  16705. /**
  16706. * 清除单独的一个层
  16707. * @param {number} zlevel
  16708. */
  16709. clearLayer: function (zlevel) {
  16710. var layer = this._layers[zlevel];
  16711. if (layer) {
  16712. layer.clear();
  16713. }
  16714. },
  16715. /**
  16716. * 释放
  16717. */
  16718. dispose: function () {
  16719. this.root.innerHTML = '';
  16720. this.root =
  16721. this.storage =
  16722. this._domRoot =
  16723. this._layers = null;
  16724. },
  16725. /**
  16726. * Get canvas which has all thing rendered
  16727. * @param {Object} opts
  16728. * @param {string} [opts.backgroundColor]
  16729. */
  16730. getRenderedCanvas: function (opts) {
  16731. opts = opts || {};
  16732. if (this._singleCanvas) {
  16733. return this._layers[0].dom;
  16734. }
  16735. var imageLayer = new Layer('image', this, opts.pixelRatio || this.dpr);
  16736. imageLayer.initContext();
  16737. imageLayer.clearColor = opts.backgroundColor;
  16738. imageLayer.clear();
  16739. var displayList = this.storage.getDisplayList(true);
  16740. var scope = {};
  16741. for (var i = 0; i < displayList.length; i++) {
  16742. var el = displayList[i];
  16743. this._doPaintEl(el, imageLayer, true, scope);
  16744. }
  16745. return imageLayer.dom;
  16746. },
  16747. /**
  16748. * 获取绘图区域宽度
  16749. */
  16750. getWidth: function () {
  16751. return this._width;
  16752. },
  16753. /**
  16754. * 获取绘图区域高度
  16755. */
  16756. getHeight: function () {
  16757. return this._height;
  16758. },
  16759. _getWidth: function () {
  16760. var root = this.root;
  16761. var stl = document.defaultView.getComputedStyle(root);
  16762. // FIXME Better way to get the width and height when element has not been append to the document
  16763. return ((root.clientWidth || parseInt10(stl.width) || parseInt10(root.style.width))
  16764. - (parseInt10(stl.paddingLeft) || 0)
  16765. - (parseInt10(stl.paddingRight) || 0)) | 0;
  16766. },
  16767. _getHeight: function () {
  16768. var root = this.root;
  16769. var stl = document.defaultView.getComputedStyle(root);
  16770. return ((root.clientHeight || parseInt10(stl.height) || parseInt10(root.style.height))
  16771. - (parseInt10(stl.paddingTop) || 0)
  16772. - (parseInt10(stl.paddingBottom) || 0)) | 0;
  16773. },
  16774. _pathToImage: function (id, path, width, height, dpr) {
  16775. var canvas = document.createElement('canvas');
  16776. var ctx = canvas.getContext('2d');
  16777. canvas.width = width * dpr;
  16778. canvas.height = height * dpr;
  16779. ctx.clearRect(0, 0, width * dpr, height * dpr);
  16780. var pathTransform = {
  16781. position: path.position,
  16782. rotation: path.rotation,
  16783. scale: path.scale
  16784. };
  16785. path.position = [0, 0, 0];
  16786. path.rotation = 0;
  16787. path.scale = [1, 1];
  16788. if (path) {
  16789. path.brush(ctx);
  16790. }
  16791. var ImageShape = __webpack_require__(62);
  16792. var imgShape = new ImageShape({
  16793. id: id,
  16794. style: {
  16795. x: 0,
  16796. y: 0,
  16797. image: canvas
  16798. }
  16799. });
  16800. if (pathTransform.position != null) {
  16801. imgShape.position = path.position = pathTransform.position;
  16802. }
  16803. if (pathTransform.rotation != null) {
  16804. imgShape.rotation = path.rotation = pathTransform.rotation;
  16805. }
  16806. if (pathTransform.scale != null) {
  16807. imgShape.scale = path.scale = pathTransform.scale;
  16808. }
  16809. return imgShape;
  16810. },
  16811. _createPathToImage: function () {
  16812. var me = this;
  16813. return function (id, e, width, height) {
  16814. return me._pathToImage(
  16815. id, e, width, height, me.dpr
  16816. );
  16817. };
  16818. }
  16819. };
  16820. module.exports = Painter;
  16821. /***/ },
  16822. /* 92 */
  16823. /***/ function(module, exports, __webpack_require__) {
  16824. /**
  16825. * @module zrender/Layer
  16826. * @author pissang(https://www.github.com/pissang)
  16827. */
  16828. var util = __webpack_require__(4);
  16829. var config = __webpack_require__(41);
  16830. var Style = __webpack_require__(47);
  16831. var Pattern = __webpack_require__(59);
  16832. function returnFalse() {
  16833. return false;
  16834. }
  16835. /**
  16836. * 创建dom
  16837. *
  16838. * @inner
  16839. * @param {string} id dom id 待用
  16840. * @param {string} type dom type,such as canvas, div etc.
  16841. * @param {Painter} painter painter instance
  16842. * @param {number} number
  16843. */
  16844. function createDom(id, type, painter, dpr) {
  16845. var newDom = document.createElement(type);
  16846. var width = painter.getWidth();
  16847. var height = painter.getHeight();
  16848. var newDomStyle = newDom.style;
  16849. // 没append呢,请原谅我这样写,清晰~
  16850. newDomStyle.position = 'absolute';
  16851. newDomStyle.left = 0;
  16852. newDomStyle.top = 0;
  16853. newDomStyle.width = width + 'px';
  16854. newDomStyle.height = height + 'px';
  16855. newDom.width = width * dpr;
  16856. newDom.height = height * dpr;
  16857. // id不作为索引用,避免可能造成的重名,定义为私有属性
  16858. newDom.setAttribute('data-zr-dom-id', id);
  16859. return newDom;
  16860. }
  16861. /**
  16862. * @alias module:zrender/Layer
  16863. * @constructor
  16864. * @extends module:zrender/mixin/Transformable
  16865. * @param {string} id
  16866. * @param {module:zrender/Painter} painter
  16867. * @param {number} [dpr]
  16868. */
  16869. var Layer = function(id, painter, dpr) {
  16870. var dom;
  16871. dpr = dpr || config.devicePixelRatio;
  16872. if (typeof id === 'string') {
  16873. dom = createDom(id, 'canvas', painter, dpr);
  16874. }
  16875. // Not using isDom because in node it will return false
  16876. else if (util.isObject(id)) {
  16877. dom = id;
  16878. id = dom.id;
  16879. }
  16880. this.id = id;
  16881. this.dom = dom;
  16882. var domStyle = dom.style;
  16883. if (domStyle) { // Not in node
  16884. dom.onselectstart = returnFalse; // 避免页面选中的尴尬
  16885. domStyle['-webkit-user-select'] = 'none';
  16886. domStyle['user-select'] = 'none';
  16887. domStyle['-webkit-touch-callout'] = 'none';
  16888. domStyle['-webkit-tap-highlight-color'] = 'rgba(0,0,0,0)';
  16889. }
  16890. this.domBack = null;
  16891. this.ctxBack = null;
  16892. this.painter = painter;
  16893. this.config = null;
  16894. // Configs
  16895. /**
  16896. * 每次清空画布的颜色
  16897. * @type {string}
  16898. * @default 0
  16899. */
  16900. this.clearColor = 0;
  16901. /**
  16902. * 是否开启动态模糊
  16903. * @type {boolean}
  16904. * @default false
  16905. */
  16906. this.motionBlur = false;
  16907. /**
  16908. * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显
  16909. * @type {number}
  16910. * @default 0.7
  16911. */
  16912. this.lastFrameAlpha = 0.7;
  16913. /**
  16914. * Layer dpr
  16915. * @type {number}
  16916. */
  16917. this.dpr = dpr;
  16918. };
  16919. Layer.prototype = {
  16920. constructor: Layer,
  16921. elCount: 0,
  16922. __dirty: true,
  16923. initContext: function () {
  16924. this.ctx = this.dom.getContext('2d');
  16925. var dpr = this.dpr;
  16926. if (dpr != 1) {
  16927. this.ctx.scale(dpr, dpr);
  16928. }
  16929. },
  16930. createBackBuffer: function () {
  16931. var dpr = this.dpr;
  16932. this.domBack = createDom('back-' + this.id, 'canvas', this.painter, dpr);
  16933. this.ctxBack = this.domBack.getContext('2d');
  16934. if (dpr != 1) {
  16935. this.ctxBack.scale(dpr, dpr);
  16936. }
  16937. },
  16938. /**
  16939. * @param {number} width
  16940. * @param {number} height
  16941. */
  16942. resize: function (width, height) {
  16943. var dpr = this.dpr;
  16944. var dom = this.dom;
  16945. var domStyle = dom.style;
  16946. var domBack = this.domBack;
  16947. domStyle.width = width + 'px';
  16948. domStyle.height = height + 'px';
  16949. dom.width = width * dpr;
  16950. dom.height = height * dpr;
  16951. if (dpr != 1) {
  16952. this.ctx.scale(dpr, dpr);
  16953. }
  16954. if (domBack) {
  16955. domBack.width = width * dpr;
  16956. domBack.height = height * dpr;
  16957. if (dpr != 1) {
  16958. this.ctxBack.scale(dpr, dpr);
  16959. }
  16960. }
  16961. },
  16962. /**
  16963. * 清空该层画布
  16964. * @param {boolean} clearAll Clear all with out motion blur
  16965. */
  16966. clear: function (clearAll) {
  16967. var dom = this.dom;
  16968. var ctx = this.ctx;
  16969. var width = dom.width;
  16970. var height = dom.height;
  16971. var clearColor = this.clearColor;
  16972. var haveMotionBLur = this.motionBlur && !clearAll;
  16973. var lastFrameAlpha = this.lastFrameAlpha;
  16974. var dpr = this.dpr;
  16975. if (haveMotionBLur) {
  16976. if (!this.domBack) {
  16977. this.createBackBuffer();
  16978. }
  16979. this.ctxBack.globalCompositeOperation = 'copy';
  16980. this.ctxBack.drawImage(
  16981. dom, 0, 0,
  16982. width / dpr,
  16983. height / dpr
  16984. );
  16985. }
  16986. ctx.clearRect(0, 0, width / dpr, height / dpr);
  16987. if (clearColor) {
  16988. var clearColorGradientOrPattern;
  16989. // Gradient
  16990. if (clearColor.colorStops) {
  16991. // Cache canvas gradient
  16992. clearColorGradientOrPattern = clearColor.__canvasGradient || Style.getGradient(ctx, clearColor, {
  16993. x: 0,
  16994. y: 0,
  16995. width: width / dpr,
  16996. height: height / dpr
  16997. });
  16998. clearColor.__canvasGradient = clearColorGradientOrPattern;
  16999. }
  17000. // Pattern
  17001. else if (clearColor.image) {
  17002. clearColorGradientOrPattern = Pattern.prototype.getCanvasPattern.call(clearColor, ctx);
  17003. }
  17004. ctx.save();
  17005. ctx.fillStyle = clearColorGradientOrPattern || clearColor;
  17006. ctx.fillRect(0, 0, width / dpr, height / dpr);
  17007. ctx.restore();
  17008. }
  17009. if (haveMotionBLur) {
  17010. var domBack = this.domBack;
  17011. ctx.save();
  17012. ctx.globalAlpha = lastFrameAlpha;
  17013. ctx.drawImage(domBack, 0, 0, width / dpr, height / dpr);
  17014. ctx.restore();
  17015. }
  17016. }
  17017. };
  17018. module.exports = Layer;
  17019. /***/ },
  17020. /* 93 */
  17021. /***/ function(module, exports, __webpack_require__) {
  17022. var graphic = __webpack_require__(43);
  17023. var zrUtil = __webpack_require__(4);
  17024. var PI = Math.PI;
  17025. /**
  17026. * @param {module:echarts/ExtensionAPI} api
  17027. * @param {Object} [opts]
  17028. * @param {string} [opts.text]
  17029. * @param {string} [opts.color]
  17030. * @param {string} [opts.textColor]
  17031. * @return {module:zrender/Element}
  17032. */
  17033. module.exports = function (api, opts) {
  17034. opts = opts || {};
  17035. zrUtil.defaults(opts, {
  17036. text: 'loading',
  17037. color: '#c23531',
  17038. textColor: '#000',
  17039. maskColor: 'rgba(255, 255, 255, 0.8)',
  17040. zlevel: 0
  17041. });
  17042. var mask = new graphic.Rect({
  17043. style: {
  17044. fill: opts.maskColor
  17045. },
  17046. zlevel: opts.zlevel,
  17047. z: 10000
  17048. });
  17049. var arc = new graphic.Arc({
  17050. shape: {
  17051. startAngle: -PI / 2,
  17052. endAngle: -PI / 2 + 0.1,
  17053. r: 10
  17054. },
  17055. style: {
  17056. stroke: opts.color,
  17057. lineCap: 'round',
  17058. lineWidth: 5
  17059. },
  17060. zlevel: opts.zlevel,
  17061. z: 10001
  17062. });
  17063. var labelRect = new graphic.Rect({
  17064. style: {
  17065. fill: 'none',
  17066. text: opts.text,
  17067. textPosition: 'right',
  17068. textDistance: 10,
  17069. textFill: opts.textColor
  17070. },
  17071. zlevel: opts.zlevel,
  17072. z: 10001
  17073. });
  17074. arc.animateShape(true)
  17075. .when(1000, {
  17076. endAngle: PI * 3 / 2
  17077. })
  17078. .start('circularInOut');
  17079. arc.animateShape(true)
  17080. .when(1000, {
  17081. startAngle: PI * 3 / 2
  17082. })
  17083. .delay(300)
  17084. .start('circularInOut');
  17085. var group = new graphic.Group();
  17086. group.add(arc);
  17087. group.add(labelRect);
  17088. group.add(mask);
  17089. // Inject resize
  17090. group.resize = function () {
  17091. var cx = api.getWidth() / 2;
  17092. var cy = api.getHeight() / 2;
  17093. arc.setShape({
  17094. cx: cx,
  17095. cy: cy
  17096. });
  17097. var r = arc.shape.r;
  17098. labelRect.setShape({
  17099. x: cx - r,
  17100. y: cy - r,
  17101. width: r * 2,
  17102. height: r * 2
  17103. });
  17104. mask.setShape({
  17105. x: 0,
  17106. y: 0,
  17107. width: api.getWidth(),
  17108. height: api.getHeight()
  17109. });
  17110. };
  17111. group.resize();
  17112. return group;
  17113. };
  17114. /***/ },
  17115. /* 94 */
  17116. /***/ function(module, exports, __webpack_require__) {
  17117. var Gradient = __webpack_require__(61);
  17118. module.exports = function (ecModel) {
  17119. function encodeColor(seriesModel) {
  17120. var colorAccessPath = (seriesModel.visualColorAccessPath || 'itemStyle.normal.color').split('.');
  17121. var data = seriesModel.getData();
  17122. var color = seriesModel.get(colorAccessPath) // Set in itemStyle
  17123. || seriesModel.getColorFromPalette(seriesModel.get('name')); // Default color
  17124. // FIXME Set color function or use the platte color
  17125. data.setVisual('color', color);
  17126. // Only visible series has each data be visual encoded
  17127. if (!ecModel.isSeriesFiltered(seriesModel)) {
  17128. if (typeof color === 'function' && !(color instanceof Gradient)) {
  17129. data.each(function (idx) {
  17130. data.setItemVisual(
  17131. idx, 'color', color(seriesModel.getDataParams(idx))
  17132. );
  17133. });
  17134. }
  17135. // itemStyle in each data item
  17136. data.each(function (idx) {
  17137. var itemModel = data.getItemModel(idx);
  17138. var color = itemModel.get(colorAccessPath, true);
  17139. if (color != null) {
  17140. data.setItemVisual(idx, 'color', color);
  17141. }
  17142. });
  17143. }
  17144. }
  17145. ecModel.eachRawSeries(encodeColor);
  17146. };
  17147. /***/ },
  17148. /* 95 */
  17149. /***/ function(module, exports, __webpack_require__) {
  17150. // Compatitable with 2.0
  17151. var zrUtil = __webpack_require__(4);
  17152. var compatStyle = __webpack_require__(96);
  17153. function get(opt, path) {
  17154. path = path.split(',');
  17155. var obj = opt;
  17156. for (var i = 0; i < path.length; i++) {
  17157. obj = obj && obj[path[i]];
  17158. if (obj == null) {
  17159. break;
  17160. }
  17161. }
  17162. return obj;
  17163. }
  17164. function set(opt, path, val, overwrite) {
  17165. path = path.split(',');
  17166. var obj = opt;
  17167. var key;
  17168. for (var i = 0; i < path.length - 1; i++) {
  17169. key = path[i];
  17170. if (obj[key] == null) {
  17171. obj[key] = {};
  17172. }
  17173. obj = obj[key];
  17174. }
  17175. if (overwrite || obj[path[i]] == null) {
  17176. obj[path[i]] = val;
  17177. }
  17178. }
  17179. function compatLayoutProperties(option) {
  17180. each(LAYOUT_PROPERTIES, function (prop) {
  17181. if (prop[0] in option && !(prop[1] in option)) {
  17182. option[prop[1]] = option[prop[0]];
  17183. }
  17184. });
  17185. }
  17186. var LAYOUT_PROPERTIES = [
  17187. ['x', 'left'], ['y', 'top'], ['x2', 'right'], ['y2', 'bottom']
  17188. ];
  17189. var COMPATITABLE_COMPONENTS = [
  17190. 'grid', 'geo', 'parallel', 'legend', 'toolbox', 'title', 'visualMap', 'dataZoom', 'timeline'
  17191. ];
  17192. var COMPATITABLE_SERIES = [
  17193. 'bar', 'boxplot', 'candlestick', 'chord', 'effectScatter',
  17194. 'funnel', 'gauge', 'lines', 'graph', 'heatmap', 'line', 'map', 'parallel',
  17195. 'pie', 'radar', 'sankey', 'scatter', 'treemap'
  17196. ];
  17197. var each = zrUtil.each;
  17198. module.exports = function (option) {
  17199. each(option.series, function (seriesOpt) {
  17200. if (!zrUtil.isObject(seriesOpt)) {
  17201. return;
  17202. }
  17203. var seriesType = seriesOpt.type;
  17204. compatStyle(seriesOpt);
  17205. if (seriesType === 'pie' || seriesType === 'gauge') {
  17206. if (seriesOpt.clockWise != null) {
  17207. seriesOpt.clockwise = seriesOpt.clockWise;
  17208. }
  17209. }
  17210. if (seriesType === 'gauge') {
  17211. var pointerColor = get(seriesOpt, 'pointer.color');
  17212. pointerColor != null
  17213. && set(seriesOpt, 'itemStyle.normal.color', pointerColor);
  17214. }
  17215. for (var i = 0; i < COMPATITABLE_SERIES.length; i++) {
  17216. if (COMPATITABLE_SERIES[i] === seriesOpt.type) {
  17217. compatLayoutProperties(seriesOpt);
  17218. break;
  17219. }
  17220. }
  17221. });
  17222. // dataRange has changed to visualMap
  17223. if (option.dataRange) {
  17224. option.visualMap = option.dataRange;
  17225. }
  17226. each(COMPATITABLE_COMPONENTS, function (componentName) {
  17227. var options = option[componentName];
  17228. if (options) {
  17229. if (!zrUtil.isArray(options)) {
  17230. options = [options];
  17231. }
  17232. each(options, function (option) {
  17233. compatLayoutProperties(option);
  17234. });
  17235. }
  17236. });
  17237. };
  17238. /***/ },
  17239. /* 96 */
  17240. /***/ function(module, exports, __webpack_require__) {
  17241. var zrUtil = __webpack_require__(4);
  17242. var POSSIBLE_STYLES = [
  17243. 'areaStyle', 'lineStyle', 'nodeStyle', 'linkStyle',
  17244. 'chordStyle', 'label', 'labelLine'
  17245. ];
  17246. function compatItemStyle(opt) {
  17247. var itemStyleOpt = opt && opt.itemStyle;
  17248. if (itemStyleOpt) {
  17249. zrUtil.each(POSSIBLE_STYLES, function (styleName) {
  17250. var normalItemStyleOpt = itemStyleOpt.normal;
  17251. var emphasisItemStyleOpt = itemStyleOpt.emphasis;
  17252. if (normalItemStyleOpt && normalItemStyleOpt[styleName]) {
  17253. opt[styleName] = opt[styleName] || {};
  17254. if (!opt[styleName].normal) {
  17255. opt[styleName].normal = normalItemStyleOpt[styleName];
  17256. }
  17257. else {
  17258. zrUtil.merge(opt[styleName].normal, normalItemStyleOpt[styleName]);
  17259. }
  17260. normalItemStyleOpt[styleName] = null;
  17261. }
  17262. if (emphasisItemStyleOpt && emphasisItemStyleOpt[styleName]) {
  17263. opt[styleName] = opt[styleName] || {};
  17264. if (!opt[styleName].emphasis) {
  17265. opt[styleName].emphasis = emphasisItemStyleOpt[styleName];
  17266. }
  17267. else {
  17268. zrUtil.merge(opt[styleName].emphasis, emphasisItemStyleOpt[styleName]);
  17269. }
  17270. emphasisItemStyleOpt[styleName] = null;
  17271. }
  17272. });
  17273. }
  17274. }
  17275. module.exports = function (seriesOpt) {
  17276. if (!seriesOpt) {
  17277. return;
  17278. }
  17279. compatItemStyle(seriesOpt);
  17280. compatItemStyle(seriesOpt.markPoint);
  17281. compatItemStyle(seriesOpt.markLine);
  17282. var data = seriesOpt.data;
  17283. if (data) {
  17284. for (var i = 0; i < data.length; i++) {
  17285. compatItemStyle(data[i]);
  17286. }
  17287. // mark point data
  17288. var markPoint = seriesOpt.markPoint;
  17289. if (markPoint && markPoint.data) {
  17290. var mpData = markPoint.data;
  17291. for (var i = 0; i < mpData.length; i++) {
  17292. compatItemStyle(mpData[i]);
  17293. }
  17294. }
  17295. // mark line data
  17296. var markLine = seriesOpt.markLine;
  17297. if (markLine && markLine.data) {
  17298. var mlData = markLine.data;
  17299. for (var i = 0; i < mlData.length; i++) {
  17300. if (zrUtil.isArray(mlData[i])) {
  17301. compatItemStyle(mlData[i][0]);
  17302. compatItemStyle(mlData[i][1]);
  17303. }
  17304. else {
  17305. compatItemStyle(mlData[i]);
  17306. }
  17307. }
  17308. }
  17309. }
  17310. };
  17311. /***/ },
  17312. /* 97 */
  17313. /***/ function(module, exports, __webpack_require__) {
  17314. /* WEBPACK VAR INJECTION */(function(global) {/**
  17315. * List for data storage
  17316. * @module echarts/data/List
  17317. */
  17318. var UNDEFINED = 'undefined';
  17319. var globalObj = typeof window === 'undefined' ? global : window;
  17320. var Float64Array = typeof globalObj.Float64Array === UNDEFINED
  17321. ? Array : globalObj.Float64Array;
  17322. var Int32Array = typeof globalObj.Int32Array === UNDEFINED
  17323. ? Array : globalObj.Int32Array;
  17324. var dataCtors = {
  17325. 'float': Float64Array,
  17326. 'int': Int32Array,
  17327. // Ordinal data type can be string or int
  17328. 'ordinal': Array,
  17329. 'number': Array,
  17330. 'time': Array
  17331. };
  17332. var Model = __webpack_require__(12);
  17333. var DataDiffer = __webpack_require__(98);
  17334. var zrUtil = __webpack_require__(4);
  17335. var modelUtil = __webpack_require__(5);
  17336. var isObject = zrUtil.isObject;
  17337. var TRANSFERABLE_PROPERTIES = [
  17338. 'stackedOn', 'hasItemOption', '_nameList', '_idList', '_rawData'
  17339. ];
  17340. var transferProperties = function (a, b) {
  17341. zrUtil.each(TRANSFERABLE_PROPERTIES.concat(b.__wrappedMethods || []), function (propName) {
  17342. if (b.hasOwnProperty(propName)) {
  17343. a[propName] = b[propName];
  17344. }
  17345. });
  17346. a.__wrappedMethods = b.__wrappedMethods;
  17347. };
  17348. /**
  17349. * @constructor
  17350. * @alias module:echarts/data/List
  17351. *
  17352. * @param {Array.<string>} dimensions
  17353. * Dimensions should be concrete names like x, y, z, lng, lat, angle, radius
  17354. * @param {module:echarts/model/Model} hostModel
  17355. */
  17356. var List = function (dimensions, hostModel) {
  17357. dimensions = dimensions || ['x', 'y'];
  17358. var dimensionInfos = {};
  17359. var dimensionNames = [];
  17360. for (var i = 0; i < dimensions.length; i++) {
  17361. var dimensionName;
  17362. var dimensionInfo = {};
  17363. if (typeof dimensions[i] === 'string') {
  17364. dimensionName = dimensions[i];
  17365. dimensionInfo = {
  17366. name: dimensionName,
  17367. stackable: false,
  17368. // Type can be 'float', 'int', 'number'
  17369. // Default is number, Precision of float may not enough
  17370. type: 'number'
  17371. };
  17372. }
  17373. else {
  17374. dimensionInfo = dimensions[i];
  17375. dimensionName = dimensionInfo.name;
  17376. dimensionInfo.type = dimensionInfo.type || 'number';
  17377. }
  17378. dimensionNames.push(dimensionName);
  17379. dimensionInfos[dimensionName] = dimensionInfo;
  17380. }
  17381. /**
  17382. * @readOnly
  17383. * @type {Array.<string>}
  17384. */
  17385. this.dimensions = dimensionNames;
  17386. /**
  17387. * Infomation of each data dimension, like data type.
  17388. * @type {Object}
  17389. */
  17390. this._dimensionInfos = dimensionInfos;
  17391. /**
  17392. * @type {module:echarts/model/Model}
  17393. */
  17394. this.hostModel = hostModel;
  17395. /**
  17396. * @type {module:echarts/model/Model}
  17397. */
  17398. this.dataType;
  17399. /**
  17400. * Indices stores the indices of data subset after filtered.
  17401. * This data subset will be used in chart.
  17402. * @type {Array.<number>}
  17403. * @readOnly
  17404. */
  17405. this.indices = [];
  17406. /**
  17407. * Data storage
  17408. * @type {Object.<key, TypedArray|Array>}
  17409. * @private
  17410. */
  17411. this._storage = {};
  17412. /**
  17413. * @type {Array.<string>}
  17414. */
  17415. this._nameList = [];
  17416. /**
  17417. * @type {Array.<string>}
  17418. */
  17419. this._idList = [];
  17420. /**
  17421. * Models of data option is stored sparse for optimizing memory cost
  17422. * @type {Array.<module:echarts/model/Model>}
  17423. * @private
  17424. */
  17425. this._optionModels = [];
  17426. /**
  17427. * @param {module:echarts/data/List}
  17428. */
  17429. this.stackedOn = null;
  17430. /**
  17431. * Global visual properties after visual coding
  17432. * @type {Object}
  17433. * @private
  17434. */
  17435. this._visual = {};
  17436. /**
  17437. * Globel layout properties.
  17438. * @type {Object}
  17439. * @private
  17440. */
  17441. this._layout = {};
  17442. /**
  17443. * Item visual properties after visual coding
  17444. * @type {Array.<Object>}
  17445. * @private
  17446. */
  17447. this._itemVisuals = [];
  17448. /**
  17449. * Item layout properties after layout
  17450. * @type {Array.<Object>}
  17451. * @private
  17452. */
  17453. this._itemLayouts = [];
  17454. /**
  17455. * Graphic elemnents
  17456. * @type {Array.<module:zrender/Element>}
  17457. * @private
  17458. */
  17459. this._graphicEls = [];
  17460. /**
  17461. * @type {Array.<Array|Object>}
  17462. * @private
  17463. */
  17464. this._rawData;
  17465. /**
  17466. * @type {Object}
  17467. * @private
  17468. */
  17469. this._extent;
  17470. };
  17471. var listProto = List.prototype;
  17472. listProto.type = 'list';
  17473. /**
  17474. * If each data item has it's own option
  17475. * @type {boolean}
  17476. */
  17477. listProto.hasItemOption = true;
  17478. /**
  17479. * Get dimension name
  17480. * @param {string|number} dim
  17481. * Dimension can be concrete names like x, y, z, lng, lat, angle, radius
  17482. * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius'
  17483. * @return {string} Concrete dim name.
  17484. */
  17485. listProto.getDimension = function (dim) {
  17486. if (!isNaN(dim)) {
  17487. dim = this.dimensions[dim] || dim;
  17488. }
  17489. return dim;
  17490. };
  17491. /**
  17492. * Get type and stackable info of particular dimension
  17493. * @param {string|number} dim
  17494. * Dimension can be concrete names like x, y, z, lng, lat, angle, radius
  17495. * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius'
  17496. */
  17497. listProto.getDimensionInfo = function (dim) {
  17498. return zrUtil.clone(this._dimensionInfos[this.getDimension(dim)]);
  17499. };
  17500. /**
  17501. * Initialize from data
  17502. * @param {Array.<Object|number|Array>} data
  17503. * @param {Array.<string>} [nameList]
  17504. * @param {Function} [dimValueGetter] (dataItem, dimName, dataIndex, dimIndex) => number
  17505. */
  17506. listProto.initData = function (data, nameList, dimValueGetter) {
  17507. data = data || [];
  17508. if (true) {
  17509. if (!zrUtil.isArray(data)) {
  17510. throw new Error('Invalid data.');
  17511. }
  17512. }
  17513. this._rawData = data;
  17514. // Clear
  17515. var storage = this._storage = {};
  17516. var indices = this.indices = [];
  17517. var dimensions = this.dimensions;
  17518. var size = data.length;
  17519. var dimensionInfoMap = this._dimensionInfos;
  17520. var idList = [];
  17521. var nameRepeatCount = {};
  17522. nameList = nameList || [];
  17523. // Init storage
  17524. for (var i = 0; i < dimensions.length; i++) {
  17525. var dimInfo = dimensionInfoMap[dimensions[i]];
  17526. var DataCtor = dataCtors[dimInfo.type];
  17527. storage[dimensions[i]] = new DataCtor(size);
  17528. }
  17529. var self = this;
  17530. if (!dimValueGetter) {
  17531. self.hasItemOption = false;
  17532. }
  17533. // Default dim value getter
  17534. dimValueGetter = dimValueGetter || function (dataItem, dimName, dataIndex, dimIndex) {
  17535. var value = modelUtil.getDataItemValue(dataItem);
  17536. // If any dataItem is like { value: 10 }
  17537. if (modelUtil.isDataItemOption(dataItem)) {
  17538. self.hasItemOption = true;
  17539. }
  17540. return modelUtil.converDataValue(
  17541. (value instanceof Array)
  17542. ? value[dimIndex]
  17543. // If value is a single number or something else not array.
  17544. : value,
  17545. dimensionInfoMap[dimName]
  17546. );
  17547. };
  17548. for (var idx = 0; idx < data.length; idx++) {
  17549. var dataItem = data[idx];
  17550. // Each data item is value
  17551. // [1, 2]
  17552. // 2
  17553. // Bar chart, line chart which uses category axis
  17554. // only gives the 'y' value. 'x' value is the indices of cateogry
  17555. // Use a tempValue to normalize the value to be a (x, y) value
  17556. // Store the data by dimensions
  17557. for (var k = 0; k < dimensions.length; k++) {
  17558. var dim = dimensions[k];
  17559. var dimStorage = storage[dim];
  17560. // PENDING NULL is empty or zero
  17561. dimStorage[idx] = dimValueGetter(dataItem, dim, idx, k);
  17562. }
  17563. indices.push(idx);
  17564. }
  17565. // Use the name in option and create id
  17566. for (var i = 0; i < data.length; i++) {
  17567. if (!nameList[i]) {
  17568. if (data[i] && data[i].name != null) {
  17569. nameList[i] = data[i].name;
  17570. }
  17571. }
  17572. var name = nameList[i] || '';
  17573. // Try using the id in option
  17574. var id = data[i] && data[i].id;
  17575. if (!id && name) {
  17576. // Use name as id and add counter to avoid same name
  17577. nameRepeatCount[name] = nameRepeatCount[name] || 0;
  17578. id = name;
  17579. if (nameRepeatCount[name] > 0) {
  17580. id += '__ec__' + nameRepeatCount[name];
  17581. }
  17582. nameRepeatCount[name]++;
  17583. }
  17584. id && (idList[i] = id);
  17585. }
  17586. this._nameList = nameList;
  17587. this._idList = idList;
  17588. };
  17589. /**
  17590. * @return {number}
  17591. */
  17592. listProto.count = function () {
  17593. return this.indices.length;
  17594. };
  17595. /**
  17596. * Get value. Return NaN if idx is out of range.
  17597. * @param {string} dim Dim must be concrete name.
  17598. * @param {number} idx
  17599. * @param {boolean} stack
  17600. * @return {number}
  17601. */
  17602. listProto.get = function (dim, idx, stack) {
  17603. var storage = this._storage;
  17604. var dataIndex = this.indices[idx];
  17605. // If value not exists
  17606. if (dataIndex == null) {
  17607. return NaN;
  17608. }
  17609. var value = storage[dim] && storage[dim][dataIndex];
  17610. // FIXME ordinal data type is not stackable
  17611. if (stack) {
  17612. var dimensionInfo = this._dimensionInfos[dim];
  17613. if (dimensionInfo && dimensionInfo.stackable) {
  17614. var stackedOn = this.stackedOn;
  17615. while (stackedOn) {
  17616. // Get no stacked data of stacked on
  17617. var stackedValue = stackedOn.get(dim, idx);
  17618. // Considering positive stack, negative stack and empty data
  17619. if ((value >= 0 && stackedValue > 0) // Positive stack
  17620. || (value <= 0 && stackedValue < 0) // Negative stack
  17621. ) {
  17622. value += stackedValue;
  17623. }
  17624. stackedOn = stackedOn.stackedOn;
  17625. }
  17626. }
  17627. }
  17628. return value;
  17629. };
  17630. /**
  17631. * Get value for multi dimensions.
  17632. * @param {Array.<string>} [dimensions] If ignored, using all dimensions.
  17633. * @param {number} idx
  17634. * @param {boolean} stack
  17635. * @return {number}
  17636. */
  17637. listProto.getValues = function (dimensions, idx, stack) {
  17638. var values = [];
  17639. if (!zrUtil.isArray(dimensions)) {
  17640. stack = idx;
  17641. idx = dimensions;
  17642. dimensions = this.dimensions;
  17643. }
  17644. for (var i = 0, len = dimensions.length; i < len; i++) {
  17645. values.push(this.get(dimensions[i], idx, stack));
  17646. }
  17647. return values;
  17648. };
  17649. /**
  17650. * If value is NaN. Inlcuding '-'
  17651. * @param {string} dim
  17652. * @param {number} idx
  17653. * @return {number}
  17654. */
  17655. listProto.hasValue = function (idx) {
  17656. var dimensions = this.dimensions;
  17657. var dimensionInfos = this._dimensionInfos;
  17658. for (var i = 0, len = dimensions.length; i < len; i++) {
  17659. if (
  17660. // Ordinal type can be string or number
  17661. dimensionInfos[dimensions[i]].type !== 'ordinal'
  17662. && isNaN(this.get(dimensions[i], idx))
  17663. ) {
  17664. return false;
  17665. }
  17666. }
  17667. return true;
  17668. };
  17669. /**
  17670. * Get extent of data in one dimension
  17671. * @param {string} dim
  17672. * @param {boolean} stack
  17673. */
  17674. listProto.getDataExtent = function (dim, stack) {
  17675. dim = this.getDimension(dim);
  17676. var dimData = this._storage[dim];
  17677. var dimInfo = this.getDimensionInfo(dim);
  17678. stack = (dimInfo && dimInfo.stackable) && stack;
  17679. var dimExtent = (this._extent || (this._extent = {}))[dim + (!!stack)];
  17680. var value;
  17681. if (dimExtent) {
  17682. return dimExtent;
  17683. }
  17684. // var dimInfo = this._dimensionInfos[dim];
  17685. if (dimData) {
  17686. var min = Infinity;
  17687. var max = -Infinity;
  17688. // var isOrdinal = dimInfo.type === 'ordinal';
  17689. for (var i = 0, len = this.count(); i < len; i++) {
  17690. value = this.get(dim, i, stack);
  17691. // FIXME
  17692. // if (isOrdinal && typeof value === 'string') {
  17693. // value = zrUtil.indexOf(dimData, value);
  17694. // }
  17695. value < min && (min = value);
  17696. value > max && (max = value);
  17697. }
  17698. return (this._extent[dim + !!stack] = [min, max]);
  17699. }
  17700. else {
  17701. return [Infinity, -Infinity];
  17702. }
  17703. };
  17704. /**
  17705. * Get sum of data in one dimension
  17706. * @param {string} dim
  17707. * @param {boolean} stack
  17708. */
  17709. listProto.getSum = function (dim, stack) {
  17710. var dimData = this._storage[dim];
  17711. var sum = 0;
  17712. if (dimData) {
  17713. for (var i = 0, len = this.count(); i < len; i++) {
  17714. var value = this.get(dim, i, stack);
  17715. if (!isNaN(value)) {
  17716. sum += value;
  17717. }
  17718. }
  17719. }
  17720. return sum;
  17721. };
  17722. /**
  17723. * Retreive the index with given value
  17724. * @param {number} idx
  17725. * @param {number} value
  17726. * @return {number}
  17727. */
  17728. // FIXME Precision of float value
  17729. listProto.indexOf = function (dim, value) {
  17730. var storage = this._storage;
  17731. var dimData = storage[dim];
  17732. var indices = this.indices;
  17733. if (dimData) {
  17734. for (var i = 0, len = indices.length; i < len; i++) {
  17735. var rawIndex = indices[i];
  17736. if (dimData[rawIndex] === value) {
  17737. return i;
  17738. }
  17739. }
  17740. }
  17741. return -1;
  17742. };
  17743. /**
  17744. * Retreive the index with given name
  17745. * @param {number} idx
  17746. * @param {number} name
  17747. * @return {number}
  17748. */
  17749. listProto.indexOfName = function (name) {
  17750. var indices = this.indices;
  17751. var nameList = this._nameList;
  17752. for (var i = 0, len = indices.length; i < len; i++) {
  17753. var rawIndex = indices[i];
  17754. if (nameList[rawIndex] === name) {
  17755. return i;
  17756. }
  17757. }
  17758. return -1;
  17759. };
  17760. /**
  17761. * Retreive the index with given raw data index
  17762. * @param {number} idx
  17763. * @param {number} name
  17764. * @return {number}
  17765. */
  17766. listProto.indexOfRawIndex = function (rawIndex) {
  17767. // Indices are ascending
  17768. var indices = this.indices;
  17769. var left = 0;
  17770. var right = indices.length - 1;
  17771. while (left <= right) {
  17772. var mid = (left + right) / 2 | 0;
  17773. if (indices[mid] < rawIndex) {
  17774. left = mid + 1;
  17775. }
  17776. else if (indices[mid] > rawIndex) {
  17777. right = mid - 1;
  17778. }
  17779. else {
  17780. return mid;
  17781. }
  17782. }
  17783. return -1;
  17784. };
  17785. /**
  17786. * Retreive the index of nearest value
  17787. * @param {string} dim
  17788. * @param {number} value
  17789. * @param {boolean} stack If given value is after stacked
  17790. * @param {number} [maxDistance=Infinity]
  17791. * @return {number}
  17792. */
  17793. listProto.indexOfNearest = function (dim, value, stack, maxDistance) {
  17794. var storage = this._storage;
  17795. var dimData = storage[dim];
  17796. if (maxDistance == null) {
  17797. maxDistance = Infinity;
  17798. }
  17799. var nearestIdx = -1;
  17800. if (dimData) {
  17801. var minDist = Number.MAX_VALUE;
  17802. for (var i = 0, len = this.count(); i < len; i++) {
  17803. var diff = value - this.get(dim, i, stack);
  17804. var dist = Math.abs(diff);
  17805. if (
  17806. diff <= maxDistance
  17807. && (dist < minDist
  17808. // For the case of two data are same on xAxis, which has sequence data.
  17809. // Show the nearest index
  17810. // https://github.com/ecomfe/echarts/issues/2869
  17811. || (dist === minDist && diff > 0)
  17812. )
  17813. ) {
  17814. minDist = dist;
  17815. nearestIdx = i;
  17816. }
  17817. }
  17818. }
  17819. return nearestIdx;
  17820. };
  17821. /**
  17822. * Get raw data index
  17823. * @param {number} idx
  17824. * @return {number}
  17825. */
  17826. listProto.getRawIndex = function (idx) {
  17827. var rawIdx = this.indices[idx];
  17828. return rawIdx == null ? -1 : rawIdx;
  17829. };
  17830. /**
  17831. * Get raw data item
  17832. * @param {number} idx
  17833. * @return {number}
  17834. */
  17835. listProto.getRawDataItem = function (idx) {
  17836. return this._rawData[this.getRawIndex(idx)];
  17837. };
  17838. /**
  17839. * @param {number} idx
  17840. * @param {boolean} [notDefaultIdx=false]
  17841. * @return {string}
  17842. */
  17843. listProto.getName = function (idx) {
  17844. return this._nameList[this.indices[idx]] || '';
  17845. };
  17846. /**
  17847. * @param {number} idx
  17848. * @param {boolean} [notDefaultIdx=false]
  17849. * @return {string}
  17850. */
  17851. listProto.getId = function (idx) {
  17852. return this._idList[this.indices[idx]] || (this.getRawIndex(idx) + '');
  17853. };
  17854. function normalizeDimensions(dimensions) {
  17855. if (!zrUtil.isArray(dimensions)) {
  17856. dimensions = [dimensions];
  17857. }
  17858. return dimensions;
  17859. }
  17860. /**
  17861. * Data iteration
  17862. * @param {string|Array.<string>}
  17863. * @param {Function} cb
  17864. * @param {boolean} [stack=false]
  17865. * @param {*} [context=this]
  17866. *
  17867. * @example
  17868. * list.each('x', function (x, idx) {});
  17869. * list.each(['x', 'y'], function (x, y, idx) {});
  17870. * list.each(function (idx) {})
  17871. */
  17872. listProto.each = function (dims, cb, stack, context) {
  17873. if (typeof dims === 'function') {
  17874. context = stack;
  17875. stack = cb;
  17876. cb = dims;
  17877. dims = [];
  17878. }
  17879. dims = zrUtil.map(normalizeDimensions(dims), this.getDimension, this);
  17880. var value = [];
  17881. var dimSize = dims.length;
  17882. var indices = this.indices;
  17883. context = context || this;
  17884. for (var i = 0; i < indices.length; i++) {
  17885. // Simple optimization
  17886. switch (dimSize) {
  17887. case 0:
  17888. cb.call(context, i);
  17889. break;
  17890. case 1:
  17891. cb.call(context, this.get(dims[0], i, stack), i);
  17892. break;
  17893. case 2:
  17894. cb.call(context, this.get(dims[0], i, stack), this.get(dims[1], i, stack), i);
  17895. break;
  17896. default:
  17897. for (var k = 0; k < dimSize; k++) {
  17898. value[k] = this.get(dims[k], i, stack);
  17899. }
  17900. // Index
  17901. value[k] = i;
  17902. cb.apply(context, value);
  17903. }
  17904. }
  17905. };
  17906. /**
  17907. * Data filter
  17908. * @param {string|Array.<string>}
  17909. * @param {Function} cb
  17910. * @param {boolean} [stack=false]
  17911. * @param {*} [context=this]
  17912. */
  17913. listProto.filterSelf = function (dimensions, cb, stack, context) {
  17914. if (typeof dimensions === 'function') {
  17915. context = stack;
  17916. stack = cb;
  17917. cb = dimensions;
  17918. dimensions = [];
  17919. }
  17920. dimensions = zrUtil.map(
  17921. normalizeDimensions(dimensions), this.getDimension, this
  17922. );
  17923. var newIndices = [];
  17924. var value = [];
  17925. var dimSize = dimensions.length;
  17926. var indices = this.indices;
  17927. context = context || this;
  17928. for (var i = 0; i < indices.length; i++) {
  17929. var keep;
  17930. // Simple optimization
  17931. if (dimSize === 1) {
  17932. keep = cb.call(
  17933. context, this.get(dimensions[0], i, stack), i
  17934. );
  17935. }
  17936. else {
  17937. for (var k = 0; k < dimSize; k++) {
  17938. value[k] = this.get(dimensions[k], i, stack);
  17939. }
  17940. value[k] = i;
  17941. keep = cb.apply(context, value);
  17942. }
  17943. if (keep) {
  17944. newIndices.push(indices[i]);
  17945. }
  17946. }
  17947. this.indices = newIndices;
  17948. // Reset data extent
  17949. this._extent = {};
  17950. return this;
  17951. };
  17952. /**
  17953. * Data mapping to a plain array
  17954. * @param {string|Array.<string>} [dimensions]
  17955. * @param {Function} cb
  17956. * @param {boolean} [stack=false]
  17957. * @param {*} [context=this]
  17958. * @return {Array}
  17959. */
  17960. listProto.mapArray = function (dimensions, cb, stack, context) {
  17961. if (typeof dimensions === 'function') {
  17962. context = stack;
  17963. stack = cb;
  17964. cb = dimensions;
  17965. dimensions = [];
  17966. }
  17967. var result = [];
  17968. this.each(dimensions, function () {
  17969. result.push(cb && cb.apply(this, arguments));
  17970. }, stack, context);
  17971. return result;
  17972. };
  17973. function cloneListForMapAndSample(original, excludeDimensions) {
  17974. var allDimensions = original.dimensions;
  17975. var list = new List(
  17976. zrUtil.map(allDimensions, original.getDimensionInfo, original),
  17977. original.hostModel
  17978. );
  17979. // FIXME If needs stackedOn, value may already been stacked
  17980. transferProperties(list, original);
  17981. var storage = list._storage = {};
  17982. var originalStorage = original._storage;
  17983. // Init storage
  17984. for (var i = 0; i < allDimensions.length; i++) {
  17985. var dim = allDimensions[i];
  17986. var dimStore = originalStorage[dim];
  17987. if (zrUtil.indexOf(excludeDimensions, dim) >= 0) {
  17988. storage[dim] = new dimStore.constructor(
  17989. originalStorage[dim].length
  17990. );
  17991. }
  17992. else {
  17993. // Direct reference for other dimensions
  17994. storage[dim] = originalStorage[dim];
  17995. }
  17996. }
  17997. return list;
  17998. }
  17999. /**
  18000. * Data mapping to a new List with given dimensions
  18001. * @param {string|Array.<string>} dimensions
  18002. * @param {Function} cb
  18003. * @param {boolean} [stack=false]
  18004. * @param {*} [context=this]
  18005. * @return {Array}
  18006. */
  18007. listProto.map = function (dimensions, cb, stack, context) {
  18008. dimensions = zrUtil.map(
  18009. normalizeDimensions(dimensions), this.getDimension, this
  18010. );
  18011. var list = cloneListForMapAndSample(this, dimensions);
  18012. // Following properties are all immutable.
  18013. // So we can reference to the same value
  18014. var indices = list.indices = this.indices;
  18015. var storage = list._storage;
  18016. var tmpRetValue = [];
  18017. this.each(dimensions, function () {
  18018. var idx = arguments[arguments.length - 1];
  18019. var retValue = cb && cb.apply(this, arguments);
  18020. if (retValue != null) {
  18021. // a number
  18022. if (typeof retValue === 'number') {
  18023. tmpRetValue[0] = retValue;
  18024. retValue = tmpRetValue;
  18025. }
  18026. for (var i = 0; i < retValue.length; i++) {
  18027. var dim = dimensions[i];
  18028. var dimStore = storage[dim];
  18029. var rawIdx = indices[idx];
  18030. if (dimStore) {
  18031. dimStore[rawIdx] = retValue[i];
  18032. }
  18033. }
  18034. }
  18035. }, stack, context);
  18036. return list;
  18037. };
  18038. /**
  18039. * Large data down sampling on given dimension
  18040. * @param {string} dimension
  18041. * @param {number} rate
  18042. * @param {Function} sampleValue
  18043. * @param {Function} sampleIndex Sample index for name and id
  18044. */
  18045. listProto.downSample = function (dimension, rate, sampleValue, sampleIndex) {
  18046. var list = cloneListForMapAndSample(this, [dimension]);
  18047. var storage = this._storage;
  18048. var targetStorage = list._storage;
  18049. var originalIndices = this.indices;
  18050. var indices = list.indices = [];
  18051. var frameValues = [];
  18052. var frameIndices = [];
  18053. var frameSize = Math.floor(1 / rate);
  18054. var dimStore = targetStorage[dimension];
  18055. var len = this.count();
  18056. // Copy data from original data
  18057. for (var i = 0; i < storage[dimension].length; i++) {
  18058. targetStorage[dimension][i] = storage[dimension][i];
  18059. }
  18060. for (var i = 0; i < len; i += frameSize) {
  18061. // Last frame
  18062. if (frameSize > len - i) {
  18063. frameSize = len - i;
  18064. frameValues.length = frameSize;
  18065. }
  18066. for (var k = 0; k < frameSize; k++) {
  18067. var idx = originalIndices[i + k];
  18068. frameValues[k] = dimStore[idx];
  18069. frameIndices[k] = idx;
  18070. }
  18071. var value = sampleValue(frameValues);
  18072. var idx = frameIndices[sampleIndex(frameValues, value) || 0];
  18073. // Only write value on the filtered data
  18074. dimStore[idx] = value;
  18075. indices.push(idx);
  18076. }
  18077. return list;
  18078. };
  18079. /**
  18080. * Get model of one data item.
  18081. *
  18082. * @param {number} idx
  18083. */
  18084. // FIXME Model proxy ?
  18085. listProto.getItemModel = function (idx) {
  18086. var hostModel = this.hostModel;
  18087. idx = this.indices[idx];
  18088. return new Model(this._rawData[idx], hostModel, hostModel && hostModel.ecModel);
  18089. };
  18090. /**
  18091. * Create a data differ
  18092. * @param {module:echarts/data/List} otherList
  18093. * @return {module:echarts/data/DataDiffer}
  18094. */
  18095. listProto.diff = function (otherList) {
  18096. var idList = this._idList;
  18097. var otherIdList = otherList && otherList._idList;
  18098. return new DataDiffer(
  18099. otherList ? otherList.indices : [], this.indices, function (idx) {
  18100. return otherIdList[idx] || (idx + '');
  18101. }, function (idx) {
  18102. return idList[idx] || (idx + '');
  18103. }
  18104. );
  18105. };
  18106. /**
  18107. * Get visual property.
  18108. * @param {string} key
  18109. */
  18110. listProto.getVisual = function (key) {
  18111. var visual = this._visual;
  18112. return visual && visual[key];
  18113. };
  18114. /**
  18115. * Set visual property
  18116. * @param {string|Object} key
  18117. * @param {*} [value]
  18118. *
  18119. * @example
  18120. * setVisual('color', color);
  18121. * setVisual({
  18122. * 'color': color
  18123. * });
  18124. */
  18125. listProto.setVisual = function (key, val) {
  18126. if (isObject(key)) {
  18127. for (var name in key) {
  18128. if (key.hasOwnProperty(name)) {
  18129. this.setVisual(name, key[name]);
  18130. }
  18131. }
  18132. return;
  18133. }
  18134. this._visual = this._visual || {};
  18135. this._visual[key] = val;
  18136. };
  18137. /**
  18138. * Set layout property.
  18139. * @param {string} key
  18140. * @param {*} [val]
  18141. */
  18142. listProto.setLayout = function (key, val) {
  18143. if (isObject(key)) {
  18144. for (var name in key) {
  18145. if (key.hasOwnProperty(name)) {
  18146. this.setLayout(name, key[name]);
  18147. }
  18148. }
  18149. return;
  18150. }
  18151. this._layout[key] = val;
  18152. };
  18153. /**
  18154. * Get layout property.
  18155. * @param {string} key.
  18156. * @return {*}
  18157. */
  18158. listProto.getLayout = function (key) {
  18159. return this._layout[key];
  18160. };
  18161. /**
  18162. * Get layout of single data item
  18163. * @param {number} idx
  18164. */
  18165. listProto.getItemLayout = function (idx) {
  18166. return this._itemLayouts[idx];
  18167. };
  18168. /**
  18169. * Set layout of single data item
  18170. * @param {number} idx
  18171. * @param {Object} layout
  18172. * @param {boolean=} [merge=false]
  18173. */
  18174. listProto.setItemLayout = function (idx, layout, merge) {
  18175. this._itemLayouts[idx] = merge
  18176. ? zrUtil.extend(this._itemLayouts[idx] || {}, layout)
  18177. : layout;
  18178. };
  18179. /**
  18180. * Clear all layout of single data item
  18181. */
  18182. listProto.clearItemLayouts = function () {
  18183. this._itemLayouts.length = 0;
  18184. };
  18185. /**
  18186. * Get visual property of single data item
  18187. * @param {number} idx
  18188. * @param {string} key
  18189. * @param {boolean} ignoreParent
  18190. */
  18191. listProto.getItemVisual = function (idx, key, ignoreParent) {
  18192. var itemVisual = this._itemVisuals[idx];
  18193. var val = itemVisual && itemVisual[key];
  18194. if (val == null && !ignoreParent) {
  18195. // Use global visual property
  18196. return this.getVisual(key);
  18197. }
  18198. return val;
  18199. };
  18200. /**
  18201. * Set visual property of single data item
  18202. *
  18203. * @param {number} idx
  18204. * @param {string|Object} key
  18205. * @param {*} [value]
  18206. *
  18207. * @example
  18208. * setItemVisual(0, 'color', color);
  18209. * setItemVisual(0, {
  18210. * 'color': color
  18211. * });
  18212. */
  18213. listProto.setItemVisual = function (idx, key, value) {
  18214. var itemVisual = this._itemVisuals[idx] || {};
  18215. this._itemVisuals[idx] = itemVisual;
  18216. if (isObject(key)) {
  18217. for (var name in key) {
  18218. if (key.hasOwnProperty(name)) {
  18219. itemVisual[name] = key[name];
  18220. }
  18221. }
  18222. return;
  18223. }
  18224. itemVisual[key] = value;
  18225. };
  18226. /**
  18227. * Clear itemVisuals and list visual.
  18228. */
  18229. listProto.clearAllVisual = function () {
  18230. this._visual = {};
  18231. this._itemVisuals = [];
  18232. };
  18233. var setItemDataAndSeriesIndex = function (child) {
  18234. child.seriesIndex = this.seriesIndex;
  18235. child.dataIndex = this.dataIndex;
  18236. child.dataType = this.dataType;
  18237. };
  18238. /**
  18239. * Set graphic element relative to data. It can be set as null
  18240. * @param {number} idx
  18241. * @param {module:zrender/Element} [el]
  18242. */
  18243. listProto.setItemGraphicEl = function (idx, el) {
  18244. var hostModel = this.hostModel;
  18245. if (el) {
  18246. // Add data index and series index for indexing the data by element
  18247. // Useful in tooltip
  18248. el.dataIndex = idx;
  18249. el.dataType = this.dataType;
  18250. el.seriesIndex = hostModel && hostModel.seriesIndex;
  18251. if (el.type === 'group') {
  18252. el.traverse(setItemDataAndSeriesIndex, el);
  18253. }
  18254. }
  18255. this._graphicEls[idx] = el;
  18256. };
  18257. /**
  18258. * @param {number} idx
  18259. * @return {module:zrender/Element}
  18260. */
  18261. listProto.getItemGraphicEl = function (idx) {
  18262. return this._graphicEls[idx];
  18263. };
  18264. /**
  18265. * @param {Function} cb
  18266. * @param {*} context
  18267. */
  18268. listProto.eachItemGraphicEl = function (cb, context) {
  18269. zrUtil.each(this._graphicEls, function (el, idx) {
  18270. if (el) {
  18271. cb && cb.call(context, el, idx);
  18272. }
  18273. });
  18274. };
  18275. /**
  18276. * Shallow clone a new list except visual and layout properties, and graph elements.
  18277. * New list only change the indices.
  18278. */
  18279. listProto.cloneShallow = function () {
  18280. var dimensionInfoList = zrUtil.map(this.dimensions, this.getDimensionInfo, this);
  18281. var list = new List(dimensionInfoList, this.hostModel);
  18282. // FIXME
  18283. list._storage = this._storage;
  18284. transferProperties(list, this);
  18285. // Clone will not change the data extent and indices
  18286. list.indices = this.indices.slice();
  18287. if (this._extent) {
  18288. list._extent = zrUtil.extend({}, this._extent);
  18289. }
  18290. return list;
  18291. };
  18292. /**
  18293. * Wrap some method to add more feature
  18294. * @param {string} methodName
  18295. * @param {Function} injectFunction
  18296. */
  18297. listProto.wrapMethod = function (methodName, injectFunction) {
  18298. var originalMethod = this[methodName];
  18299. if (typeof originalMethod !== 'function') {
  18300. return;
  18301. }
  18302. this.__wrappedMethods = this.__wrappedMethods || [];
  18303. this.__wrappedMethods.push(methodName);
  18304. this[methodName] = function () {
  18305. var res = originalMethod.apply(this, arguments);
  18306. return injectFunction.apply(this, [res].concat(zrUtil.slice(arguments)));
  18307. };
  18308. };
  18309. // Methods that create a new list based on this list should be listed here.
  18310. // Notice that those method should `RETURN` the new list.
  18311. listProto.TRANSFERABLE_METHODS = ['cloneShallow', 'downSample', 'map'];
  18312. // Methods that change indices of this list should be listed here.
  18313. listProto.CHANGABLE_METHODS = ['filterSelf'];
  18314. module.exports = List;
  18315. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
  18316. /***/ },
  18317. /* 98 */
  18318. /***/ function(module, exports) {
  18319. 'use strict';
  18320. function defaultKeyGetter(item) {
  18321. return item;
  18322. }
  18323. function DataDiffer(oldArr, newArr, oldKeyGetter, newKeyGetter) {
  18324. this._old = oldArr;
  18325. this._new = newArr;
  18326. this._oldKeyGetter = oldKeyGetter || defaultKeyGetter;
  18327. this._newKeyGetter = newKeyGetter || defaultKeyGetter;
  18328. }
  18329. DataDiffer.prototype = {
  18330. constructor: DataDiffer,
  18331. /**
  18332. * Callback function when add a data
  18333. */
  18334. add: function (func) {
  18335. this._add = func;
  18336. return this;
  18337. },
  18338. /**
  18339. * Callback function when update a data
  18340. */
  18341. update: function (func) {
  18342. this._update = func;
  18343. return this;
  18344. },
  18345. /**
  18346. * Callback function when remove a data
  18347. */
  18348. remove: function (func) {
  18349. this._remove = func;
  18350. return this;
  18351. },
  18352. execute: function () {
  18353. var oldArr = this._old;
  18354. var newArr = this._new;
  18355. var oldKeyGetter = this._oldKeyGetter;
  18356. var newKeyGetter = this._newKeyGetter;
  18357. var oldDataIndexMap = {};
  18358. var newDataIndexMap = {};
  18359. var oldDataKeyArr = [];
  18360. var newDataKeyArr = [];
  18361. var i;
  18362. initIndexMap(oldArr, oldDataIndexMap, oldDataKeyArr, oldKeyGetter);
  18363. initIndexMap(newArr, newDataIndexMap, newDataKeyArr, newKeyGetter);
  18364. // Travel by inverted order to make sure order consistency
  18365. // when duplicate keys exists (consider newDataIndex.pop() below).
  18366. // For performance consideration, these code below do not look neat.
  18367. for (i = 0; i < oldArr.length; i++) {
  18368. var key = oldDataKeyArr[i];
  18369. var idx = newDataIndexMap[key];
  18370. // idx can never be empty array here. see 'set null' logic below.
  18371. if (idx != null) {
  18372. // Consider there is duplicate key (for example, use dataItem.name as key).
  18373. // We should make sure every item in newArr and oldArr can be visited.
  18374. var len = idx.length;
  18375. if (len) {
  18376. len === 1 && (newDataIndexMap[key] = null);
  18377. idx = idx.unshift();
  18378. }
  18379. else {
  18380. newDataIndexMap[key] = null;
  18381. }
  18382. this._update && this._update(idx, i);
  18383. }
  18384. else {
  18385. this._remove && this._remove(i);
  18386. }
  18387. }
  18388. for (var i = 0; i < newDataKeyArr.length; i++) {
  18389. var key = newDataKeyArr[i];
  18390. if (newDataIndexMap.hasOwnProperty(key)) {
  18391. var idx = newDataIndexMap[key];
  18392. if (idx == null) {
  18393. continue;
  18394. }
  18395. // idx can never be empty array here. see 'set null' logic above.
  18396. if (!idx.length) {
  18397. this._add && this._add(idx);
  18398. }
  18399. else {
  18400. for (var j = 0, len = idx.length; j < len; j++) {
  18401. this._add && this._add(idx[j]);
  18402. }
  18403. }
  18404. }
  18405. }
  18406. }
  18407. };
  18408. function initIndexMap(arr, map, keyArr, keyGetter) {
  18409. for (var i = 0; i < arr.length; i++) {
  18410. var key = keyGetter(arr[i], i);
  18411. var existence = map[key];
  18412. if (existence == null) {
  18413. keyArr.push(key);
  18414. map[key] = i;
  18415. }
  18416. else {
  18417. if (!existence.length) {
  18418. map[key] = existence = [existence];
  18419. }
  18420. existence.push(i);
  18421. }
  18422. }
  18423. }
  18424. module.exports = DataDiffer;
  18425. /***/ },
  18426. /* 99 */
  18427. /***/ function(module, exports, __webpack_require__) {
  18428. var zrUtil = __webpack_require__(4);
  18429. var echarts = __webpack_require__(1);
  18430. var PRIORITY = echarts.PRIORITY;
  18431. __webpack_require__(100);
  18432. __webpack_require__(103);
  18433. echarts.registerVisual(zrUtil.curry(
  18434. __webpack_require__(109), 'line', 'circle', 'line'
  18435. ));
  18436. echarts.registerLayout(zrUtil.curry(
  18437. __webpack_require__(110), 'line'
  18438. ));
  18439. // Down sample after filter
  18440. echarts.registerProcessor(PRIORITY.PROCESSOR.STATISTIC, zrUtil.curry(
  18441. __webpack_require__(111), 'line'
  18442. ));
  18443. // In case developer forget to include grid component
  18444. __webpack_require__(112);
  18445. /***/ },
  18446. /* 100 */
  18447. /***/ function(module, exports, __webpack_require__) {
  18448. 'use strict';
  18449. var createListFromArray = __webpack_require__(101);
  18450. var SeriesModel = __webpack_require__(28);
  18451. module.exports = SeriesModel.extend({
  18452. type: 'series.line',
  18453. dependencies: ['grid', 'polar'],
  18454. getInitialData: function (option, ecModel) {
  18455. if (true) {
  18456. var coordSys = option.coordinateSystem;
  18457. if (coordSys !== 'polar' && coordSys !== 'cartesian2d') {
  18458. throw new Error('Line not support coordinateSystem besides cartesian and polar');
  18459. }
  18460. }
  18461. return createListFromArray(option.data, this, ecModel);
  18462. },
  18463. defaultOption: {
  18464. zlevel: 0, // 一级层叠
  18465. z: 2, // 二级层叠
  18466. coordinateSystem: 'cartesian2d',
  18467. legendHoverLink: true,
  18468. hoverAnimation: true,
  18469. // stack: null
  18470. xAxisIndex: 0,
  18471. yAxisIndex: 0,
  18472. polarIndex: 0,
  18473. // If clip the overflow value
  18474. clipOverflow: true,
  18475. label: {
  18476. normal: {
  18477. position: 'top'
  18478. }
  18479. },
  18480. // itemStyle: {
  18481. // normal: {},
  18482. // emphasis: {}
  18483. // },
  18484. lineStyle: {
  18485. normal: {
  18486. width: 2,
  18487. type: 'solid'
  18488. }
  18489. },
  18490. // areaStyle: {},
  18491. // false, 'start', 'end', 'middle'
  18492. step: false,
  18493. // Disabled if step is true
  18494. smooth: false,
  18495. smoothMonotone: null,
  18496. // 拐点图形类型
  18497. symbol: 'emptyCircle',
  18498. // 拐点图形大小
  18499. symbolSize: 4,
  18500. // 拐点图形旋转控制
  18501. symbolRotate: null,
  18502. // 是否显示 symbol, 只有在 tooltip hover 的时候显示
  18503. showSymbol: true,
  18504. // 标志图形默认只有主轴显示(随主轴标签间隔隐藏策略)
  18505. showAllSymbol: false,
  18506. // 是否连接断点
  18507. connectNulls: false,
  18508. // 数据过滤,'average', 'max', 'min', 'sum'
  18509. sampling: 'none',
  18510. animationEasing: 'linear',
  18511. // Disable progressive
  18512. progressive: 0,
  18513. hoverLayerThreshold: Infinity
  18514. }
  18515. });
  18516. /***/ },
  18517. /* 101 */
  18518. /***/ function(module, exports, __webpack_require__) {
  18519. 'use strict';
  18520. var List = __webpack_require__(97);
  18521. var completeDimensions = __webpack_require__(102);
  18522. var zrUtil = __webpack_require__(4);
  18523. var modelUtil = __webpack_require__(5);
  18524. var CoordinateSystem = __webpack_require__(26);
  18525. var getDataItemValue = modelUtil.getDataItemValue;
  18526. var converDataValue = modelUtil.converDataValue;
  18527. function firstDataNotNull(data) {
  18528. var i = 0;
  18529. while (i < data.length && data[i] == null) {
  18530. i++;
  18531. }
  18532. return data[i];
  18533. }
  18534. function ifNeedCompleteOrdinalData(data) {
  18535. var sampleItem = firstDataNotNull(data);
  18536. return sampleItem != null
  18537. && !zrUtil.isArray(getDataItemValue(sampleItem));
  18538. }
  18539. /**
  18540. * Helper function to create a list from option data
  18541. */
  18542. function createListFromArray(data, seriesModel, ecModel) {
  18543. // If data is undefined
  18544. data = data || [];
  18545. if (true) {
  18546. if (!zrUtil.isArray(data)) {
  18547. throw new Error('Invalid data.');
  18548. }
  18549. }
  18550. var coordSysName = seriesModel.get('coordinateSystem');
  18551. var creator = creators[coordSysName];
  18552. var registeredCoordSys = CoordinateSystem.get(coordSysName);
  18553. // FIXME
  18554. var axesInfo = creator && creator(data, seriesModel, ecModel);
  18555. var dimensions = axesInfo && axesInfo.dimensions;
  18556. if (!dimensions) {
  18557. // Get dimensions from registered coordinate system
  18558. dimensions = (registeredCoordSys && registeredCoordSys.dimensions) || ['x', 'y'];
  18559. dimensions = completeDimensions(dimensions, data, dimensions.concat(['value']));
  18560. }
  18561. var categoryIndex = axesInfo ? axesInfo.categoryIndex : -1;
  18562. var list = new List(dimensions, seriesModel);
  18563. var nameList = createNameList(axesInfo, data);
  18564. var categories = {};
  18565. var dimValueGetter = (categoryIndex >= 0 && ifNeedCompleteOrdinalData(data))
  18566. ? function (itemOpt, dimName, dataIndex, dimIndex) {
  18567. // If any dataItem is like { value: 10 }
  18568. if (modelUtil.isDataItemOption(itemOpt)) {
  18569. list.hasItemOption = true;
  18570. }
  18571. // Use dataIndex as ordinal value in categoryAxis
  18572. return dimIndex === categoryIndex
  18573. ? dataIndex
  18574. : converDataValue(getDataItemValue(itemOpt), dimensions[dimIndex]);
  18575. }
  18576. : function (itemOpt, dimName, dataIndex, dimIndex) {
  18577. var value = getDataItemValue(itemOpt);
  18578. var val = converDataValue(value && value[dimIndex], dimensions[dimIndex]);
  18579. // If any dataItem is like { value: 10 }
  18580. if (modelUtil.isDataItemOption(itemOpt)) {
  18581. list.hasItemOption = true;
  18582. }
  18583. var categoryAxesModels = axesInfo && axesInfo.categoryAxesModels;
  18584. if (categoryAxesModels && categoryAxesModels[dimName]) {
  18585. // If given value is a category string
  18586. if (typeof val === 'string') {
  18587. // Lazy get categories
  18588. categories[dimName] = categories[dimName]
  18589. || categoryAxesModels[dimName].getCategories();
  18590. val = zrUtil.indexOf(categories[dimName], val);
  18591. if (val < 0 && !isNaN(val)) {
  18592. // In case some one write '1', '2' istead of 1, 2
  18593. val = +val;
  18594. }
  18595. }
  18596. }
  18597. return val;
  18598. };
  18599. list.hasItemOption = false;
  18600. list.initData(data, nameList, dimValueGetter);
  18601. return list;
  18602. }
  18603. function isStackable(axisType) {
  18604. return axisType !== 'category' && axisType !== 'time';
  18605. }
  18606. function getDimTypeByAxis(axisType) {
  18607. return axisType === 'category'
  18608. ? 'ordinal'
  18609. : axisType === 'time'
  18610. ? 'time'
  18611. : 'float';
  18612. }
  18613. /**
  18614. * Creaters for each coord system.
  18615. */
  18616. var creators = {
  18617. cartesian2d: function (data, seriesModel, ecModel) {
  18618. var xAxisModel = ecModel.getComponent('xAxis', seriesModel.get('xAxisIndex'));
  18619. var yAxisModel = ecModel.getComponent('yAxis', seriesModel.get('yAxisIndex'));
  18620. if (true) {
  18621. if (!xAxisModel) {
  18622. throw new Error('xAxis "' + seriesModel.get('xAxisIndex') + '" not found');
  18623. }
  18624. if (!yAxisModel) {
  18625. throw new Error('yAxis "' + seriesModel.get('yAxisIndex') + '" not found');
  18626. }
  18627. }
  18628. var xAxisType = xAxisModel.get('type');
  18629. var yAxisType = yAxisModel.get('type');
  18630. var dimensions = [
  18631. {
  18632. name: 'x',
  18633. type: getDimTypeByAxis(xAxisType),
  18634. stackable: isStackable(xAxisType)
  18635. },
  18636. {
  18637. name: 'y',
  18638. // If two category axes
  18639. type: getDimTypeByAxis(yAxisType),
  18640. stackable: isStackable(yAxisType)
  18641. }
  18642. ];
  18643. var isXAxisCateogry = xAxisType === 'category';
  18644. var isYAxisCategory = yAxisType === 'category';
  18645. completeDimensions(dimensions, data, ['x', 'y', 'z']);
  18646. var categoryAxesModels = {};
  18647. if (isXAxisCateogry) {
  18648. categoryAxesModels.x = xAxisModel;
  18649. }
  18650. if (isYAxisCategory) {
  18651. categoryAxesModels.y = yAxisModel;
  18652. }
  18653. return {
  18654. dimensions: dimensions,
  18655. categoryIndex: isXAxisCateogry ? 0 : (isYAxisCategory ? 1 : -1),
  18656. categoryAxesModels: categoryAxesModels
  18657. };
  18658. },
  18659. polar: function (data, seriesModel, ecModel) {
  18660. var polarIndex = seriesModel.get('polarIndex') || 0;
  18661. var axisFinder = function (axisModel) {
  18662. return axisModel.get('polarIndex') === polarIndex;
  18663. };
  18664. var angleAxisModel = ecModel.findComponents({
  18665. mainType: 'angleAxis', filter: axisFinder
  18666. })[0];
  18667. var radiusAxisModel = ecModel.findComponents({
  18668. mainType: 'radiusAxis', filter: axisFinder
  18669. })[0];
  18670. if (true) {
  18671. if (!angleAxisModel) {
  18672. throw new Error('angleAxis option not found');
  18673. }
  18674. if (!radiusAxisModel) {
  18675. throw new Error('radiusAxis option not found');
  18676. }
  18677. }
  18678. var radiusAxisType = radiusAxisModel.get('type');
  18679. var angleAxisType = angleAxisModel.get('type');
  18680. var dimensions = [
  18681. {
  18682. name: 'radius',
  18683. type: getDimTypeByAxis(radiusAxisType),
  18684. stackable: isStackable(radiusAxisType)
  18685. },
  18686. {
  18687. name: 'angle',
  18688. type: getDimTypeByAxis(angleAxisType),
  18689. stackable: isStackable(angleAxisType)
  18690. }
  18691. ];
  18692. var isAngleAxisCateogry = angleAxisType === 'category';
  18693. var isRadiusAxisCateogry = radiusAxisType === 'category';
  18694. completeDimensions(dimensions, data, ['radius', 'angle', 'value']);
  18695. var categoryAxesModels = {};
  18696. if (isRadiusAxisCateogry) {
  18697. categoryAxesModels.radius = radiusAxisModel;
  18698. }
  18699. if (isAngleAxisCateogry) {
  18700. categoryAxesModels.angle = angleAxisModel;
  18701. }
  18702. return {
  18703. dimensions: dimensions,
  18704. categoryIndex: isAngleAxisCateogry ? 1 : (isRadiusAxisCateogry ? 0 : -1),
  18705. categoryAxesModels: categoryAxesModels
  18706. };
  18707. },
  18708. geo: function (data, seriesModel, ecModel) {
  18709. // TODO Region
  18710. // 多个散点图系列在同一个地区的时候
  18711. return {
  18712. dimensions: completeDimensions([
  18713. {name: 'lng'},
  18714. {name: 'lat'}
  18715. ], data, ['lng', 'lat', 'value'])
  18716. };
  18717. }
  18718. };
  18719. function createNameList(result, data) {
  18720. var nameList = [];
  18721. var categoryDim = result && result.dimensions[result.categoryIndex];
  18722. var categoryAxisModel;
  18723. if (categoryDim) {
  18724. categoryAxisModel = result.categoryAxesModels[categoryDim.name];
  18725. }
  18726. if (categoryAxisModel) {
  18727. // FIXME Two category axis
  18728. var categories = categoryAxisModel.getCategories();
  18729. if (categories) {
  18730. var dataLen = data.length;
  18731. // Ordered data is given explicitly like
  18732. // [[3, 0.2], [1, 0.3], [2, 0.15]]
  18733. // or given scatter data,
  18734. // pick the category
  18735. if (zrUtil.isArray(data[0]) && data[0].length > 1) {
  18736. nameList = [];
  18737. for (var i = 0; i < dataLen; i++) {
  18738. nameList[i] = categories[data[i][result.categoryIndex || 0]];
  18739. }
  18740. }
  18741. else {
  18742. nameList = categories.slice(0);
  18743. }
  18744. }
  18745. }
  18746. return nameList;
  18747. }
  18748. module.exports = createListFromArray;
  18749. /***/ },
  18750. /* 102 */
  18751. /***/ function(module, exports, __webpack_require__) {
  18752. /**
  18753. * Complete dimensions by data (guess dimension).
  18754. */
  18755. var zrUtil = __webpack_require__(4);
  18756. /**
  18757. * Complete the dimensions array guessed from the data structure.
  18758. * @param {Array.<string>} dimensions Necessary dimensions, like ['x', 'y']
  18759. * @param {Array} data Data list. [[1, 2, 3], [2, 3, 4]]
  18760. * @param {Array.<string>} defaultNames Default names to fill not necessary dimensions, like ['value']
  18761. * @param {string} extraPrefix Prefix of name when filling the left dimensions.
  18762. * @return {Array.<string>}
  18763. */
  18764. function completeDimensions(dimensions, data, defaultNames, extraPrefix) {
  18765. if (!data) {
  18766. return dimensions;
  18767. }
  18768. var value0 = retrieveValue(data[0]);
  18769. var dimSize = zrUtil.isArray(value0) && value0.length || 1;
  18770. defaultNames = defaultNames || [];
  18771. extraPrefix = extraPrefix || 'extra';
  18772. for (var i = 0; i < dimSize; i++) {
  18773. if (!dimensions[i]) {
  18774. var name = defaultNames[i] || (extraPrefix + (i - defaultNames.length));
  18775. dimensions[i] = guessOrdinal(data, i)
  18776. ? {type: 'ordinal', name: name}
  18777. : name;
  18778. }
  18779. }
  18780. return dimensions;
  18781. }
  18782. // The rule should not be complex, otherwise user might not
  18783. // be able to known where the data is wrong.
  18784. var guessOrdinal = completeDimensions.guessOrdinal = function (data, dimIndex) {
  18785. for (var i = 0, len = data.length; i < len; i++) {
  18786. var value = retrieveValue(data[i]);
  18787. if (!zrUtil.isArray(value)) {
  18788. return false;
  18789. }
  18790. var value = value[dimIndex];
  18791. if (value != null && isFinite(value)) {
  18792. return false;
  18793. }
  18794. else if (zrUtil.isString(value) && value !== '-') {
  18795. return true;
  18796. }
  18797. }
  18798. return false;
  18799. };
  18800. function retrieveValue(o) {
  18801. return zrUtil.isArray(o) ? o : zrUtil.isObject(o) ? o.value: o;
  18802. }
  18803. module.exports = completeDimensions;
  18804. /***/ },
  18805. /* 103 */
  18806. /***/ function(module, exports, __webpack_require__) {
  18807. 'use strict';
  18808. // FIXME step not support polar
  18809. var zrUtil = __webpack_require__(4);
  18810. var SymbolDraw = __webpack_require__(104);
  18811. var Symbol = __webpack_require__(105);
  18812. var lineAnimationDiff = __webpack_require__(107);
  18813. var graphic = __webpack_require__(43);
  18814. var polyHelper = __webpack_require__(108);
  18815. var ChartView = __webpack_require__(42);
  18816. function isPointsSame(points1, points2) {
  18817. if (points1.length !== points2.length) {
  18818. return;
  18819. }
  18820. for (var i = 0; i < points1.length; i++) {
  18821. var p1 = points1[i];
  18822. var p2 = points2[i];
  18823. if (p1[0] !== p2[0] || p1[1] !== p2[1]) {
  18824. return;
  18825. }
  18826. }
  18827. return true;
  18828. }
  18829. function getSmooth(smooth) {
  18830. return typeof (smooth) === 'number' ? smooth : (smooth ? 0.3 : 0);
  18831. }
  18832. function getAxisExtentWithGap(axis) {
  18833. var extent = axis.getGlobalExtent();
  18834. if (axis.onBand) {
  18835. // Remove extra 1px to avoid line miter in clipped edge
  18836. var halfBandWidth = axis.getBandWidth() / 2 - 1;
  18837. var dir = extent[1] > extent[0] ? 1 : -1;
  18838. extent[0] += dir * halfBandWidth;
  18839. extent[1] -= dir * halfBandWidth;
  18840. }
  18841. return extent;
  18842. }
  18843. function sign(val) {
  18844. return val >= 0 ? 1 : -1;
  18845. }
  18846. /**
  18847. * @param {module:echarts/coord/cartesian/Cartesian2D|module:echarts/coord/polar/Polar} coordSys
  18848. * @param {module:echarts/data/List} data
  18849. * @param {Array.<Array.<number>>} points
  18850. * @private
  18851. */
  18852. function getStackedOnPoints(coordSys, data) {
  18853. var baseAxis = coordSys.getBaseAxis();
  18854. var valueAxis = coordSys.getOtherAxis(baseAxis);
  18855. var valueStart = baseAxis.onZero
  18856. ? 0 : valueAxis.scale.getExtent()[0];
  18857. var valueDim = valueAxis.dim;
  18858. var baseDataOffset = valueDim === 'x' || valueDim === 'radius' ? 1 : 0;
  18859. return data.mapArray([valueDim], function (val, idx) {
  18860. var stackedOnSameSign;
  18861. var stackedOn = data.stackedOn;
  18862. // Find first stacked value with same sign
  18863. while (stackedOn &&
  18864. sign(stackedOn.get(valueDim, idx)) === sign(val)
  18865. ) {
  18866. stackedOnSameSign = stackedOn;
  18867. break;
  18868. }
  18869. var stackedData = [];
  18870. stackedData[baseDataOffset] = data.get(baseAxis.dim, idx);
  18871. stackedData[1 - baseDataOffset] = stackedOnSameSign
  18872. ? stackedOnSameSign.get(valueDim, idx, true) : valueStart;
  18873. return coordSys.dataToPoint(stackedData);
  18874. }, true);
  18875. }
  18876. function queryDataIndex(data, payload) {
  18877. if (payload.dataIndex != null) {
  18878. return payload.dataIndex;
  18879. }
  18880. else if (payload.name != null) {
  18881. return data.indexOfName(payload.name);
  18882. }
  18883. }
  18884. function createGridClipShape(cartesian, hasAnimation, seriesModel) {
  18885. var xExtent = getAxisExtentWithGap(cartesian.getAxis('x'));
  18886. var yExtent = getAxisExtentWithGap(cartesian.getAxis('y'));
  18887. var isHorizontal = cartesian.getBaseAxis().isHorizontal();
  18888. var x = Math.min(xExtent[0], xExtent[1]);
  18889. var y = Math.min(yExtent[0], yExtent[1]);
  18890. var width = Math.max(xExtent[0], xExtent[1]) - x;
  18891. var height = Math.max(yExtent[0], yExtent[1]) - y;
  18892. var lineWidth = seriesModel.get('lineStyle.normal.width') || 2;
  18893. // Expand clip shape to avoid clipping when line value exceeds axis
  18894. var expandSize = seriesModel.get('clipOverflow') ? lineWidth / 2 : Math.max(width, height);
  18895. if (isHorizontal) {
  18896. y -= expandSize;
  18897. height += expandSize * 2;
  18898. }
  18899. else {
  18900. x -= expandSize;
  18901. width += expandSize * 2;
  18902. }
  18903. var clipPath = new graphic.Rect({
  18904. shape: {
  18905. x: x,
  18906. y: y,
  18907. width: width,
  18908. height: height
  18909. }
  18910. });
  18911. if (hasAnimation) {
  18912. clipPath.shape[isHorizontal ? 'width' : 'height'] = 0;
  18913. graphic.initProps(clipPath, {
  18914. shape: {
  18915. width: width,
  18916. height: height
  18917. }
  18918. }, seriesModel);
  18919. }
  18920. return clipPath;
  18921. }
  18922. function createPolarClipShape(polar, hasAnimation, seriesModel) {
  18923. var angleAxis = polar.getAngleAxis();
  18924. var radiusAxis = polar.getRadiusAxis();
  18925. var radiusExtent = radiusAxis.getExtent();
  18926. var angleExtent = angleAxis.getExtent();
  18927. var RADIAN = Math.PI / 180;
  18928. var clipPath = new graphic.Sector({
  18929. shape: {
  18930. cx: polar.cx,
  18931. cy: polar.cy,
  18932. r0: radiusExtent[0],
  18933. r: radiusExtent[1],
  18934. startAngle: -angleExtent[0] * RADIAN,
  18935. endAngle: -angleExtent[1] * RADIAN,
  18936. clockwise: angleAxis.inverse
  18937. }
  18938. });
  18939. if (hasAnimation) {
  18940. clipPath.shape.endAngle = -angleExtent[0] * RADIAN;
  18941. graphic.initProps(clipPath, {
  18942. shape: {
  18943. endAngle: -angleExtent[1] * RADIAN
  18944. }
  18945. }, seriesModel);
  18946. }
  18947. return clipPath;
  18948. }
  18949. function createClipShape(coordSys, hasAnimation, seriesModel) {
  18950. return coordSys.type === 'polar'
  18951. ? createPolarClipShape(coordSys, hasAnimation, seriesModel)
  18952. : createGridClipShape(coordSys, hasAnimation, seriesModel);
  18953. }
  18954. function turnPointsIntoStep(points, coordSys, stepTurnAt) {
  18955. var baseAxis = coordSys.getBaseAxis();
  18956. var baseIndex = baseAxis.dim === 'x' || baseAxis.dim === 'radius' ? 0 : 1;
  18957. var stepPoints = [];
  18958. for (var i = 0; i < points.length - 1; i++) {
  18959. var nextPt = points[i + 1];
  18960. var pt = points[i];
  18961. stepPoints.push(pt);
  18962. var stepPt = [];
  18963. switch (stepTurnAt) {
  18964. case 'end':
  18965. stepPt[baseIndex] = nextPt[baseIndex];
  18966. stepPt[1 - baseIndex] = pt[1 - baseIndex];
  18967. // default is start
  18968. stepPoints.push(stepPt);
  18969. break;
  18970. case 'middle':
  18971. // default is start
  18972. var middle = (pt[baseIndex] + nextPt[baseIndex]) / 2;
  18973. var stepPt2 = [];
  18974. stepPt[baseIndex] = stepPt2[baseIndex] = middle;
  18975. stepPt[1 - baseIndex] = pt[1 - baseIndex];
  18976. stepPt2[1 - baseIndex] = nextPt[1 - baseIndex];
  18977. stepPoints.push(stepPt);
  18978. stepPoints.push(stepPt2);
  18979. break;
  18980. default:
  18981. stepPt[baseIndex] = pt[baseIndex];
  18982. stepPt[1 - baseIndex] = nextPt[1 - baseIndex];
  18983. // default is start
  18984. stepPoints.push(stepPt);
  18985. }
  18986. }
  18987. // Last points
  18988. points[i] && stepPoints.push(points[i]);
  18989. return stepPoints;
  18990. }
  18991. function clamp(number, extent) {
  18992. return Math.max(Math.min(number, extent[1]), extent[0]);
  18993. }
  18994. function getVisualGradient(data, coordSys) {
  18995. var visualMetaList = data.getVisual('visualMeta');
  18996. if (!visualMetaList || !visualMetaList.length) {
  18997. return;
  18998. }
  18999. var visualMeta;
  19000. for (var i = visualMetaList.length - 1; i >= 0; i--) {
  19001. // Can only be x or y
  19002. if (visualMetaList[i].dimension < 2) {
  19003. visualMeta = visualMetaList[i];
  19004. break;
  19005. }
  19006. }
  19007. if (!visualMeta || coordSys.type !== 'cartesian2d') {
  19008. if (true) {
  19009. console.warn('Visual map on line style only support x or y dimension.');
  19010. }
  19011. return;
  19012. }
  19013. var dimension = visualMeta.dimension;
  19014. var dimName = data.dimensions[dimension];
  19015. var dataExtent = data.getDataExtent(dimName);
  19016. var stops = visualMeta.stops;
  19017. var colorStops = [];
  19018. if (stops[0].interval) {
  19019. stops.sort(function (a, b) {
  19020. return a.interval[0] - b.interval[0];
  19021. });
  19022. }
  19023. var firstStop = stops[0];
  19024. var lastStop = stops[stops.length - 1];
  19025. // Interval can be infinity in piecewise case
  19026. var min = firstStop.interval ? clamp(firstStop.interval[0], dataExtent) : firstStop.value;
  19027. var max = lastStop.interval ? clamp(lastStop.interval[1], dataExtent) : lastStop.value;
  19028. var stopsSpan = max - min;
  19029. // In the piecewise case data out of visual range
  19030. // ----dataMin----dataMax-----visualMin----visualMax
  19031. if (stopsSpan === 0) {
  19032. return data.getItemVisual(0, 'color');
  19033. }
  19034. for (var i = 0; i < stops.length; i++) {
  19035. // Piecewise
  19036. if (stops[i].interval) {
  19037. if (stops[i].interval[1] === stops[i].interval[0]) {
  19038. continue;
  19039. }
  19040. colorStops.push({
  19041. // Make sure offset is between 0 and 1
  19042. offset: (clamp(stops[i].interval[0], dataExtent) - min) / stopsSpan,
  19043. color: stops[i].color
  19044. }, {
  19045. offset: (clamp(stops[i].interval[1], dataExtent) - min) / stopsSpan,
  19046. color: stops[i].color
  19047. });
  19048. }
  19049. // Continous
  19050. else {
  19051. // if (i > 0 && stops[i].value === stops[i - 1].value) {
  19052. // continue;
  19053. // }
  19054. colorStops.push({
  19055. offset: (stops[i].value - min) / stopsSpan,
  19056. color: stops[i].color
  19057. });
  19058. }
  19059. }
  19060. var gradient = new graphic.LinearGradient(
  19061. 0, 0, 0, 0, colorStops, true
  19062. );
  19063. var axis = coordSys.getAxis(dimName);
  19064. var start = Math.round(axis.toGlobalCoord(axis.dataToCoord(min)));
  19065. var end = Math.round(axis.toGlobalCoord(axis.dataToCoord(max)));
  19066. // zrUtil.each(colorStops, function (colorStop) {
  19067. // // Make sure each offset has rounded px to avoid not sharp edge
  19068. // colorStop.offset = (Math.round(colorStop.offset * (end - start) + start) - start) / (end - start);
  19069. // });
  19070. gradient[dimName] = start;
  19071. gradient[dimName + '2'] = end;
  19072. return gradient;
  19073. }
  19074. module.exports = ChartView.extend({
  19075. type: 'line',
  19076. init: function () {
  19077. var lineGroup = new graphic.Group();
  19078. var symbolDraw = new SymbolDraw();
  19079. this.group.add(symbolDraw.group);
  19080. this._symbolDraw = symbolDraw;
  19081. this._lineGroup = lineGroup;
  19082. },
  19083. render: function (seriesModel, ecModel, api) {
  19084. var coordSys = seriesModel.coordinateSystem;
  19085. var group = this.group;
  19086. var data = seriesModel.getData();
  19087. var lineStyleModel = seriesModel.getModel('lineStyle.normal');
  19088. var areaStyleModel = seriesModel.getModel('areaStyle.normal');
  19089. var points = data.mapArray(data.getItemLayout, true);
  19090. var isCoordSysPolar = coordSys.type === 'polar';
  19091. var prevCoordSys = this._coordSys;
  19092. var symbolDraw = this._symbolDraw;
  19093. var polyline = this._polyline;
  19094. var polygon = this._polygon;
  19095. var lineGroup = this._lineGroup;
  19096. var hasAnimation = seriesModel.get('animation');
  19097. var isAreaChart = !areaStyleModel.isEmpty();
  19098. var stackedOnPoints = getStackedOnPoints(coordSys, data);
  19099. var showSymbol = seriesModel.get('showSymbol');
  19100. var isSymbolIgnore = showSymbol && !isCoordSysPolar && !seriesModel.get('showAllSymbol')
  19101. && this._getSymbolIgnoreFunc(data, coordSys);
  19102. // Remove temporary symbols
  19103. var oldData = this._data;
  19104. oldData && oldData.eachItemGraphicEl(function (el, idx) {
  19105. if (el.__temp) {
  19106. group.remove(el);
  19107. oldData.setItemGraphicEl(idx, null);
  19108. }
  19109. });
  19110. // Remove previous created symbols if showSymbol changed to false
  19111. if (!showSymbol) {
  19112. symbolDraw.remove();
  19113. }
  19114. group.add(lineGroup);
  19115. // FIXME step not support polar
  19116. var step = !isCoordSysPolar && seriesModel.get('step');
  19117. // Initialization animation or coordinate system changed
  19118. if (
  19119. !(polyline && prevCoordSys.type === coordSys.type && step === this._step)
  19120. ) {
  19121. showSymbol && symbolDraw.updateData(data, isSymbolIgnore);
  19122. if (step) {
  19123. // TODO If stacked series is not step
  19124. points = turnPointsIntoStep(points, coordSys, step);
  19125. stackedOnPoints = turnPointsIntoStep(stackedOnPoints, coordSys, step);
  19126. }
  19127. polyline = this._newPolyline(points, coordSys, hasAnimation);
  19128. if (isAreaChart) {
  19129. polygon = this._newPolygon(
  19130. points, stackedOnPoints,
  19131. coordSys, hasAnimation
  19132. );
  19133. }
  19134. lineGroup.setClipPath(createClipShape(coordSys, true, seriesModel));
  19135. }
  19136. else {
  19137. if (isAreaChart && !polygon) {
  19138. // If areaStyle is added
  19139. polygon = this._newPolygon(
  19140. points, stackedOnPoints,
  19141. coordSys, hasAnimation
  19142. );
  19143. }
  19144. else if (polygon && !isAreaChart) {
  19145. // If areaStyle is removed
  19146. lineGroup.remove(polygon);
  19147. polygon = this._polygon = null;
  19148. }
  19149. // Update clipPath
  19150. lineGroup.setClipPath(createClipShape(coordSys, false, seriesModel));
  19151. // Always update, or it is wrong in the case turning on legend
  19152. // because points are not changed
  19153. showSymbol && symbolDraw.updateData(data, isSymbolIgnore);
  19154. // Stop symbol animation and sync with line points
  19155. // FIXME performance?
  19156. data.eachItemGraphicEl(function (el) {
  19157. el.stopAnimation(true);
  19158. });
  19159. // In the case data zoom triggerred refreshing frequently
  19160. // Data may not change if line has a category axis. So it should animate nothing
  19161. if (!isPointsSame(this._stackedOnPoints, stackedOnPoints)
  19162. || !isPointsSame(this._points, points)
  19163. ) {
  19164. if (hasAnimation) {
  19165. this._updateAnimation(
  19166. data, stackedOnPoints, coordSys, api, step
  19167. );
  19168. }
  19169. else {
  19170. polyline.setShape({
  19171. points: points
  19172. });
  19173. polygon && polygon.setShape({
  19174. points: points,
  19175. stackedOnPoints: stackedOnPoints
  19176. });
  19177. }
  19178. }
  19179. }
  19180. var visualColor = getVisualGradient(data, coordSys) || data.getVisual('color');
  19181. polyline.useStyle(zrUtil.defaults(
  19182. // Use color in lineStyle first
  19183. lineStyleModel.getLineStyle(),
  19184. {
  19185. fill: 'none',
  19186. stroke: visualColor,
  19187. lineJoin: 'bevel'
  19188. }
  19189. ));
  19190. var smooth = seriesModel.get('smooth');
  19191. smooth = getSmooth(seriesModel.get('smooth'));
  19192. polyline.setShape({
  19193. smooth: smooth,
  19194. smoothMonotone: seriesModel.get('smoothMonotone'),
  19195. connectNulls: seriesModel.get('connectNulls')
  19196. });
  19197. if (polygon) {
  19198. var stackedOn = data.stackedOn;
  19199. var stackedOnSmooth = 0;
  19200. polygon.useStyle(zrUtil.defaults(
  19201. areaStyleModel.getAreaStyle(),
  19202. {
  19203. fill: visualColor,
  19204. opacity: 0.7,
  19205. lineJoin: 'bevel'
  19206. }
  19207. ));
  19208. if (stackedOn) {
  19209. var stackedOnSeries = stackedOn.hostModel;
  19210. stackedOnSmooth = getSmooth(stackedOnSeries.get('smooth'));
  19211. }
  19212. polygon.setShape({
  19213. smooth: smooth,
  19214. stackedOnSmooth: stackedOnSmooth,
  19215. smoothMonotone: seriesModel.get('smoothMonotone'),
  19216. connectNulls: seriesModel.get('connectNulls')
  19217. });
  19218. }
  19219. this._data = data;
  19220. // Save the coordinate system for transition animation when data changed
  19221. this._coordSys = coordSys;
  19222. this._stackedOnPoints = stackedOnPoints;
  19223. this._points = points;
  19224. this._step = step;
  19225. },
  19226. highlight: function (seriesModel, ecModel, api, payload) {
  19227. var data = seriesModel.getData();
  19228. var dataIndex = queryDataIndex(data, payload);
  19229. if (!(dataIndex instanceof Array) && dataIndex != null && dataIndex >= 0) {
  19230. var symbol = data.getItemGraphicEl(dataIndex);
  19231. if (!symbol) {
  19232. // Create a temporary symbol if it is not exists
  19233. var pt = data.getItemLayout(dataIndex);
  19234. symbol = new Symbol(data, dataIndex);
  19235. symbol.position = pt;
  19236. symbol.setZ(
  19237. seriesModel.get('zlevel'),
  19238. seriesModel.get('z')
  19239. );
  19240. symbol.ignore = isNaN(pt[0]) || isNaN(pt[1]);
  19241. symbol.__temp = true;
  19242. data.setItemGraphicEl(dataIndex, symbol);
  19243. // Stop scale animation
  19244. symbol.stopSymbolAnimation(true);
  19245. this.group.add(symbol);
  19246. }
  19247. symbol.highlight();
  19248. }
  19249. else {
  19250. // Highlight whole series
  19251. ChartView.prototype.highlight.call(
  19252. this, seriesModel, ecModel, api, payload
  19253. );
  19254. }
  19255. },
  19256. downplay: function (seriesModel, ecModel, api, payload) {
  19257. var data = seriesModel.getData();
  19258. var dataIndex = queryDataIndex(data, payload);
  19259. if (dataIndex != null && dataIndex >= 0) {
  19260. var symbol = data.getItemGraphicEl(dataIndex);
  19261. if (symbol) {
  19262. if (symbol.__temp) {
  19263. data.setItemGraphicEl(dataIndex, null);
  19264. this.group.remove(symbol);
  19265. }
  19266. else {
  19267. symbol.downplay();
  19268. }
  19269. }
  19270. }
  19271. else {
  19272. // Downplay whole series
  19273. ChartView.prototype.downplay.call(
  19274. this, seriesModel, ecModel, api, payload
  19275. );
  19276. }
  19277. },
  19278. /**
  19279. * @param {module:zrender/container/Group} group
  19280. * @param {Array.<Array.<number>>} points
  19281. * @private
  19282. */
  19283. _newPolyline: function (points) {
  19284. var polyline = this._polyline;
  19285. // Remove previous created polyline
  19286. if (polyline) {
  19287. this._lineGroup.remove(polyline);
  19288. }
  19289. polyline = new polyHelper.Polyline({
  19290. shape: {
  19291. points: points
  19292. },
  19293. silent: true,
  19294. z2: 10
  19295. });
  19296. this._lineGroup.add(polyline);
  19297. this._polyline = polyline;
  19298. return polyline;
  19299. },
  19300. /**
  19301. * @param {module:zrender/container/Group} group
  19302. * @param {Array.<Array.<number>>} stackedOnPoints
  19303. * @param {Array.<Array.<number>>} points
  19304. * @private
  19305. */
  19306. _newPolygon: function (points, stackedOnPoints) {
  19307. var polygon = this._polygon;
  19308. // Remove previous created polygon
  19309. if (polygon) {
  19310. this._lineGroup.remove(polygon);
  19311. }
  19312. polygon = new polyHelper.Polygon({
  19313. shape: {
  19314. points: points,
  19315. stackedOnPoints: stackedOnPoints
  19316. },
  19317. silent: true
  19318. });
  19319. this._lineGroup.add(polygon);
  19320. this._polygon = polygon;
  19321. return polygon;
  19322. },
  19323. /**
  19324. * @private
  19325. */
  19326. _getSymbolIgnoreFunc: function (data, coordSys) {
  19327. var categoryAxis = coordSys.getAxesByScale('ordinal')[0];
  19328. // `getLabelInterval` is provided by echarts/component/axis
  19329. if (categoryAxis && categoryAxis.isLabelIgnored) {
  19330. return zrUtil.bind(categoryAxis.isLabelIgnored, categoryAxis);
  19331. }
  19332. },
  19333. /**
  19334. * @private
  19335. */
  19336. // FIXME Two value axis
  19337. _updateAnimation: function (data, stackedOnPoints, coordSys, api, step) {
  19338. var polyline = this._polyline;
  19339. var polygon = this._polygon;
  19340. var seriesModel = data.hostModel;
  19341. var diff = lineAnimationDiff(
  19342. this._data, data,
  19343. this._stackedOnPoints, stackedOnPoints,
  19344. this._coordSys, coordSys
  19345. );
  19346. var current = diff.current;
  19347. var stackedOnCurrent = diff.stackedOnCurrent;
  19348. var next = diff.next;
  19349. var stackedOnNext = diff.stackedOnNext;
  19350. if (step) {
  19351. // TODO If stacked series is not step
  19352. current = turnPointsIntoStep(diff.current, coordSys, step);
  19353. stackedOnCurrent = turnPointsIntoStep(diff.stackedOnCurrent, coordSys, step);
  19354. next = turnPointsIntoStep(diff.next, coordSys, step);
  19355. stackedOnNext = turnPointsIntoStep(diff.stackedOnNext, coordSys, step);
  19356. }
  19357. polyline.shape.__points = diff.current;
  19358. polyline.shape.points = current;
  19359. graphic.updateProps(polyline, {
  19360. shape: {
  19361. points: next
  19362. }
  19363. }, seriesModel);
  19364. if (polygon) {
  19365. polygon.setShape({
  19366. points: current,
  19367. stackedOnPoints: stackedOnCurrent
  19368. });
  19369. graphic.updateProps(polygon, {
  19370. shape: {
  19371. points: next,
  19372. stackedOnPoints: stackedOnNext,
  19373. __points: diff.next
  19374. }
  19375. }, seriesModel);
  19376. }
  19377. var updatedDataInfo = [];
  19378. var diffStatus = diff.status;
  19379. for (var i = 0; i < diffStatus.length; i++) {
  19380. var cmd = diffStatus[i].cmd;
  19381. if (cmd === '=') {
  19382. var el = data.getItemGraphicEl(diffStatus[i].idx1);
  19383. if (el) {
  19384. updatedDataInfo.push({
  19385. el: el,
  19386. ptIdx: i // Index of points
  19387. });
  19388. }
  19389. }
  19390. }
  19391. if (polyline.animators && polyline.animators.length) {
  19392. polyline.animators[0].during(function () {
  19393. for (var i = 0; i < updatedDataInfo.length; i++) {
  19394. var el = updatedDataInfo[i].el;
  19395. el.attr('position', polyline.shape.__points[updatedDataInfo[i].ptIdx]);
  19396. }
  19397. });
  19398. }
  19399. },
  19400. remove: function (ecModel) {
  19401. var group = this.group;
  19402. var oldData = this._data;
  19403. this._lineGroup.removeAll();
  19404. this._symbolDraw.remove(true);
  19405. // Remove temporary created elements when highlighting
  19406. oldData && oldData.eachItemGraphicEl(function (el, idx) {
  19407. if (el.__temp) {
  19408. group.remove(el);
  19409. oldData.setItemGraphicEl(idx, null);
  19410. }
  19411. });
  19412. this._polyline =
  19413. this._polygon =
  19414. this._coordSys =
  19415. this._points =
  19416. this._stackedOnPoints =
  19417. this._data = null;
  19418. }
  19419. });
  19420. /***/ },
  19421. /* 104 */
  19422. /***/ function(module, exports, __webpack_require__) {
  19423. /**
  19424. * @module echarts/chart/helper/SymbolDraw
  19425. */
  19426. var graphic = __webpack_require__(43);
  19427. var Symbol = __webpack_require__(105);
  19428. /**
  19429. * @constructor
  19430. * @alias module:echarts/chart/helper/SymbolDraw
  19431. * @param {module:zrender/graphic/Group} [symbolCtor]
  19432. */
  19433. function SymbolDraw(symbolCtor) {
  19434. this.group = new graphic.Group();
  19435. this._symbolCtor = symbolCtor || Symbol;
  19436. }
  19437. var symbolDrawProto = SymbolDraw.prototype;
  19438. function symbolNeedsDraw(data, idx, isIgnore) {
  19439. var point = data.getItemLayout(idx);
  19440. return point && !isNaN(point[0]) && !isNaN(point[1]) && !(isIgnore && isIgnore(idx))
  19441. && data.getItemVisual(idx, 'symbol') !== 'none';
  19442. }
  19443. /**
  19444. * Update symbols draw by new data
  19445. * @param {module:echarts/data/List} data
  19446. * @param {Array.<boolean>} [isIgnore]
  19447. */
  19448. symbolDrawProto.updateData = function (data, isIgnore) {
  19449. var group = this.group;
  19450. var seriesModel = data.hostModel;
  19451. var oldData = this._data;
  19452. var SymbolCtor = this._symbolCtor;
  19453. var seriesScope = {
  19454. itemStyle: seriesModel.getModel('itemStyle.normal').getItemStyle(['color']),
  19455. hoverItemStyle: seriesModel.getModel('itemStyle.emphasis').getItemStyle(),
  19456. symbolRotate: seriesModel.get('symbolRotate'),
  19457. symbolOffset: seriesModel.get('symbolOffset'),
  19458. hoverAnimation: seriesModel.get('hoverAnimation'),
  19459. labelModel: seriesModel.getModel('label.normal'),
  19460. hoverLabelModel: seriesModel.getModel('label.emphasis')
  19461. };
  19462. data.diff(oldData)
  19463. .add(function (newIdx) {
  19464. var point = data.getItemLayout(newIdx);
  19465. if (symbolNeedsDraw(data, newIdx, isIgnore)) {
  19466. var symbolEl = new SymbolCtor(data, newIdx, seriesScope);
  19467. symbolEl.attr('position', point);
  19468. data.setItemGraphicEl(newIdx, symbolEl);
  19469. group.add(symbolEl);
  19470. }
  19471. })
  19472. .update(function (newIdx, oldIdx) {
  19473. var symbolEl = oldData.getItemGraphicEl(oldIdx);
  19474. var point = data.getItemLayout(newIdx);
  19475. if (!symbolNeedsDraw(data, newIdx, isIgnore)) {
  19476. group.remove(symbolEl);
  19477. return;
  19478. }
  19479. if (!symbolEl) {
  19480. symbolEl = new SymbolCtor(data, newIdx);
  19481. symbolEl.attr('position', point);
  19482. }
  19483. else {
  19484. symbolEl.updateData(data, newIdx, seriesScope);
  19485. graphic.updateProps(symbolEl, {
  19486. position: point
  19487. }, seriesModel);
  19488. }
  19489. // Add back
  19490. group.add(symbolEl);
  19491. data.setItemGraphicEl(newIdx, symbolEl);
  19492. })
  19493. .remove(function (oldIdx) {
  19494. var el = oldData.getItemGraphicEl(oldIdx);
  19495. el && el.fadeOut(function () {
  19496. group.remove(el);
  19497. });
  19498. })
  19499. .execute();
  19500. this._data = data;
  19501. };
  19502. symbolDrawProto.updateLayout = function () {
  19503. var data = this._data;
  19504. if (data) {
  19505. // Not use animation
  19506. data.eachItemGraphicEl(function (el, idx) {
  19507. var point = data.getItemLayout(idx);
  19508. el.attr('position', point);
  19509. });
  19510. }
  19511. };
  19512. symbolDrawProto.remove = function (enableAnimation) {
  19513. var group = this.group;
  19514. var data = this._data;
  19515. if (data) {
  19516. if (enableAnimation) {
  19517. data.eachItemGraphicEl(function (el) {
  19518. el.fadeOut(function () {
  19519. group.remove(el);
  19520. });
  19521. });
  19522. }
  19523. else {
  19524. group.removeAll();
  19525. }
  19526. }
  19527. };
  19528. module.exports = SymbolDraw;
  19529. /***/ },
  19530. /* 105 */
  19531. /***/ function(module, exports, __webpack_require__) {
  19532. /**
  19533. * @module echarts/chart/helper/Symbol
  19534. */
  19535. var zrUtil = __webpack_require__(4);
  19536. var symbolUtil = __webpack_require__(106);
  19537. var graphic = __webpack_require__(43);
  19538. var numberUtil = __webpack_require__(7);
  19539. function normalizeSymbolSize(symbolSize) {
  19540. if (!(symbolSize instanceof Array)) {
  19541. symbolSize = [+symbolSize, +symbolSize];
  19542. }
  19543. return symbolSize;
  19544. }
  19545. /**
  19546. * @constructor
  19547. * @alias {module:echarts/chart/helper/Symbol}
  19548. * @param {module:echarts/data/List} data
  19549. * @param {number} idx
  19550. * @extends {module:zrender/graphic/Group}
  19551. */
  19552. function Symbol(data, idx, seriesScope) {
  19553. graphic.Group.call(this);
  19554. this.updateData(data, idx, seriesScope);
  19555. }
  19556. var symbolProto = Symbol.prototype;
  19557. function driftSymbol(dx, dy) {
  19558. this.parent.drift(dx, dy);
  19559. }
  19560. symbolProto._createSymbol = function (symbolType, data, idx) {
  19561. // Remove paths created before
  19562. this.removeAll();
  19563. var seriesModel = data.hostModel;
  19564. var color = data.getItemVisual(idx, 'color');
  19565. var symbolPath = symbolUtil.createSymbol(
  19566. symbolType, -0.5, -0.5, 1, 1, color
  19567. );
  19568. symbolPath.attr({
  19569. z2: 100,
  19570. culling: true,
  19571. scale: [0, 0]
  19572. });
  19573. // Rewrite drift method
  19574. symbolPath.drift = driftSymbol;
  19575. var size = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'));
  19576. graphic.initProps(symbolPath, {
  19577. scale: size
  19578. }, seriesModel, idx);
  19579. this._symbolType = symbolType;
  19580. this.add(symbolPath);
  19581. };
  19582. /**
  19583. * Stop animation
  19584. * @param {boolean} toLastFrame
  19585. */
  19586. symbolProto.stopSymbolAnimation = function (toLastFrame) {
  19587. this.childAt(0).stopAnimation(toLastFrame);
  19588. };
  19589. /**
  19590. * Get scale(aka, current symbol size).
  19591. * Including the change caused by animation
  19592. */
  19593. symbolProto.getScale = function () {
  19594. return this.childAt(0).scale;
  19595. };
  19596. /**
  19597. * Highlight symbol
  19598. */
  19599. symbolProto.highlight = function () {
  19600. this.childAt(0).trigger('emphasis');
  19601. };
  19602. /**
  19603. * Downplay symbol
  19604. */
  19605. symbolProto.downplay = function () {
  19606. this.childAt(0).trigger('normal');
  19607. };
  19608. /**
  19609. * @param {number} zlevel
  19610. * @param {number} z
  19611. */
  19612. symbolProto.setZ = function (zlevel, z) {
  19613. var symbolPath = this.childAt(0);
  19614. symbolPath.zlevel = zlevel;
  19615. symbolPath.z = z;
  19616. };
  19617. symbolProto.setDraggable = function (draggable) {
  19618. var symbolPath = this.childAt(0);
  19619. symbolPath.draggable = draggable;
  19620. symbolPath.cursor = draggable ? 'move' : 'pointer';
  19621. };
  19622. /**
  19623. * Update symbol properties
  19624. * @param {module:echarts/data/List} data
  19625. * @param {number} idx
  19626. */
  19627. symbolProto.updateData = function (data, idx, seriesScope) {
  19628. this.silent = false;
  19629. var symbolType = data.getItemVisual(idx, 'symbol') || 'circle';
  19630. var seriesModel = data.hostModel;
  19631. var symbolSize = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'));
  19632. if (symbolType !== this._symbolType) {
  19633. this._createSymbol(symbolType, data, idx);
  19634. }
  19635. else {
  19636. var symbolPath = this.childAt(0);
  19637. graphic.updateProps(symbolPath, {
  19638. scale: symbolSize
  19639. }, seriesModel, idx);
  19640. }
  19641. this._updateCommon(data, idx, symbolSize, seriesScope);
  19642. this._seriesModel = seriesModel;
  19643. };
  19644. // Update common properties
  19645. var normalStyleAccessPath = ['itemStyle', 'normal'];
  19646. var emphasisStyleAccessPath = ['itemStyle', 'emphasis'];
  19647. var normalLabelAccessPath = ['label', 'normal'];
  19648. var emphasisLabelAccessPath = ['label', 'emphasis'];
  19649. symbolProto._updateCommon = function (data, idx, symbolSize, seriesScope) {
  19650. var symbolPath = this.childAt(0);
  19651. var seriesModel = data.hostModel;
  19652. var color = data.getItemVisual(idx, 'color');
  19653. // Reset style
  19654. if (symbolPath.type !== 'image') {
  19655. symbolPath.useStyle({
  19656. strokeNoScale: true
  19657. });
  19658. }
  19659. seriesScope = seriesScope || null;
  19660. var itemStyle = seriesScope && seriesScope.itemStyle;
  19661. var hoverItemStyle = seriesScope && seriesScope.hoverItemStyle;
  19662. var symbolRotate = seriesScope && seriesScope.symbolRotate;
  19663. var symbolOffset = seriesScope && seriesScope.symbolOffset;
  19664. var labelModel = seriesScope && seriesScope.labelModel;
  19665. var hoverLabelModel = seriesScope && seriesScope.hoverLabelModel;
  19666. var hoverAnimation = seriesScope && seriesScope.hoverAnimation;
  19667. if (!seriesScope || data.hasItemOption) {
  19668. var itemModel = data.getItemModel(idx);
  19669. // Color must be excluded.
  19670. // Because symbol provide setColor individually to set fill and stroke
  19671. itemStyle = itemModel.getModel(normalStyleAccessPath).getItemStyle(['color']);
  19672. hoverItemStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle();
  19673. symbolRotate = itemModel.getShallow('symbolRotate');
  19674. symbolOffset = itemModel.getShallow('symbolOffset');
  19675. labelModel = itemModel.getModel(normalLabelAccessPath);
  19676. hoverLabelModel = itemModel.getModel(emphasisLabelAccessPath);
  19677. hoverAnimation = itemModel.getShallow('hoverAnimation');
  19678. }
  19679. else {
  19680. hoverItemStyle = zrUtil.extend({}, hoverItemStyle);
  19681. }
  19682. var elStyle = symbolPath.style;
  19683. symbolPath.rotation = (symbolRotate || 0) * Math.PI / 180 || 0;
  19684. if (symbolOffset) {
  19685. symbolPath.attr('position', [
  19686. numberUtil.parsePercent(symbolOffset[0], symbolSize[0]),
  19687. numberUtil.parsePercent(symbolOffset[1], symbolSize[1])
  19688. ]);
  19689. }
  19690. // PENDING setColor before setStyle!!!
  19691. symbolPath.setColor(color);
  19692. symbolPath.setStyle(itemStyle);
  19693. var opacity = data.getItemVisual(idx, 'opacity');
  19694. if (opacity != null) {
  19695. elStyle.opacity = opacity;
  19696. }
  19697. // Get last value dim
  19698. var dimensions = data.dimensions.slice();
  19699. var valueDim;
  19700. var dataType;
  19701. while (dimensions.length && (
  19702. valueDim = dimensions.pop(),
  19703. dataType = data.getDimensionInfo(valueDim).type,
  19704. dataType === 'ordinal' || dataType === 'time'
  19705. )) {} // jshint ignore:line
  19706. if (valueDim != null && labelModel.getShallow('show')) {
  19707. graphic.setText(elStyle, labelModel, color);
  19708. elStyle.text = zrUtil.retrieve(
  19709. seriesModel.getFormattedLabel(idx, 'normal'),
  19710. data.get(valueDim, idx)
  19711. );
  19712. }
  19713. else {
  19714. elStyle.text = '';
  19715. }
  19716. if (valueDim != null && hoverLabelModel.getShallow('show')) {
  19717. graphic.setText(hoverItemStyle, hoverLabelModel, color);
  19718. hoverItemStyle.text = zrUtil.retrieve(
  19719. seriesModel.getFormattedLabel(idx, 'emphasis'),
  19720. data.get(valueDim, idx)
  19721. );
  19722. }
  19723. else {
  19724. hoverItemStyle.text = '';
  19725. }
  19726. var size = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'));
  19727. symbolPath.off('mouseover')
  19728. .off('mouseout')
  19729. .off('emphasis')
  19730. .off('normal');
  19731. graphic.setHoverStyle(symbolPath, hoverItemStyle);
  19732. if (hoverAnimation && seriesModel.ifEnableAnimation()) {
  19733. var onEmphasis = function() {
  19734. var ratio = size[1] / size[0];
  19735. this.animateTo({
  19736. scale: [
  19737. Math.max(size[0] * 1.1, size[0] + 3),
  19738. Math.max(size[1] * 1.1, size[1] + 3 * ratio)
  19739. ]
  19740. }, 400, 'elasticOut');
  19741. };
  19742. var onNormal = function() {
  19743. this.animateTo({
  19744. scale: size
  19745. }, 400, 'elasticOut');
  19746. };
  19747. symbolPath.on('mouseover', onEmphasis)
  19748. .on('mouseout', onNormal)
  19749. .on('emphasis', onEmphasis)
  19750. .on('normal', onNormal);
  19751. }
  19752. };
  19753. symbolProto.fadeOut = function (cb) {
  19754. var symbolPath = this.childAt(0);
  19755. // Avoid mistaken hover when fading out
  19756. this.silent = true;
  19757. // Not show text when animating
  19758. symbolPath.style.text = '';
  19759. graphic.updateProps(symbolPath, {
  19760. scale: [0, 0]
  19761. }, this._seriesModel, this.dataIndex, cb);
  19762. };
  19763. zrUtil.inherits(Symbol, graphic.Group);
  19764. module.exports = Symbol;
  19765. /***/ },
  19766. /* 106 */
  19767. /***/ function(module, exports, __webpack_require__) {
  19768. 'use strict';
  19769. // Symbol factory
  19770. var graphic = __webpack_require__(43);
  19771. var BoundingRect = __webpack_require__(9);
  19772. /**
  19773. * Triangle shape
  19774. * @inner
  19775. */
  19776. var Triangle = graphic.extendShape({
  19777. type: 'triangle',
  19778. shape: {
  19779. cx: 0,
  19780. cy: 0,
  19781. width: 0,
  19782. height: 0
  19783. },
  19784. buildPath: function (path, shape) {
  19785. var cx = shape.cx;
  19786. var cy = shape.cy;
  19787. var width = shape.width / 2;
  19788. var height = shape.height / 2;
  19789. path.moveTo(cx, cy - height);
  19790. path.lineTo(cx + width, cy + height);
  19791. path.lineTo(cx - width, cy + height);
  19792. path.closePath();
  19793. }
  19794. });
  19795. /**
  19796. * Diamond shape
  19797. * @inner
  19798. */
  19799. var Diamond = graphic.extendShape({
  19800. type: 'diamond',
  19801. shape: {
  19802. cx: 0,
  19803. cy: 0,
  19804. width: 0,
  19805. height: 0
  19806. },
  19807. buildPath: function (path, shape) {
  19808. var cx = shape.cx;
  19809. var cy = shape.cy;
  19810. var width = shape.width / 2;
  19811. var height = shape.height / 2;
  19812. path.moveTo(cx, cy - height);
  19813. path.lineTo(cx + width, cy);
  19814. path.lineTo(cx, cy + height);
  19815. path.lineTo(cx - width, cy);
  19816. path.closePath();
  19817. }
  19818. });
  19819. /**
  19820. * Pin shape
  19821. * @inner
  19822. */
  19823. var Pin = graphic.extendShape({
  19824. type: 'pin',
  19825. shape: {
  19826. // x, y on the cusp
  19827. x: 0,
  19828. y: 0,
  19829. width: 0,
  19830. height: 0
  19831. },
  19832. buildPath: function (path, shape) {
  19833. var x = shape.x;
  19834. var y = shape.y;
  19835. var w = shape.width / 5 * 3;
  19836. // Height must be larger than width
  19837. var h = Math.max(w, shape.height);
  19838. var r = w / 2;
  19839. // Dist on y with tangent point and circle center
  19840. var dy = r * r / (h - r);
  19841. var cy = y - h + r + dy;
  19842. var angle = Math.asin(dy / r);
  19843. // Dist on x with tangent point and circle center
  19844. var dx = Math.cos(angle) * r;
  19845. var tanX = Math.sin(angle);
  19846. var tanY = Math.cos(angle);
  19847. path.arc(
  19848. x, cy, r,
  19849. Math.PI - angle,
  19850. Math.PI * 2 + angle
  19851. );
  19852. var cpLen = r * 0.6;
  19853. var cpLen2 = r * 0.7;
  19854. path.bezierCurveTo(
  19855. x + dx - tanX * cpLen, cy + dy + tanY * cpLen,
  19856. x, y - cpLen2,
  19857. x, y
  19858. );
  19859. path.bezierCurveTo(
  19860. x, y - cpLen2,
  19861. x - dx + tanX * cpLen, cy + dy + tanY * cpLen,
  19862. x - dx, cy + dy
  19863. );
  19864. path.closePath();
  19865. }
  19866. });
  19867. /**
  19868. * Arrow shape
  19869. * @inner
  19870. */
  19871. var Arrow = graphic.extendShape({
  19872. type: 'arrow',
  19873. shape: {
  19874. x: 0,
  19875. y: 0,
  19876. width: 0,
  19877. height: 0
  19878. },
  19879. buildPath: function (ctx, shape) {
  19880. var height = shape.height;
  19881. var width = shape.width;
  19882. var x = shape.x;
  19883. var y = shape.y;
  19884. var dx = width / 3 * 2;
  19885. ctx.moveTo(x, y);
  19886. ctx.lineTo(x + dx, y + height);
  19887. ctx.lineTo(x, y + height / 4 * 3);
  19888. ctx.lineTo(x - dx, y + height);
  19889. ctx.lineTo(x, y);
  19890. ctx.closePath();
  19891. }
  19892. });
  19893. /**
  19894. * Map of path contructors
  19895. * @type {Object.<string, module:zrender/graphic/Path>}
  19896. */
  19897. var symbolCtors = {
  19898. line: graphic.Line,
  19899. rect: graphic.Rect,
  19900. roundRect: graphic.Rect,
  19901. square: graphic.Rect,
  19902. circle: graphic.Circle,
  19903. diamond: Diamond,
  19904. pin: Pin,
  19905. arrow: Arrow,
  19906. triangle: Triangle
  19907. };
  19908. var symbolShapeMakers = {
  19909. line: function (x, y, w, h, shape) {
  19910. // FIXME
  19911. shape.x1 = x;
  19912. shape.y1 = y + h / 2;
  19913. shape.x2 = x + w;
  19914. shape.y2 = y + h / 2;
  19915. },
  19916. rect: function (x, y, w, h, shape) {
  19917. shape.x = x;
  19918. shape.y = y;
  19919. shape.width = w;
  19920. shape.height = h;
  19921. },
  19922. roundRect: function (x, y, w, h, shape) {
  19923. shape.x = x;
  19924. shape.y = y;
  19925. shape.width = w;
  19926. shape.height = h;
  19927. shape.r = Math.min(w, h) / 4;
  19928. },
  19929. square: function (x, y, w, h, shape) {
  19930. var size = Math.min(w, h);
  19931. shape.x = x;
  19932. shape.y = y;
  19933. shape.width = size;
  19934. shape.height = size;
  19935. },
  19936. circle: function (x, y, w, h, shape) {
  19937. // Put circle in the center of square
  19938. shape.cx = x + w / 2;
  19939. shape.cy = y + h / 2;
  19940. shape.r = Math.min(w, h) / 2;
  19941. },
  19942. diamond: function (x, y, w, h, shape) {
  19943. shape.cx = x + w / 2;
  19944. shape.cy = y + h / 2;
  19945. shape.width = w;
  19946. shape.height = h;
  19947. },
  19948. pin: function (x, y, w, h, shape) {
  19949. shape.x = x + w / 2;
  19950. shape.y = y + h / 2;
  19951. shape.width = w;
  19952. shape.height = h;
  19953. },
  19954. arrow: function (x, y, w, h, shape) {
  19955. shape.x = x + w / 2;
  19956. shape.y = y + h / 2;
  19957. shape.width = w;
  19958. shape.height = h;
  19959. },
  19960. triangle: function (x, y, w, h, shape) {
  19961. shape.cx = x + w / 2;
  19962. shape.cy = y + h / 2;
  19963. shape.width = w;
  19964. shape.height = h;
  19965. }
  19966. };
  19967. var symbolBuildProxies = {};
  19968. for (var name in symbolCtors) {
  19969. symbolBuildProxies[name] = new symbolCtors[name]();
  19970. }
  19971. var Symbol = graphic.extendShape({
  19972. type: 'symbol',
  19973. shape: {
  19974. symbolType: '',
  19975. x: 0,
  19976. y: 0,
  19977. width: 0,
  19978. height: 0
  19979. },
  19980. beforeBrush: function () {
  19981. var style = this.style;
  19982. var shape = this.shape;
  19983. // FIXME
  19984. if (shape.symbolType === 'pin' && style.textPosition === 'inside') {
  19985. style.textPosition = ['50%', '40%'];
  19986. style.textAlign = 'center';
  19987. style.textVerticalAlign = 'middle';
  19988. }
  19989. },
  19990. buildPath: function (ctx, shape, inBundle) {
  19991. var symbolType = shape.symbolType;
  19992. var proxySymbol = symbolBuildProxies[symbolType];
  19993. if (shape.symbolType !== 'none') {
  19994. if (!proxySymbol) {
  19995. // Default rect
  19996. symbolType = 'rect';
  19997. proxySymbol = symbolBuildProxies[symbolType];
  19998. }
  19999. symbolShapeMakers[symbolType](
  20000. shape.x, shape.y, shape.width, shape.height, proxySymbol.shape
  20001. );
  20002. proxySymbol.buildPath(ctx, proxySymbol.shape, inBundle);
  20003. }
  20004. }
  20005. });
  20006. // Provide setColor helper method to avoid determine if set the fill or stroke outside
  20007. var symbolPathSetColor = function (color) {
  20008. if (this.type !== 'image') {
  20009. var symbolStyle = this.style;
  20010. var symbolShape = this.shape;
  20011. if (symbolShape && symbolShape.symbolType === 'line') {
  20012. symbolStyle.stroke = color;
  20013. }
  20014. else if (this.__isEmptyBrush) {
  20015. symbolStyle.stroke = color;
  20016. symbolStyle.fill = '#fff';
  20017. }
  20018. else {
  20019. // FIXME 判断图形默认是填充还是描边,使用 onlyStroke ?
  20020. symbolStyle.fill && (symbolStyle.fill = color);
  20021. symbolStyle.stroke && (symbolStyle.stroke = color);
  20022. }
  20023. this.dirty(false);
  20024. }
  20025. };
  20026. var symbolUtil = {
  20027. /**
  20028. * Create a symbol element with given symbol configuration: shape, x, y, width, height, color
  20029. * @param {string} symbolType
  20030. * @param {number} x
  20031. * @param {number} y
  20032. * @param {number} w
  20033. * @param {number} h
  20034. * @param {string} color
  20035. */
  20036. createSymbol: function (symbolType, x, y, w, h, color) {
  20037. var isEmpty = symbolType.indexOf('empty') === 0;
  20038. if (isEmpty) {
  20039. symbolType = symbolType.substr(5, 1).toLowerCase() + symbolType.substr(6);
  20040. }
  20041. var symbolPath;
  20042. if (symbolType.indexOf('image://') === 0) {
  20043. symbolPath = new graphic.Image({
  20044. style: {
  20045. image: symbolType.slice(8),
  20046. x: x,
  20047. y: y,
  20048. width: w,
  20049. height: h
  20050. }
  20051. });
  20052. }
  20053. else if (symbolType.indexOf('path://') === 0) {
  20054. symbolPath = graphic.makePath(symbolType.slice(7), {}, new BoundingRect(x, y, w, h));
  20055. }
  20056. else {
  20057. symbolPath = new Symbol({
  20058. shape: {
  20059. symbolType: symbolType,
  20060. x: x,
  20061. y: y,
  20062. width: w,
  20063. height: h
  20064. }
  20065. });
  20066. }
  20067. symbolPath.__isEmptyBrush = isEmpty;
  20068. symbolPath.setColor = symbolPathSetColor;
  20069. symbolPath.setColor(color);
  20070. return symbolPath;
  20071. }
  20072. };
  20073. module.exports = symbolUtil;
  20074. /***/ },
  20075. /* 107 */
  20076. /***/ function(module, exports) {
  20077. // var arrayDiff = require('zrender/lib/core/arrayDiff');
  20078. // 'zrender/core/arrayDiff' has been used before, but it did
  20079. // not do well in performance when roam with fixed dataZoom window.
  20080. function sign(val) {
  20081. return val >= 0 ? 1 : -1;
  20082. }
  20083. function getStackedOnPoint(coordSys, data, idx) {
  20084. var baseAxis = coordSys.getBaseAxis();
  20085. var valueAxis = coordSys.getOtherAxis(baseAxis);
  20086. var valueStart = baseAxis.onZero
  20087. ? 0 : valueAxis.scale.getExtent()[0];
  20088. var valueDim = valueAxis.dim;
  20089. var baseDataOffset = valueDim === 'x' || valueDim === 'radius' ? 1 : 0;
  20090. var stackedOnSameSign;
  20091. var stackedOn = data.stackedOn;
  20092. var val = data.get(valueDim, idx);
  20093. // Find first stacked value with same sign
  20094. while (stackedOn &&
  20095. sign(stackedOn.get(valueDim, idx)) === sign(val)
  20096. ) {
  20097. stackedOnSameSign = stackedOn;
  20098. break;
  20099. }
  20100. var stackedData = [];
  20101. stackedData[baseDataOffset] = data.get(baseAxis.dim, idx);
  20102. stackedData[1 - baseDataOffset] = stackedOnSameSign
  20103. ? stackedOnSameSign.get(valueDim, idx, true) : valueStart;
  20104. return coordSys.dataToPoint(stackedData);
  20105. }
  20106. // function convertToIntId(newIdList, oldIdList) {
  20107. // // Generate int id instead of string id.
  20108. // // Compare string maybe slow in score function of arrDiff
  20109. // // Assume id in idList are all unique
  20110. // var idIndicesMap = {};
  20111. // var idx = 0;
  20112. // for (var i = 0; i < newIdList.length; i++) {
  20113. // idIndicesMap[newIdList[i]] = idx;
  20114. // newIdList[i] = idx++;
  20115. // }
  20116. // for (var i = 0; i < oldIdList.length; i++) {
  20117. // var oldId = oldIdList[i];
  20118. // // Same with newIdList
  20119. // if (idIndicesMap[oldId]) {
  20120. // oldIdList[i] = idIndicesMap[oldId];
  20121. // }
  20122. // else {
  20123. // oldIdList[i] = idx++;
  20124. // }
  20125. // }
  20126. // }
  20127. function diffData(oldData, newData) {
  20128. var diffResult = [];
  20129. newData.diff(oldData)
  20130. .add(function (idx) {
  20131. diffResult.push({cmd: '+', idx: idx});
  20132. })
  20133. .update(function (newIdx, oldIdx) {
  20134. diffResult.push({cmd: '=', idx: oldIdx, idx1: newIdx});
  20135. })
  20136. .remove(function (idx) {
  20137. diffResult.push({cmd: '-', idx: idx});
  20138. })
  20139. .execute();
  20140. return diffResult;
  20141. }
  20142. module.exports = function (
  20143. oldData, newData,
  20144. oldStackedOnPoints, newStackedOnPoints,
  20145. oldCoordSys, newCoordSys
  20146. ) {
  20147. var diff = diffData(oldData, newData);
  20148. // var newIdList = newData.mapArray(newData.getId);
  20149. // var oldIdList = oldData.mapArray(oldData.getId);
  20150. // convertToIntId(newIdList, oldIdList);
  20151. // // FIXME One data ?
  20152. // diff = arrayDiff(oldIdList, newIdList);
  20153. var currPoints = [];
  20154. var nextPoints = [];
  20155. // Points for stacking base line
  20156. var currStackedPoints = [];
  20157. var nextStackedPoints = [];
  20158. var status = [];
  20159. var sortedIndices = [];
  20160. var rawIndices = [];
  20161. var dims = newCoordSys.dimensions;
  20162. for (var i = 0; i < diff.length; i++) {
  20163. var diffItem = diff[i];
  20164. var pointAdded = true;
  20165. // FIXME, animation is not so perfect when dataZoom window moves fast
  20166. // Which is in case remvoing or add more than one data in the tail or head
  20167. switch (diffItem.cmd) {
  20168. case '=':
  20169. var currentPt = oldData.getItemLayout(diffItem.idx);
  20170. var nextPt = newData.getItemLayout(diffItem.idx1);
  20171. // If previous data is NaN, use next point directly
  20172. if (isNaN(currentPt[0]) || isNaN(currentPt[1])) {
  20173. currentPt = nextPt.slice();
  20174. }
  20175. currPoints.push(currentPt);
  20176. nextPoints.push(nextPt);
  20177. currStackedPoints.push(oldStackedOnPoints[diffItem.idx]);
  20178. nextStackedPoints.push(newStackedOnPoints[diffItem.idx1]);
  20179. rawIndices.push(newData.getRawIndex(diffItem.idx1));
  20180. break;
  20181. case '+':
  20182. var idx = diffItem.idx;
  20183. currPoints.push(
  20184. oldCoordSys.dataToPoint([
  20185. newData.get(dims[0], idx, true), newData.get(dims[1], idx, true)
  20186. ])
  20187. );
  20188. nextPoints.push(newData.getItemLayout(idx).slice());
  20189. currStackedPoints.push(
  20190. getStackedOnPoint(oldCoordSys, newData, idx)
  20191. );
  20192. nextStackedPoints.push(newStackedOnPoints[idx]);
  20193. rawIndices.push(newData.getRawIndex(idx));
  20194. break;
  20195. case '-':
  20196. var idx = diffItem.idx;
  20197. var rawIndex = oldData.getRawIndex(idx);
  20198. // Data is replaced. In the case of dynamic data queue
  20199. // FIXME FIXME FIXME
  20200. if (rawIndex !== idx) {
  20201. currPoints.push(oldData.getItemLayout(idx));
  20202. nextPoints.push(newCoordSys.dataToPoint([
  20203. oldData.get(dims[0], idx, true), oldData.get(dims[1], idx, true)
  20204. ]));
  20205. currStackedPoints.push(oldStackedOnPoints[idx]);
  20206. nextStackedPoints.push(
  20207. getStackedOnPoint(
  20208. newCoordSys, oldData, idx
  20209. )
  20210. );
  20211. rawIndices.push(rawIndex);
  20212. }
  20213. else {
  20214. pointAdded = false;
  20215. }
  20216. }
  20217. // Original indices
  20218. if (pointAdded) {
  20219. status.push(diffItem);
  20220. sortedIndices.push(sortedIndices.length);
  20221. }
  20222. }
  20223. // Diff result may be crossed if all items are changed
  20224. // Sort by data index
  20225. sortedIndices.sort(function (a, b) {
  20226. return rawIndices[a] - rawIndices[b];
  20227. });
  20228. var sortedCurrPoints = [];
  20229. var sortedNextPoints = [];
  20230. var sortedCurrStackedPoints = [];
  20231. var sortedNextStackedPoints = [];
  20232. var sortedStatus = [];
  20233. for (var i = 0; i < sortedIndices.length; i++) {
  20234. var idx = sortedIndices[i];
  20235. sortedCurrPoints[i] = currPoints[idx];
  20236. sortedNextPoints[i] = nextPoints[idx];
  20237. sortedCurrStackedPoints[i] = currStackedPoints[idx];
  20238. sortedNextStackedPoints[i] = nextStackedPoints[idx];
  20239. sortedStatus[i] = status[idx];
  20240. }
  20241. return {
  20242. current: sortedCurrPoints,
  20243. next: sortedNextPoints,
  20244. stackedOnCurrent: sortedCurrStackedPoints,
  20245. stackedOnNext: sortedNextStackedPoints,
  20246. status: sortedStatus
  20247. };
  20248. };
  20249. /***/ },
  20250. /* 108 */
  20251. /***/ function(module, exports, __webpack_require__) {
  20252. // Poly path support NaN point
  20253. var Path = __webpack_require__(45);
  20254. var vec2 = __webpack_require__(10);
  20255. var vec2Min = vec2.min;
  20256. var vec2Max = vec2.max;
  20257. var scaleAndAdd = vec2.scaleAndAdd;
  20258. var v2Copy = vec2.copy;
  20259. // Temporary variable
  20260. var v = [];
  20261. var cp0 = [];
  20262. var cp1 = [];
  20263. function isPointNull(p) {
  20264. return isNaN(p[0]) || isNaN(p[1]);
  20265. }
  20266. function drawSegment(
  20267. ctx, points, start, segLen, allLen,
  20268. dir, smoothMin, smoothMax, smooth, smoothMonotone, connectNulls
  20269. ) {
  20270. var prevIdx = 0;
  20271. var idx = start;
  20272. for (var k = 0; k < segLen; k++) {
  20273. var p = points[idx];
  20274. if (idx >= allLen || idx < 0) {
  20275. break;
  20276. }
  20277. if (isPointNull(p)) {
  20278. if (connectNulls) {
  20279. idx += dir;
  20280. continue;
  20281. }
  20282. break;
  20283. }
  20284. if (idx === start) {
  20285. ctx[dir > 0 ? 'moveTo' : 'lineTo'](p[0], p[1]);
  20286. v2Copy(cp0, p);
  20287. }
  20288. else {
  20289. if (smooth > 0) {
  20290. var nextIdx = idx + dir;
  20291. var nextP = points[nextIdx];
  20292. if (connectNulls) {
  20293. // Find next point not null
  20294. while (nextP && isPointNull(points[nextIdx])) {
  20295. nextIdx += dir;
  20296. nextP = points[nextIdx];
  20297. }
  20298. }
  20299. var ratioNextSeg = 0.5;
  20300. var prevP = points[prevIdx];
  20301. var nextP = points[nextIdx];
  20302. // Last point
  20303. if (!nextP || isPointNull(nextP)) {
  20304. v2Copy(cp1, p);
  20305. }
  20306. else {
  20307. // If next data is null in not connect case
  20308. if (isPointNull(nextP) && !connectNulls) {
  20309. nextP = p;
  20310. }
  20311. vec2.sub(v, nextP, prevP);
  20312. var lenPrevSeg;
  20313. var lenNextSeg;
  20314. if (smoothMonotone === 'x' || smoothMonotone === 'y') {
  20315. var dim = smoothMonotone === 'x' ? 0 : 1;
  20316. lenPrevSeg = Math.abs(p[dim] - prevP[dim]);
  20317. lenNextSeg = Math.abs(p[dim] - nextP[dim]);
  20318. }
  20319. else {
  20320. lenPrevSeg = vec2.dist(p, prevP);
  20321. lenNextSeg = vec2.dist(p, nextP);
  20322. }
  20323. // Use ratio of seg length
  20324. ratioNextSeg = lenNextSeg / (lenNextSeg + lenPrevSeg);
  20325. scaleAndAdd(cp1, p, v, -smooth * (1 - ratioNextSeg));
  20326. }
  20327. // Smooth constraint
  20328. vec2Min(cp0, cp0, smoothMax);
  20329. vec2Max(cp0, cp0, smoothMin);
  20330. vec2Min(cp1, cp1, smoothMax);
  20331. vec2Max(cp1, cp1, smoothMin);
  20332. ctx.bezierCurveTo(
  20333. cp0[0], cp0[1],
  20334. cp1[0], cp1[1],
  20335. p[0], p[1]
  20336. );
  20337. // cp0 of next segment
  20338. scaleAndAdd(cp0, p, v, smooth * ratioNextSeg);
  20339. }
  20340. else {
  20341. ctx.lineTo(p[0], p[1]);
  20342. }
  20343. }
  20344. prevIdx = idx;
  20345. idx += dir;
  20346. }
  20347. return k;
  20348. }
  20349. function getBoundingBox(points, smoothConstraint) {
  20350. var ptMin = [Infinity, Infinity];
  20351. var ptMax = [-Infinity, -Infinity];
  20352. if (smoothConstraint) {
  20353. for (var i = 0; i < points.length; i++) {
  20354. var pt = points[i];
  20355. if (pt[0] < ptMin[0]) { ptMin[0] = pt[0]; }
  20356. if (pt[1] < ptMin[1]) { ptMin[1] = pt[1]; }
  20357. if (pt[0] > ptMax[0]) { ptMax[0] = pt[0]; }
  20358. if (pt[1] > ptMax[1]) { ptMax[1] = pt[1]; }
  20359. }
  20360. }
  20361. return {
  20362. min: smoothConstraint ? ptMin : ptMax,
  20363. max: smoothConstraint ? ptMax : ptMin
  20364. };
  20365. }
  20366. module.exports = {
  20367. Polyline: Path.extend({
  20368. type: 'ec-polyline',
  20369. shape: {
  20370. points: [],
  20371. smooth: 0,
  20372. smoothConstraint: true,
  20373. smoothMonotone: null,
  20374. connectNulls: false
  20375. },
  20376. style: {
  20377. fill: null,
  20378. stroke: '#000'
  20379. },
  20380. buildPath: function (ctx, shape) {
  20381. var points = shape.points;
  20382. var i = 0;
  20383. var len = points.length;
  20384. var result = getBoundingBox(points, shape.smoothConstraint);
  20385. if (shape.connectNulls) {
  20386. // Must remove first and last null values avoid draw error in polygon
  20387. for (; len > 0; len--) {
  20388. if (!isPointNull(points[len - 1])) {
  20389. break;
  20390. }
  20391. }
  20392. for (; i < len; i++) {
  20393. if (!isPointNull(points[i])) {
  20394. break;
  20395. }
  20396. }
  20397. }
  20398. while (i < len) {
  20399. i += drawSegment(
  20400. ctx, points, i, len, len,
  20401. 1, result.min, result.max, shape.smooth,
  20402. shape.smoothMonotone, shape.connectNulls
  20403. ) + 1;
  20404. }
  20405. }
  20406. }),
  20407. Polygon: Path.extend({
  20408. type: 'ec-polygon',
  20409. shape: {
  20410. points: [],
  20411. // Offset between stacked base points and points
  20412. stackedOnPoints: [],
  20413. smooth: 0,
  20414. stackedOnSmooth: 0,
  20415. smoothConstraint: true,
  20416. smoothMonotone: null,
  20417. connectNulls: false
  20418. },
  20419. buildPath: function (ctx, shape) {
  20420. var points = shape.points;
  20421. var stackedOnPoints = shape.stackedOnPoints;
  20422. var i = 0;
  20423. var len = points.length;
  20424. var smoothMonotone = shape.smoothMonotone;
  20425. var bbox = getBoundingBox(points, shape.smoothConstraint);
  20426. var stackedOnBBox = getBoundingBox(stackedOnPoints, shape.smoothConstraint);
  20427. if (shape.connectNulls) {
  20428. // Must remove first and last null values avoid draw error in polygon
  20429. for (; len > 0; len--) {
  20430. if (!isPointNull(points[len - 1])) {
  20431. break;
  20432. }
  20433. }
  20434. for (; i < len; i++) {
  20435. if (!isPointNull(points[i])) {
  20436. break;
  20437. }
  20438. }
  20439. }
  20440. while (i < len) {
  20441. var k = drawSegment(
  20442. ctx, points, i, len, len,
  20443. 1, bbox.min, bbox.max, shape.smooth,
  20444. smoothMonotone, shape.connectNulls
  20445. );
  20446. drawSegment(
  20447. ctx, stackedOnPoints, i + k - 1, k, len,
  20448. -1, stackedOnBBox.min, stackedOnBBox.max, shape.stackedOnSmooth,
  20449. smoothMonotone, shape.connectNulls
  20450. );
  20451. i += k + 1;
  20452. ctx.closePath();
  20453. }
  20454. }
  20455. })
  20456. };
  20457. /***/ },
  20458. /* 109 */
  20459. /***/ function(module, exports) {
  20460. module.exports = function (seriesType, defaultSymbolType, legendSymbol, ecModel, api) {
  20461. // Encoding visual for all series include which is filtered for legend drawing
  20462. ecModel.eachRawSeriesByType(seriesType, function (seriesModel) {
  20463. var data = seriesModel.getData();
  20464. var symbolType = seriesModel.get('symbol') || defaultSymbolType;
  20465. var symbolSize = seriesModel.get('symbolSize');
  20466. data.setVisual({
  20467. legendSymbol: legendSymbol || symbolType,
  20468. symbol: symbolType,
  20469. symbolSize: symbolSize
  20470. });
  20471. // Only visible series has each data be visual encoded
  20472. if (!ecModel.isSeriesFiltered(seriesModel)) {
  20473. if (typeof symbolSize === 'function') {
  20474. data.each(function (idx) {
  20475. var rawValue = seriesModel.getRawValue(idx);
  20476. // FIXME
  20477. var params = seriesModel.getDataParams(idx);
  20478. data.setItemVisual(idx, 'symbolSize', symbolSize(rawValue, params));
  20479. });
  20480. }
  20481. data.each(function (idx) {
  20482. var itemModel = data.getItemModel(idx);
  20483. var itemSymbolType = itemModel.getShallow('symbol', true);
  20484. var itemSymbolSize = itemModel.getShallow('symbolSize', true);
  20485. // If has item symbol
  20486. if (itemSymbolType != null) {
  20487. data.setItemVisual(idx, 'symbol', itemSymbolType);
  20488. }
  20489. if (itemSymbolSize != null) {
  20490. // PENDING Transform symbolSize ?
  20491. data.setItemVisual(idx, 'symbolSize', itemSymbolSize);
  20492. }
  20493. });
  20494. }
  20495. });
  20496. };
  20497. /***/ },
  20498. /* 110 */
  20499. /***/ function(module, exports) {
  20500. module.exports = function (seriesType, ecModel) {
  20501. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  20502. var data = seriesModel.getData();
  20503. var coordSys = seriesModel.coordinateSystem;
  20504. if (coordSys) {
  20505. var dims = coordSys.dimensions;
  20506. if (coordSys.type === 'singleAxis') {
  20507. data.each(dims[0], function (x, idx) {
  20508. // Also {Array.<number>}, not undefined to avoid if...else... statement
  20509. data.setItemLayout(idx, isNaN(x) ? [NaN, NaN] : coordSys.dataToPoint(x));
  20510. });
  20511. }
  20512. else {
  20513. data.each(dims, function (x, y, idx) {
  20514. // Also {Array.<number>}, not undefined to avoid if...else... statement
  20515. data.setItemLayout(
  20516. idx, (isNaN(x) || isNaN(y)) ? [NaN, NaN] : coordSys.dataToPoint([x, y])
  20517. );
  20518. }, true);
  20519. }
  20520. }
  20521. });
  20522. };
  20523. /***/ },
  20524. /* 111 */
  20525. /***/ function(module, exports) {
  20526. var samplers = {
  20527. average: function (frame) {
  20528. var sum = 0;
  20529. var count = 0;
  20530. for (var i = 0; i < frame.length; i++) {
  20531. if (!isNaN(frame[i])) {
  20532. sum += frame[i];
  20533. count++;
  20534. }
  20535. }
  20536. // Return NaN if count is 0
  20537. return count === 0 ? NaN : sum / count;
  20538. },
  20539. sum: function (frame) {
  20540. var sum = 0;
  20541. for (var i = 0; i < frame.length; i++) {
  20542. // Ignore NaN
  20543. sum += frame[i] || 0;
  20544. }
  20545. return sum;
  20546. },
  20547. max: function (frame) {
  20548. var max = -Infinity;
  20549. for (var i = 0; i < frame.length; i++) {
  20550. frame[i] > max && (max = frame[i]);
  20551. }
  20552. return max;
  20553. },
  20554. min: function (frame) {
  20555. var min = Infinity;
  20556. for (var i = 0; i < frame.length; i++) {
  20557. frame[i] < min && (min = frame[i]);
  20558. }
  20559. return min;
  20560. },
  20561. // TODO
  20562. // Median
  20563. nearest: function (frame) {
  20564. return frame[0];
  20565. }
  20566. };
  20567. var indexSampler = function (frame, value) {
  20568. return Math.round(frame.length / 2);
  20569. };
  20570. module.exports = function (seriesType, ecModel, api) {
  20571. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  20572. var data = seriesModel.getData();
  20573. var sampling = seriesModel.get('sampling');
  20574. var coordSys = seriesModel.coordinateSystem;
  20575. // Only cartesian2d support down sampling
  20576. if (coordSys.type === 'cartesian2d' && sampling) {
  20577. var baseAxis = coordSys.getBaseAxis();
  20578. var valueAxis = coordSys.getOtherAxis(baseAxis);
  20579. var extent = baseAxis.getExtent();
  20580. // Coordinste system has been resized
  20581. var size = extent[1] - extent[0];
  20582. var rate = Math.round(data.count() / size);
  20583. if (rate > 1) {
  20584. var sampler;
  20585. if (typeof sampling === 'string') {
  20586. sampler = samplers[sampling];
  20587. }
  20588. else if (typeof sampling === 'function') {
  20589. sampler = sampling;
  20590. }
  20591. if (sampler) {
  20592. data = data.downSample(
  20593. valueAxis.dim, 1 / rate, sampler, indexSampler
  20594. );
  20595. seriesModel.setData(data);
  20596. }
  20597. }
  20598. }
  20599. }, this);
  20600. };
  20601. /***/ },
  20602. /* 112 */
  20603. /***/ function(module, exports, __webpack_require__) {
  20604. 'use strict';
  20605. var graphic = __webpack_require__(43);
  20606. var zrUtil = __webpack_require__(4);
  20607. __webpack_require__(113);
  20608. __webpack_require__(130);
  20609. // Grid view
  20610. __webpack_require__(1).extendComponentView({
  20611. type: 'grid',
  20612. render: function (gridModel, ecModel) {
  20613. this.group.removeAll();
  20614. if (gridModel.get('show')) {
  20615. this.group.add(new graphic.Rect({
  20616. shape:gridModel.coordinateSystem.getRect(),
  20617. style: zrUtil.defaults({
  20618. fill: gridModel.get('backgroundColor')
  20619. }, gridModel.getItemStyle()),
  20620. silent: true
  20621. }));
  20622. }
  20623. }
  20624. });
  20625. /***/ },
  20626. /* 113 */
  20627. /***/ function(module, exports, __webpack_require__) {
  20628. /**
  20629. * Grid is a region which contains at most 4 cartesian systems
  20630. *
  20631. * TODO Default cartesian
  20632. */
  20633. var factory = exports;
  20634. var layout = __webpack_require__(21);
  20635. var axisHelper = __webpack_require__(114);
  20636. var zrUtil = __webpack_require__(4);
  20637. var Cartesian2D = __webpack_require__(120);
  20638. var Axis2D = __webpack_require__(122);
  20639. var each = zrUtil.each;
  20640. var ifAxisCrossZero = axisHelper.ifAxisCrossZero;
  20641. var niceScaleExtent = axisHelper.niceScaleExtent;
  20642. // 依赖 GridModel, AxisModel 做预处理
  20643. __webpack_require__(125);
  20644. /**
  20645. * Check if the axis is used in the specified grid
  20646. * @inner
  20647. */
  20648. function isAxisUsedInTheGrid(axisModel, gridModel, ecModel) {
  20649. return ecModel.getComponent('grid', axisModel.get('gridIndex')) === gridModel;
  20650. }
  20651. function getLabelUnionRect(axis) {
  20652. var axisModel = axis.model;
  20653. var labels = axisModel.getFormattedLabels();
  20654. var rect;
  20655. var step = 1;
  20656. var labelCount = labels.length;
  20657. if (labelCount > 40) {
  20658. // Simple optimization for large amount of labels
  20659. step = Math.ceil(labelCount / 40);
  20660. }
  20661. for (var i = 0; i < labelCount; i += step) {
  20662. if (!axis.isLabelIgnored(i)) {
  20663. var singleRect = axisModel.getTextRect(labels[i]);
  20664. // FIXME consider label rotate
  20665. rect ? rect.union(singleRect) : (rect = singleRect);
  20666. }
  20667. }
  20668. return rect;
  20669. }
  20670. function Grid(gridModel, ecModel, api) {
  20671. /**
  20672. * @type {Object.<string, module:echarts/coord/cartesian/Cartesian2D>}
  20673. * @private
  20674. */
  20675. this._coordsMap = {};
  20676. /**
  20677. * @type {Array.<module:echarts/coord/cartesian/Cartesian>}
  20678. * @private
  20679. */
  20680. this._coordsList = [];
  20681. /**
  20682. * @type {Object.<string, module:echarts/coord/cartesian/Axis2D>}
  20683. * @private
  20684. */
  20685. this._axesMap = {};
  20686. /**
  20687. * @type {Array.<module:echarts/coord/cartesian/Axis2D>}
  20688. * @private
  20689. */
  20690. this._axesList = [];
  20691. this._initCartesian(gridModel, ecModel, api);
  20692. this._model = gridModel;
  20693. }
  20694. var gridProto = Grid.prototype;
  20695. gridProto.type = 'grid';
  20696. gridProto.getRect = function () {
  20697. return this._rect;
  20698. };
  20699. gridProto.update = function (ecModel, api) {
  20700. var axesMap = this._axesMap;
  20701. this._updateScale(ecModel, this._model);
  20702. function ifAxisCanNotOnZero(otherAxisDim) {
  20703. var axes = axesMap[otherAxisDim];
  20704. for (var idx in axes) {
  20705. var axis = axes[idx];
  20706. if (axis && (axis.type === 'category' || !ifAxisCrossZero(axis))) {
  20707. return true;
  20708. }
  20709. }
  20710. return false;
  20711. }
  20712. each(axesMap.x, function (xAxis) {
  20713. niceScaleExtent(xAxis, xAxis.model);
  20714. });
  20715. each(axesMap.y, function (yAxis) {
  20716. niceScaleExtent(yAxis, yAxis.model);
  20717. });
  20718. // Fix configuration
  20719. each(axesMap.x, function (xAxis) {
  20720. // onZero can not be enabled in these two situations
  20721. // 1. When any other axis is a category axis
  20722. // 2. When any other axis not across 0 point
  20723. if (ifAxisCanNotOnZero('y')) {
  20724. xAxis.onZero = false;
  20725. }
  20726. });
  20727. each(axesMap.y, function (yAxis) {
  20728. if (ifAxisCanNotOnZero('x')) {
  20729. yAxis.onZero = false;
  20730. }
  20731. });
  20732. // Resize again if containLabel is enabled
  20733. // FIXME It may cause getting wrong grid size in data processing stage
  20734. this.resize(this._model, api);
  20735. };
  20736. /**
  20737. * Resize the grid
  20738. * @param {module:echarts/coord/cartesian/GridModel} gridModel
  20739. * @param {module:echarts/ExtensionAPI} api
  20740. */
  20741. gridProto.resize = function (gridModel, api) {
  20742. var gridRect = layout.getLayoutRect(
  20743. gridModel.getBoxLayoutParams(), {
  20744. width: api.getWidth(),
  20745. height: api.getHeight()
  20746. });
  20747. this._rect = gridRect;
  20748. var axesList = this._axesList;
  20749. adjustAxes();
  20750. // Minus label size
  20751. if (gridModel.get('containLabel')) {
  20752. each(axesList, function (axis) {
  20753. if (!axis.model.get('axisLabel.inside')) {
  20754. var labelUnionRect = getLabelUnionRect(axis);
  20755. if (labelUnionRect) {
  20756. var dim = axis.isHorizontal() ? 'height' : 'width';
  20757. var margin = axis.model.get('axisLabel.margin');
  20758. gridRect[dim] -= labelUnionRect[dim] + margin;
  20759. if (axis.position === 'top') {
  20760. gridRect.y += labelUnionRect.height + margin;
  20761. }
  20762. else if (axis.position === 'left') {
  20763. gridRect.x += labelUnionRect.width + margin;
  20764. }
  20765. }
  20766. }
  20767. });
  20768. adjustAxes();
  20769. }
  20770. function adjustAxes() {
  20771. each(axesList, function (axis) {
  20772. var isHorizontal = axis.isHorizontal();
  20773. var extent = isHorizontal ? [0, gridRect.width] : [0, gridRect.height];
  20774. var idx = axis.inverse ? 1 : 0;
  20775. axis.setExtent(extent[idx], extent[1 - idx]);
  20776. updateAxisTransfrom(axis, isHorizontal ? gridRect.x : gridRect.y);
  20777. });
  20778. }
  20779. };
  20780. /**
  20781. * @param {string} axisType
  20782. * @param {ndumber} [axisIndex]
  20783. */
  20784. gridProto.getAxis = function (axisType, axisIndex) {
  20785. var axesMapOnDim = this._axesMap[axisType];
  20786. if (axesMapOnDim != null) {
  20787. if (axisIndex == null) {
  20788. // Find first axis
  20789. for (var name in axesMapOnDim) {
  20790. return axesMapOnDim[name];
  20791. }
  20792. }
  20793. return axesMapOnDim[axisIndex];
  20794. }
  20795. };
  20796. gridProto.getCartesian = function (xAxisIndex, yAxisIndex) {
  20797. if (xAxisIndex != null && yAxisIndex != null) {
  20798. var key = 'x' + xAxisIndex + 'y' + yAxisIndex;
  20799. return this._coordsMap[key];
  20800. }
  20801. else {
  20802. // When only xAxisIndex or yAxisIndex given, find its first cartesian.
  20803. for (var i = 0, coordList = this._coordsList; i < coordList.length; i++) {
  20804. if (coordList[i].getAxis('x').index === xAxisIndex
  20805. || coordList[i].getAxis('y').index === yAxisIndex
  20806. ) {
  20807. return coordList[i];
  20808. }
  20809. }
  20810. }
  20811. };
  20812. /**
  20813. * Initialize cartesian coordinate systems
  20814. * @private
  20815. */
  20816. gridProto._initCartesian = function (gridModel, ecModel, api) {
  20817. var axisPositionUsed = {
  20818. left: false,
  20819. right: false,
  20820. top: false,
  20821. bottom: false
  20822. };
  20823. var axesMap = {
  20824. x: {},
  20825. y: {}
  20826. };
  20827. var axesCount = {
  20828. x: 0,
  20829. y: 0
  20830. };
  20831. /// Create axis
  20832. ecModel.eachComponent('xAxis', createAxisCreator('x'), this);
  20833. ecModel.eachComponent('yAxis', createAxisCreator('y'), this);
  20834. if (!axesCount.x || !axesCount.y) {
  20835. // Roll back when there no either x or y axis
  20836. this._axesMap = {};
  20837. this._axesList = [];
  20838. return;
  20839. }
  20840. this._axesMap = axesMap;
  20841. /// Create cartesian2d
  20842. each(axesMap.x, function (xAxis, xAxisIndex) {
  20843. each(axesMap.y, function (yAxis, yAxisIndex) {
  20844. var key = 'x' + xAxisIndex + 'y' + yAxisIndex;
  20845. var cartesian = new Cartesian2D(key);
  20846. cartesian.grid = this;
  20847. this._coordsMap[key] = cartesian;
  20848. this._coordsList.push(cartesian);
  20849. cartesian.addAxis(xAxis);
  20850. cartesian.addAxis(yAxis);
  20851. }, this);
  20852. }, this);
  20853. function createAxisCreator(axisType) {
  20854. return function (axisModel, idx) {
  20855. if (!isAxisUsedInTheGrid(axisModel, gridModel, ecModel)) {
  20856. return;
  20857. }
  20858. var axisPosition = axisModel.get('position');
  20859. if (axisType === 'x') {
  20860. // Fix position
  20861. if (axisPosition !== 'top' && axisPosition !== 'bottom') {
  20862. // Default bottom of X
  20863. axisPosition = 'bottom';
  20864. if (axisPositionUsed[axisPosition]) {
  20865. axisPosition = axisPosition === 'top' ? 'bottom' : 'top';
  20866. }
  20867. }
  20868. }
  20869. else {
  20870. // Fix position
  20871. if (axisPosition !== 'left' && axisPosition !== 'right') {
  20872. // Default left of Y
  20873. axisPosition = 'left';
  20874. if (axisPositionUsed[axisPosition]) {
  20875. axisPosition = axisPosition === 'left' ? 'right' : 'left';
  20876. }
  20877. }
  20878. }
  20879. axisPositionUsed[axisPosition] = true;
  20880. var axis = new Axis2D(
  20881. axisType, axisHelper.createScaleByModel(axisModel),
  20882. [0, 0],
  20883. axisModel.get('type'),
  20884. axisPosition
  20885. );
  20886. var isCategory = axis.type === 'category';
  20887. axis.onBand = isCategory && axisModel.get('boundaryGap');
  20888. axis.inverse = axisModel.get('inverse');
  20889. axis.onZero = axisModel.get('axisLine.onZero');
  20890. // Inject axis into axisModel
  20891. axisModel.axis = axis;
  20892. // Inject axisModel into axis
  20893. axis.model = axisModel;
  20894. // Inject grid info axis
  20895. axis.grid = this;
  20896. // Index of axis, can be used as key
  20897. axis.index = idx;
  20898. this._axesList.push(axis);
  20899. axesMap[axisType][idx] = axis;
  20900. axesCount[axisType]++;
  20901. };
  20902. }
  20903. };
  20904. /**
  20905. * Update cartesian properties from series
  20906. * @param {module:echarts/model/Option} option
  20907. * @private
  20908. */
  20909. gridProto._updateScale = function (ecModel, gridModel) {
  20910. // Reset scale
  20911. zrUtil.each(this._axesList, function (axis) {
  20912. axis.scale.setExtent(Infinity, -Infinity);
  20913. });
  20914. ecModel.eachSeries(function (seriesModel) {
  20915. if (seriesModel.get('coordinateSystem') === 'cartesian2d') {
  20916. var xAxisIndex = seriesModel.get('xAxisIndex');
  20917. var yAxisIndex = seriesModel.get('yAxisIndex');
  20918. var xAxisModel = ecModel.getComponent('xAxis', xAxisIndex);
  20919. var yAxisModel = ecModel.getComponent('yAxis', yAxisIndex);
  20920. if (!isAxisUsedInTheGrid(xAxisModel, gridModel, ecModel)
  20921. || !isAxisUsedInTheGrid(yAxisModel, gridModel, ecModel)
  20922. ) {
  20923. return;
  20924. }
  20925. var cartesian = this.getCartesian(xAxisIndex, yAxisIndex);
  20926. var data = seriesModel.getData();
  20927. var xAxis = cartesian.getAxis('x');
  20928. var yAxis = cartesian.getAxis('y');
  20929. if (data.type === 'list') {
  20930. unionExtent(data, xAxis, seriesModel);
  20931. unionExtent(data, yAxis, seriesModel);
  20932. }
  20933. }
  20934. }, this);
  20935. function unionExtent(data, axis, seriesModel) {
  20936. each(seriesModel.coordDimToDataDim(axis.dim), function (dim) {
  20937. axis.scale.unionExtent(data.getDataExtent(
  20938. dim, axis.scale.type !== 'ordinal'
  20939. ));
  20940. });
  20941. }
  20942. };
  20943. /**
  20944. * @inner
  20945. */
  20946. function updateAxisTransfrom(axis, coordBase) {
  20947. var axisExtent = axis.getExtent();
  20948. var axisExtentSum = axisExtent[0] + axisExtent[1];
  20949. // Fast transform
  20950. axis.toGlobalCoord = axis.dim === 'x'
  20951. ? function (coord) {
  20952. return coord + coordBase;
  20953. }
  20954. : function (coord) {
  20955. return axisExtentSum - coord + coordBase;
  20956. };
  20957. axis.toLocalCoord = axis.dim === 'x'
  20958. ? function (coord) {
  20959. return coord - coordBase;
  20960. }
  20961. : function (coord) {
  20962. return axisExtentSum - coord + coordBase;
  20963. };
  20964. }
  20965. Grid.create = function (ecModel, api) {
  20966. var grids = [];
  20967. ecModel.eachComponent('grid', function (gridModel, idx) {
  20968. var grid = new Grid(gridModel, ecModel, api);
  20969. grid.name = 'grid_' + idx;
  20970. grid.resize(gridModel, api);
  20971. gridModel.coordinateSystem = grid;
  20972. grids.push(grid);
  20973. });
  20974. // Inject the coordinateSystems into seriesModel
  20975. ecModel.eachSeries(function (seriesModel) {
  20976. if (seriesModel.get('coordinateSystem') !== 'cartesian2d') {
  20977. return;
  20978. }
  20979. var xAxisIndex = seriesModel.get('xAxisIndex');
  20980. var yAxisIndex = seriesModel.get('yAxisIndex');
  20981. var xAxisModel = ecModel.getComponent('xAxis', xAxisIndex);
  20982. if (true) {
  20983. var yAxisModel = ecModel.getComponent('yAxis', yAxisIndex);
  20984. if (xAxisModel.get('gridIndex') !== yAxisModel.get('gridIndex')) {
  20985. throw new Error('xAxis and yAxis must use the same grid');
  20986. }
  20987. }
  20988. var grid = grids[xAxisModel.get('gridIndex')];
  20989. seriesModel.coordinateSystem = grid.getCartesian(xAxisIndex, yAxisIndex);
  20990. });
  20991. return grids;
  20992. };
  20993. // For deciding which dimensions to use when creating list data
  20994. Grid.dimensions = Cartesian2D.prototype.dimensions;
  20995. __webpack_require__(26).register('cartesian2d', Grid);
  20996. module.exports = Grid;
  20997. /***/ },
  20998. /* 114 */
  20999. /***/ function(module, exports, __webpack_require__) {
  21000. var OrdinalScale = __webpack_require__(115);
  21001. var IntervalScale = __webpack_require__(117);
  21002. __webpack_require__(118);
  21003. __webpack_require__(119);
  21004. var Scale = __webpack_require__(116);
  21005. var numberUtil = __webpack_require__(7);
  21006. var zrUtil = __webpack_require__(4);
  21007. var textContain = __webpack_require__(8);
  21008. var axisHelper = {};
  21009. /**
  21010. * Get axis scale extent before niced.
  21011. */
  21012. axisHelper.getScaleExtent = function (axis, model) {
  21013. var scale = axis.scale;
  21014. var originalExtent = scale.getExtent();
  21015. var span = originalExtent[1] - originalExtent[0];
  21016. if (scale.type === 'ordinal') {
  21017. // If series has no data, scale extent may be wrong
  21018. if (!isFinite(span)) {
  21019. return [0, 0];
  21020. }
  21021. else {
  21022. return originalExtent;
  21023. }
  21024. }
  21025. var min = model.getMin ? model.getMin() : model.get('min');
  21026. var max = model.getMax ? model.getMax() : model.get('max');
  21027. var crossZero = model.getNeedCrossZero
  21028. ? model.getNeedCrossZero() : !model.get('scale');
  21029. var boundaryGap = model.get('boundaryGap');
  21030. if (!zrUtil.isArray(boundaryGap)) {
  21031. boundaryGap = [boundaryGap || 0, boundaryGap || 0];
  21032. }
  21033. boundaryGap[0] = numberUtil.parsePercent(boundaryGap[0], 1);
  21034. boundaryGap[1] = numberUtil.parsePercent(boundaryGap[1], 1);
  21035. var fixMin = true;
  21036. var fixMax = true;
  21037. // Add boundary gap
  21038. if (min == null) {
  21039. min = originalExtent[0] - boundaryGap[0] * span;
  21040. fixMin = false;
  21041. }
  21042. if (max == null) {
  21043. max = originalExtent[1] + boundaryGap[1] * span;
  21044. fixMax = false;
  21045. }
  21046. if (min === 'dataMin') {
  21047. min = originalExtent[0];
  21048. }
  21049. if (max === 'dataMax') {
  21050. max = originalExtent[1];
  21051. }
  21052. // Evaluate if axis needs cross zero
  21053. if (crossZero) {
  21054. // Axis is over zero and min is not set
  21055. if (min > 0 && max > 0 && !fixMin) {
  21056. min = 0;
  21057. }
  21058. // Axis is under zero and max is not set
  21059. if (min < 0 && max < 0 && !fixMax) {
  21060. max = 0;
  21061. }
  21062. }
  21063. return [min, max];
  21064. };
  21065. axisHelper.niceScaleExtent = function (axis, model) {
  21066. var scale = axis.scale;
  21067. var extent = axisHelper.getScaleExtent(axis, model);
  21068. var fixMin = (model.getMin ? model.getMin() : model.get('min')) != null;
  21069. var fixMax = (model.getMax ? model.getMax() : model.get('max')) != null;
  21070. var splitNumber = model.get('splitNumber');
  21071. scale.setExtent(extent[0], extent[1]);
  21072. scale.niceExtent(splitNumber, fixMin, fixMax);
  21073. // Use minInterval to constraint the calculated interval.
  21074. // If calculated interval is less than minInterval. increase the interval quantity until
  21075. // it is larger than minInterval.
  21076. // For example:
  21077. // minInterval is 1, calculated interval is 0.2, so increase it to be 1. In this way we can get
  21078. // an integer axis.
  21079. var minInterval = model.get('minInterval');
  21080. if (isFinite(minInterval) && !fixMin && !fixMax && scale.type === 'interval') {
  21081. var interval = scale.getInterval();
  21082. var intervalScale = Math.max(Math.abs(interval), minInterval) / interval;
  21083. // while (interval < minInterval) {
  21084. // var quantity = numberUtil.quantity(interval);
  21085. // interval = quantity * 10;
  21086. // scaleQuantity *= 10;
  21087. // }
  21088. extent = scale.getExtent();
  21089. scale.setExtent(intervalScale * extent[0], extent[1] * intervalScale);
  21090. scale.niceExtent(splitNumber);
  21091. }
  21092. // If some one specified the min, max. And the default calculated interval
  21093. // is not good enough. He can specify the interval. It is often appeared
  21094. // in angle axis with angle 0 - 360. Interval calculated in interval scale is hard
  21095. // to be 60.
  21096. // FIXME
  21097. var interval = model.get('interval');
  21098. if (interval != null) {
  21099. scale.setInterval && scale.setInterval(interval);
  21100. }
  21101. };
  21102. /**
  21103. * @param {module:echarts/model/Model} model
  21104. * @param {string} [axisType] Default retrieve from model.type
  21105. * @return {module:echarts/scale/*}
  21106. */
  21107. axisHelper.createScaleByModel = function(model, axisType) {
  21108. axisType = axisType || model.get('type');
  21109. if (axisType) {
  21110. switch (axisType) {
  21111. // Buildin scale
  21112. case 'category':
  21113. return new OrdinalScale(
  21114. model.getCategories(), [Infinity, -Infinity]
  21115. );
  21116. case 'value':
  21117. return new IntervalScale();
  21118. // Extended scale, like time and log
  21119. default:
  21120. return (Scale.getClass(axisType) || IntervalScale).create(model);
  21121. }
  21122. }
  21123. };
  21124. /**
  21125. * Check if the axis corss 0
  21126. */
  21127. axisHelper.ifAxisCrossZero = function (axis) {
  21128. var dataExtent = axis.scale.getExtent();
  21129. var min = dataExtent[0];
  21130. var max = dataExtent[1];
  21131. return !((min > 0 && max > 0) || (min < 0 && max < 0));
  21132. };
  21133. /**
  21134. * @param {Array.<number>} tickCoords In axis self coordinate.
  21135. * @param {Array.<string>} labels
  21136. * @param {string} font
  21137. * @param {boolean} isAxisHorizontal
  21138. * @return {number}
  21139. */
  21140. axisHelper.getAxisLabelInterval = function (tickCoords, labels, font, isAxisHorizontal) {
  21141. // FIXME
  21142. // 不同角的axis和label,不只是horizontal和vertical.
  21143. var textSpaceTakenRect;
  21144. var autoLabelInterval = 0;
  21145. var accumulatedLabelInterval = 0;
  21146. var step = 1;
  21147. if (labels.length > 40) {
  21148. // Simple optimization for large amount of labels
  21149. step = Math.floor(labels.length / 40);
  21150. }
  21151. for (var i = 0; i < tickCoords.length; i += step) {
  21152. var tickCoord = tickCoords[i];
  21153. var rect = textContain.getBoundingRect(
  21154. labels[i], font, 'center', 'top'
  21155. );
  21156. rect[isAxisHorizontal ? 'x' : 'y'] += tickCoord;
  21157. // FIXME Magic number 1.5
  21158. rect[isAxisHorizontal ? 'width' : 'height'] *= 1.3;
  21159. if (!textSpaceTakenRect) {
  21160. textSpaceTakenRect = rect.clone();
  21161. }
  21162. // There is no space for current label;
  21163. else if (textSpaceTakenRect.intersect(rect)) {
  21164. accumulatedLabelInterval++;
  21165. autoLabelInterval = Math.max(autoLabelInterval, accumulatedLabelInterval);
  21166. }
  21167. else {
  21168. textSpaceTakenRect.union(rect);
  21169. // Reset
  21170. accumulatedLabelInterval = 0;
  21171. }
  21172. }
  21173. if (autoLabelInterval === 0 && step > 1) {
  21174. return step;
  21175. }
  21176. return (autoLabelInterval + 1) * step - 1;
  21177. };
  21178. /**
  21179. * @param {Object} axis
  21180. * @param {Function} labelFormatter
  21181. * @return {Array.<string>}
  21182. */
  21183. axisHelper.getFormattedLabels = function (axis, labelFormatter) {
  21184. var scale = axis.scale;
  21185. var labels = scale.getTicksLabels();
  21186. var ticks = scale.getTicks();
  21187. if (typeof labelFormatter === 'string') {
  21188. labelFormatter = (function (tpl) {
  21189. return function (val) {
  21190. return tpl.replace('{value}', val);
  21191. };
  21192. })(labelFormatter);
  21193. return zrUtil.map(labels, labelFormatter);
  21194. }
  21195. else if (typeof labelFormatter === 'function') {
  21196. return zrUtil.map(ticks, function (tick, idx) {
  21197. return labelFormatter(
  21198. axis.type === 'category' ? scale.getLabel(tick) : tick,
  21199. idx
  21200. );
  21201. }, this);
  21202. }
  21203. else {
  21204. return labels;
  21205. }
  21206. };
  21207. module.exports = axisHelper;
  21208. /***/ },
  21209. /* 115 */
  21210. /***/ function(module, exports, __webpack_require__) {
  21211. /**
  21212. * Linear continuous scale
  21213. * @module echarts/coord/scale/Ordinal
  21214. *
  21215. * http://en.wikipedia.org/wiki/Level_of_measurement
  21216. */
  21217. // FIXME only one data
  21218. var zrUtil = __webpack_require__(4);
  21219. var Scale = __webpack_require__(116);
  21220. var scaleProto = Scale.prototype;
  21221. var OrdinalScale = Scale.extend({
  21222. type: 'ordinal',
  21223. init: function (data, extent) {
  21224. this._data = data;
  21225. this._extent = extent || [0, data.length - 1];
  21226. },
  21227. parse: function (val) {
  21228. return typeof val === 'string'
  21229. ? zrUtil.indexOf(this._data, val)
  21230. // val might be float.
  21231. : Math.round(val);
  21232. },
  21233. contain: function (rank) {
  21234. rank = this.parse(rank);
  21235. return scaleProto.contain.call(this, rank)
  21236. && this._data[rank] != null;
  21237. },
  21238. /**
  21239. * Normalize given rank or name to linear [0, 1]
  21240. * @param {number|string} [val]
  21241. * @return {number}
  21242. */
  21243. normalize: function (val) {
  21244. return scaleProto.normalize.call(this, this.parse(val));
  21245. },
  21246. scale: function (val) {
  21247. return Math.round(scaleProto.scale.call(this, val));
  21248. },
  21249. /**
  21250. * @return {Array}
  21251. */
  21252. getTicks: function () {
  21253. var ticks = [];
  21254. var extent = this._extent;
  21255. var rank = extent[0];
  21256. while (rank <= extent[1]) {
  21257. ticks.push(rank);
  21258. rank++;
  21259. }
  21260. return ticks;
  21261. },
  21262. /**
  21263. * Get item on rank n
  21264. * @param {number} n
  21265. * @return {string}
  21266. */
  21267. getLabel: function (n) {
  21268. return this._data[n];
  21269. },
  21270. /**
  21271. * @return {number}
  21272. */
  21273. count: function () {
  21274. return this._extent[1] - this._extent[0] + 1;
  21275. },
  21276. niceTicks: zrUtil.noop,
  21277. niceExtent: zrUtil.noop
  21278. });
  21279. /**
  21280. * @return {module:echarts/scale/Time}
  21281. */
  21282. OrdinalScale.create = function () {
  21283. return new OrdinalScale();
  21284. };
  21285. module.exports = OrdinalScale;
  21286. /***/ },
  21287. /* 116 */
  21288. /***/ function(module, exports, __webpack_require__) {
  21289. /**
  21290. * // Scale class management
  21291. * @module echarts/scale/Scale
  21292. */
  21293. var clazzUtil = __webpack_require__(13);
  21294. function Scale() {
  21295. /**
  21296. * Extent
  21297. * @type {Array.<number>}
  21298. * @protected
  21299. */
  21300. this._extent = [Infinity, -Infinity];
  21301. /**
  21302. * Step is calculated in adjustExtent
  21303. * @type {Array.<number>}
  21304. * @protected
  21305. */
  21306. this._interval = 0;
  21307. this.init && this.init.apply(this, arguments);
  21308. }
  21309. var scaleProto = Scale.prototype;
  21310. /**
  21311. * Parse input val to valid inner number.
  21312. * @param {*} val
  21313. * @return {number}
  21314. */
  21315. scaleProto.parse = function (val) {
  21316. // Notice: This would be a trap here, If the implementation
  21317. // of this method depends on extent, and this method is used
  21318. // before extent set (like in dataZoom), it would be wrong.
  21319. // Nevertheless, parse does not depend on extent generally.
  21320. return val;
  21321. };
  21322. scaleProto.contain = function (val) {
  21323. var extent = this._extent;
  21324. return val >= extent[0] && val <= extent[1];
  21325. };
  21326. /**
  21327. * Normalize value to linear [0, 1], return 0.5 if extent span is 0
  21328. * @param {number} val
  21329. * @return {number}
  21330. */
  21331. scaleProto.normalize = function (val) {
  21332. var extent = this._extent;
  21333. if (extent[1] === extent[0]) {
  21334. return 0.5;
  21335. }
  21336. return (val - extent[0]) / (extent[1] - extent[0]);
  21337. };
  21338. /**
  21339. * Scale normalized value
  21340. * @param {number} val
  21341. * @return {number}
  21342. */
  21343. scaleProto.scale = function (val) {
  21344. var extent = this._extent;
  21345. return val * (extent[1] - extent[0]) + extent[0];
  21346. };
  21347. /**
  21348. * Set extent from data
  21349. * @param {Array.<number>} other
  21350. */
  21351. scaleProto.unionExtent = function (other) {
  21352. var extent = this._extent;
  21353. other[0] < extent[0] && (extent[0] = other[0]);
  21354. other[1] > extent[1] && (extent[1] = other[1]);
  21355. // not setExtent because in log axis it may transformed to power
  21356. // this.setExtent(extent[0], extent[1]);
  21357. };
  21358. /**
  21359. * Get extent
  21360. * @return {Array.<number>}
  21361. */
  21362. scaleProto.getExtent = function () {
  21363. return this._extent.slice();
  21364. };
  21365. /**
  21366. * Set extent
  21367. * @param {number} start
  21368. * @param {number} end
  21369. */
  21370. scaleProto.setExtent = function (start, end) {
  21371. var thisExtent = this._extent;
  21372. if (!isNaN(start)) {
  21373. thisExtent[0] = start;
  21374. }
  21375. if (!isNaN(end)) {
  21376. thisExtent[1] = end;
  21377. }
  21378. };
  21379. /**
  21380. * @return {Array.<string>}
  21381. */
  21382. scaleProto.getTicksLabels = function () {
  21383. var labels = [];
  21384. var ticks = this.getTicks();
  21385. for (var i = 0; i < ticks.length; i++) {
  21386. labels.push(this.getLabel(ticks[i]));
  21387. }
  21388. return labels;
  21389. };
  21390. clazzUtil.enableClassExtend(Scale);
  21391. clazzUtil.enableClassManagement(Scale, {
  21392. registerWhenExtend: true
  21393. });
  21394. module.exports = Scale;
  21395. /***/ },
  21396. /* 117 */
  21397. /***/ function(module, exports, __webpack_require__) {
  21398. /**
  21399. * Interval scale
  21400. * @module echarts/scale/Interval
  21401. */
  21402. var numberUtil = __webpack_require__(7);
  21403. var formatUtil = __webpack_require__(6);
  21404. var Scale = __webpack_require__(116);
  21405. var mathFloor = Math.floor;
  21406. var mathCeil = Math.ceil;
  21407. /**
  21408. * @alias module:echarts/coord/scale/Interval
  21409. * @constructor
  21410. */
  21411. var IntervalScale = Scale.extend({
  21412. type: 'interval',
  21413. _interval: 0,
  21414. setExtent: function (start, end) {
  21415. var thisExtent = this._extent;
  21416. //start,end may be a Number like '25',so...
  21417. if (!isNaN(start)) {
  21418. thisExtent[0] = parseFloat(start);
  21419. }
  21420. if (!isNaN(end)) {
  21421. thisExtent[1] = parseFloat(end);
  21422. }
  21423. },
  21424. unionExtent: function (other) {
  21425. var extent = this._extent;
  21426. other[0] < extent[0] && (extent[0] = other[0]);
  21427. other[1] > extent[1] && (extent[1] = other[1]);
  21428. // unionExtent may called by it's sub classes
  21429. IntervalScale.prototype.setExtent.call(this, extent[0], extent[1]);
  21430. },
  21431. /**
  21432. * Get interval
  21433. */
  21434. getInterval: function () {
  21435. if (!this._interval) {
  21436. this.niceTicks();
  21437. }
  21438. return this._interval;
  21439. },
  21440. /**
  21441. * Set interval
  21442. */
  21443. setInterval: function (interval) {
  21444. this._interval = interval;
  21445. // Dropped auto calculated niceExtent and use user setted extent
  21446. // We assume user wan't to set both interval, min, max to get a better result
  21447. this._niceExtent = this._extent.slice();
  21448. },
  21449. /**
  21450. * @return {Array.<number>}
  21451. */
  21452. getTicks: function () {
  21453. if (!this._interval) {
  21454. this.niceTicks();
  21455. }
  21456. var interval = this._interval;
  21457. var extent = this._extent;
  21458. var ticks = [];
  21459. // Consider this case: using dataZoom toolbox, zoom and zoom.
  21460. var safeLimit = 10000;
  21461. if (interval) {
  21462. var niceExtent = this._niceExtent;
  21463. if (extent[0] < niceExtent[0]) {
  21464. ticks.push(extent[0]);
  21465. }
  21466. var tick = niceExtent[0];
  21467. while (tick <= niceExtent[1]) {
  21468. ticks.push(tick);
  21469. // Avoid rounding error
  21470. tick = numberUtil.round(tick + interval);
  21471. if (ticks.length > safeLimit) {
  21472. return [];
  21473. }
  21474. }
  21475. if (extent[1] > niceExtent[1]) {
  21476. ticks.push(extent[1]);
  21477. }
  21478. }
  21479. return ticks;
  21480. },
  21481. /**
  21482. * @return {Array.<string>}
  21483. */
  21484. getTicksLabels: function () {
  21485. var labels = [];
  21486. var ticks = this.getTicks();
  21487. for (var i = 0; i < ticks.length; i++) {
  21488. labels.push(this.getLabel(ticks[i]));
  21489. }
  21490. return labels;
  21491. },
  21492. /**
  21493. * @param {number} n
  21494. * @return {number}
  21495. */
  21496. getLabel: function (data) {
  21497. return formatUtil.addCommas(data);
  21498. },
  21499. /**
  21500. * Update interval and extent of intervals for nice ticks
  21501. *
  21502. * @param {number} [splitNumber = 5] Desired number of ticks
  21503. */
  21504. niceTicks: function (splitNumber) {
  21505. splitNumber = splitNumber || 5;
  21506. var extent = this._extent;
  21507. var span = extent[1] - extent[0];
  21508. if (!isFinite(span)) {
  21509. return;
  21510. }
  21511. // User may set axis min 0 and data are all negative
  21512. // FIXME If it needs to reverse ?
  21513. if (span < 0) {
  21514. span = -span;
  21515. extent.reverse();
  21516. }
  21517. // From "Nice Numbers for Graph Labels" of Graphic Gems
  21518. // var niceSpan = numberUtil.nice(span, false);
  21519. var step = numberUtil.nice(span / splitNumber, true);
  21520. // Niced extent inside original extent
  21521. var niceExtent = [
  21522. numberUtil.round(mathCeil(extent[0] / step) * step),
  21523. numberUtil.round(mathFloor(extent[1] / step) * step)
  21524. ];
  21525. this._interval = step;
  21526. this._niceExtent = niceExtent;
  21527. },
  21528. /**
  21529. * Nice extent.
  21530. * @param {number} [splitNumber = 5] Given approx tick number
  21531. * @param {boolean} [fixMin=false]
  21532. * @param {boolean} [fixMax=false]
  21533. */
  21534. niceExtent: function (splitNumber, fixMin, fixMax) {
  21535. var extent = this._extent;
  21536. // If extent start and end are same, expand them
  21537. if (extent[0] === extent[1]) {
  21538. if (extent[0] !== 0) {
  21539. // Expand extent
  21540. var expandSize = extent[0];
  21541. // In the fowllowing case
  21542. // Axis has been fixed max 100
  21543. // Plus data are all 100 and axis extent are [100, 100].
  21544. // Extend to the both side will cause expanded max is larger than fixed max.
  21545. // So only expand to the smaller side.
  21546. if (!fixMax) {
  21547. extent[1] += expandSize / 2;
  21548. extent[0] -= expandSize / 2;
  21549. }
  21550. else {
  21551. extent[0] -= expandSize / 2;
  21552. }
  21553. }
  21554. else {
  21555. extent[1] = 1;
  21556. }
  21557. }
  21558. var span = extent[1] - extent[0];
  21559. // If there are no data and extent are [Infinity, -Infinity]
  21560. if (!isFinite(span)) {
  21561. extent[0] = 0;
  21562. extent[1] = 1;
  21563. }
  21564. this.niceTicks(splitNumber);
  21565. // var extent = this._extent;
  21566. var interval = this._interval;
  21567. if (!fixMin) {
  21568. extent[0] = numberUtil.round(mathFloor(extent[0] / interval) * interval);
  21569. }
  21570. if (!fixMax) {
  21571. extent[1] = numberUtil.round(mathCeil(extent[1] / interval) * interval);
  21572. }
  21573. }
  21574. });
  21575. /**
  21576. * @return {module:echarts/scale/Time}
  21577. */
  21578. IntervalScale.create = function () {
  21579. return new IntervalScale();
  21580. };
  21581. module.exports = IntervalScale;
  21582. /***/ },
  21583. /* 118 */
  21584. /***/ function(module, exports, __webpack_require__) {
  21585. /**
  21586. * Interval scale
  21587. * @module echarts/coord/scale/Time
  21588. */
  21589. var zrUtil = __webpack_require__(4);
  21590. var numberUtil = __webpack_require__(7);
  21591. var formatUtil = __webpack_require__(6);
  21592. var IntervalScale = __webpack_require__(117);
  21593. var intervalScaleProto = IntervalScale.prototype;
  21594. var mathCeil = Math.ceil;
  21595. var mathFloor = Math.floor;
  21596. var ONE_SECOND = 1000;
  21597. var ONE_MINUTE = ONE_SECOND * 60;
  21598. var ONE_HOUR = ONE_MINUTE * 60;
  21599. var ONE_DAY = ONE_HOUR * 24;
  21600. // FIXME 公用?
  21601. var bisect = function (a, x, lo, hi) {
  21602. while (lo < hi) {
  21603. var mid = lo + hi >>> 1;
  21604. if (a[mid][2] < x) {
  21605. lo = mid + 1;
  21606. }
  21607. else {
  21608. hi = mid;
  21609. }
  21610. }
  21611. return lo;
  21612. };
  21613. /**
  21614. * @alias module:echarts/coord/scale/Time
  21615. * @constructor
  21616. */
  21617. var TimeScale = IntervalScale.extend({
  21618. type: 'time',
  21619. // Overwrite
  21620. getLabel: function (val) {
  21621. var stepLvl = this._stepLvl;
  21622. var date = new Date(val);
  21623. return formatUtil.formatTime(stepLvl[0], date);
  21624. },
  21625. // Overwrite
  21626. niceExtent: function (approxTickNum, fixMin, fixMax) {
  21627. var extent = this._extent;
  21628. // If extent start and end are same, expand them
  21629. if (extent[0] === extent[1]) {
  21630. // Expand extent
  21631. extent[0] -= ONE_DAY;
  21632. extent[1] += ONE_DAY;
  21633. }
  21634. // If there are no data and extent are [Infinity, -Infinity]
  21635. if (extent[1] === -Infinity && extent[0] === Infinity) {
  21636. var d = new Date();
  21637. extent[1] = new Date(d.getFullYear(), d.getMonth(), d.getDate());
  21638. extent[0] = extent[1] - ONE_DAY;
  21639. }
  21640. this.niceTicks(approxTickNum);
  21641. // var extent = this._extent;
  21642. var interval = this._interval;
  21643. if (!fixMin) {
  21644. extent[0] = numberUtil.round(mathFloor(extent[0] / interval) * interval);
  21645. }
  21646. if (!fixMax) {
  21647. extent[1] = numberUtil.round(mathCeil(extent[1] / interval) * interval);
  21648. }
  21649. },
  21650. // Overwrite
  21651. niceTicks: function (approxTickNum) {
  21652. approxTickNum = approxTickNum || 10;
  21653. var extent = this._extent;
  21654. var span = extent[1] - extent[0];
  21655. var approxInterval = span / approxTickNum;
  21656. var scaleLevelsLen = scaleLevels.length;
  21657. var idx = bisect(scaleLevels, approxInterval, 0, scaleLevelsLen);
  21658. var level = scaleLevels[Math.min(idx, scaleLevelsLen - 1)];
  21659. var interval = level[2];
  21660. // Same with interval scale if span is much larger than 1 year
  21661. if (level[0] === 'year') {
  21662. var yearSpan = span / interval;
  21663. // From "Nice Numbers for Graph Labels" of Graphic Gems
  21664. // var niceYearSpan = numberUtil.nice(yearSpan, false);
  21665. var yearStep = numberUtil.nice(yearSpan / approxTickNum, true);
  21666. interval *= yearStep;
  21667. }
  21668. var niceExtent = [
  21669. mathCeil(extent[0] / interval) * interval,
  21670. mathFloor(extent[1] / interval) * interval
  21671. ];
  21672. this._stepLvl = level;
  21673. // Interval will be used in getTicks
  21674. this._interval = interval;
  21675. this._niceExtent = niceExtent;
  21676. },
  21677. parse: function (val) {
  21678. // val might be float.
  21679. return +numberUtil.parseDate(val);
  21680. }
  21681. });
  21682. zrUtil.each(['contain', 'normalize'], function (methodName) {
  21683. TimeScale.prototype[methodName] = function (val) {
  21684. return intervalScaleProto[methodName].call(this, this.parse(val));
  21685. };
  21686. });
  21687. // Steps from d3
  21688. var scaleLevels = [
  21689. // Format step interval
  21690. ['hh:mm:ss', 1, ONE_SECOND], // 1s
  21691. ['hh:mm:ss', 5, ONE_SECOND * 5], // 5s
  21692. ['hh:mm:ss', 10, ONE_SECOND * 10], // 10s
  21693. ['hh:mm:ss', 15, ONE_SECOND * 15], // 15s
  21694. ['hh:mm:ss', 30, ONE_SECOND * 30], // 30s
  21695. ['hh:mm\nMM-dd',1, ONE_MINUTE], // 1m
  21696. ['hh:mm\nMM-dd',5, ONE_MINUTE * 5], // 5m
  21697. ['hh:mm\nMM-dd',10, ONE_MINUTE * 10], // 10m
  21698. ['hh:mm\nMM-dd',15, ONE_MINUTE * 15], // 15m
  21699. ['hh:mm\nMM-dd',30, ONE_MINUTE * 30], // 30m
  21700. ['hh:mm\nMM-dd',1, ONE_HOUR], // 1h
  21701. ['hh:mm\nMM-dd',2, ONE_HOUR * 2], // 2h
  21702. ['hh:mm\nMM-dd',6, ONE_HOUR * 6], // 6h
  21703. ['hh:mm\nMM-dd',12, ONE_HOUR * 12], // 12h
  21704. ['MM-dd\nyyyy', 1, ONE_DAY], // 1d
  21705. ['week', 7, ONE_DAY * 7], // 7d
  21706. ['month', 1, ONE_DAY * 31], // 1M
  21707. ['quarter', 3, ONE_DAY * 380 / 4], // 3M
  21708. ['half-year', 6, ONE_DAY * 380 / 2], // 6M
  21709. ['year', 1, ONE_DAY * 380] // 1Y
  21710. ];
  21711. /**
  21712. * @return {module:echarts/scale/Time}
  21713. */
  21714. TimeScale.create = function () {
  21715. return new TimeScale();
  21716. };
  21717. module.exports = TimeScale;
  21718. /***/ },
  21719. /* 119 */
  21720. /***/ function(module, exports, __webpack_require__) {
  21721. /**
  21722. * Log scale
  21723. * @module echarts/scale/Log
  21724. */
  21725. var zrUtil = __webpack_require__(4);
  21726. var Scale = __webpack_require__(116);
  21727. var numberUtil = __webpack_require__(7);
  21728. // Use some method of IntervalScale
  21729. var IntervalScale = __webpack_require__(117);
  21730. var scaleProto = Scale.prototype;
  21731. var intervalScaleProto = IntervalScale.prototype;
  21732. var mathFloor = Math.floor;
  21733. var mathCeil = Math.ceil;
  21734. var mathPow = Math.pow;
  21735. var LOG_BASE = 10;
  21736. var mathLog = Math.log;
  21737. var LogScale = Scale.extend({
  21738. type: 'log',
  21739. /**
  21740. * @return {Array.<number>}
  21741. */
  21742. getTicks: function () {
  21743. return zrUtil.map(intervalScaleProto.getTicks.call(this), function (val) {
  21744. return numberUtil.round(mathPow(LOG_BASE, val));
  21745. });
  21746. },
  21747. /**
  21748. * @param {number} val
  21749. * @return {string}
  21750. */
  21751. getLabel: intervalScaleProto.getLabel,
  21752. /**
  21753. * @param {number} val
  21754. * @return {number}
  21755. */
  21756. scale: function (val) {
  21757. val = scaleProto.scale.call(this, val);
  21758. return mathPow(LOG_BASE, val);
  21759. },
  21760. /**
  21761. * @param {number} start
  21762. * @param {number} end
  21763. */
  21764. setExtent: function (start, end) {
  21765. start = mathLog(start) / mathLog(LOG_BASE);
  21766. end = mathLog(end) / mathLog(LOG_BASE);
  21767. intervalScaleProto.setExtent.call(this, start, end);
  21768. },
  21769. /**
  21770. * @return {number} end
  21771. */
  21772. getExtent: function () {
  21773. var extent = scaleProto.getExtent.call(this);
  21774. extent[0] = mathPow(LOG_BASE, extent[0]);
  21775. extent[1] = mathPow(LOG_BASE, extent[1]);
  21776. return extent;
  21777. },
  21778. /**
  21779. * @param {Array.<number>} extent
  21780. */
  21781. unionExtent: function (extent) {
  21782. extent[0] = mathLog(extent[0]) / mathLog(LOG_BASE);
  21783. extent[1] = mathLog(extent[1]) / mathLog(LOG_BASE);
  21784. scaleProto.unionExtent.call(this, extent);
  21785. },
  21786. /**
  21787. * Update interval and extent of intervals for nice ticks
  21788. * @param {number} [approxTickNum = 10] Given approx tick number
  21789. */
  21790. niceTicks: function (approxTickNum) {
  21791. approxTickNum = approxTickNum || 10;
  21792. var extent = this._extent;
  21793. var span = extent[1] - extent[0];
  21794. if (span === Infinity || span <= 0) {
  21795. return;
  21796. }
  21797. var interval = mathPow(10, mathFloor(mathLog(span / approxTickNum) / Math.LN10));
  21798. var err = approxTickNum / span * interval;
  21799. // Filter ticks to get closer to the desired count.
  21800. if (err <= 0.5) {
  21801. interval *= 10;
  21802. }
  21803. var niceExtent = [
  21804. numberUtil.round(mathCeil(extent[0] / interval) * interval),
  21805. numberUtil.round(mathFloor(extent[1] / interval) * interval)
  21806. ];
  21807. this._interval = interval;
  21808. this._niceExtent = niceExtent;
  21809. },
  21810. /**
  21811. * Nice extent.
  21812. * @param {number} [approxTickNum = 10] Given approx tick number
  21813. * @param {boolean} [fixMin=false]
  21814. * @param {boolean} [fixMax=false]
  21815. */
  21816. niceExtent: intervalScaleProto.niceExtent
  21817. });
  21818. zrUtil.each(['contain', 'normalize'], function (methodName) {
  21819. LogScale.prototype[methodName] = function (val) {
  21820. val = mathLog(val) / mathLog(LOG_BASE);
  21821. return scaleProto[methodName].call(this, val);
  21822. };
  21823. });
  21824. LogScale.create = function () {
  21825. return new LogScale();
  21826. };
  21827. module.exports = LogScale;
  21828. /***/ },
  21829. /* 120 */
  21830. /***/ function(module, exports, __webpack_require__) {
  21831. 'use strict';
  21832. var zrUtil = __webpack_require__(4);
  21833. var Cartesian = __webpack_require__(121);
  21834. function Cartesian2D(name) {
  21835. Cartesian.call(this, name);
  21836. }
  21837. Cartesian2D.prototype = {
  21838. constructor: Cartesian2D,
  21839. type: 'cartesian2d',
  21840. /**
  21841. * @type {Array.<string>}
  21842. * @readOnly
  21843. */
  21844. dimensions: ['x', 'y'],
  21845. /**
  21846. * Base axis will be used on stacking.
  21847. *
  21848. * @return {module:echarts/coord/cartesian/Axis2D}
  21849. */
  21850. getBaseAxis: function () {
  21851. return this.getAxesByScale('ordinal')[0]
  21852. || this.getAxesByScale('time')[0]
  21853. || this.getAxis('x');
  21854. },
  21855. /**
  21856. * If contain point
  21857. * @param {Array.<number>} point
  21858. * @return {boolean}
  21859. */
  21860. containPoint: function (point) {
  21861. var axisX = this.getAxis('x');
  21862. var axisY = this.getAxis('y');
  21863. return axisX.contain(axisX.toLocalCoord(point[0]))
  21864. && axisY.contain(axisY.toLocalCoord(point[1]));
  21865. },
  21866. /**
  21867. * If contain data
  21868. * @param {Array.<number>} data
  21869. * @return {boolean}
  21870. */
  21871. containData: function (data) {
  21872. return this.getAxis('x').containData(data[0])
  21873. && this.getAxis('y').containData(data[1]);
  21874. },
  21875. /**
  21876. * Convert series data to an array of points
  21877. * @param {module:echarts/data/List} data
  21878. * @param {boolean} stack
  21879. * @return {Array}
  21880. * Return array of points. For example:
  21881. * `[[10, 10], [20, 20], [30, 30]]`
  21882. */
  21883. dataToPoints: function (data, stack) {
  21884. return data.mapArray(['x', 'y'], function (x, y) {
  21885. return this.dataToPoint([x, y]);
  21886. }, stack, this);
  21887. },
  21888. /**
  21889. * @param {Array.<number>} data
  21890. * @param {boolean} [clamp=false]
  21891. * @return {Array.<number>}
  21892. */
  21893. dataToPoint: function (data, clamp) {
  21894. var xAxis = this.getAxis('x');
  21895. var yAxis = this.getAxis('y');
  21896. return [
  21897. xAxis.toGlobalCoord(xAxis.dataToCoord(data[0], clamp)),
  21898. yAxis.toGlobalCoord(yAxis.dataToCoord(data[1], clamp))
  21899. ];
  21900. },
  21901. /**
  21902. * @param {Array.<number>} point
  21903. * @param {boolean} [clamp=false]
  21904. * @return {Array.<number>}
  21905. */
  21906. pointToData: function (point, clamp) {
  21907. var xAxis = this.getAxis('x');
  21908. var yAxis = this.getAxis('y');
  21909. return [
  21910. xAxis.coordToData(xAxis.toLocalCoord(point[0]), clamp),
  21911. yAxis.coordToData(yAxis.toLocalCoord(point[1]), clamp)
  21912. ];
  21913. },
  21914. /**
  21915. * Get other axis
  21916. * @param {module:echarts/coord/cartesian/Axis2D} axis
  21917. */
  21918. getOtherAxis: function (axis) {
  21919. return this.getAxis(axis.dim === 'x' ? 'y' : 'x');
  21920. }
  21921. };
  21922. zrUtil.inherits(Cartesian2D, Cartesian);
  21923. module.exports = Cartesian2D;
  21924. /***/ },
  21925. /* 121 */
  21926. /***/ function(module, exports, __webpack_require__) {
  21927. 'use strict';
  21928. /**
  21929. * Cartesian coordinate system
  21930. * @module echarts/coord/Cartesian
  21931. *
  21932. */
  21933. var zrUtil = __webpack_require__(4);
  21934. function dimAxisMapper(dim) {
  21935. return this._axes[dim];
  21936. }
  21937. /**
  21938. * @alias module:echarts/coord/Cartesian
  21939. * @constructor
  21940. */
  21941. var Cartesian = function (name) {
  21942. this._axes = {};
  21943. this._dimList = [];
  21944. /**
  21945. * @type {string}
  21946. */
  21947. this.name = name || '';
  21948. };
  21949. Cartesian.prototype = {
  21950. constructor: Cartesian,
  21951. type: 'cartesian',
  21952. /**
  21953. * Get axis
  21954. * @param {number|string} dim
  21955. * @return {module:echarts/coord/Cartesian~Axis}
  21956. */
  21957. getAxis: function (dim) {
  21958. return this._axes[dim];
  21959. },
  21960. /**
  21961. * Get axes list
  21962. * @return {Array.<module:echarts/coord/Cartesian~Axis>}
  21963. */
  21964. getAxes: function () {
  21965. return zrUtil.map(this._dimList, dimAxisMapper, this);
  21966. },
  21967. /**
  21968. * Get axes list by given scale type
  21969. */
  21970. getAxesByScale: function (scaleType) {
  21971. scaleType = scaleType.toLowerCase();
  21972. return zrUtil.filter(
  21973. this.getAxes(),
  21974. function (axis) {
  21975. return axis.scale.type === scaleType;
  21976. }
  21977. );
  21978. },
  21979. /**
  21980. * Add axis
  21981. * @param {module:echarts/coord/Cartesian.Axis}
  21982. */
  21983. addAxis: function (axis) {
  21984. var dim = axis.dim;
  21985. this._axes[dim] = axis;
  21986. this._dimList.push(dim);
  21987. },
  21988. /**
  21989. * Convert data to coord in nd space
  21990. * @param {Array.<number>|Object.<string, number>} val
  21991. * @return {Array.<number>|Object.<string, number>}
  21992. */
  21993. dataToCoord: function (val) {
  21994. return this._dataCoordConvert(val, 'dataToCoord');
  21995. },
  21996. /**
  21997. * Convert coord in nd space to data
  21998. * @param {Array.<number>|Object.<string, number>} val
  21999. * @return {Array.<number>|Object.<string, number>}
  22000. */
  22001. coordToData: function (val) {
  22002. return this._dataCoordConvert(val, 'coordToData');
  22003. },
  22004. _dataCoordConvert: function (input, method) {
  22005. var dimList = this._dimList;
  22006. var output = input instanceof Array ? [] : {};
  22007. for (var i = 0; i < dimList.length; i++) {
  22008. var dim = dimList[i];
  22009. var axis = this._axes[dim];
  22010. output[dim] = axis[method](input[dim]);
  22011. }
  22012. return output;
  22013. }
  22014. };
  22015. module.exports = Cartesian;
  22016. /***/ },
  22017. /* 122 */
  22018. /***/ function(module, exports, __webpack_require__) {
  22019. var zrUtil = __webpack_require__(4);
  22020. var Axis = __webpack_require__(123);
  22021. var axisLabelInterval = __webpack_require__(124);
  22022. /**
  22023. * Extend axis 2d
  22024. * @constructor module:echarts/coord/cartesian/Axis2D
  22025. * @extends {module:echarts/coord/cartesian/Axis}
  22026. * @param {string} dim
  22027. * @param {*} scale
  22028. * @param {Array.<number>} coordExtent
  22029. * @param {string} axisType
  22030. * @param {string} position
  22031. */
  22032. var Axis2D = function (dim, scale, coordExtent, axisType, position) {
  22033. Axis.call(this, dim, scale, coordExtent);
  22034. /**
  22035. * Axis type
  22036. * - 'category'
  22037. * - 'value'
  22038. * - 'time'
  22039. * - 'log'
  22040. * @type {string}
  22041. */
  22042. this.type = axisType || 'value';
  22043. /**
  22044. * Axis position
  22045. * - 'top'
  22046. * - 'bottom'
  22047. * - 'left'
  22048. * - 'right'
  22049. */
  22050. this.position = position || 'bottom';
  22051. };
  22052. Axis2D.prototype = {
  22053. constructor: Axis2D,
  22054. /**
  22055. * Index of axis, can be used as key
  22056. */
  22057. index: 0,
  22058. /**
  22059. * If axis is on the zero position of the other axis
  22060. * @type {boolean}
  22061. */
  22062. onZero: false,
  22063. /**
  22064. * Axis model
  22065. * @param {module:echarts/coord/cartesian/AxisModel}
  22066. */
  22067. model: null,
  22068. isHorizontal: function () {
  22069. var position = this.position;
  22070. return position === 'top' || position === 'bottom';
  22071. },
  22072. getGlobalExtent: function () {
  22073. var ret = this.getExtent();
  22074. ret[0] = this.toGlobalCoord(ret[0]);
  22075. ret[1] = this.toGlobalCoord(ret[1]);
  22076. return ret;
  22077. },
  22078. /**
  22079. * @return {number}
  22080. */
  22081. getLabelInterval: function () {
  22082. var labelInterval = this._labelInterval;
  22083. if (!labelInterval) {
  22084. labelInterval = this._labelInterval = axisLabelInterval(this);
  22085. }
  22086. return labelInterval;
  22087. },
  22088. /**
  22089. * If label is ignored.
  22090. * Automatically used when axis is category and label can not be all shown
  22091. * @param {number} idx
  22092. * @return {boolean}
  22093. */
  22094. isLabelIgnored: function (idx) {
  22095. if (this.type === 'category') {
  22096. var labelInterval = this.getLabelInterval();
  22097. return ((typeof labelInterval === 'function')
  22098. && !labelInterval(idx, this.scale.getLabel(idx)))
  22099. || idx % (labelInterval + 1);
  22100. }
  22101. },
  22102. /**
  22103. * Transform global coord to local coord,
  22104. * i.e. var localCoord = axis.toLocalCoord(80);
  22105. * designate by module:echarts/coord/cartesian/Grid.
  22106. * @type {Function}
  22107. */
  22108. toLocalCoord: null,
  22109. /**
  22110. * Transform global coord to local coord,
  22111. * i.e. var globalCoord = axis.toLocalCoord(40);
  22112. * designate by module:echarts/coord/cartesian/Grid.
  22113. * @type {Function}
  22114. */
  22115. toGlobalCoord: null
  22116. };
  22117. zrUtil.inherits(Axis2D, Axis);
  22118. module.exports = Axis2D;
  22119. /***/ },
  22120. /* 123 */
  22121. /***/ function(module, exports, __webpack_require__) {
  22122. var numberUtil = __webpack_require__(7);
  22123. var linearMap = numberUtil.linearMap;
  22124. var zrUtil = __webpack_require__(4);
  22125. function fixExtentWithBands(extent, nTick) {
  22126. var size = extent[1] - extent[0];
  22127. var len = nTick;
  22128. var margin = size / len / 2;
  22129. extent[0] += margin;
  22130. extent[1] -= margin;
  22131. }
  22132. var normalizedExtent = [0, 1];
  22133. /**
  22134. * @name module:echarts/coord/CartesianAxis
  22135. * @constructor
  22136. */
  22137. var Axis = function (dim, scale, extent) {
  22138. /**
  22139. * Axis dimension. Such as 'x', 'y', 'z', 'angle', 'radius'
  22140. * @type {string}
  22141. */
  22142. this.dim = dim;
  22143. /**
  22144. * Axis scale
  22145. * @type {module:echarts/coord/scale/*}
  22146. */
  22147. this.scale = scale;
  22148. /**
  22149. * @type {Array.<number>}
  22150. * @private
  22151. */
  22152. this._extent = extent || [0, 0];
  22153. /**
  22154. * @type {boolean}
  22155. */
  22156. this.inverse = false;
  22157. /**
  22158. * Usually true when axis has a ordinal scale
  22159. * @type {boolean}
  22160. */
  22161. this.onBand = false;
  22162. };
  22163. Axis.prototype = {
  22164. constructor: Axis,
  22165. /**
  22166. * If axis extent contain given coord
  22167. * @param {number} coord
  22168. * @return {boolean}
  22169. */
  22170. contain: function (coord) {
  22171. var extent = this._extent;
  22172. var min = Math.min(extent[0], extent[1]);
  22173. var max = Math.max(extent[0], extent[1]);
  22174. return coord >= min && coord <= max;
  22175. },
  22176. /**
  22177. * If axis extent contain given data
  22178. * @param {number} data
  22179. * @return {boolean}
  22180. */
  22181. containData: function (data) {
  22182. return this.contain(this.dataToCoord(data));
  22183. },
  22184. /**
  22185. * Get coord extent.
  22186. * @return {Array.<number>}
  22187. */
  22188. getExtent: function () {
  22189. var ret = this._extent.slice();
  22190. return ret;
  22191. },
  22192. /**
  22193. * Get precision used for formatting
  22194. * @param {Array.<number>} [dataExtent]
  22195. * @return {number}
  22196. */
  22197. getPixelPrecision: function (dataExtent) {
  22198. return numberUtil.getPixelPrecision(
  22199. dataExtent || this.scale.getExtent(),
  22200. this._extent
  22201. );
  22202. },
  22203. /**
  22204. * Set coord extent
  22205. * @param {number} start
  22206. * @param {number} end
  22207. */
  22208. setExtent: function (start, end) {
  22209. var extent = this._extent;
  22210. extent[0] = start;
  22211. extent[1] = end;
  22212. },
  22213. /**
  22214. * Convert data to coord. Data is the rank if it has a ordinal scale
  22215. * @param {number} data
  22216. * @param {boolean} clamp
  22217. * @return {number}
  22218. */
  22219. dataToCoord: function (data, clamp) {
  22220. var extent = this._extent;
  22221. var scale = this.scale;
  22222. data = scale.normalize(data);
  22223. if (this.onBand && scale.type === 'ordinal') {
  22224. extent = extent.slice();
  22225. fixExtentWithBands(extent, scale.count());
  22226. }
  22227. return linearMap(data, normalizedExtent, extent, clamp);
  22228. },
  22229. /**
  22230. * Convert coord to data. Data is the rank if it has a ordinal scale
  22231. * @param {number} coord
  22232. * @param {boolean} clamp
  22233. * @return {number}
  22234. */
  22235. coordToData: function (coord, clamp) {
  22236. var extent = this._extent;
  22237. var scale = this.scale;
  22238. if (this.onBand && scale.type === 'ordinal') {
  22239. extent = extent.slice();
  22240. fixExtentWithBands(extent, scale.count());
  22241. }
  22242. var t = linearMap(coord, extent, normalizedExtent, clamp);
  22243. return this.scale.scale(t);
  22244. },
  22245. /**
  22246. * @return {Array.<number>}
  22247. */
  22248. getTicksCoords: function (alignWithLabel) {
  22249. if (this.onBand && !alignWithLabel) {
  22250. var bands = this.getBands();
  22251. var coords = [];
  22252. for (var i = 0; i < bands.length; i++) {
  22253. coords.push(bands[i][0]);
  22254. }
  22255. if (bands[i - 1]) {
  22256. coords.push(bands[i - 1][1]);
  22257. }
  22258. return coords;
  22259. }
  22260. else {
  22261. return zrUtil.map(this.scale.getTicks(), this.dataToCoord, this);
  22262. }
  22263. },
  22264. /**
  22265. * Coords of labels are on the ticks or on the middle of bands
  22266. * @return {Array.<number>}
  22267. */
  22268. getLabelsCoords: function () {
  22269. return zrUtil.map(this.scale.getTicks(), this.dataToCoord, this);
  22270. },
  22271. /**
  22272. * Get bands.
  22273. *
  22274. * If axis has labels [1, 2, 3, 4]. Bands on the axis are
  22275. * |---1---|---2---|---3---|---4---|.
  22276. *
  22277. * @return {Array}
  22278. */
  22279. // FIXME Situation when labels is on ticks
  22280. getBands: function () {
  22281. var extent = this.getExtent();
  22282. var bands = [];
  22283. var len = this.scale.count();
  22284. var start = extent[0];
  22285. var end = extent[1];
  22286. var span = end - start;
  22287. for (var i = 0; i < len; i++) {
  22288. bands.push([
  22289. span * i / len + start,
  22290. span * (i + 1) / len + start
  22291. ]);
  22292. }
  22293. return bands;
  22294. },
  22295. /**
  22296. * Get width of band
  22297. * @return {number}
  22298. */
  22299. getBandWidth: function () {
  22300. var axisExtent = this._extent;
  22301. var dataExtent = this.scale.getExtent();
  22302. var len = dataExtent[1] - dataExtent[0] + (this.onBand ? 1 : 0);
  22303. // Fix #2728, avoid NaN when only one data.
  22304. len === 0 && (len = 1);
  22305. var size = Math.abs(axisExtent[1] - axisExtent[0]);
  22306. return Math.abs(size) / len;
  22307. }
  22308. };
  22309. module.exports = Axis;
  22310. /***/ },
  22311. /* 124 */
  22312. /***/ function(module, exports, __webpack_require__) {
  22313. 'use strict';
  22314. /**
  22315. * Helper function for axisLabelInterval calculation
  22316. */
  22317. var zrUtil = __webpack_require__(4);
  22318. var axisHelper = __webpack_require__(114);
  22319. module.exports = function (axis) {
  22320. var axisModel = axis.model;
  22321. var labelModel = axisModel.getModel('axisLabel');
  22322. var labelInterval = labelModel.get('interval');
  22323. if (!(axis.type === 'category' && labelInterval === 'auto')) {
  22324. return labelInterval === 'auto' ? 0 : labelInterval;
  22325. }
  22326. return axisHelper.getAxisLabelInterval(
  22327. zrUtil.map(axis.scale.getTicks(), axis.dataToCoord, axis),
  22328. axisModel.getFormattedLabels(),
  22329. labelModel.getModel('textStyle').getFont(),
  22330. axis.isHorizontal()
  22331. );
  22332. };
  22333. /***/ },
  22334. /* 125 */
  22335. /***/ function(module, exports, __webpack_require__) {
  22336. 'use strict';
  22337. // Grid 是在有直角坐标系的时候必须要存在的
  22338. // 所以这里也要被 Cartesian2D 依赖
  22339. __webpack_require__(126);
  22340. var ComponentModel = __webpack_require__(19);
  22341. module.exports = ComponentModel.extend({
  22342. type: 'grid',
  22343. dependencies: ['xAxis', 'yAxis'],
  22344. layoutMode: 'box',
  22345. /**
  22346. * @type {module:echarts/coord/cartesian/Grid}
  22347. */
  22348. coordinateSystem: null,
  22349. defaultOption: {
  22350. show: false,
  22351. zlevel: 0,
  22352. z: 0,
  22353. left: '10%',
  22354. top: 60,
  22355. right: '10%',
  22356. bottom: 60,
  22357. // If grid size contain label
  22358. containLabel: false,
  22359. // width: {totalWidth} - left - right,
  22360. // height: {totalHeight} - top - bottom,
  22361. backgroundColor: 'rgba(0,0,0,0)',
  22362. borderWidth: 1,
  22363. borderColor: '#ccc'
  22364. }
  22365. });
  22366. /***/ },
  22367. /* 126 */
  22368. /***/ function(module, exports, __webpack_require__) {
  22369. 'use strict';
  22370. var ComponentModel = __webpack_require__(19);
  22371. var zrUtil = __webpack_require__(4);
  22372. var axisModelCreator = __webpack_require__(127);
  22373. var AxisModel = ComponentModel.extend({
  22374. type: 'cartesian2dAxis',
  22375. /**
  22376. * @type {module:echarts/coord/cartesian/Axis2D}
  22377. */
  22378. axis: null,
  22379. /**
  22380. * @override
  22381. */
  22382. init: function () {
  22383. AxisModel.superApply(this, 'init', arguments);
  22384. this._resetRange();
  22385. },
  22386. /**
  22387. * @override
  22388. */
  22389. mergeOption: function () {
  22390. AxisModel.superApply(this, 'mergeOption', arguments);
  22391. this._resetRange();
  22392. },
  22393. /**
  22394. * @override
  22395. */
  22396. restoreData: function () {
  22397. AxisModel.superApply(this, 'restoreData', arguments);
  22398. this._resetRange();
  22399. },
  22400. /**
  22401. * @public
  22402. * @param {number} rangeStart
  22403. * @param {number} rangeEnd
  22404. */
  22405. setRange: function (rangeStart, rangeEnd) {
  22406. this.option.rangeStart = rangeStart;
  22407. this.option.rangeEnd = rangeEnd;
  22408. },
  22409. /**
  22410. * @public
  22411. * @return {Array.<number|string|Date>}
  22412. */
  22413. getMin: function () {
  22414. var option = this.option;
  22415. return option.rangeStart != null ? option.rangeStart : option.min;
  22416. },
  22417. /**
  22418. * @public
  22419. * @return {Array.<number|string|Date>}
  22420. */
  22421. getMax: function () {
  22422. var option = this.option;
  22423. return option.rangeEnd != null ? option.rangeEnd : option.max;
  22424. },
  22425. /**
  22426. * @public
  22427. * @return {boolean}
  22428. */
  22429. getNeedCrossZero: function () {
  22430. var option = this.option;
  22431. return (option.rangeStart != null || option.rangeEnd != null)
  22432. ? false : !option.scale;
  22433. },
  22434. /**
  22435. * @private
  22436. */
  22437. _resetRange: function () {
  22438. // rangeStart and rangeEnd is readonly.
  22439. this.option.rangeStart = this.option.rangeEnd = null;
  22440. }
  22441. });
  22442. function getAxisType(axisDim, option) {
  22443. // Default axis with data is category axis
  22444. return option.type || (option.data ? 'category' : 'value');
  22445. }
  22446. zrUtil.merge(AxisModel.prototype, __webpack_require__(129));
  22447. var extraOption = {
  22448. gridIndex: 0,
  22449. // Offset is for multiple axis on the same position
  22450. offset: 0
  22451. };
  22452. axisModelCreator('x', AxisModel, getAxisType, extraOption);
  22453. axisModelCreator('y', AxisModel, getAxisType, extraOption);
  22454. module.exports = AxisModel;
  22455. /***/ },
  22456. /* 127 */
  22457. /***/ function(module, exports, __webpack_require__) {
  22458. var axisDefault = __webpack_require__(128);
  22459. var zrUtil = __webpack_require__(4);
  22460. var ComponentModel = __webpack_require__(19);
  22461. var layout = __webpack_require__(21);
  22462. // FIXME axisType is fixed ?
  22463. var AXIS_TYPES = ['value', 'category', 'time', 'log'];
  22464. /**
  22465. * Generate sub axis model class
  22466. * @param {string} axisName 'x' 'y' 'radius' 'angle' 'parallel'
  22467. * @param {module:echarts/model/Component} BaseAxisModelClass
  22468. * @param {Function} axisTypeDefaulter
  22469. * @param {Object} [extraDefaultOption]
  22470. */
  22471. module.exports = function (axisName, BaseAxisModelClass, axisTypeDefaulter, extraDefaultOption) {
  22472. zrUtil.each(AXIS_TYPES, function (axisType) {
  22473. BaseAxisModelClass.extend({
  22474. type: axisName + 'Axis.' + axisType,
  22475. mergeDefaultAndTheme: function (option, ecModel) {
  22476. var layoutMode = this.layoutMode;
  22477. var inputPositionParams = layoutMode
  22478. ? layout.getLayoutParams(option) : {};
  22479. var themeModel = ecModel.getTheme();
  22480. zrUtil.merge(option, themeModel.get(axisType + 'Axis'));
  22481. zrUtil.merge(option, this.getDefaultOption());
  22482. option.type = axisTypeDefaulter(axisName, option);
  22483. if (layoutMode) {
  22484. layout.mergeLayoutParam(option, inputPositionParams, layoutMode);
  22485. }
  22486. },
  22487. defaultOption: zrUtil.mergeAll(
  22488. [
  22489. {},
  22490. axisDefault[axisType + 'Axis'],
  22491. extraDefaultOption
  22492. ],
  22493. true
  22494. )
  22495. });
  22496. });
  22497. ComponentModel.registerSubTypeDefaulter(
  22498. axisName + 'Axis',
  22499. zrUtil.curry(axisTypeDefaulter, axisName)
  22500. );
  22501. };
  22502. /***/ },
  22503. /* 128 */
  22504. /***/ function(module, exports, __webpack_require__) {
  22505. var zrUtil = __webpack_require__(4);
  22506. var defaultOption = {
  22507. show: true,
  22508. zlevel: 0, // 一级层叠
  22509. z: 0, // 二级层叠
  22510. // 反向坐标轴
  22511. inverse: false,
  22512. // 坐标轴名字,默认为空
  22513. name: '',
  22514. // 坐标轴名字位置,支持'start' | 'middle' | 'end'
  22515. nameLocation: 'end',
  22516. // 坐标轴名字旋转,degree。
  22517. nameRotate: null, // Adapt to axis rotate, when nameLocation is 'middle'.
  22518. nameTruncate: {
  22519. maxWidth: null,
  22520. ellipsis: '...',
  22521. placeholder: '.'
  22522. },
  22523. // 坐标轴文字样式,默认取全局样式
  22524. nameTextStyle: {},
  22525. // 文字与轴线距离
  22526. nameGap: 15,
  22527. silent: false, // Default false to support tooltip.
  22528. triggerEvent: false, // Default false to avoid legacy user event listener fail.
  22529. tooltip: {
  22530. show: false
  22531. },
  22532. // 坐标轴线
  22533. axisLine: {
  22534. // 默认显示,属性show控制显示与否
  22535. show: true,
  22536. onZero: true,
  22537. // 属性lineStyle控制线条样式
  22538. lineStyle: {
  22539. color: '#333',
  22540. width: 1,
  22541. type: 'solid'
  22542. }
  22543. },
  22544. // 坐标轴小标记
  22545. axisTick: {
  22546. // 属性show控制显示与否,默认显示
  22547. show: true,
  22548. // 控制小标记是否在grid里
  22549. inside: false,
  22550. // 属性length控制线长
  22551. length: 5,
  22552. // 属性lineStyle控制线条样式
  22553. lineStyle: {
  22554. width: 1
  22555. }
  22556. },
  22557. // 坐标轴文本标签,详见axis.axisLabel
  22558. axisLabel: {
  22559. show: true,
  22560. // 控制文本标签是否在grid里
  22561. inside: false,
  22562. rotate: 0,
  22563. margin: 8,
  22564. // formatter: null,
  22565. // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  22566. textStyle: {
  22567. fontSize: 12
  22568. }
  22569. },
  22570. // 分隔线
  22571. splitLine: {
  22572. // 默认显示,属性show控制显示与否
  22573. show: true,
  22574. // 属性lineStyle(详见lineStyle)控制线条样式
  22575. lineStyle: {
  22576. color: ['#ccc'],
  22577. width: 1,
  22578. type: 'solid'
  22579. }
  22580. },
  22581. // 分隔区域
  22582. splitArea: {
  22583. // 默认不显示,属性show控制显示与否
  22584. show: false,
  22585. // 属性areaStyle(详见areaStyle)控制区域样式
  22586. areaStyle: {
  22587. color: ['rgba(250,250,250,0.3)','rgba(200,200,200,0.3)']
  22588. }
  22589. }
  22590. };
  22591. var categoryAxis = zrUtil.merge({
  22592. // 类目起始和结束两端空白策略
  22593. boundaryGap: true,
  22594. // splitArea: {
  22595. // show: false
  22596. // },
  22597. splitLine: {
  22598. show: false
  22599. },
  22600. // 坐标轴小标记
  22601. axisTick: {
  22602. // If tick is align with label when boundaryGap is true
  22603. // Default with axisTick
  22604. alignWithLabel: false,
  22605. interval: 'auto'
  22606. },
  22607. // 坐标轴文本标签,详见axis.axisLabel
  22608. axisLabel: {
  22609. interval: 'auto'
  22610. }
  22611. }, defaultOption);
  22612. var valueAxis = zrUtil.merge({
  22613. // 数值起始和结束两端空白策略
  22614. boundaryGap: [0, 0],
  22615. // 最小值, 设置成 'dataMin' 则从数据中计算最小值
  22616. // min: null,
  22617. // 最大值,设置成 'dataMax' 则从数据中计算最大值
  22618. // max: null,
  22619. // Readonly prop, specifies start value of the range when using data zoom.
  22620. // rangeStart: null
  22621. // Readonly prop, specifies end value of the range when using data zoom.
  22622. // rangeEnd: null
  22623. // 脱离0值比例,放大聚焦到最终_min,_max区间
  22624. // scale: false,
  22625. // 分割段数,默认为5
  22626. splitNumber: 5
  22627. // Minimum interval
  22628. // minInterval: null
  22629. }, defaultOption);
  22630. // FIXME
  22631. var timeAxis = zrUtil.defaults({
  22632. scale: true,
  22633. min: 'dataMin',
  22634. max: 'dataMax'
  22635. }, valueAxis);
  22636. var logAxis = zrUtil.defaults({}, valueAxis);
  22637. logAxis.scale = true;
  22638. module.exports = {
  22639. categoryAxis: categoryAxis,
  22640. valueAxis: valueAxis,
  22641. timeAxis: timeAxis,
  22642. logAxis: logAxis
  22643. };
  22644. /***/ },
  22645. /* 129 */
  22646. /***/ function(module, exports, __webpack_require__) {
  22647. var zrUtil = __webpack_require__(4);
  22648. var axisHelper = __webpack_require__(114);
  22649. function getName(obj) {
  22650. if (zrUtil.isObject(obj) && obj.value != null) {
  22651. return obj.value;
  22652. }
  22653. else {
  22654. return obj;
  22655. }
  22656. }
  22657. /**
  22658. * Get categories
  22659. */
  22660. function getCategories() {
  22661. return this.get('type') === 'category'
  22662. && zrUtil.map(this.get('data'), getName);
  22663. }
  22664. /**
  22665. * Format labels
  22666. * @return {Array.<string>}
  22667. */
  22668. function getFormattedLabels() {
  22669. return axisHelper.getFormattedLabels(
  22670. this.axis,
  22671. this.get('axisLabel.formatter')
  22672. );
  22673. }
  22674. module.exports = {
  22675. getFormattedLabels: getFormattedLabels,
  22676. getCategories: getCategories
  22677. };
  22678. /***/ },
  22679. /* 130 */
  22680. /***/ function(module, exports, __webpack_require__) {
  22681. 'use strict';
  22682. // TODO boundaryGap
  22683. __webpack_require__(126);
  22684. __webpack_require__(131);
  22685. /***/ },
  22686. /* 131 */
  22687. /***/ function(module, exports, __webpack_require__) {
  22688. var zrUtil = __webpack_require__(4);
  22689. var graphic = __webpack_require__(43);
  22690. var AxisBuilder = __webpack_require__(132);
  22691. var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick;
  22692. var getInterval = AxisBuilder.getInterval;
  22693. var axisBuilderAttrs = [
  22694. 'axisLine', 'axisLabel', 'axisTick', 'axisName'
  22695. ];
  22696. var selfBuilderAttrs = [
  22697. 'splitArea', 'splitLine'
  22698. ];
  22699. // function getAlignWithLabel(model, axisModel) {
  22700. // var alignWithLabel = model.get('alignWithLabel');
  22701. // if (alignWithLabel === 'auto') {
  22702. // alignWithLabel = axisModel.get('axisTick.alignWithLabel');
  22703. // }
  22704. // return alignWithLabel;
  22705. // }
  22706. var AxisView = __webpack_require__(1).extendComponentView({
  22707. type: 'axis',
  22708. render: function (axisModel, ecModel) {
  22709. this.group.removeAll();
  22710. var oldAxisGroup = this._axisGroup;
  22711. this._axisGroup = new graphic.Group();
  22712. this.group.add(this._axisGroup);
  22713. if (!axisModel.get('show')) {
  22714. return;
  22715. }
  22716. var gridModel = ecModel.getComponent('grid', axisModel.get('gridIndex'));
  22717. var layout = layoutAxis(gridModel, axisModel);
  22718. var axisBuilder = new AxisBuilder(axisModel, layout);
  22719. zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder);
  22720. this._axisGroup.add(axisBuilder.getGroup());
  22721. zrUtil.each(selfBuilderAttrs, function (name) {
  22722. if (axisModel.get(name + '.show')) {
  22723. this['_' + name](axisModel, gridModel, layout.labelInterval);
  22724. }
  22725. }, this);
  22726. graphic.groupTransition(oldAxisGroup, this._axisGroup, axisModel);
  22727. },
  22728. /**
  22729. * @param {module:echarts/coord/cartesian/AxisModel} axisModel
  22730. * @param {module:echarts/coord/cartesian/GridModel} gridModel
  22731. * @param {number|Function} labelInterval
  22732. * @private
  22733. */
  22734. _splitLine: function (axisModel, gridModel, labelInterval) {
  22735. var axis = axisModel.axis;
  22736. var splitLineModel = axisModel.getModel('splitLine');
  22737. var lineStyleModel = splitLineModel.getModel('lineStyle');
  22738. var lineColors = lineStyleModel.get('color');
  22739. var lineInterval = getInterval(splitLineModel, labelInterval);
  22740. lineColors = zrUtil.isArray(lineColors) ? lineColors : [lineColors];
  22741. var gridRect = gridModel.coordinateSystem.getRect();
  22742. var isHorizontal = axis.isHorizontal();
  22743. var lineCount = 0;
  22744. var ticksCoords = axis.getTicksCoords(
  22745. // splitLineModel.get('alignWithLabel')
  22746. );
  22747. var ticks = axis.scale.getTicks();
  22748. var p1 = [];
  22749. var p2 = [];
  22750. // Simple optimization
  22751. // Batching the lines if color are the same
  22752. var lineStyle = lineStyleModel.getLineStyle();
  22753. for (var i = 0; i < ticksCoords.length; i++) {
  22754. if (ifIgnoreOnTick(axis, i, lineInterval)) {
  22755. continue;
  22756. }
  22757. var tickCoord = axis.toGlobalCoord(ticksCoords[i]);
  22758. if (isHorizontal) {
  22759. p1[0] = tickCoord;
  22760. p1[1] = gridRect.y;
  22761. p2[0] = tickCoord;
  22762. p2[1] = gridRect.y + gridRect.height;
  22763. }
  22764. else {
  22765. p1[0] = gridRect.x;
  22766. p1[1] = tickCoord;
  22767. p2[0] = gridRect.x + gridRect.width;
  22768. p2[1] = tickCoord;
  22769. }
  22770. var colorIndex = (lineCount++) % lineColors.length;
  22771. this._axisGroup.add(new graphic.Line(graphic.subPixelOptimizeLine({
  22772. anid: 'line_' + ticks[i],
  22773. shape: {
  22774. x1: p1[0],
  22775. y1: p1[1],
  22776. x2: p2[0],
  22777. y2: p2[1]
  22778. },
  22779. style: zrUtil.defaults({
  22780. stroke: lineColors[colorIndex]
  22781. }, lineStyle),
  22782. silent: true
  22783. })));
  22784. }
  22785. },
  22786. /**
  22787. * @param {module:echarts/coord/cartesian/AxisModel} axisModel
  22788. * @param {module:echarts/coord/cartesian/GridModel} gridModel
  22789. * @param {number|Function} labelInterval
  22790. * @private
  22791. */
  22792. _splitArea: function (axisModel, gridModel, labelInterval) {
  22793. var axis = axisModel.axis;
  22794. var splitAreaModel = axisModel.getModel('splitArea');
  22795. var areaStyleModel = splitAreaModel.getModel('areaStyle');
  22796. var areaColors = areaStyleModel.get('color');
  22797. var gridRect = gridModel.coordinateSystem.getRect();
  22798. var ticksCoords = axis.getTicksCoords(
  22799. // splitAreaModel.get('alignWithLabel')
  22800. );
  22801. var ticks = axis.scale.getTicks();
  22802. var prevX = axis.toGlobalCoord(ticksCoords[0]);
  22803. var prevY = axis.toGlobalCoord(ticksCoords[0]);
  22804. var count = 0;
  22805. var areaInterval = getInterval(splitAreaModel, labelInterval);
  22806. var areaStyle = areaStyleModel.getAreaStyle();
  22807. areaColors = zrUtil.isArray(areaColors) ? areaColors : [areaColors];
  22808. for (var i = 1; i < ticksCoords.length; i++) {
  22809. if (ifIgnoreOnTick(axis, i, areaInterval)) {
  22810. continue;
  22811. }
  22812. var tickCoord = axis.toGlobalCoord(ticksCoords[i]);
  22813. var x;
  22814. var y;
  22815. var width;
  22816. var height;
  22817. if (axis.isHorizontal()) {
  22818. x = prevX;
  22819. y = gridRect.y;
  22820. width = tickCoord - x;
  22821. height = gridRect.height;
  22822. }
  22823. else {
  22824. x = gridRect.x;
  22825. y = prevY;
  22826. width = gridRect.width;
  22827. height = tickCoord - y;
  22828. }
  22829. var colorIndex = (count++) % areaColors.length;
  22830. this._axisGroup.add(new graphic.Rect({
  22831. anid: 'area_' + ticks[i],
  22832. shape: {
  22833. x: x,
  22834. y: y,
  22835. width: width,
  22836. height: height
  22837. },
  22838. style: zrUtil.defaults({
  22839. fill: areaColors[colorIndex]
  22840. }, areaStyle),
  22841. silent: true
  22842. }));
  22843. prevX = x + width;
  22844. prevY = y + height;
  22845. }
  22846. }
  22847. });
  22848. AxisView.extend({
  22849. type: 'xAxis'
  22850. });
  22851. AxisView.extend({
  22852. type: 'yAxis'
  22853. });
  22854. /**
  22855. * @inner
  22856. */
  22857. function layoutAxis(gridModel, axisModel) {
  22858. var grid = gridModel.coordinateSystem;
  22859. var axis = axisModel.axis;
  22860. var layout = {};
  22861. var rawAxisPosition = axis.position;
  22862. var axisPosition = axis.onZero ? 'onZero' : rawAxisPosition;
  22863. var axisDim = axis.dim;
  22864. // [left, right, top, bottom]
  22865. var rect = grid.getRect();
  22866. var rectBound = [rect.x, rect.x + rect.width, rect.y, rect.y + rect.height];
  22867. var axisOffset = axisModel.get('offset') || 0;
  22868. var posMap = {
  22869. x: { top: rectBound[2] - axisOffset, bottom: rectBound[3] + axisOffset },
  22870. y: { left: rectBound[0] - axisOffset, right: rectBound[1] + axisOffset }
  22871. };
  22872. posMap.x.onZero = Math.max(Math.min(getZero('y'), posMap.x.bottom), posMap.x.top);
  22873. posMap.y.onZero = Math.max(Math.min(getZero('x'), posMap.y.right), posMap.y.left);
  22874. function getZero(dim, val) {
  22875. var theAxis = grid.getAxis(dim);
  22876. return theAxis.toGlobalCoord(theAxis.dataToCoord(0));
  22877. }
  22878. // Axis position
  22879. layout.position = [
  22880. axisDim === 'y' ? posMap.y[axisPosition] : rectBound[0],
  22881. axisDim === 'x' ? posMap.x[axisPosition] : rectBound[3]
  22882. ];
  22883. // Axis rotation
  22884. layout.rotation = Math.PI / 2 * (axisDim === 'x' ? 0 : 1);
  22885. // Tick and label direction, x y is axisDim
  22886. var dirMap = {top: -1, bottom: 1, left: -1, right: 1};
  22887. layout.labelDirection = layout.tickDirection = layout.nameDirection = dirMap[rawAxisPosition];
  22888. if (axis.onZero) {
  22889. layout.labelOffset = posMap[axisDim][rawAxisPosition] - posMap[axisDim].onZero;
  22890. }
  22891. if (axisModel.getModel('axisTick').get('inside')) {
  22892. layout.tickDirection = -layout.tickDirection;
  22893. }
  22894. if (axisModel.getModel('axisLabel').get('inside')) {
  22895. layout.labelDirection = -layout.labelDirection;
  22896. }
  22897. // Special label rotation
  22898. var labelRotation = axisModel.getModel('axisLabel').get('rotate');
  22899. layout.labelRotation = axisPosition === 'top' ? -labelRotation : labelRotation;
  22900. // label interval when auto mode.
  22901. layout.labelInterval = axis.getLabelInterval();
  22902. // Over splitLine and splitArea
  22903. layout.z2 = 1;
  22904. return layout;
  22905. }
  22906. /***/ },
  22907. /* 132 */
  22908. /***/ function(module, exports, __webpack_require__) {
  22909. var zrUtil = __webpack_require__(4);
  22910. var formatUtil = __webpack_require__(6);
  22911. var graphic = __webpack_require__(43);
  22912. var Model = __webpack_require__(12);
  22913. var numberUtil = __webpack_require__(7);
  22914. var remRadian = numberUtil.remRadian;
  22915. var isRadianAroundZero = numberUtil.isRadianAroundZero;
  22916. var vec2 = __webpack_require__(10);
  22917. var v2ApplyTransform = vec2.applyTransform;
  22918. var retrieve = zrUtil.retrieve;
  22919. var PI = Math.PI;
  22920. function makeAxisEventDataBase(axisModel) {
  22921. var eventData = {
  22922. componentType: axisModel.mainType
  22923. };
  22924. eventData[axisModel.mainType + 'Index'] = axisModel.componentIndex;
  22925. return eventData;
  22926. }
  22927. /**
  22928. * A final axis is translated and rotated from a "standard axis".
  22929. * So opt.position and opt.rotation is required.
  22930. *
  22931. * A standard axis is and axis from [0, 0] to [0, axisExtent[1]],
  22932. * for example: (0, 0) ------------> (0, 50)
  22933. *
  22934. * nameDirection or tickDirection or labelDirection is 1 means tick
  22935. * or label is below the standard axis, whereas is -1 means above
  22936. * the standard axis. labelOffset means offset between label and axis,
  22937. * which is useful when 'onZero', where axisLabel is in the grid and
  22938. * label in outside grid.
  22939. *
  22940. * Tips: like always,
  22941. * positive rotation represents anticlockwise, and negative rotation
  22942. * represents clockwise.
  22943. * The direction of position coordinate is the same as the direction
  22944. * of screen coordinate.
  22945. *
  22946. * Do not need to consider axis 'inverse', which is auto processed by
  22947. * axis extent.
  22948. *
  22949. * @param {module:zrender/container/Group} group
  22950. * @param {Object} axisModel
  22951. * @param {Object} opt Standard axis parameters.
  22952. * @param {Array.<number>} opt.position [x, y]
  22953. * @param {number} opt.rotation by radian
  22954. * @param {number} [opt.nameDirection=1] 1 or -1 Used when nameLocation is 'middle'.
  22955. * @param {number} [opt.tickDirection=1] 1 or -1
  22956. * @param {number} [opt.labelDirection=1] 1 or -1
  22957. * @param {number} [opt.labelOffset=0] Usefull when onZero.
  22958. * @param {string} [opt.axisLabelShow] default get from axisModel.
  22959. * @param {string} [opt.axisName] default get from axisModel.
  22960. * @param {number} [opt.axisNameAvailableWidth]
  22961. * @param {number} [opt.labelRotation] by degree, default get from axisModel.
  22962. * @param {number} [opt.labelInterval] Default label interval when label
  22963. * interval from model is null or 'auto'.
  22964. * @param {number} [opt.strokeContainThreshold] Default label interval when label
  22965. */
  22966. var AxisBuilder = function (axisModel, opt) {
  22967. /**
  22968. * @readOnly
  22969. */
  22970. this.opt = opt;
  22971. /**
  22972. * @readOnly
  22973. */
  22974. this.axisModel = axisModel;
  22975. // Default value
  22976. zrUtil.defaults(
  22977. opt,
  22978. {
  22979. labelOffset: 0,
  22980. nameDirection: 1,
  22981. tickDirection: 1,
  22982. labelDirection: 1,
  22983. silent: true
  22984. }
  22985. );
  22986. /**
  22987. * @readOnly
  22988. */
  22989. this.group = new graphic.Group();
  22990. // FIXME Not use a seperate text group?
  22991. var dumbGroup = new graphic.Group({
  22992. position: opt.position.slice(),
  22993. rotation: opt.rotation
  22994. });
  22995. // this.group.add(dumbGroup);
  22996. // this._dumbGroup = dumbGroup;
  22997. dumbGroup.updateTransform();
  22998. this._transform = dumbGroup.transform;
  22999. this._dumbGroup = dumbGroup;
  23000. };
  23001. AxisBuilder.prototype = {
  23002. constructor: AxisBuilder,
  23003. hasBuilder: function (name) {
  23004. return !!builders[name];
  23005. },
  23006. add: function (name) {
  23007. builders[name].call(this);
  23008. },
  23009. getGroup: function () {
  23010. return this.group;
  23011. }
  23012. };
  23013. var builders = {
  23014. /**
  23015. * @private
  23016. */
  23017. axisLine: function () {
  23018. var opt = this.opt;
  23019. var axisModel = this.axisModel;
  23020. if (!axisModel.get('axisLine.show')) {
  23021. return;
  23022. }
  23023. var extent = this.axisModel.axis.getExtent();
  23024. var matrix = this._transform;
  23025. var pt1 = [extent[0], 0];
  23026. var pt2 = [extent[1], 0];
  23027. if (matrix) {
  23028. v2ApplyTransform(pt1, pt1, matrix);
  23029. v2ApplyTransform(pt2, pt2, matrix);
  23030. }
  23031. this.group.add(new graphic.Line(graphic.subPixelOptimizeLine({
  23032. // Id for animation
  23033. anid: 'line',
  23034. shape: {
  23035. x1: pt1[0],
  23036. y1: pt1[1],
  23037. x2: pt2[0],
  23038. y2: pt2[1]
  23039. },
  23040. style: zrUtil.extend(
  23041. {lineCap: 'round'},
  23042. axisModel.getModel('axisLine.lineStyle').getLineStyle()
  23043. ),
  23044. strokeContainThreshold: opt.strokeContainThreshold || 5,
  23045. silent: true,
  23046. z2: 1
  23047. })));
  23048. },
  23049. /**
  23050. * @private
  23051. */
  23052. axisTick: function () {
  23053. var axisModel = this.axisModel;
  23054. if (!axisModel.get('axisTick.show')) {
  23055. return;
  23056. }
  23057. var axis = axisModel.axis;
  23058. var tickModel = axisModel.getModel('axisTick');
  23059. var opt = this.opt;
  23060. var lineStyleModel = tickModel.getModel('lineStyle');
  23061. var tickLen = tickModel.get('length');
  23062. var tickInterval = getInterval(tickModel, opt.labelInterval);
  23063. var ticksCoords = axis.getTicksCoords(tickModel.get('alignWithLabel'));
  23064. var ticks = axis.scale.getTicks();
  23065. var pt1 = [];
  23066. var pt2 = [];
  23067. var matrix = this._transform;
  23068. for (var i = 0; i < ticksCoords.length; i++) {
  23069. // Only ordinal scale support tick interval
  23070. if (ifIgnoreOnTick(axis, i, tickInterval)) {
  23071. continue;
  23072. }
  23073. var tickCoord = ticksCoords[i];
  23074. pt1[0] = tickCoord;
  23075. pt1[1] = 0;
  23076. pt2[0] = tickCoord;
  23077. pt2[1] = opt.tickDirection * tickLen;
  23078. if (matrix) {
  23079. v2ApplyTransform(pt1, pt1, matrix);
  23080. v2ApplyTransform(pt2, pt2, matrix);
  23081. }
  23082. // Tick line, Not use group transform to have better line draw
  23083. this.group.add(new graphic.Line(graphic.subPixelOptimizeLine({
  23084. // Id for animation
  23085. anid: 'tick_' + ticks[i],
  23086. shape: {
  23087. x1: pt1[0],
  23088. y1: pt1[1],
  23089. x2: pt2[0],
  23090. y2: pt2[1]
  23091. },
  23092. style: zrUtil.defaults(
  23093. lineStyleModel.getLineStyle(),
  23094. {
  23095. stroke: axisModel.get('axisLine.lineStyle.color')
  23096. }
  23097. ),
  23098. z2: 2,
  23099. silent: true
  23100. })));
  23101. }
  23102. },
  23103. /**
  23104. * @param {module:echarts/coord/cartesian/AxisModel} axisModel
  23105. * @param {module:echarts/coord/cartesian/GridModel} gridModel
  23106. * @private
  23107. */
  23108. axisLabel: function () {
  23109. var opt = this.opt;
  23110. var axisModel = this.axisModel;
  23111. var show = retrieve(opt.axisLabelShow, axisModel.get('axisLabel.show'));
  23112. if (!show) {
  23113. return;
  23114. }
  23115. var axis = axisModel.axis;
  23116. var labelModel = axisModel.getModel('axisLabel');
  23117. var textStyleModel = labelModel.getModel('textStyle');
  23118. var labelMargin = labelModel.get('margin');
  23119. var ticks = axis.scale.getTicks();
  23120. var labels = axisModel.getFormattedLabels();
  23121. // Special label rotate.
  23122. var labelRotation = retrieve(opt.labelRotation, labelModel.get('rotate')) || 0;
  23123. // To radian.
  23124. labelRotation = labelRotation * PI / 180;
  23125. var labelLayout = innerTextLayout(opt, labelRotation, opt.labelDirection);
  23126. var categoryData = axisModel.get('data');
  23127. var textEls = [];
  23128. var silent = isSilent(axisModel);
  23129. var triggerEvent = axisModel.get('triggerEvent');
  23130. for (var i = 0; i < ticks.length; i++) {
  23131. if (ifIgnoreOnTick(axis, i, opt.labelInterval)) {
  23132. continue;
  23133. }
  23134. var itemTextStyleModel = textStyleModel;
  23135. if (categoryData && categoryData[i] && categoryData[i].textStyle) {
  23136. itemTextStyleModel = new Model(
  23137. categoryData[i].textStyle, textStyleModel, axisModel.ecModel
  23138. );
  23139. }
  23140. var textColor = itemTextStyleModel.getTextColor()
  23141. || axisModel.get('axisLine.lineStyle.color');
  23142. var tickCoord = axis.dataToCoord(ticks[i]);
  23143. var pos = [
  23144. tickCoord,
  23145. opt.labelOffset + opt.labelDirection * labelMargin
  23146. ];
  23147. var labelBeforeFormat = axis.scale.getLabel(ticks[i]);
  23148. var textEl = new graphic.Text({
  23149. // Id for animation
  23150. anid: 'label_' + ticks[i],
  23151. style: {
  23152. text: labels[i],
  23153. textAlign: itemTextStyleModel.get('align', true) || labelLayout.textAlign,
  23154. textVerticalAlign: itemTextStyleModel.get('baseline', true) || labelLayout.verticalAlign,
  23155. textFont: itemTextStyleModel.getFont(),
  23156. fill: typeof textColor === 'function' ? textColor(labelBeforeFormat) : textColor
  23157. },
  23158. position: pos,
  23159. rotation: labelLayout.rotation,
  23160. silent: silent,
  23161. z2: 10
  23162. });
  23163. // Pack data for mouse event
  23164. if (triggerEvent) {
  23165. textEl.eventData = makeAxisEventDataBase(axisModel);
  23166. textEl.eventData.targetType = 'axisLabel';
  23167. textEl.eventData.value = labelBeforeFormat;
  23168. }
  23169. // FIXME
  23170. this._dumbGroup.add(textEl);
  23171. textEl.updateTransform();
  23172. textEls.push(textEl);
  23173. this.group.add(textEl);
  23174. textEl.decomposeTransform();
  23175. }
  23176. function isTwoLabelOverlapped(current, next) {
  23177. var firstRect = current && current.getBoundingRect().clone();
  23178. var nextRect = next && next.getBoundingRect().clone();
  23179. if (firstRect && nextRect) {
  23180. firstRect.applyTransform(current.getLocalTransform());
  23181. nextRect.applyTransform(next.getLocalTransform());
  23182. return firstRect.intersect(nextRect);
  23183. }
  23184. }
  23185. if (axis.type !== 'category') {
  23186. // If min or max are user set, we need to check
  23187. // If the tick on min(max) are overlap on their neighbour tick
  23188. // If they are overlapped, we need to hide the min(max) tick label
  23189. if (axisModel.getMin ? axisModel.getMin() : axisModel.get('min')) {
  23190. var firstLabel = textEls[0];
  23191. var nextLabel = textEls[1];
  23192. if (isTwoLabelOverlapped(firstLabel, nextLabel)) {
  23193. firstLabel.ignore = true;
  23194. }
  23195. }
  23196. if (axisModel.getMax ? axisModel.getMax() : axisModel.get('max')) {
  23197. var lastLabel = textEls[textEls.length - 1];
  23198. var prevLabel = textEls[textEls.length - 2];
  23199. if (isTwoLabelOverlapped(prevLabel, lastLabel)) {
  23200. lastLabel.ignore = true;
  23201. }
  23202. }
  23203. }
  23204. },
  23205. /**
  23206. * @private
  23207. */
  23208. axisName: function () {
  23209. var opt = this.opt;
  23210. var axisModel = this.axisModel;
  23211. var name = retrieve(opt.axisName, axisModel.get('name'));
  23212. if (!name) {
  23213. return;
  23214. }
  23215. var nameLocation = axisModel.get('nameLocation');
  23216. var nameDirection = opt.nameDirection;
  23217. var textStyleModel = axisModel.getModel('nameTextStyle');
  23218. var gap = axisModel.get('nameGap') || 0;
  23219. var extent = this.axisModel.axis.getExtent();
  23220. var gapSignal = extent[0] > extent[1] ? -1 : 1;
  23221. var pos = [
  23222. nameLocation === 'start'
  23223. ? extent[0] - gapSignal * gap
  23224. : nameLocation === 'end'
  23225. ? extent[1] + gapSignal * gap
  23226. : (extent[0] + extent[1]) / 2, // 'middle'
  23227. // Reuse labelOffset.
  23228. nameLocation === 'middle' ? opt.labelOffset + nameDirection * gap : 0
  23229. ];
  23230. var labelLayout;
  23231. var nameRotation = axisModel.get('nameRotate');
  23232. if (nameRotation != null) {
  23233. nameRotation = nameRotation * PI / 180; // To radian.
  23234. }
  23235. var axisNameAvailableWidth;
  23236. if (nameLocation === 'middle') {
  23237. labelLayout = innerTextLayout(
  23238. opt,
  23239. nameRotation != null ? nameRotation : opt.rotation, // Adapt to axis.
  23240. nameDirection
  23241. );
  23242. }
  23243. else {
  23244. labelLayout = endTextLayout(
  23245. opt, nameLocation, nameRotation || 0, extent
  23246. );
  23247. axisNameAvailableWidth = opt.axisNameAvailableWidth;
  23248. if (axisNameAvailableWidth != null) {
  23249. axisNameAvailableWidth = Math.abs(
  23250. axisNameAvailableWidth / Math.sin(labelLayout.rotation)
  23251. );
  23252. !isFinite(axisNameAvailableWidth) && (axisNameAvailableWidth = null);
  23253. }
  23254. }
  23255. var textFont = textStyleModel.getFont();
  23256. var truncateOpt = axisModel.get('nameTruncate', true) || {};
  23257. var ellipsis = truncateOpt.ellipsis;
  23258. var maxWidth = retrieve(truncateOpt.maxWidth, axisNameAvailableWidth);
  23259. var truncatedText = (ellipsis != null && maxWidth != null)
  23260. ? formatUtil.truncateText(
  23261. name, maxWidth, textFont, ellipsis,
  23262. {minChar: 2, placeholder: truncateOpt.placeholder}
  23263. )
  23264. : name;
  23265. var tooltipOpt = axisModel.get('tooltip', true);
  23266. var mainType = axisModel.mainType;
  23267. var formatterParams = {
  23268. componentType: mainType,
  23269. name: name,
  23270. $vars: ['name']
  23271. };
  23272. formatterParams[mainType + 'Index'] = axisModel.componentIndex;
  23273. var textEl = new graphic.Text({
  23274. // Id for animation
  23275. anid: 'name',
  23276. __fullText: name,
  23277. __truncatedText: truncatedText,
  23278. style: {
  23279. text: truncatedText,
  23280. textFont: textFont,
  23281. fill: textStyleModel.getTextColor()
  23282. || axisModel.get('axisLine.lineStyle.color'),
  23283. textAlign: labelLayout.textAlign,
  23284. textVerticalAlign: labelLayout.verticalAlign
  23285. },
  23286. position: pos,
  23287. rotation: labelLayout.rotation,
  23288. silent: isSilent(axisModel),
  23289. z2: 1,
  23290. tooltip: (tooltipOpt && tooltipOpt.show)
  23291. ? zrUtil.extend({
  23292. content: name,
  23293. formatter: function () {
  23294. return name;
  23295. },
  23296. formatterParams: formatterParams
  23297. }, tooltipOpt)
  23298. : null
  23299. });
  23300. if (axisModel.get('triggerEvent')) {
  23301. textEl.eventData = makeAxisEventDataBase(axisModel);
  23302. textEl.eventData.targetType = 'axisName';
  23303. textEl.eventData.name = name;
  23304. }
  23305. // FIXME
  23306. this._dumbGroup.add(textEl);
  23307. textEl.updateTransform();
  23308. this.group.add(textEl);
  23309. textEl.decomposeTransform();
  23310. }
  23311. };
  23312. /**
  23313. * @inner
  23314. */
  23315. function innerTextLayout(opt, textRotation, direction) {
  23316. var rotationDiff = remRadian(textRotation - opt.rotation);
  23317. var textAlign;
  23318. var verticalAlign;
  23319. if (isRadianAroundZero(rotationDiff)) { // Label is parallel with axis line.
  23320. verticalAlign = direction > 0 ? 'top' : 'bottom';
  23321. textAlign = 'center';
  23322. }
  23323. else if (isRadianAroundZero(rotationDiff - PI)) { // Label is inverse parallel with axis line.
  23324. verticalAlign = direction > 0 ? 'bottom' : 'top';
  23325. textAlign = 'center';
  23326. }
  23327. else {
  23328. verticalAlign = 'middle';
  23329. if (rotationDiff > 0 && rotationDiff < PI) {
  23330. textAlign = direction > 0 ? 'right' : 'left';
  23331. }
  23332. else {
  23333. textAlign = direction > 0 ? 'left' : 'right';
  23334. }
  23335. }
  23336. return {
  23337. rotation: rotationDiff,
  23338. textAlign: textAlign,
  23339. verticalAlign: verticalAlign
  23340. };
  23341. }
  23342. /**
  23343. * @inner
  23344. */
  23345. function endTextLayout(opt, textPosition, textRotate, extent) {
  23346. var rotationDiff = remRadian(textRotate - opt.rotation);
  23347. var textAlign;
  23348. var verticalAlign;
  23349. var inverse = extent[0] > extent[1];
  23350. var onLeft = (textPosition === 'start' && !inverse)
  23351. || (textPosition !== 'start' && inverse);
  23352. if (isRadianAroundZero(rotationDiff - PI / 2)) {
  23353. verticalAlign = onLeft ? 'bottom' : 'top';
  23354. textAlign = 'center';
  23355. }
  23356. else if (isRadianAroundZero(rotationDiff - PI * 1.5)) {
  23357. verticalAlign = onLeft ? 'top' : 'bottom';
  23358. textAlign = 'center';
  23359. }
  23360. else {
  23361. verticalAlign = 'middle';
  23362. if (rotationDiff < PI * 1.5 && rotationDiff > PI / 2) {
  23363. textAlign = onLeft ? 'left' : 'right';
  23364. }
  23365. else {
  23366. textAlign = onLeft ? 'right' : 'left';
  23367. }
  23368. }
  23369. return {
  23370. rotation: rotationDiff,
  23371. textAlign: textAlign,
  23372. verticalAlign: verticalAlign
  23373. };
  23374. }
  23375. /**
  23376. * @inner
  23377. */
  23378. function isSilent(axisModel) {
  23379. var tooltipOpt = axisModel.get('tooltip');
  23380. return axisModel.get('silent')
  23381. // Consider mouse cursor, add these restrictions.
  23382. || !(
  23383. axisModel.get('triggerEvent') || (tooltipOpt && tooltipOpt.show)
  23384. );
  23385. }
  23386. /**
  23387. * @static
  23388. */
  23389. var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick = function (axis, i, interval) {
  23390. var rawTick;
  23391. var scale = axis.scale;
  23392. return scale.type === 'ordinal'
  23393. && (
  23394. typeof interval === 'function'
  23395. ? (
  23396. rawTick = scale.getTicks()[i],
  23397. !interval(rawTick, scale.getLabel(rawTick))
  23398. )
  23399. : i % (interval + 1)
  23400. );
  23401. };
  23402. /**
  23403. * @static
  23404. */
  23405. var getInterval = AxisBuilder.getInterval = function (model, labelInterval) {
  23406. var interval = model.get('interval');
  23407. if (interval == null || interval == 'auto') {
  23408. interval = labelInterval;
  23409. }
  23410. return interval;
  23411. };
  23412. module.exports = AxisBuilder;
  23413. /***/ },
  23414. /* 133 */
  23415. /***/ function(module, exports, __webpack_require__) {
  23416. var zrUtil = __webpack_require__(4);
  23417. __webpack_require__(113);
  23418. __webpack_require__(134);
  23419. __webpack_require__(135);
  23420. var barLayoutGrid = __webpack_require__(137);
  23421. var echarts = __webpack_require__(1);
  23422. echarts.registerLayout(zrUtil.curry(barLayoutGrid, 'bar'));
  23423. // Visual coding for legend
  23424. echarts.registerVisual(function (ecModel) {
  23425. ecModel.eachSeriesByType('bar', function (seriesModel) {
  23426. var data = seriesModel.getData();
  23427. data.setVisual('legendSymbol', 'roundRect');
  23428. });
  23429. });
  23430. // In case developer forget to include grid component
  23431. __webpack_require__(112);
  23432. /***/ },
  23433. /* 134 */
  23434. /***/ function(module, exports, __webpack_require__) {
  23435. 'use strict';
  23436. var SeriesModel = __webpack_require__(28);
  23437. var createListFromArray = __webpack_require__(101);
  23438. module.exports = SeriesModel.extend({
  23439. type: 'series.bar',
  23440. dependencies: ['grid', 'polar'],
  23441. getInitialData: function (option, ecModel) {
  23442. if (true) {
  23443. var coordSys = option.coordinateSystem;
  23444. if (coordSys !== 'cartesian2d') {
  23445. throw new Error('Bar only support cartesian2d coordinateSystem');
  23446. }
  23447. }
  23448. return createListFromArray(option.data, this, ecModel);
  23449. },
  23450. getMarkerPosition: function (value) {
  23451. var coordSys = this.coordinateSystem;
  23452. if (coordSys) {
  23453. // PENDING if clamp ?
  23454. var pt = coordSys.dataToPoint(value, true);
  23455. var data = this.getData();
  23456. var offset = data.getLayout('offset');
  23457. var size = data.getLayout('size');
  23458. var offsetIndex = coordSys.getBaseAxis().isHorizontal() ? 0 : 1;
  23459. pt[offsetIndex] += offset + size / 2;
  23460. return pt;
  23461. }
  23462. return [NaN, NaN];
  23463. },
  23464. brushSelector: 'rect',
  23465. defaultOption: {
  23466. zlevel: 0, // 一级层叠
  23467. z: 2, // 二级层叠
  23468. coordinateSystem: 'cartesian2d',
  23469. legendHoverLink: true,
  23470. // stack: null
  23471. // Cartesian coordinate system
  23472. xAxisIndex: 0,
  23473. yAxisIndex: 0,
  23474. // 最小高度改为0
  23475. barMinHeight: 0,
  23476. // barMaxWidth: null,
  23477. // 默认自适应
  23478. // barWidth: null,
  23479. // 柱间距离,默认为柱形宽度的30%,可设固定值
  23480. // barGap: '30%',
  23481. // 类目间柱形距离,默认为类目间距的20%,可设固定值
  23482. // barCategoryGap: '20%',
  23483. // label: {
  23484. // normal: {
  23485. // show: false
  23486. // }
  23487. // },
  23488. itemStyle: {
  23489. normal: {
  23490. // color: '各异'
  23491. },
  23492. emphasis: {}
  23493. }
  23494. }
  23495. });
  23496. /***/ },
  23497. /* 135 */
  23498. /***/ function(module, exports, __webpack_require__) {
  23499. 'use strict';
  23500. var zrUtil = __webpack_require__(4);
  23501. var graphic = __webpack_require__(43);
  23502. zrUtil.extend(__webpack_require__(12).prototype, __webpack_require__(136));
  23503. function fixLayoutWithLineWidth(layout, lineWidth) {
  23504. var signX = layout.width > 0 ? 1 : -1;
  23505. var signY = layout.height > 0 ? 1 : -1;
  23506. // In case width or height are too small.
  23507. lineWidth = Math.min(lineWidth, Math.abs(layout.width), Math.abs(layout.height));
  23508. layout.x += signX * lineWidth / 2;
  23509. layout.y += signY * lineWidth / 2;
  23510. layout.width -= signX * lineWidth;
  23511. layout.height -= signY * lineWidth;
  23512. }
  23513. module.exports = __webpack_require__(1).extendChartView({
  23514. type: 'bar',
  23515. render: function (seriesModel, ecModel, api) {
  23516. var coordinateSystemType = seriesModel.get('coordinateSystem');
  23517. if (coordinateSystemType === 'cartesian2d') {
  23518. this._renderOnCartesian(seriesModel, ecModel, api);
  23519. }
  23520. return this.group;
  23521. },
  23522. _renderOnCartesian: function (seriesModel, ecModel, api) {
  23523. var group = this.group;
  23524. var data = seriesModel.getData();
  23525. var oldData = this._data;
  23526. var cartesian = seriesModel.coordinateSystem;
  23527. var baseAxis = cartesian.getBaseAxis();
  23528. var isHorizontal = baseAxis.isHorizontal();
  23529. var enableAnimation = seriesModel.get('animation');
  23530. var barBorderWidthQuery = ['itemStyle', 'normal', 'barBorderWidth'];
  23531. function createRect(dataIndex, isUpdate) {
  23532. var layout = data.getItemLayout(dataIndex);
  23533. var lineWidth = data.getItemModel(dataIndex).get(barBorderWidthQuery) || 0;
  23534. fixLayoutWithLineWidth(layout, lineWidth);
  23535. var rect = new graphic.Rect({
  23536. shape: zrUtil.extend({}, layout)
  23537. });
  23538. // Animation
  23539. if (enableAnimation) {
  23540. var rectShape = rect.shape;
  23541. var animateProperty = isHorizontal ? 'height' : 'width';
  23542. var animateTarget = {};
  23543. rectShape[animateProperty] = 0;
  23544. animateTarget[animateProperty] = layout[animateProperty];
  23545. graphic[isUpdate? 'updateProps' : 'initProps'](rect, {
  23546. shape: animateTarget
  23547. }, seriesModel, dataIndex);
  23548. }
  23549. return rect;
  23550. }
  23551. data.diff(oldData)
  23552. .add(function (dataIndex) {
  23553. // 空数据
  23554. if (!data.hasValue(dataIndex)) {
  23555. return;
  23556. }
  23557. var rect = createRect(dataIndex);
  23558. data.setItemGraphicEl(dataIndex, rect);
  23559. group.add(rect);
  23560. })
  23561. .update(function (newIndex, oldIndex) {
  23562. var rect = oldData.getItemGraphicEl(oldIndex);
  23563. // 空数据
  23564. if (!data.hasValue(newIndex)) {
  23565. group.remove(rect);
  23566. return;
  23567. }
  23568. if (!rect) {
  23569. rect = createRect(newIndex, true);
  23570. }
  23571. var layout = data.getItemLayout(newIndex);
  23572. var lineWidth = data.getItemModel(newIndex).get(barBorderWidthQuery) || 0;
  23573. fixLayoutWithLineWidth(layout, lineWidth);
  23574. graphic.updateProps(rect, {
  23575. shape: layout
  23576. }, seriesModel, newIndex);
  23577. data.setItemGraphicEl(newIndex, rect);
  23578. // Add back
  23579. group.add(rect);
  23580. })
  23581. .remove(function (idx) {
  23582. var rect = oldData.getItemGraphicEl(idx);
  23583. if (rect) {
  23584. // Not show text when animating
  23585. rect.style.text = '';
  23586. graphic.updateProps(rect, {
  23587. shape: {
  23588. width: 0
  23589. }
  23590. }, seriesModel, idx, function () {
  23591. group.remove(rect);
  23592. });
  23593. }
  23594. })
  23595. .execute();
  23596. this._updateStyle(seriesModel, data, isHorizontal);
  23597. this._data = data;
  23598. },
  23599. _updateStyle: function (seriesModel, data, isHorizontal) {
  23600. function setLabel(style, model, color, labelText, labelPositionOutside) {
  23601. graphic.setText(style, model, color);
  23602. style.text = labelText;
  23603. if (style.textPosition === 'outside') {
  23604. style.textPosition = labelPositionOutside;
  23605. }
  23606. }
  23607. data.eachItemGraphicEl(function (rect, idx) {
  23608. var itemModel = data.getItemModel(idx);
  23609. var color = data.getItemVisual(idx, 'color');
  23610. var opacity = data.getItemVisual(idx, 'opacity');
  23611. var layout = data.getItemLayout(idx);
  23612. var itemStyleModel = itemModel.getModel('itemStyle.normal');
  23613. var hoverStyle = itemModel.getModel('itemStyle.emphasis').getBarItemStyle();
  23614. rect.setShape('r', itemStyleModel.get('barBorderRadius') || 0);
  23615. rect.useStyle(zrUtil.defaults(
  23616. {
  23617. fill: color,
  23618. opacity: opacity
  23619. },
  23620. itemStyleModel.getBarItemStyle()
  23621. ));
  23622. var labelPositionOutside = isHorizontal
  23623. ? (layout.height > 0 ? 'bottom' : 'top')
  23624. : (layout.width > 0 ? 'left' : 'right');
  23625. var labelModel = itemModel.getModel('label.normal');
  23626. var hoverLabelModel = itemModel.getModel('label.emphasis');
  23627. var rectStyle = rect.style;
  23628. if (labelModel.get('show')) {
  23629. setLabel(
  23630. rectStyle, labelModel, color,
  23631. zrUtil.retrieve(
  23632. seriesModel.getFormattedLabel(idx, 'normal'),
  23633. seriesModel.getRawValue(idx)
  23634. ),
  23635. labelPositionOutside
  23636. );
  23637. }
  23638. else {
  23639. rectStyle.text = '';
  23640. }
  23641. if (hoverLabelModel.get('show')) {
  23642. setLabel(
  23643. hoverStyle, hoverLabelModel, color,
  23644. zrUtil.retrieve(
  23645. seriesModel.getFormattedLabel(idx, 'emphasis'),
  23646. seriesModel.getRawValue(idx)
  23647. ),
  23648. labelPositionOutside
  23649. );
  23650. }
  23651. else {
  23652. hoverStyle.text = '';
  23653. }
  23654. graphic.setHoverStyle(rect, hoverStyle);
  23655. });
  23656. },
  23657. remove: function (ecModel, api) {
  23658. var group = this.group;
  23659. if (ecModel.get('animation')) {
  23660. if (this._data) {
  23661. this._data.eachItemGraphicEl(function (el) {
  23662. // Not show text when animating
  23663. el.style.text = '';
  23664. graphic.updateProps(el, {
  23665. shape: {
  23666. width: 0
  23667. }
  23668. }, ecModel, el.dataIndex, function () {
  23669. group.remove(el);
  23670. });
  23671. });
  23672. }
  23673. }
  23674. else {
  23675. group.removeAll();
  23676. }
  23677. }
  23678. });
  23679. /***/ },
  23680. /* 136 */
  23681. /***/ function(module, exports, __webpack_require__) {
  23682. var getBarItemStyle = __webpack_require__(15)(
  23683. [
  23684. ['fill', 'color'],
  23685. ['stroke', 'borderColor'],
  23686. ['lineWidth', 'borderWidth'],
  23687. // Compatitable with 2
  23688. ['stroke', 'barBorderColor'],
  23689. ['lineWidth', 'barBorderWidth'],
  23690. ['opacity'],
  23691. ['shadowBlur'],
  23692. ['shadowOffsetX'],
  23693. ['shadowOffsetY'],
  23694. ['shadowColor']
  23695. ]
  23696. );
  23697. module.exports = {
  23698. getBarItemStyle: function (excludes) {
  23699. var style = getBarItemStyle.call(this, excludes);
  23700. if (this.getBorderLineDash) {
  23701. var lineDash = this.getBorderLineDash();
  23702. lineDash && (style.lineDash = lineDash);
  23703. }
  23704. return style;
  23705. }
  23706. };
  23707. /***/ },
  23708. /* 137 */
  23709. /***/ function(module, exports, __webpack_require__) {
  23710. 'use strict';
  23711. var zrUtil = __webpack_require__(4);
  23712. var numberUtil = __webpack_require__(7);
  23713. var parsePercent = numberUtil.parsePercent;
  23714. function getSeriesStackId(seriesModel) {
  23715. return seriesModel.get('stack') || '__ec_stack_' + seriesModel.seriesIndex;
  23716. }
  23717. function getAxisKey(axis) {
  23718. return axis.dim + axis.index;
  23719. }
  23720. function calBarWidthAndOffset(barSeries, api) {
  23721. // Columns info on each category axis. Key is cartesian name
  23722. var columnsMap = {};
  23723. zrUtil.each(barSeries, function (seriesModel, idx) {
  23724. var data = seriesModel.getData();
  23725. var cartesian = seriesModel.coordinateSystem;
  23726. var baseAxis = cartesian.getBaseAxis();
  23727. var axisExtent = baseAxis.getExtent();
  23728. var bandWidth = baseAxis.type === 'category'
  23729. ? baseAxis.getBandWidth()
  23730. : (Math.abs(axisExtent[1] - axisExtent[0]) / data.count());
  23731. var columnsOnAxis = columnsMap[getAxisKey(baseAxis)] || {
  23732. bandWidth: bandWidth,
  23733. remainedWidth: bandWidth,
  23734. autoWidthCount: 0,
  23735. categoryGap: '20%',
  23736. gap: '30%',
  23737. stacks: {}
  23738. };
  23739. var stacks = columnsOnAxis.stacks;
  23740. columnsMap[getAxisKey(baseAxis)] = columnsOnAxis;
  23741. var stackId = getSeriesStackId(seriesModel);
  23742. if (!stacks[stackId]) {
  23743. columnsOnAxis.autoWidthCount++;
  23744. }
  23745. stacks[stackId] = stacks[stackId] || {
  23746. width: 0,
  23747. maxWidth: 0
  23748. };
  23749. var barWidth = parsePercent(
  23750. seriesModel.get('barWidth'), bandWidth
  23751. );
  23752. var barMaxWidth = parsePercent(
  23753. seriesModel.get('barMaxWidth'), bandWidth
  23754. );
  23755. var barGap = seriesModel.get('barGap');
  23756. var barCategoryGap = seriesModel.get('barCategoryGap');
  23757. // TODO
  23758. if (barWidth && !stacks[stackId].width) {
  23759. barWidth = Math.min(columnsOnAxis.remainedWidth, barWidth);
  23760. stacks[stackId].width = barWidth;
  23761. columnsOnAxis.remainedWidth -= barWidth;
  23762. }
  23763. barMaxWidth && (stacks[stackId].maxWidth = barMaxWidth);
  23764. (barGap != null) && (columnsOnAxis.gap = barGap);
  23765. (barCategoryGap != null) && (columnsOnAxis.categoryGap = barCategoryGap);
  23766. });
  23767. var result = {};
  23768. zrUtil.each(columnsMap, function (columnsOnAxis, coordSysName) {
  23769. result[coordSysName] = {};
  23770. var stacks = columnsOnAxis.stacks;
  23771. var bandWidth = columnsOnAxis.bandWidth;
  23772. var categoryGap = parsePercent(columnsOnAxis.categoryGap, bandWidth);
  23773. var barGapPercent = parsePercent(columnsOnAxis.gap, 1);
  23774. var remainedWidth = columnsOnAxis.remainedWidth;
  23775. var autoWidthCount = columnsOnAxis.autoWidthCount;
  23776. var autoWidth = (remainedWidth - categoryGap)
  23777. / (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
  23778. autoWidth = Math.max(autoWidth, 0);
  23779. // Find if any auto calculated bar exceeded maxBarWidth
  23780. zrUtil.each(stacks, function (column, stack) {
  23781. var maxWidth = column.maxWidth;
  23782. if (!column.width && maxWidth && maxWidth < autoWidth) {
  23783. maxWidth = Math.min(maxWidth, remainedWidth);
  23784. remainedWidth -= maxWidth;
  23785. column.width = maxWidth;
  23786. autoWidthCount--;
  23787. }
  23788. });
  23789. // Recalculate width again
  23790. autoWidth = (remainedWidth - categoryGap)
  23791. / (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
  23792. autoWidth = Math.max(autoWidth, 0);
  23793. var widthSum = 0;
  23794. var lastColumn;
  23795. zrUtil.each(stacks, function (column, idx) {
  23796. if (!column.width) {
  23797. column.width = autoWidth;
  23798. }
  23799. lastColumn = column;
  23800. widthSum += column.width * (1 + barGapPercent);
  23801. });
  23802. if (lastColumn) {
  23803. widthSum -= lastColumn.width * barGapPercent;
  23804. }
  23805. var offset = -widthSum / 2;
  23806. zrUtil.each(stacks, function (column, stackId) {
  23807. result[coordSysName][stackId] = result[coordSysName][stackId] || {
  23808. offset: offset,
  23809. width: column.width
  23810. };
  23811. offset += column.width * (1 + barGapPercent);
  23812. });
  23813. });
  23814. return result;
  23815. }
  23816. /**
  23817. * @param {string} seriesType
  23818. * @param {module:echarts/model/Global} ecModel
  23819. * @param {module:echarts/ExtensionAPI} api
  23820. */
  23821. function barLayoutGrid(seriesType, ecModel, api) {
  23822. var barWidthAndOffset = calBarWidthAndOffset(
  23823. zrUtil.filter(
  23824. ecModel.getSeriesByType(seriesType),
  23825. function (seriesModel) {
  23826. return !ecModel.isSeriesFiltered(seriesModel)
  23827. && seriesModel.coordinateSystem
  23828. && seriesModel.coordinateSystem.type === 'cartesian2d';
  23829. }
  23830. )
  23831. );
  23832. var lastStackCoords = {};
  23833. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  23834. var data = seriesModel.getData();
  23835. var cartesian = seriesModel.coordinateSystem;
  23836. var baseAxis = cartesian.getBaseAxis();
  23837. var stackId = getSeriesStackId(seriesModel);
  23838. var columnLayoutInfo = barWidthAndOffset[getAxisKey(baseAxis)][stackId];
  23839. var columnOffset = columnLayoutInfo.offset;
  23840. var columnWidth = columnLayoutInfo.width;
  23841. var valueAxis = cartesian.getOtherAxis(baseAxis);
  23842. var barMinHeight = seriesModel.get('barMinHeight') || 0;
  23843. var valueAxisStart = baseAxis.onZero
  23844. ? valueAxis.toGlobalCoord(valueAxis.dataToCoord(0))
  23845. : valueAxis.getGlobalExtent()[0];
  23846. var coords = cartesian.dataToPoints(data, true);
  23847. lastStackCoords[stackId] = lastStackCoords[stackId] || [];
  23848. data.setLayout({
  23849. offset: columnOffset,
  23850. size: columnWidth
  23851. });
  23852. data.each(valueAxis.dim, function (value, idx) {
  23853. // 空数据
  23854. if (isNaN(value)) {
  23855. return;
  23856. }
  23857. if (!lastStackCoords[stackId][idx]) {
  23858. lastStackCoords[stackId][idx] = {
  23859. // Positive stack
  23860. p: valueAxisStart,
  23861. // Negative stack
  23862. n: valueAxisStart
  23863. };
  23864. }
  23865. var sign = value >= 0 ? 'p' : 'n';
  23866. var coord = coords[idx];
  23867. var lastCoord = lastStackCoords[stackId][idx][sign];
  23868. var x, y, width, height;
  23869. if (valueAxis.isHorizontal()) {
  23870. x = lastCoord;
  23871. y = coord[1] + columnOffset;
  23872. width = coord[0] - lastCoord;
  23873. height = columnWidth;
  23874. if (Math.abs(width) < barMinHeight) {
  23875. width = (width < 0 ? -1 : 1) * barMinHeight;
  23876. }
  23877. lastStackCoords[stackId][idx][sign] += width;
  23878. }
  23879. else {
  23880. x = coord[0] + columnOffset;
  23881. y = lastCoord;
  23882. width = columnWidth;
  23883. height = coord[1] - lastCoord;
  23884. if (Math.abs(height) < barMinHeight) {
  23885. // Include zero to has a positive bar
  23886. height = (height <= 0 ? -1 : 1) * barMinHeight;
  23887. }
  23888. lastStackCoords[stackId][idx][sign] += height;
  23889. }
  23890. data.setItemLayout(idx, {
  23891. x: x,
  23892. y: y,
  23893. width: width,
  23894. height: height
  23895. });
  23896. }, true);
  23897. }, this);
  23898. }
  23899. module.exports = barLayoutGrid;
  23900. /***/ },
  23901. /* 138 */
  23902. /***/ function(module, exports, __webpack_require__) {
  23903. var zrUtil = __webpack_require__(4);
  23904. var echarts = __webpack_require__(1);
  23905. __webpack_require__(139);
  23906. __webpack_require__(141);
  23907. __webpack_require__(142)('pie', [{
  23908. type: 'pieToggleSelect',
  23909. event: 'pieselectchanged',
  23910. method: 'toggleSelected'
  23911. }, {
  23912. type: 'pieSelect',
  23913. event: 'pieselected',
  23914. method: 'select'
  23915. }, {
  23916. type: 'pieUnSelect',
  23917. event: 'pieunselected',
  23918. method: 'unSelect'
  23919. }]);
  23920. echarts.registerVisual(zrUtil.curry(__webpack_require__(143), 'pie'));
  23921. echarts.registerLayout(zrUtil.curry(
  23922. __webpack_require__(144), 'pie'
  23923. ));
  23924. echarts.registerProcessor(zrUtil.curry(__webpack_require__(146), 'pie'));
  23925. /***/ },
  23926. /* 139 */
  23927. /***/ function(module, exports, __webpack_require__) {
  23928. 'use strict';
  23929. var List = __webpack_require__(97);
  23930. var zrUtil = __webpack_require__(4);
  23931. var modelUtil = __webpack_require__(5);
  23932. var completeDimensions = __webpack_require__(102);
  23933. var dataSelectableMixin = __webpack_require__(140);
  23934. var PieSeries = __webpack_require__(1).extendSeriesModel({
  23935. type: 'series.pie',
  23936. // Overwrite
  23937. init: function (option) {
  23938. PieSeries.superApply(this, 'init', arguments);
  23939. // Enable legend selection for each data item
  23940. // Use a function instead of direct access because data reference may changed
  23941. this.legendDataProvider = function () {
  23942. return this._dataBeforeProcessed;
  23943. };
  23944. this.updateSelectedMap(option.data);
  23945. this._defaultLabelLine(option);
  23946. },
  23947. // Overwrite
  23948. mergeOption: function (newOption) {
  23949. PieSeries.superCall(this, 'mergeOption', newOption);
  23950. this.updateSelectedMap(this.option.data);
  23951. },
  23952. getInitialData: function (option, ecModel) {
  23953. var dimensions = completeDimensions(['value'], option.data);
  23954. var list = new List(dimensions, this);
  23955. list.initData(option.data);
  23956. return list;
  23957. },
  23958. // Overwrite
  23959. getDataParams: function (dataIndex) {
  23960. var data = this._data;
  23961. var params = PieSeries.superCall(this, 'getDataParams', dataIndex);
  23962. var sum = data.getSum('value');
  23963. // FIXME toFixed?
  23964. //
  23965. // Percent is 0 if sum is 0
  23966. params.percent = !sum ? 0 : +(data.get('value', dataIndex) / sum * 100).toFixed(2);
  23967. params.$vars.push('percent');
  23968. return params;
  23969. },
  23970. _defaultLabelLine: function (option) {
  23971. // Extend labelLine emphasis
  23972. modelUtil.defaultEmphasis(option.labelLine, ['show']);
  23973. var labelLineNormalOpt = option.labelLine.normal;
  23974. var labelLineEmphasisOpt = option.labelLine.emphasis;
  23975. // Not show label line if `label.normal.show = false`
  23976. labelLineNormalOpt.show = labelLineNormalOpt.show
  23977. && option.label.normal.show;
  23978. labelLineEmphasisOpt.show = labelLineEmphasisOpt.show
  23979. && option.label.emphasis.show;
  23980. },
  23981. defaultOption: {
  23982. zlevel: 0,
  23983. z: 2,
  23984. legendHoverLink: true,
  23985. hoverAnimation: true,
  23986. // 默认全局居中
  23987. center: ['50%', '50%'],
  23988. radius: [0, '75%'],
  23989. // 默认顺时针
  23990. clockwise: true,
  23991. startAngle: 90,
  23992. // 最小角度改为0
  23993. minAngle: 0,
  23994. // 选中是扇区偏移量
  23995. selectedOffset: 10,
  23996. // If use strategy to avoid label overlapping
  23997. avoidLabelOverlap: true,
  23998. // 选择模式,默认关闭,可选single,multiple
  23999. // selectedMode: false,
  24000. // 南丁格尔玫瑰图模式,'radius'(半径) | 'area'(面积)
  24001. // roseType: null,
  24002. label: {
  24003. normal: {
  24004. // If rotate around circle
  24005. rotate: false,
  24006. show: true,
  24007. // 'outer', 'inside', 'center'
  24008. position: 'outer'
  24009. // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  24010. // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
  24011. // distance: 当position为inner时有效,为label位置到圆心的距离与圆半径(环状图为内外半径和)的比例系数
  24012. },
  24013. emphasis: {}
  24014. },
  24015. // Enabled when label.normal.position is 'outer'
  24016. labelLine: {
  24017. normal: {
  24018. show: true,
  24019. // 引导线两段中的第一段长度
  24020. length: 15,
  24021. // 引导线两段中的第二段长度
  24022. length2: 15,
  24023. smooth: false,
  24024. lineStyle: {
  24025. // color: 各异,
  24026. width: 1,
  24027. type: 'solid'
  24028. }
  24029. }
  24030. },
  24031. itemStyle: {
  24032. normal: {
  24033. borderWidth: 1
  24034. },
  24035. emphasis: {}
  24036. },
  24037. animationEasing: 'cubicOut',
  24038. data: []
  24039. }
  24040. });
  24041. zrUtil.mixin(PieSeries, dataSelectableMixin);
  24042. module.exports = PieSeries;
  24043. /***/ },
  24044. /* 140 */
  24045. /***/ function(module, exports, __webpack_require__) {
  24046. /**
  24047. * Data selectable mixin for chart series.
  24048. * To eanble data select, option of series must have `selectedMode`.
  24049. * And each data item will use `selected` to toggle itself selected status
  24050. *
  24051. * @module echarts/chart/helper/DataSelectable
  24052. */
  24053. var zrUtil = __webpack_require__(4);
  24054. module.exports = {
  24055. updateSelectedMap: function (targetList) {
  24056. this._selectTargetMap = zrUtil.reduce(targetList || [], function (targetMap, target) {
  24057. targetMap[target.name] = target;
  24058. return targetMap;
  24059. }, {});
  24060. },
  24061. /**
  24062. * @param {string} name
  24063. */
  24064. // PENGING If selectedMode is null ?
  24065. select: function (name) {
  24066. var targetMap = this._selectTargetMap;
  24067. var target = targetMap[name];
  24068. var selectedMode = this.get('selectedMode');
  24069. if (selectedMode === 'single') {
  24070. zrUtil.each(targetMap, function (target) {
  24071. target.selected = false;
  24072. });
  24073. }
  24074. target && (target.selected = true);
  24075. },
  24076. /**
  24077. * @param {string} name
  24078. */
  24079. unSelect: function (name) {
  24080. var target = this._selectTargetMap[name];
  24081. // var selectedMode = this.get('selectedMode');
  24082. // selectedMode !== 'single' && target && (target.selected = false);
  24083. target && (target.selected = false);
  24084. },
  24085. /**
  24086. * @param {string} name
  24087. */
  24088. toggleSelected: function (name) {
  24089. var target = this._selectTargetMap[name];
  24090. if (target != null) {
  24091. this[target.selected ? 'unSelect' : 'select'](name);
  24092. return target.selected;
  24093. }
  24094. },
  24095. /**
  24096. * @param {string} name
  24097. */
  24098. isSelected: function (name) {
  24099. var target = this._selectTargetMap[name];
  24100. return target && target.selected;
  24101. }
  24102. };
  24103. /***/ },
  24104. /* 141 */
  24105. /***/ function(module, exports, __webpack_require__) {
  24106. var graphic = __webpack_require__(43);
  24107. var zrUtil = __webpack_require__(4);
  24108. /**
  24109. * @param {module:echarts/model/Series} seriesModel
  24110. * @param {boolean} hasAnimation
  24111. * @inner
  24112. */
  24113. function updateDataSelected(uid, seriesModel, hasAnimation, api) {
  24114. var data = seriesModel.getData();
  24115. var dataIndex = this.dataIndex;
  24116. var name = data.getName(dataIndex);
  24117. var selectedOffset = seriesModel.get('selectedOffset');
  24118. api.dispatchAction({
  24119. type: 'pieToggleSelect',
  24120. from: uid,
  24121. name: name,
  24122. seriesId: seriesModel.id
  24123. });
  24124. data.each(function (idx) {
  24125. toggleItemSelected(
  24126. data.getItemGraphicEl(idx),
  24127. data.getItemLayout(idx),
  24128. seriesModel.isSelected(data.getName(idx)),
  24129. selectedOffset,
  24130. hasAnimation
  24131. );
  24132. });
  24133. }
  24134. /**
  24135. * @param {module:zrender/graphic/Sector} el
  24136. * @param {Object} layout
  24137. * @param {boolean} isSelected
  24138. * @param {number} selectedOffset
  24139. * @param {boolean} hasAnimation
  24140. * @inner
  24141. */
  24142. function toggleItemSelected(el, layout, isSelected, selectedOffset, hasAnimation) {
  24143. var midAngle = (layout.startAngle + layout.endAngle) / 2;
  24144. var dx = Math.cos(midAngle);
  24145. var dy = Math.sin(midAngle);
  24146. var offset = isSelected ? selectedOffset : 0;
  24147. var position = [dx * offset, dy * offset];
  24148. hasAnimation
  24149. // animateTo will stop revious animation like update transition
  24150. ? el.animate()
  24151. .when(200, {
  24152. position: position
  24153. })
  24154. .start('bounceOut')
  24155. : el.attr('position', position);
  24156. }
  24157. /**
  24158. * Piece of pie including Sector, Label, LabelLine
  24159. * @constructor
  24160. * @extends {module:zrender/graphic/Group}
  24161. */
  24162. function PiePiece(data, idx) {
  24163. graphic.Group.call(this);
  24164. var sector = new graphic.Sector({
  24165. z2: 2
  24166. });
  24167. var polyline = new graphic.Polyline();
  24168. var text = new graphic.Text();
  24169. this.add(sector);
  24170. this.add(polyline);
  24171. this.add(text);
  24172. this.updateData(data, idx, true);
  24173. // Hover to change label and labelLine
  24174. function onEmphasis() {
  24175. polyline.ignore = polyline.hoverIgnore;
  24176. text.ignore = text.hoverIgnore;
  24177. }
  24178. function onNormal() {
  24179. polyline.ignore = polyline.normalIgnore;
  24180. text.ignore = text.normalIgnore;
  24181. }
  24182. this.on('emphasis', onEmphasis)
  24183. .on('normal', onNormal)
  24184. .on('mouseover', onEmphasis)
  24185. .on('mouseout', onNormal);
  24186. }
  24187. var piePieceProto = PiePiece.prototype;
  24188. function getLabelStyle(data, idx, state, labelModel, labelPosition) {
  24189. var textStyleModel = labelModel.getModel('textStyle');
  24190. var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner';
  24191. return {
  24192. fill: textStyleModel.getTextColor()
  24193. || (isLabelInside ? '#fff' : data.getItemVisual(idx, 'color')),
  24194. opacity: data.getItemVisual(idx, 'opacity'),
  24195. textFont: textStyleModel.getFont(),
  24196. text: zrUtil.retrieve(
  24197. data.hostModel.getFormattedLabel(idx, state), data.getName(idx)
  24198. )
  24199. };
  24200. }
  24201. piePieceProto.updateData = function (data, idx, firstCreate) {
  24202. var sector = this.childAt(0);
  24203. var seriesModel = data.hostModel;
  24204. var itemModel = data.getItemModel(idx);
  24205. var layout = data.getItemLayout(idx);
  24206. var sectorShape = zrUtil.extend({}, layout);
  24207. sectorShape.label = null;
  24208. if (firstCreate) {
  24209. sector.setShape(sectorShape);
  24210. sector.shape.endAngle = layout.startAngle;
  24211. graphic.updateProps(sector, {
  24212. shape: {
  24213. endAngle: layout.endAngle
  24214. }
  24215. }, seriesModel, idx);
  24216. }
  24217. else {
  24218. graphic.updateProps(sector, {
  24219. shape: sectorShape
  24220. }, seriesModel, idx);
  24221. }
  24222. // Update common style
  24223. var itemStyleModel = itemModel.getModel('itemStyle');
  24224. var visualColor = data.getItemVisual(idx, 'color');
  24225. sector.useStyle(
  24226. zrUtil.defaults(
  24227. {
  24228. lineJoin: 'bevel',
  24229. fill: visualColor
  24230. },
  24231. itemStyleModel.getModel('normal').getItemStyle()
  24232. )
  24233. );
  24234. sector.hoverStyle = itemStyleModel.getModel('emphasis').getItemStyle();
  24235. // Toggle selected
  24236. toggleItemSelected(
  24237. this,
  24238. data.getItemLayout(idx),
  24239. itemModel.get('selected'),
  24240. seriesModel.get('selectedOffset'),
  24241. seriesModel.get('animation')
  24242. );
  24243. function onEmphasis() {
  24244. // Sector may has animation of updating data. Force to move to the last frame
  24245. // Or it may stopped on the wrong shape
  24246. sector.stopAnimation(true);
  24247. sector.animateTo({
  24248. shape: {
  24249. r: layout.r + 10
  24250. }
  24251. }, 300, 'elasticOut');
  24252. }
  24253. function onNormal() {
  24254. sector.stopAnimation(true);
  24255. sector.animateTo({
  24256. shape: {
  24257. r: layout.r
  24258. }
  24259. }, 300, 'elasticOut');
  24260. }
  24261. sector.off('mouseover').off('mouseout').off('emphasis').off('normal');
  24262. if (itemModel.get('hoverAnimation') && seriesModel.ifEnableAnimation()) {
  24263. sector
  24264. .on('mouseover', onEmphasis)
  24265. .on('mouseout', onNormal)
  24266. .on('emphasis', onEmphasis)
  24267. .on('normal', onNormal);
  24268. }
  24269. this._updateLabel(data, idx);
  24270. graphic.setHoverStyle(this);
  24271. };
  24272. piePieceProto._updateLabel = function (data, idx) {
  24273. var labelLine = this.childAt(1);
  24274. var labelText = this.childAt(2);
  24275. var seriesModel = data.hostModel;
  24276. var itemModel = data.getItemModel(idx);
  24277. var layout = data.getItemLayout(idx);
  24278. var labelLayout = layout.label;
  24279. var visualColor = data.getItemVisual(idx, 'color');
  24280. graphic.updateProps(labelLine, {
  24281. shape: {
  24282. points: labelLayout.linePoints || [
  24283. [labelLayout.x, labelLayout.y], [labelLayout.x, labelLayout.y], [labelLayout.x, labelLayout.y]
  24284. ]
  24285. }
  24286. }, seriesModel, idx);
  24287. graphic.updateProps(labelText, {
  24288. style: {
  24289. x: labelLayout.x,
  24290. y: labelLayout.y
  24291. }
  24292. }, seriesModel, idx);
  24293. labelText.attr({
  24294. style: {
  24295. textVerticalAlign: labelLayout.verticalAlign,
  24296. textAlign: labelLayout.textAlign,
  24297. textFont: labelLayout.font
  24298. },
  24299. rotation: labelLayout.rotation,
  24300. origin: [labelLayout.x, labelLayout.y],
  24301. z2: 10
  24302. });
  24303. var labelModel = itemModel.getModel('label.normal');
  24304. var labelHoverModel = itemModel.getModel('label.emphasis');
  24305. var labelLineModel = itemModel.getModel('labelLine.normal');
  24306. var labelLineHoverModel = itemModel.getModel('labelLine.emphasis');
  24307. var labelPosition = labelModel.get('position') || labelHoverModel.get('position');
  24308. labelText.setStyle(getLabelStyle(data, idx, 'normal', labelModel, labelPosition));
  24309. labelText.ignore = labelText.normalIgnore = !labelModel.get('show');
  24310. labelText.hoverIgnore = !labelHoverModel.get('show');
  24311. labelLine.ignore = labelLine.normalIgnore = !labelLineModel.get('show');
  24312. labelLine.hoverIgnore = !labelLineHoverModel.get('show');
  24313. // Default use item visual color
  24314. labelLine.setStyle({
  24315. stroke: visualColor,
  24316. opacity: data.getItemVisual(idx, 'opacity')
  24317. });
  24318. labelLine.setStyle(labelLineModel.getModel('lineStyle').getLineStyle());
  24319. labelText.hoverStyle = getLabelStyle(data, idx, 'emphasis', labelHoverModel, labelPosition);
  24320. labelLine.hoverStyle = labelLineHoverModel.getModel('lineStyle').getLineStyle();
  24321. var smooth = labelLineModel.get('smooth');
  24322. if (smooth && smooth === true) {
  24323. smooth = 0.4;
  24324. }
  24325. labelLine.setShape({
  24326. smooth: smooth
  24327. });
  24328. };
  24329. zrUtil.inherits(PiePiece, graphic.Group);
  24330. // Pie view
  24331. var Pie = __webpack_require__(42).extend({
  24332. type: 'pie',
  24333. init: function () {
  24334. var sectorGroup = new graphic.Group();
  24335. this._sectorGroup = sectorGroup;
  24336. },
  24337. render: function (seriesModel, ecModel, api, payload) {
  24338. if (payload && (payload.from === this.uid)) {
  24339. return;
  24340. }
  24341. var data = seriesModel.getData();
  24342. var oldData = this._data;
  24343. var group = this.group;
  24344. var hasAnimation = ecModel.get('animation');
  24345. var isFirstRender = !oldData;
  24346. var onSectorClick = zrUtil.curry(
  24347. updateDataSelected, this.uid, seriesModel, hasAnimation, api
  24348. );
  24349. var selectedMode = seriesModel.get('selectedMode');
  24350. data.diff(oldData)
  24351. .add(function (idx) {
  24352. var piePiece = new PiePiece(data, idx);
  24353. if (isFirstRender) {
  24354. piePiece.eachChild(function (child) {
  24355. child.stopAnimation(true);
  24356. });
  24357. }
  24358. selectedMode && piePiece.on('click', onSectorClick);
  24359. data.setItemGraphicEl(idx, piePiece);
  24360. group.add(piePiece);
  24361. })
  24362. .update(function (newIdx, oldIdx) {
  24363. var piePiece = oldData.getItemGraphicEl(oldIdx);
  24364. piePiece.updateData(data, newIdx);
  24365. piePiece.off('click');
  24366. selectedMode && piePiece.on('click', onSectorClick);
  24367. group.add(piePiece);
  24368. data.setItemGraphicEl(newIdx, piePiece);
  24369. })
  24370. .remove(function (idx) {
  24371. var piePiece = oldData.getItemGraphicEl(idx);
  24372. group.remove(piePiece);
  24373. })
  24374. .execute();
  24375. if (hasAnimation && isFirstRender && data.count() > 0) {
  24376. var shape = data.getItemLayout(0);
  24377. var r = Math.max(api.getWidth(), api.getHeight()) / 2;
  24378. var removeClipPath = zrUtil.bind(group.removeClipPath, group);
  24379. group.setClipPath(this._createClipPath(
  24380. shape.cx, shape.cy, r, shape.startAngle, shape.clockwise, removeClipPath, seriesModel
  24381. ));
  24382. }
  24383. this._data = data;
  24384. },
  24385. _createClipPath: function (
  24386. cx, cy, r, startAngle, clockwise, cb, seriesModel
  24387. ) {
  24388. var clipPath = new graphic.Sector({
  24389. shape: {
  24390. cx: cx,
  24391. cy: cy,
  24392. r0: 0,
  24393. r: r,
  24394. startAngle: startAngle,
  24395. endAngle: startAngle,
  24396. clockwise: clockwise
  24397. }
  24398. });
  24399. graphic.initProps(clipPath, {
  24400. shape: {
  24401. endAngle: startAngle + (clockwise ? 1 : -1) * Math.PI * 2
  24402. }
  24403. }, seriesModel, cb);
  24404. return clipPath;
  24405. }
  24406. });
  24407. module.exports = Pie;
  24408. /***/ },
  24409. /* 142 */
  24410. /***/ function(module, exports, __webpack_require__) {
  24411. var echarts = __webpack_require__(1);
  24412. var zrUtil = __webpack_require__(4);
  24413. module.exports = function (seriesType, actionInfos) {
  24414. zrUtil.each(actionInfos, function (actionInfo) {
  24415. actionInfo.update = 'updateView';
  24416. /**
  24417. * @payload
  24418. * @property {string} seriesName
  24419. * @property {string} name
  24420. */
  24421. echarts.registerAction(actionInfo, function (payload, ecModel) {
  24422. var selected = {};
  24423. ecModel.eachComponent(
  24424. {mainType: 'series', subType: seriesType, query: payload},
  24425. function (seriesModel) {
  24426. if (seriesModel[actionInfo.method]) {
  24427. seriesModel[actionInfo.method](payload.name);
  24428. }
  24429. var data = seriesModel.getData();
  24430. // Create selected map
  24431. data.each(function (idx) {
  24432. var name = data.getName(idx);
  24433. selected[name] = seriesModel.isSelected(name) || false;
  24434. });
  24435. }
  24436. );
  24437. return {
  24438. name: payload.name,
  24439. selected: selected
  24440. };
  24441. });
  24442. });
  24443. };
  24444. /***/ },
  24445. /* 143 */
  24446. /***/ function(module, exports) {
  24447. // Pick color from palette for each data item
  24448. module.exports = function (seriesType, ecModel) {
  24449. // Pie and funnel may use diferrent scope
  24450. var paletteScope = {};
  24451. ecModel.eachRawSeriesByType(seriesType, function (seriesModel) {
  24452. var dataAll = seriesModel.getRawData();
  24453. var idxMap = {};
  24454. if (!ecModel.isSeriesFiltered(seriesModel)) {
  24455. var data = seriesModel.getData();
  24456. data.each(function (idx) {
  24457. var rawIdx = data.getRawIndex(idx);
  24458. idxMap[rawIdx] = idx;
  24459. });
  24460. dataAll.each(function (rawIdx) {
  24461. // FIXME Performance
  24462. var itemModel = dataAll.getItemModel(rawIdx);
  24463. var filteredIdx = idxMap[rawIdx];
  24464. // If series.itemStyle.normal.color is a function. itemVisual may be encoded
  24465. var singleDataColor = data.getItemVisual(filteredIdx, 'color', true);
  24466. if (!singleDataColor) {
  24467. var color = itemModel.get('itemStyle.normal.color')
  24468. || seriesModel.getColorFromPalette(dataAll.getName(rawIdx), paletteScope);
  24469. // Legend may use the visual info in data before processed
  24470. dataAll.setItemVisual(rawIdx, 'color', color);
  24471. data.setItemVisual(filteredIdx, 'color', color);
  24472. }
  24473. else {
  24474. // Set data all color for legend
  24475. dataAll.setItemVisual(rawIdx, 'color', singleDataColor);
  24476. }
  24477. });
  24478. }
  24479. });
  24480. };
  24481. /***/ },
  24482. /* 144 */
  24483. /***/ function(module, exports, __webpack_require__) {
  24484. // TODO minAngle
  24485. var numberUtil = __webpack_require__(7);
  24486. var parsePercent = numberUtil.parsePercent;
  24487. var labelLayout = __webpack_require__(145);
  24488. var zrUtil = __webpack_require__(4);
  24489. var PI2 = Math.PI * 2;
  24490. var RADIAN = Math.PI / 180;
  24491. module.exports = function (seriesType, ecModel, api, payload) {
  24492. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  24493. var center = seriesModel.get('center');
  24494. var radius = seriesModel.get('radius');
  24495. if (!zrUtil.isArray(radius)) {
  24496. radius = [0, radius];
  24497. }
  24498. if (!zrUtil.isArray(center)) {
  24499. center = [center, center];
  24500. }
  24501. var width = api.getWidth();
  24502. var height = api.getHeight();
  24503. var size = Math.min(width, height);
  24504. var cx = parsePercent(center[0], width);
  24505. var cy = parsePercent(center[1], height);
  24506. var r0 = parsePercent(radius[0], size / 2);
  24507. var r = parsePercent(radius[1], size / 2);
  24508. var data = seriesModel.getData();
  24509. var startAngle = -seriesModel.get('startAngle') * RADIAN;
  24510. var minAngle = seriesModel.get('minAngle') * RADIAN;
  24511. var sum = data.getSum('value');
  24512. // Sum may be 0
  24513. var unitRadian = Math.PI / (sum || data.count()) * 2;
  24514. var clockwise = seriesModel.get('clockwise');
  24515. var roseType = seriesModel.get('roseType');
  24516. // [0...max]
  24517. var extent = data.getDataExtent('value');
  24518. extent[0] = 0;
  24519. // In the case some sector angle is smaller than minAngle
  24520. var restAngle = PI2;
  24521. var valueSumLargerThanMinAngle = 0;
  24522. var currentAngle = startAngle;
  24523. var dir = clockwise ? 1 : -1;
  24524. data.each('value', function (value, idx) {
  24525. var angle;
  24526. // FIXME 兼容 2.0 但是 roseType 是 area 的时候才是这样?
  24527. if (roseType !== 'area') {
  24528. angle = sum === 0 ? unitRadian : (value * unitRadian);
  24529. }
  24530. else {
  24531. angle = PI2 / (data.count() || 1);
  24532. }
  24533. if (angle < minAngle) {
  24534. angle = minAngle;
  24535. restAngle -= minAngle;
  24536. }
  24537. else {
  24538. valueSumLargerThanMinAngle += value;
  24539. }
  24540. var endAngle = currentAngle + dir * angle;
  24541. data.setItemLayout(idx, {
  24542. angle: angle,
  24543. startAngle: currentAngle,
  24544. endAngle: endAngle,
  24545. clockwise: clockwise,
  24546. cx: cx,
  24547. cy: cy,
  24548. r0: r0,
  24549. r: roseType
  24550. ? numberUtil.linearMap(value, extent, [r0, r])
  24551. : r
  24552. });
  24553. currentAngle = endAngle;
  24554. }, true);
  24555. // Some sector is constrained by minAngle
  24556. // Rest sectors needs recalculate angle
  24557. if (restAngle < PI2) {
  24558. // Average the angle if rest angle is not enough after all angles is
  24559. // Constrained by minAngle
  24560. if (restAngle <= 1e-3) {
  24561. var angle = PI2 / data.count();
  24562. data.each(function (idx) {
  24563. var layout = data.getItemLayout(idx);
  24564. layout.startAngle = startAngle + dir * idx * angle;
  24565. layout.endAngle = startAngle + dir * (idx + 1) * angle;
  24566. });
  24567. }
  24568. else {
  24569. unitRadian = restAngle / valueSumLargerThanMinAngle;
  24570. currentAngle = startAngle;
  24571. data.each('value', function (value, idx) {
  24572. var layout = data.getItemLayout(idx);
  24573. var angle = layout.angle === minAngle
  24574. ? minAngle : value * unitRadian;
  24575. layout.startAngle = currentAngle;
  24576. layout.endAngle = currentAngle + dir * angle;
  24577. currentAngle += angle;
  24578. });
  24579. }
  24580. }
  24581. labelLayout(seriesModel, r, width, height);
  24582. });
  24583. };
  24584. /***/ },
  24585. /* 145 */
  24586. /***/ function(module, exports, __webpack_require__) {
  24587. 'use strict';
  24588. // FIXME emphasis label position is not same with normal label position
  24589. var textContain = __webpack_require__(8);
  24590. function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
  24591. list.sort(function (a, b) {
  24592. return a.y - b.y;
  24593. });
  24594. // 压
  24595. function shiftDown(start, end, delta, dir) {
  24596. for (var j = start; j < end; j++) {
  24597. list[j].y += delta;
  24598. if (j > start
  24599. && j + 1 < end
  24600. && list[j + 1].y > list[j].y + list[j].height
  24601. ) {
  24602. shiftUp(j, delta / 2);
  24603. return;
  24604. }
  24605. }
  24606. shiftUp(end - 1, delta / 2);
  24607. }
  24608. // 弹
  24609. function shiftUp(end, delta) {
  24610. for (var j = end; j >= 0; j--) {
  24611. list[j].y -= delta;
  24612. if (j > 0
  24613. && list[j].y > list[j - 1].y + list[j - 1].height
  24614. ) {
  24615. break;
  24616. }
  24617. }
  24618. }
  24619. function changeX(list, isDownList, cx, cy, r, dir) {
  24620. var lastDeltaX = dir > 0
  24621. ? isDownList // 右侧
  24622. ? Number.MAX_VALUE // 下
  24623. : 0 // 上
  24624. : isDownList // 左侧
  24625. ? Number.MAX_VALUE // 下
  24626. : 0; // 上
  24627. for (var i = 0, l = list.length; i < l; i++) {
  24628. // Not change x for center label
  24629. if (list[i].position === 'center') {
  24630. continue;
  24631. }
  24632. var deltaY = Math.abs(list[i].y - cy);
  24633. var length = list[i].len;
  24634. var length2 = list[i].len2;
  24635. var deltaX = (deltaY < r + length)
  24636. ? Math.sqrt(
  24637. (r + length + length2) * (r + length + length2)
  24638. - deltaY * deltaY
  24639. )
  24640. : Math.abs(list[i].x - cx);
  24641. if (isDownList && deltaX >= lastDeltaX) {
  24642. // 右下,左下
  24643. deltaX = lastDeltaX - 10;
  24644. }
  24645. if (!isDownList && deltaX <= lastDeltaX) {
  24646. // 右上,左上
  24647. deltaX = lastDeltaX + 10;
  24648. }
  24649. list[i].x = cx + deltaX * dir;
  24650. lastDeltaX = deltaX;
  24651. }
  24652. }
  24653. var lastY = 0;
  24654. var delta;
  24655. var len = list.length;
  24656. var upList = [];
  24657. var downList = [];
  24658. for (var i = 0; i < len; i++) {
  24659. delta = list[i].y - lastY;
  24660. if (delta < 0) {
  24661. shiftDown(i, len, -delta, dir);
  24662. }
  24663. lastY = list[i].y + list[i].height;
  24664. }
  24665. if (viewHeight - lastY < 0) {
  24666. shiftUp(len - 1, lastY - viewHeight);
  24667. }
  24668. for (var i = 0; i < len; i++) {
  24669. if (list[i].y >= cy) {
  24670. downList.push(list[i]);
  24671. }
  24672. else {
  24673. upList.push(list[i]);
  24674. }
  24675. }
  24676. changeX(upList, false, cx, cy, r, dir);
  24677. changeX(downList, true, cx, cy, r, dir);
  24678. }
  24679. function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight) {
  24680. var leftList = [];
  24681. var rightList = [];
  24682. for (var i = 0; i < labelLayoutList.length; i++) {
  24683. if (labelLayoutList[i].x < cx) {
  24684. leftList.push(labelLayoutList[i]);
  24685. }
  24686. else {
  24687. rightList.push(labelLayoutList[i]);
  24688. }
  24689. }
  24690. adjustSingleSide(rightList, cx, cy, r, 1, viewWidth, viewHeight);
  24691. adjustSingleSide(leftList, cx, cy, r, -1, viewWidth, viewHeight);
  24692. for (var i = 0; i < labelLayoutList.length; i++) {
  24693. var linePoints = labelLayoutList[i].linePoints;
  24694. if (linePoints) {
  24695. var dist = linePoints[1][0] - linePoints[2][0];
  24696. if (labelLayoutList[i].x < cx) {
  24697. linePoints[2][0] = labelLayoutList[i].x + 3;
  24698. }
  24699. else {
  24700. linePoints[2][0] = labelLayoutList[i].x - 3;
  24701. }
  24702. linePoints[1][1] = linePoints[2][1] = labelLayoutList[i].y;
  24703. linePoints[1][0] = linePoints[2][0] + dist;
  24704. }
  24705. }
  24706. }
  24707. module.exports = function (seriesModel, r, viewWidth, viewHeight) {
  24708. var data = seriesModel.getData();
  24709. var labelLayoutList = [];
  24710. var cx;
  24711. var cy;
  24712. var hasLabelRotate = false;
  24713. data.each(function (idx) {
  24714. var layout = data.getItemLayout(idx);
  24715. var itemModel = data.getItemModel(idx);
  24716. var labelModel = itemModel.getModel('label.normal');
  24717. // Use position in normal or emphasis
  24718. var labelPosition = labelModel.get('position') || itemModel.get('label.emphasis.position');
  24719. var labelLineModel = itemModel.getModel('labelLine.normal');
  24720. var labelLineLen = labelLineModel.get('length');
  24721. var labelLineLen2 = labelLineModel.get('length2');
  24722. var midAngle = (layout.startAngle + layout.endAngle) / 2;
  24723. var dx = Math.cos(midAngle);
  24724. var dy = Math.sin(midAngle);
  24725. var textX;
  24726. var textY;
  24727. var linePoints;
  24728. var textAlign;
  24729. cx = layout.cx;
  24730. cy = layout.cy;
  24731. var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner';
  24732. if (labelPosition === 'center') {
  24733. textX = layout.cx;
  24734. textY = layout.cy;
  24735. textAlign = 'center';
  24736. }
  24737. else {
  24738. var x1 = (isLabelInside ? (layout.r + layout.r0) / 2 * dx : layout.r * dx) + cx;
  24739. var y1 = (isLabelInside ? (layout.r + layout.r0) / 2 * dy : layout.r * dy) + cy;
  24740. textX = x1 + dx * 3;
  24741. textY = y1 + dy * 3;
  24742. if (!isLabelInside) {
  24743. // For roseType
  24744. var x2 = x1 + dx * (labelLineLen + r - layout.r);
  24745. var y2 = y1 + dy * (labelLineLen + r - layout.r);
  24746. var x3 = x2 + ((dx < 0 ? -1 : 1) * labelLineLen2);
  24747. var y3 = y2;
  24748. textX = x3 + (dx < 0 ? -5 : 5);
  24749. textY = y3;
  24750. linePoints = [[x1, y1], [x2, y2], [x3, y3]];
  24751. }
  24752. textAlign = isLabelInside ? 'center' : (dx > 0 ? 'left' : 'right');
  24753. }
  24754. var font = labelModel.getModel('textStyle').getFont();
  24755. var labelRotate = labelModel.get('rotate')
  24756. ? (dx < 0 ? -midAngle + Math.PI : -midAngle) : 0;
  24757. var text = seriesModel.getFormattedLabel(idx, 'normal')
  24758. || data.getName(idx);
  24759. var textRect = textContain.getBoundingRect(
  24760. text, font, textAlign, 'top'
  24761. );
  24762. hasLabelRotate = !!labelRotate;
  24763. layout.label = {
  24764. x: textX,
  24765. y: textY,
  24766. position: labelPosition,
  24767. height: textRect.height,
  24768. len: labelLineLen,
  24769. len2: labelLineLen2,
  24770. linePoints: linePoints,
  24771. textAlign: textAlign,
  24772. verticalAlign: 'middle',
  24773. font: font,
  24774. rotation: labelRotate
  24775. };
  24776. // Not layout the inside label
  24777. if (!isLabelInside) {
  24778. labelLayoutList.push(layout.label);
  24779. }
  24780. });
  24781. if (!hasLabelRotate && seriesModel.get('avoidLabelOverlap')) {
  24782. avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight);
  24783. }
  24784. };
  24785. /***/ },
  24786. /* 146 */
  24787. /***/ function(module, exports) {
  24788. module.exports = function (seriesType, ecModel) {
  24789. var legendModels = ecModel.findComponents({
  24790. mainType: 'legend'
  24791. });
  24792. if (!legendModels || !legendModels.length) {
  24793. return;
  24794. }
  24795. ecModel.eachSeriesByType(seriesType, function (series) {
  24796. var data = series.getData();
  24797. data.filterSelf(function (idx) {
  24798. var name = data.getName(idx);
  24799. // If in any legend component the status is not selected.
  24800. for (var i = 0; i < legendModels.length; i++) {
  24801. if (!legendModels[i].isSelected(name)) {
  24802. return false;
  24803. }
  24804. }
  24805. return true;
  24806. }, this);
  24807. }, this);
  24808. };
  24809. /***/ },
  24810. /* 147 */
  24811. /***/ function(module, exports, __webpack_require__) {
  24812. var zrUtil = __webpack_require__(4);
  24813. var echarts = __webpack_require__(1);
  24814. __webpack_require__(148);
  24815. __webpack_require__(149);
  24816. echarts.registerVisual(zrUtil.curry(
  24817. __webpack_require__(109), 'scatter', 'circle', null
  24818. ));
  24819. echarts.registerLayout(zrUtil.curry(
  24820. __webpack_require__(110), 'scatter'
  24821. ));
  24822. // In case developer forget to include grid component
  24823. __webpack_require__(112);
  24824. /***/ },
  24825. /* 148 */
  24826. /***/ function(module, exports, __webpack_require__) {
  24827. 'use strict';
  24828. var createListFromArray = __webpack_require__(101);
  24829. var SeriesModel = __webpack_require__(28);
  24830. module.exports = SeriesModel.extend({
  24831. type: 'series.scatter',
  24832. dependencies: ['grid', 'polar'],
  24833. getInitialData: function (option, ecModel) {
  24834. var list = createListFromArray(option.data, this, ecModel);
  24835. return list;
  24836. },
  24837. brushSelector: 'point',
  24838. defaultOption: {
  24839. coordinateSystem: 'cartesian2d',
  24840. zlevel: 0,
  24841. z: 2,
  24842. legendHoverLink: true,
  24843. hoverAnimation: true,
  24844. // Cartesian coordinate system
  24845. xAxisIndex: 0,
  24846. yAxisIndex: 0,
  24847. // Polar coordinate system
  24848. polarIndex: 0,
  24849. // Geo coordinate system
  24850. geoIndex: 0,
  24851. // symbol: null, // 图形类型
  24852. symbolSize: 10, // 图形大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2
  24853. // symbolRotate: null, // 图形旋转控制
  24854. large: false,
  24855. // Available when large is true
  24856. largeThreshold: 2000,
  24857. // label: {
  24858. // normal: {
  24859. // show: false
  24860. // distance: 5,
  24861. // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  24862. // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为
  24863. // 'inside'|'left'|'right'|'top'|'bottom'
  24864. // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
  24865. // }
  24866. // },
  24867. itemStyle: {
  24868. normal: {
  24869. opacity: 0.8
  24870. // color: 各异
  24871. }
  24872. }
  24873. }
  24874. });
  24875. /***/ },
  24876. /* 149 */
  24877. /***/ function(module, exports, __webpack_require__) {
  24878. var SymbolDraw = __webpack_require__(104);
  24879. var LargeSymbolDraw = __webpack_require__(150);
  24880. __webpack_require__(1).extendChartView({
  24881. type: 'scatter',
  24882. init: function () {
  24883. this._normalSymbolDraw = new SymbolDraw();
  24884. this._largeSymbolDraw = new LargeSymbolDraw();
  24885. },
  24886. render: function (seriesModel, ecModel, api) {
  24887. var data = seriesModel.getData();
  24888. var largeSymbolDraw = this._largeSymbolDraw;
  24889. var normalSymbolDraw = this._normalSymbolDraw;
  24890. var group = this.group;
  24891. var symbolDraw = seriesModel.get('large') && data.count() > seriesModel.get('largeThreshold')
  24892. ? largeSymbolDraw : normalSymbolDraw;
  24893. this._symbolDraw = symbolDraw;
  24894. symbolDraw.updateData(data);
  24895. group.add(symbolDraw.group);
  24896. group.remove(
  24897. symbolDraw === largeSymbolDraw
  24898. ? normalSymbolDraw.group : largeSymbolDraw.group
  24899. );
  24900. },
  24901. updateLayout: function (seriesModel) {
  24902. this._symbolDraw.updateLayout(seriesModel);
  24903. },
  24904. remove: function (ecModel, api) {
  24905. this._symbolDraw && this._symbolDraw.remove(api, true);
  24906. }
  24907. });
  24908. /***/ },
  24909. /* 150 */
  24910. /***/ function(module, exports, __webpack_require__) {
  24911. // TODO Batch by color
  24912. var graphic = __webpack_require__(43);
  24913. var symbolUtil = __webpack_require__(106);
  24914. var LargeSymbolPath = graphic.extendShape({
  24915. shape: {
  24916. points: null,
  24917. sizes: null
  24918. },
  24919. symbolProxy: null,
  24920. buildPath: function (path, shape) {
  24921. var points = shape.points;
  24922. var sizes = shape.sizes;
  24923. var symbolProxy = this.symbolProxy;
  24924. var symbolProxyShape = symbolProxy.shape;
  24925. for (var i = 0; i < points.length; i++) {
  24926. var pt = points[i];
  24927. var size = sizes[i];
  24928. if (size[0] < 4) {
  24929. // Optimize for small symbol
  24930. path.rect(
  24931. pt[0] - size[0] / 2, pt[1] - size[1] / 2,
  24932. size[0], size[1]
  24933. );
  24934. }
  24935. else {
  24936. symbolProxyShape.x = pt[0] - size[0] / 2;
  24937. symbolProxyShape.y = pt[1] - size[1] / 2;
  24938. symbolProxyShape.width = size[0];
  24939. symbolProxyShape.height = size[1];
  24940. symbolProxy.buildPath(path, symbolProxyShape, true);
  24941. }
  24942. }
  24943. },
  24944. findDataIndex: function (x, y) {
  24945. var shape = this.shape;
  24946. var points = shape.points;
  24947. var sizes = shape.sizes;
  24948. // Not consider transform
  24949. // Treat each element as a rect
  24950. // top down traverse
  24951. for (var i = points.length - 1; i >= 0; i--) {
  24952. var pt = points[i];
  24953. var size = sizes[i];
  24954. var x0 = pt[0] - size[0] / 2;
  24955. var y0 = pt[1] - size[1] / 2;
  24956. if (x >= x0 && y >= y0 && x <= x0 + size[0] && y <= y0 + size[1]) {
  24957. // i is dataIndex
  24958. return i;
  24959. }
  24960. }
  24961. return -1;
  24962. }
  24963. });
  24964. function LargeSymbolDraw() {
  24965. this.group = new graphic.Group();
  24966. this._symbolEl = new LargeSymbolPath({
  24967. // rectHover: true,
  24968. // cursor: 'default'
  24969. });
  24970. }
  24971. var largeSymbolProto = LargeSymbolDraw.prototype;
  24972. /**
  24973. * Update symbols draw by new data
  24974. * @param {module:echarts/data/List} data
  24975. */
  24976. largeSymbolProto.updateData = function (data) {
  24977. this.group.removeAll();
  24978. var symbolEl = this._symbolEl;
  24979. var seriesModel = data.hostModel;
  24980. symbolEl.setShape({
  24981. points: data.mapArray(data.getItemLayout),
  24982. sizes: data.mapArray(
  24983. function (idx) {
  24984. var size = data.getItemVisual(idx, 'symbolSize');
  24985. if (!(size instanceof Array)) {
  24986. size = [size, size];
  24987. }
  24988. return size;
  24989. }
  24990. )
  24991. });
  24992. // Create symbolProxy to build path for each data
  24993. symbolEl.symbolProxy = symbolUtil.createSymbol(
  24994. data.getVisual('symbol'), 0, 0, 0, 0
  24995. );
  24996. // Use symbolProxy setColor method
  24997. symbolEl.setColor = symbolEl.symbolProxy.setColor;
  24998. symbolEl.useStyle(
  24999. seriesModel.getModel('itemStyle.normal').getItemStyle(['color'])
  25000. );
  25001. var visualColor = data.getVisual('color');
  25002. if (visualColor) {
  25003. symbolEl.setColor(visualColor);
  25004. }
  25005. // Enable tooltip
  25006. // PENDING May have performance issue when path is extremely large
  25007. symbolEl.seriesIndex = seriesModel.seriesIndex;
  25008. symbolEl.on('mousemove', function (e) {
  25009. symbolEl.dataIndex = null;
  25010. var dataIndex = symbolEl.findDataIndex(e.offsetX, e.offsetY);
  25011. if (dataIndex > 0) {
  25012. // Provide dataIndex for tooltip
  25013. symbolEl.dataIndex = dataIndex;
  25014. }
  25015. });
  25016. // Add back
  25017. this.group.add(symbolEl);
  25018. };
  25019. largeSymbolProto.updateLayout = function (seriesModel) {
  25020. var data = seriesModel.getData();
  25021. this._symbolEl.setShape({
  25022. points: data.mapArray(data.getItemLayout)
  25023. });
  25024. };
  25025. largeSymbolProto.remove = function () {
  25026. this.group.removeAll();
  25027. };
  25028. module.exports = LargeSymbolDraw;
  25029. /***/ },
  25030. /* 151 */
  25031. /***/ function(module, exports, __webpack_require__) {
  25032. var zrUtil = __webpack_require__(4);
  25033. var echarts = __webpack_require__(1);
  25034. // Must use radar component
  25035. __webpack_require__(152);
  25036. __webpack_require__(157);
  25037. __webpack_require__(158);
  25038. echarts.registerVisual(zrUtil.curry(__webpack_require__(143), 'radar'));
  25039. echarts.registerVisual(zrUtil.curry(
  25040. __webpack_require__(109), 'radar', 'circle', null
  25041. ));
  25042. echarts.registerLayout(__webpack_require__(159));
  25043. echarts.registerProcessor(
  25044. zrUtil.curry(__webpack_require__(146), 'radar')
  25045. );
  25046. echarts.registerPreprocessor(__webpack_require__(160));
  25047. /***/ },
  25048. /* 152 */
  25049. /***/ function(module, exports, __webpack_require__) {
  25050. __webpack_require__(153);
  25051. __webpack_require__(155);
  25052. __webpack_require__(156);
  25053. /***/ },
  25054. /* 153 */
  25055. /***/ function(module, exports, __webpack_require__) {
  25056. // TODO clockwise
  25057. var zrUtil = __webpack_require__(4);
  25058. var IndicatorAxis = __webpack_require__(154);
  25059. var IntervalScale = __webpack_require__(117);
  25060. var numberUtil = __webpack_require__(7);
  25061. var axisHelper = __webpack_require__(114);
  25062. function Radar(radarModel, ecModel, api) {
  25063. this._model = radarModel;
  25064. /**
  25065. * Radar dimensions
  25066. * @type {Array.<string>}
  25067. */
  25068. this.dimensions = [];
  25069. this._indicatorAxes = zrUtil.map(radarModel.getIndicatorModels(), function (indicatorModel, idx) {
  25070. var dim = 'indicator_' + idx;
  25071. var indicatorAxis = new IndicatorAxis(dim, new IntervalScale());
  25072. indicatorAxis.name = indicatorModel.get('name');
  25073. // Inject model and axis
  25074. indicatorAxis.model = indicatorModel;
  25075. indicatorModel.axis = indicatorAxis;
  25076. this.dimensions.push(dim);
  25077. return indicatorAxis;
  25078. }, this);
  25079. this.resize(radarModel, api);
  25080. /**
  25081. * @type {number}
  25082. * @readOnly
  25083. */
  25084. this.cx;
  25085. /**
  25086. * @type {number}
  25087. * @readOnly
  25088. */
  25089. this.cy;
  25090. /**
  25091. * @type {number}
  25092. * @readOnly
  25093. */
  25094. this.r;
  25095. /**
  25096. * @type {number}
  25097. * @readOnly
  25098. */
  25099. this.startAngle;
  25100. }
  25101. Radar.prototype.getIndicatorAxes = function () {
  25102. return this._indicatorAxes;
  25103. };
  25104. Radar.prototype.dataToPoint = function (value, indicatorIndex) {
  25105. var indicatorAxis = this._indicatorAxes[indicatorIndex];
  25106. return this.coordToPoint(indicatorAxis.dataToCoord(value), indicatorIndex);
  25107. };
  25108. Radar.prototype.coordToPoint = function (coord, indicatorIndex) {
  25109. var indicatorAxis = this._indicatorAxes[indicatorIndex];
  25110. var angle = indicatorAxis.angle;
  25111. var x = this.cx + coord * Math.cos(angle);
  25112. var y = this.cy - coord * Math.sin(angle);
  25113. return [x, y];
  25114. };
  25115. Radar.prototype.pointToData = function (pt) {
  25116. var dx = pt[0] - this.cx;
  25117. var dy = pt[1] - this.cy;
  25118. var radius = Math.sqrt(dx * dx + dy * dy);
  25119. dx /= radius;
  25120. dy /= radius;
  25121. var radian = Math.atan2(-dy, dx);
  25122. // Find the closest angle
  25123. // FIXME index can calculated directly
  25124. var minRadianDiff = Infinity;
  25125. var closestAxis;
  25126. var closestAxisIdx = -1;
  25127. for (var i = 0; i < this._indicatorAxes.length; i++) {
  25128. var indicatorAxis = this._indicatorAxes[i];
  25129. var diff = Math.abs(radian - indicatorAxis.angle);
  25130. if (diff < minRadianDiff) {
  25131. closestAxis = indicatorAxis;
  25132. closestAxisIdx = i;
  25133. minRadianDiff = diff;
  25134. }
  25135. }
  25136. return [closestAxisIdx, +(closestAxis && closestAxis.coodToData(radius))];
  25137. };
  25138. Radar.prototype.resize = function (radarModel, api) {
  25139. var center = radarModel.get('center');
  25140. var viewWidth = api.getWidth();
  25141. var viewHeight = api.getHeight();
  25142. var viewSize = Math.min(viewWidth, viewHeight) / 2;
  25143. this.cx = numberUtil.parsePercent(center[0], viewWidth);
  25144. this.cy = numberUtil.parsePercent(center[1], viewHeight);
  25145. this.startAngle = radarModel.get('startAngle') * Math.PI / 180;
  25146. this.r = numberUtil.parsePercent(radarModel.get('radius'), viewSize);
  25147. zrUtil.each(this._indicatorAxes, function (indicatorAxis, idx) {
  25148. indicatorAxis.setExtent(0, this.r);
  25149. var angle = (this.startAngle + idx * Math.PI * 2 / this._indicatorAxes.length);
  25150. // Normalize to [-PI, PI]
  25151. angle = Math.atan2(Math.sin(angle), Math.cos(angle));
  25152. indicatorAxis.angle = angle;
  25153. }, this);
  25154. };
  25155. Radar.prototype.update = function (ecModel, api) {
  25156. var indicatorAxes = this._indicatorAxes;
  25157. var radarModel = this._model;
  25158. zrUtil.each(indicatorAxes, function (indicatorAxis) {
  25159. indicatorAxis.scale.setExtent(Infinity, -Infinity);
  25160. });
  25161. ecModel.eachSeriesByType('radar', function (radarSeries, idx) {
  25162. if (radarSeries.get('coordinateSystem') !== 'radar'
  25163. || ecModel.getComponent('radar', radarSeries.get('radarIndex')) !== radarModel
  25164. ) {
  25165. return;
  25166. }
  25167. var data = radarSeries.getData();
  25168. zrUtil.each(indicatorAxes, function (indicatorAxis) {
  25169. indicatorAxis.scale.unionExtent(data.getDataExtent(indicatorAxis.dim));
  25170. });
  25171. }, this);
  25172. var splitNumber = radarModel.get('splitNumber');
  25173. function increaseInterval(interval) {
  25174. var exp10 = Math.pow(10, Math.floor(Math.log(interval) / Math.LN10));
  25175. // Increase interval
  25176. var f = interval / exp10;
  25177. if (f === 2) {
  25178. f = 5;
  25179. }
  25180. else { // f is 2 or 5
  25181. f *= 2;
  25182. }
  25183. return f * exp10;
  25184. }
  25185. // Force all the axis fixing the maxSplitNumber.
  25186. zrUtil.each(indicatorAxes, function (indicatorAxis, idx) {
  25187. var rawExtent = axisHelper.getScaleExtent(indicatorAxis, indicatorAxis.model);
  25188. axisHelper.niceScaleExtent(indicatorAxis, indicatorAxis.model);
  25189. var axisModel = indicatorAxis.model;
  25190. var scale = indicatorAxis.scale;
  25191. var fixedMin = axisModel.get('min');
  25192. var fixedMax = axisModel.get('max');
  25193. var interval = scale.getInterval();
  25194. if (fixedMin != null && fixedMax != null) {
  25195. // User set min, max, divide to get new interval
  25196. // FIXME precision
  25197. scale.setInterval(
  25198. (fixedMax - fixedMin) / splitNumber
  25199. );
  25200. }
  25201. else if (fixedMin != null) {
  25202. var max;
  25203. // User set min, expand extent on the other side
  25204. do {
  25205. max = fixedMin + interval * splitNumber;
  25206. scale.setExtent(+fixedMin, max);
  25207. // Interval must been set after extent
  25208. // FIXME
  25209. scale.setInterval(interval);
  25210. interval = increaseInterval(interval);
  25211. } while (max < rawExtent[1] && isFinite(max) && isFinite(rawExtent[1]));
  25212. }
  25213. else if (fixedMax != null) {
  25214. var min;
  25215. // User set min, expand extent on the other side
  25216. do {
  25217. min = fixedMax - interval * splitNumber;
  25218. scale.setExtent(min, +fixedMax);
  25219. scale.setInterval(interval);
  25220. interval = increaseInterval(interval);
  25221. } while (min > rawExtent[0] && isFinite(min) && isFinite(rawExtent[0]));
  25222. }
  25223. else {
  25224. var nicedSplitNumber = scale.getTicks().length - 1;
  25225. if (nicedSplitNumber > splitNumber) {
  25226. interval = increaseInterval(interval);
  25227. }
  25228. // PENDING
  25229. var center = Math.round((rawExtent[0] + rawExtent[1]) / 2 / interval) * interval;
  25230. var halfSplitNumber = Math.round(splitNumber / 2);
  25231. scale.setExtent(
  25232. numberUtil.round(center - halfSplitNumber * interval),
  25233. numberUtil.round(center + (splitNumber - halfSplitNumber) * interval)
  25234. );
  25235. scale.setInterval(interval);
  25236. }
  25237. });
  25238. };
  25239. /**
  25240. * Radar dimensions is based on the data
  25241. * @type {Array}
  25242. */
  25243. Radar.dimensions = [];
  25244. Radar.create = function (ecModel, api) {
  25245. var radarList = [];
  25246. ecModel.eachComponent('radar', function (radarModel) {
  25247. var radar = new Radar(radarModel, ecModel, api);
  25248. radarList.push(radar);
  25249. radarModel.coordinateSystem = radar;
  25250. });
  25251. ecModel.eachSeriesByType('radar', function (radarSeries) {
  25252. if (radarSeries.get('coordinateSystem') === 'radar') {
  25253. // Inject coordinate system
  25254. radarSeries.coordinateSystem = radarList[radarSeries.get('radarIndex') || 0];
  25255. }
  25256. });
  25257. return radarList;
  25258. };
  25259. __webpack_require__(26).register('radar', Radar);
  25260. module.exports = Radar;
  25261. /***/ },
  25262. /* 154 */
  25263. /***/ function(module, exports, __webpack_require__) {
  25264. var zrUtil = __webpack_require__(4);
  25265. var Axis = __webpack_require__(123);
  25266. function IndicatorAxis(dim, scale, radiusExtent) {
  25267. Axis.call(this, dim, scale, radiusExtent);
  25268. /**
  25269. * Axis type
  25270. * - 'category'
  25271. * - 'value'
  25272. * - 'time'
  25273. * - 'log'
  25274. * @type {string}
  25275. */
  25276. this.type = 'value';
  25277. this.angle = 0;
  25278. /**
  25279. * Indicator name
  25280. * @type {string}
  25281. */
  25282. this.name = '';
  25283. /**
  25284. * @type {module:echarts/model/Model}
  25285. */
  25286. this.model;
  25287. }
  25288. zrUtil.inherits(IndicatorAxis, Axis);
  25289. module.exports = IndicatorAxis;
  25290. /***/ },
  25291. /* 155 */
  25292. /***/ function(module, exports, __webpack_require__) {
  25293. var axisDefault = __webpack_require__(128);
  25294. var valueAxisDefault = axisDefault.valueAxis;
  25295. var Model = __webpack_require__(12);
  25296. var zrUtil = __webpack_require__(4);
  25297. var axisModelCommonMixin = __webpack_require__(129);
  25298. function defaultsShow(opt, show) {
  25299. return zrUtil.defaults({
  25300. show: show
  25301. }, opt);
  25302. }
  25303. var RadarModel = __webpack_require__(1).extendComponentModel({
  25304. type: 'radar',
  25305. optionUpdated: function () {
  25306. var boundaryGap = this.get('boundaryGap');
  25307. var splitNumber = this.get('splitNumber');
  25308. var scale = this.get('scale');
  25309. var axisLine = this.get('axisLine');
  25310. var axisTick = this.get('axisTick');
  25311. var axisLabel = this.get('axisLabel');
  25312. var nameTextStyle = this.get('name.textStyle');
  25313. var showName = this.get('name.show');
  25314. var nameFormatter = this.get('name.formatter');
  25315. var nameGap = this.get('nameGap');
  25316. var indicatorModels = zrUtil.map(this.get('indicator') || [], function (indicatorOpt) {
  25317. // PENDING
  25318. if (indicatorOpt.max != null && indicatorOpt.max > 0) {
  25319. indicatorOpt.min = 0;
  25320. }
  25321. else if (indicatorOpt.min != null && indicatorOpt.min < 0) {
  25322. indicatorOpt.max = 0;
  25323. }
  25324. // Use same configuration
  25325. indicatorOpt = zrUtil.merge(zrUtil.clone(indicatorOpt), {
  25326. boundaryGap: boundaryGap,
  25327. splitNumber: splitNumber,
  25328. scale: scale,
  25329. axisLine: axisLine,
  25330. axisTick: axisTick,
  25331. axisLabel: axisLabel,
  25332. // Competitable with 2 and use text
  25333. name: indicatorOpt.text,
  25334. nameLocation: 'end',
  25335. nameGap: nameGap,
  25336. // min: 0,
  25337. nameTextStyle: nameTextStyle
  25338. }, false);
  25339. if (!showName) {
  25340. indicatorOpt.name = '';
  25341. }
  25342. if (typeof nameFormatter === 'string') {
  25343. indicatorOpt.name = nameFormatter.replace('{value}', indicatorOpt.name);
  25344. }
  25345. else if (typeof nameFormatter === 'function') {
  25346. indicatorOpt.name = nameFormatter(
  25347. indicatorOpt.name, indicatorOpt
  25348. );
  25349. }
  25350. return zrUtil.extend(
  25351. new Model(indicatorOpt, null, this.ecModel),
  25352. axisModelCommonMixin
  25353. );
  25354. }, this);
  25355. this.getIndicatorModels = function () {
  25356. return indicatorModels;
  25357. };
  25358. },
  25359. defaultOption: {
  25360. zlevel: 0,
  25361. z: 0,
  25362. center: ['50%', '50%'],
  25363. radius: '75%',
  25364. startAngle: 90,
  25365. name: {
  25366. show: true
  25367. // formatter: null
  25368. // textStyle: {}
  25369. },
  25370. boundaryGap: [0, 0],
  25371. splitNumber: 5,
  25372. nameGap: 15,
  25373. scale: false,
  25374. // Polygon or circle
  25375. shape: 'polygon',
  25376. axisLine: zrUtil.merge(
  25377. {
  25378. lineStyle: {
  25379. color: '#bbb'
  25380. }
  25381. },
  25382. valueAxisDefault.axisLine
  25383. ),
  25384. axisLabel: defaultsShow(valueAxisDefault.axisLabel, false),
  25385. axisTick: defaultsShow(valueAxisDefault.axisTick, false),
  25386. splitLine: defaultsShow(valueAxisDefault.splitLine, true),
  25387. splitArea: defaultsShow(valueAxisDefault.splitArea, true),
  25388. // {text, min, max}
  25389. indicator: []
  25390. }
  25391. });
  25392. module.exports = RadarModel;
  25393. /***/ },
  25394. /* 156 */
  25395. /***/ function(module, exports, __webpack_require__) {
  25396. var AxisBuilder = __webpack_require__(132);
  25397. var zrUtil = __webpack_require__(4);
  25398. var graphic = __webpack_require__(43);
  25399. var axisBuilderAttrs = [
  25400. 'axisLine', 'axisLabel', 'axisTick', 'axisName'
  25401. ];
  25402. module.exports = __webpack_require__(1).extendComponentView({
  25403. type: 'radar',
  25404. render: function (radarModel, ecModel, api) {
  25405. var group = this.group;
  25406. group.removeAll();
  25407. this._buildAxes(radarModel);
  25408. this._buildSplitLineAndArea(radarModel);
  25409. },
  25410. _buildAxes: function (radarModel) {
  25411. var radar = radarModel.coordinateSystem;
  25412. var indicatorAxes = radar.getIndicatorAxes();
  25413. var axisBuilders = zrUtil.map(indicatorAxes, function (indicatorAxis) {
  25414. var axisBuilder = new AxisBuilder(indicatorAxis.model, {
  25415. position: [radar.cx, radar.cy],
  25416. rotation: indicatorAxis.angle,
  25417. labelDirection: -1,
  25418. tickDirection: -1,
  25419. nameDirection: 1
  25420. });
  25421. return axisBuilder;
  25422. });
  25423. zrUtil.each(axisBuilders, function (axisBuilder) {
  25424. zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder);
  25425. this.group.add(axisBuilder.getGroup());
  25426. }, this);
  25427. },
  25428. _buildSplitLineAndArea: function (radarModel) {
  25429. var radar = radarModel.coordinateSystem;
  25430. var splitNumber = radarModel.get('splitNumber');
  25431. var indicatorAxes = radar.getIndicatorAxes();
  25432. if (!indicatorAxes.length) {
  25433. return;
  25434. }
  25435. var shape = radarModel.get('shape');
  25436. var splitLineModel = radarModel.getModel('splitLine');
  25437. var splitAreaModel = radarModel.getModel('splitArea');
  25438. var lineStyleModel = splitLineModel.getModel('lineStyle');
  25439. var areaStyleModel = splitAreaModel.getModel('areaStyle');
  25440. var showSplitLine = splitLineModel.get('show');
  25441. var showSplitArea = splitAreaModel.get('show');
  25442. var splitLineColors = lineStyleModel.get('color');
  25443. var splitAreaColors = areaStyleModel.get('color');
  25444. splitLineColors = zrUtil.isArray(splitLineColors) ? splitLineColors : [splitLineColors];
  25445. splitAreaColors = zrUtil.isArray(splitAreaColors) ? splitAreaColors : [splitAreaColors];
  25446. var splitLines = [];
  25447. var splitAreas = [];
  25448. function getColorIndex(areaOrLine, areaOrLineColorList, idx) {
  25449. var colorIndex = idx % areaOrLineColorList.length;
  25450. areaOrLine[colorIndex] = areaOrLine[colorIndex] || [];
  25451. return colorIndex;
  25452. }
  25453. if (shape === 'circle') {
  25454. var ticksRadius = indicatorAxes[0].getTicksCoords();
  25455. var cx = radar.cx;
  25456. var cy = radar.cy;
  25457. for (var i = 0; i < ticksRadius.length; i++) {
  25458. if (showSplitLine) {
  25459. var colorIndex = getColorIndex(splitLines, splitLineColors, i);
  25460. splitLines[colorIndex].push(new graphic.Circle({
  25461. shape: {
  25462. cx: cx,
  25463. cy: cy,
  25464. r: ticksRadius[i]
  25465. }
  25466. }));
  25467. }
  25468. if (showSplitArea && i < ticksRadius.length - 1) {
  25469. var colorIndex = getColorIndex(splitAreas, splitAreaColors, i);
  25470. splitAreas[colorIndex].push(new graphic.Ring({
  25471. shape: {
  25472. cx: cx,
  25473. cy: cy,
  25474. r0: ticksRadius[i],
  25475. r: ticksRadius[i + 1]
  25476. }
  25477. }));
  25478. }
  25479. }
  25480. }
  25481. // Polyyon
  25482. else {
  25483. var axesTicksPoints = zrUtil.map(indicatorAxes, function (indicatorAxis, idx) {
  25484. var ticksCoords = indicatorAxis.getTicksCoords();
  25485. return zrUtil.map(ticksCoords, function (tickCoord) {
  25486. return radar.coordToPoint(tickCoord, idx);
  25487. });
  25488. });
  25489. var prevPoints = [];
  25490. for (var i = 0; i <= splitNumber; i++) {
  25491. var points = [];
  25492. for (var j = 0; j < indicatorAxes.length; j++) {
  25493. points.push(axesTicksPoints[j][i]);
  25494. }
  25495. // Close
  25496. points.push(points[0].slice());
  25497. if (showSplitLine) {
  25498. var colorIndex = getColorIndex(splitLines, splitLineColors, i);
  25499. splitLines[colorIndex].push(new graphic.Polyline({
  25500. shape: {
  25501. points: points
  25502. }
  25503. }));
  25504. }
  25505. if (showSplitArea && prevPoints) {
  25506. var colorIndex = getColorIndex(splitAreas, splitAreaColors, i - 1);
  25507. splitAreas[colorIndex].push(new graphic.Polygon({
  25508. shape: {
  25509. points: points.concat(prevPoints)
  25510. }
  25511. }));
  25512. }
  25513. prevPoints = points.slice().reverse();
  25514. }
  25515. }
  25516. var lineStyle = lineStyleModel.getLineStyle();
  25517. var areaStyle = areaStyleModel.getAreaStyle();
  25518. // Add splitArea before splitLine
  25519. zrUtil.each(splitAreas, function (splitAreas, idx) {
  25520. this.group.add(graphic.mergePath(
  25521. splitAreas, {
  25522. style: zrUtil.defaults({
  25523. stroke: 'none',
  25524. fill: splitAreaColors[idx % splitAreaColors.length]
  25525. }, areaStyle),
  25526. silent: true
  25527. }
  25528. ));
  25529. }, this);
  25530. zrUtil.each(splitLines, function (splitLines, idx) {
  25531. this.group.add(graphic.mergePath(
  25532. splitLines, {
  25533. style: zrUtil.defaults({
  25534. fill: 'none',
  25535. stroke: splitLineColors[idx % splitLineColors.length]
  25536. }, lineStyle),
  25537. silent: true
  25538. }
  25539. ));
  25540. }, this);
  25541. }
  25542. });
  25543. /***/ },
  25544. /* 157 */
  25545. /***/ function(module, exports, __webpack_require__) {
  25546. 'use strict';
  25547. var SeriesModel = __webpack_require__(28);
  25548. var List = __webpack_require__(97);
  25549. var completeDimensions = __webpack_require__(102);
  25550. var zrUtil = __webpack_require__(4);
  25551. var RadarSeries = SeriesModel.extend({
  25552. type: 'series.radar',
  25553. dependencies: ['radar'],
  25554. // Overwrite
  25555. init: function (option) {
  25556. RadarSeries.superApply(this, 'init', arguments);
  25557. // Enable legend selection for each data item
  25558. // Use a function instead of direct access because data reference may changed
  25559. this.legendDataProvider = function () {
  25560. return this._dataBeforeProcessed;
  25561. };
  25562. },
  25563. getInitialData: function (option, ecModel) {
  25564. var data = option.data || [];
  25565. var dimensions = completeDimensions(
  25566. [], data, [], 'indicator_'
  25567. );
  25568. var list = new List(dimensions, this);
  25569. list.initData(data);
  25570. return list;
  25571. },
  25572. formatTooltip: function (dataIndex) {
  25573. var value = this.getRawValue(dataIndex);
  25574. var coordSys = this.coordinateSystem;
  25575. var indicatorAxes = coordSys.getIndicatorAxes();
  25576. return (this._data.getName(dataIndex) == '' ? this.name : this._data.getName(dataIndex)) + '<br/>'
  25577. + zrUtil.map(indicatorAxes, function (axis, idx) {
  25578. return axis.name + ' : ' + value[idx];
  25579. }).join('<br />');
  25580. },
  25581. defaultOption: {
  25582. zlevel: 0,
  25583. z: 2,
  25584. coordinateSystem: 'radar',
  25585. legendHoverLink: true,
  25586. radarIndex: 0,
  25587. lineStyle: {
  25588. normal: {
  25589. width: 2,
  25590. type: 'solid'
  25591. }
  25592. },
  25593. label: {
  25594. normal: {
  25595. position: 'top'
  25596. }
  25597. },
  25598. // areaStyle: {
  25599. // },
  25600. // itemStyle: {}
  25601. symbol: 'emptyCircle',
  25602. symbolSize: 4
  25603. // symbolRotate: null
  25604. }
  25605. });
  25606. module.exports = RadarSeries;
  25607. /***/ },
  25608. /* 158 */
  25609. /***/ function(module, exports, __webpack_require__) {
  25610. var graphic = __webpack_require__(43);
  25611. var zrUtil = __webpack_require__(4);
  25612. var symbolUtil = __webpack_require__(106);
  25613. function normalizeSymbolSize(symbolSize) {
  25614. if (!zrUtil.isArray(symbolSize)) {
  25615. symbolSize = [+symbolSize, +symbolSize];
  25616. }
  25617. return symbolSize;
  25618. }
  25619. module.exports = __webpack_require__(1).extendChartView({
  25620. type: 'radar',
  25621. render: function (seriesModel, ecModel, api) {
  25622. var polar = seriesModel.coordinateSystem;
  25623. var group = this.group;
  25624. var data = seriesModel.getData();
  25625. var oldData = this._data;
  25626. function createSymbol(data, idx) {
  25627. var symbolType = data.getItemVisual(idx, 'symbol') || 'circle';
  25628. var color = data.getItemVisual(idx, 'color');
  25629. if (symbolType === 'none') {
  25630. return;
  25631. }
  25632. var symbolPath = symbolUtil.createSymbol(
  25633. symbolType, -0.5, -0.5, 1, 1, color
  25634. );
  25635. symbolPath.attr({
  25636. style: {
  25637. strokeNoScale: true
  25638. },
  25639. z2: 100,
  25640. scale: normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'))
  25641. });
  25642. return symbolPath;
  25643. }
  25644. function updateSymbols(oldPoints, newPoints, symbolGroup, data, idx, isInit) {
  25645. // Simply rerender all
  25646. symbolGroup.removeAll();
  25647. for (var i = 0; i < newPoints.length - 1; i++) {
  25648. var symbolPath = createSymbol(data, idx);
  25649. if (symbolPath) {
  25650. symbolPath.__dimIdx = i;
  25651. if (oldPoints[i]) {
  25652. symbolPath.attr('position', oldPoints[i]);
  25653. graphic[isInit ? 'initProps' : 'updateProps'](
  25654. symbolPath, {
  25655. position: newPoints[i]
  25656. }, seriesModel, idx
  25657. );
  25658. }
  25659. else {
  25660. symbolPath.attr('position', newPoints[i]);
  25661. }
  25662. symbolGroup.add(symbolPath);
  25663. }
  25664. }
  25665. }
  25666. function getInitialPoints(points) {
  25667. return zrUtil.map(points, function (pt) {
  25668. return [polar.cx, polar.cy];
  25669. });
  25670. }
  25671. data.diff(oldData)
  25672. .add(function (idx) {
  25673. var points = data.getItemLayout(idx);
  25674. if (!points) {
  25675. return;
  25676. }
  25677. var polygon = new graphic.Polygon();
  25678. var polyline = new graphic.Polyline();
  25679. var target = {
  25680. shape: {
  25681. points: points
  25682. }
  25683. };
  25684. polygon.shape.points = getInitialPoints(points);
  25685. polyline.shape.points = getInitialPoints(points);
  25686. graphic.initProps(polygon, target, seriesModel, idx);
  25687. graphic.initProps(polyline, target, seriesModel, idx);
  25688. var itemGroup = new graphic.Group();
  25689. var symbolGroup = new graphic.Group();
  25690. itemGroup.add(polyline);
  25691. itemGroup.add(polygon);
  25692. itemGroup.add(symbolGroup);
  25693. updateSymbols(
  25694. polyline.shape.points, points, symbolGroup, data, idx, true
  25695. );
  25696. data.setItemGraphicEl(idx, itemGroup);
  25697. })
  25698. .update(function (newIdx, oldIdx) {
  25699. var itemGroup = oldData.getItemGraphicEl(oldIdx);
  25700. var polyline = itemGroup.childAt(0);
  25701. var polygon = itemGroup.childAt(1);
  25702. var symbolGroup = itemGroup.childAt(2);
  25703. var target = {
  25704. shape: {
  25705. points: data.getItemLayout(newIdx)
  25706. }
  25707. };
  25708. if (!target.shape.points) {
  25709. return;
  25710. }
  25711. updateSymbols(
  25712. polyline.shape.points, target.shape.points, symbolGroup, data, newIdx, false
  25713. );
  25714. graphic.updateProps(polyline, target, seriesModel);
  25715. graphic.updateProps(polygon, target, seriesModel);
  25716. data.setItemGraphicEl(newIdx, itemGroup);
  25717. })
  25718. .remove(function (idx) {
  25719. group.remove(oldData.getItemGraphicEl(idx));
  25720. })
  25721. .execute();
  25722. data.eachItemGraphicEl(function (itemGroup, idx) {
  25723. var itemModel = data.getItemModel(idx);
  25724. var polyline = itemGroup.childAt(0);
  25725. var polygon = itemGroup.childAt(1);
  25726. var symbolGroup = itemGroup.childAt(2);
  25727. var color = data.getItemVisual(idx, 'color');
  25728. group.add(itemGroup);
  25729. polyline.useStyle(
  25730. zrUtil.defaults(
  25731. itemModel.getModel('lineStyle.normal').getLineStyle(),
  25732. {
  25733. fill: 'none',
  25734. stroke: color
  25735. }
  25736. )
  25737. );
  25738. polyline.hoverStyle = itemModel.getModel('lineStyle.emphasis').getLineStyle();
  25739. var areaStyleModel = itemModel.getModel('areaStyle.normal');
  25740. var hoverAreaStyleModel = itemModel.getModel('areaStyle.emphasis');
  25741. var polygonIgnore = areaStyleModel.isEmpty() && areaStyleModel.parentModel.isEmpty();
  25742. var hoverPolygonIgnore = hoverAreaStyleModel.isEmpty() && hoverAreaStyleModel.parentModel.isEmpty();
  25743. hoverPolygonIgnore = hoverPolygonIgnore && polygonIgnore;
  25744. polygon.ignore = polygonIgnore;
  25745. polygon.useStyle(
  25746. zrUtil.defaults(
  25747. areaStyleModel.getAreaStyle(),
  25748. {
  25749. fill: color,
  25750. opacity: 0.7
  25751. }
  25752. )
  25753. );
  25754. polygon.hoverStyle = hoverAreaStyleModel.getAreaStyle();
  25755. var itemStyle = itemModel.getModel('itemStyle.normal').getItemStyle(['color']);
  25756. var itemHoverStyle = itemModel.getModel('itemStyle.emphasis').getItemStyle();
  25757. var labelModel = itemModel.getModel('label.normal');
  25758. var labelHoverModel = itemModel.getModel('label.emphasis');
  25759. symbolGroup.eachChild(function (symbolPath) {
  25760. symbolPath.setStyle(itemStyle);
  25761. symbolPath.hoverStyle = zrUtil.clone(itemHoverStyle);
  25762. var defaultText = data.get(data.dimensions[symbolPath.__dimIdx], idx);
  25763. graphic.setText(symbolPath.style, labelModel, color);
  25764. symbolPath.setStyle({
  25765. text: labelModel.get('show') ? zrUtil.retrieve(
  25766. seriesModel.getFormattedLabel(
  25767. idx, 'normal', null, symbolPath.__dimIdx
  25768. ),
  25769. defaultText
  25770. ) : ''
  25771. });
  25772. graphic.setText(symbolPath.hoverStyle, labelHoverModel, color);
  25773. symbolPath.hoverStyle.text = labelHoverModel.get('show') ? zrUtil.retrieve(
  25774. seriesModel.getFormattedLabel(
  25775. idx, 'emphasis', null, symbolPath.__dimIdx
  25776. ),
  25777. defaultText
  25778. ) : '';
  25779. });
  25780. function onEmphasis() {
  25781. polygon.attr('ignore', hoverPolygonIgnore);
  25782. }
  25783. function onNormal() {
  25784. polygon.attr('ignore', polygonIgnore);
  25785. }
  25786. itemGroup.off('mouseover').off('mouseout').off('normal').off('emphasis');
  25787. itemGroup.on('emphasis', onEmphasis)
  25788. .on('mouseover', onEmphasis)
  25789. .on('normal', onNormal)
  25790. .on('mouseout', onNormal);
  25791. graphic.setHoverStyle(itemGroup);
  25792. });
  25793. this._data = data;
  25794. },
  25795. remove: function () {
  25796. this.group.removeAll();
  25797. this._data = null;
  25798. }
  25799. });
  25800. /***/ },
  25801. /* 159 */
  25802. /***/ function(module, exports) {
  25803. module.exports = function (ecModel) {
  25804. ecModel.eachSeriesByType('radar', function (seriesModel) {
  25805. var data = seriesModel.getData();
  25806. var points = [];
  25807. var coordSys = seriesModel.coordinateSystem;
  25808. if (!coordSys) {
  25809. return;
  25810. }
  25811. function pointsConverter(val, idx) {
  25812. points[idx] = points[idx] || [];
  25813. points[idx][i] = coordSys.dataToPoint(val, i);
  25814. }
  25815. for (var i = 0; i < coordSys.getIndicatorAxes().length; i++) {
  25816. var dim = data.dimensions[i];
  25817. data.each(dim, pointsConverter);
  25818. }
  25819. data.each(function (idx) {
  25820. // Close polygon
  25821. points[idx][0] && points[idx].push(points[idx][0].slice());
  25822. data.setItemLayout(idx, points[idx]);
  25823. });
  25824. });
  25825. };
  25826. /***/ },
  25827. /* 160 */
  25828. /***/ function(module, exports, __webpack_require__) {
  25829. // Backward compat for radar chart in 2
  25830. var zrUtil = __webpack_require__(4);
  25831. module.exports = function (option) {
  25832. var polarOptArr = option.polar;
  25833. if (polarOptArr) {
  25834. if (!zrUtil.isArray(polarOptArr)) {
  25835. polarOptArr = [polarOptArr];
  25836. }
  25837. var polarNotRadar = [];
  25838. zrUtil.each(polarOptArr, function (polarOpt, idx) {
  25839. if (polarOpt.indicator) {
  25840. if (polarOpt.type && !polarOpt.shape) {
  25841. polarOpt.shape = polarOpt.type;
  25842. }
  25843. option.radar = option.radar || [];
  25844. if (!zrUtil.isArray(option.radar)) {
  25845. option.radar = [option.radar];
  25846. }
  25847. option.radar.push(polarOpt);
  25848. }
  25849. else {
  25850. polarNotRadar.push(polarOpt);
  25851. }
  25852. });
  25853. option.polar = polarNotRadar;
  25854. }
  25855. zrUtil.each(option.series, function (seriesOpt) {
  25856. if (seriesOpt.type === 'radar' && seriesOpt.polarIndex) {
  25857. seriesOpt.radarIndex = seriesOpt.polarIndex;
  25858. }
  25859. });
  25860. };
  25861. /***/ },
  25862. /* 161 */
  25863. /***/ function(module, exports, __webpack_require__) {
  25864. var echarts = __webpack_require__(1);
  25865. var PRIORITY = echarts.PRIORITY;
  25866. __webpack_require__(162);
  25867. __webpack_require__(172);
  25868. __webpack_require__(176);
  25869. __webpack_require__(163);
  25870. echarts.registerLayout(__webpack_require__(178));
  25871. echarts.registerVisual(__webpack_require__(179));
  25872. echarts.registerProcessor(PRIORITY.PROCESSOR.STATISTIC, __webpack_require__(180));
  25873. echarts.registerPreprocessor(__webpack_require__(181));
  25874. __webpack_require__(142)('map', [{
  25875. type: 'mapToggleSelect',
  25876. event: 'mapselectchanged',
  25877. method: 'toggleSelected'
  25878. }, {
  25879. type: 'mapSelect',
  25880. event: 'mapselected',
  25881. method: 'select'
  25882. }, {
  25883. type: 'mapUnSelect',
  25884. event: 'mapunselected',
  25885. method: 'unSelect'
  25886. }]);
  25887. /***/ },
  25888. /* 162 */
  25889. /***/ function(module, exports, __webpack_require__) {
  25890. var List = __webpack_require__(97);
  25891. var SeriesModel = __webpack_require__(28);
  25892. var zrUtil = __webpack_require__(4);
  25893. var completeDimensions = __webpack_require__(102);
  25894. var formatUtil = __webpack_require__(6);
  25895. var encodeHTML = formatUtil.encodeHTML;
  25896. var addCommas = formatUtil.addCommas;
  25897. var dataSelectableMixin = __webpack_require__(140);
  25898. var geoCreator = __webpack_require__(163);
  25899. var MapSeries = SeriesModel.extend({
  25900. type: 'series.map',
  25901. layoutMode: 'box',
  25902. /**
  25903. * Only first map series of same mapType will drawMap
  25904. * @type {boolean}
  25905. */
  25906. needsDrawMap: false,
  25907. /**
  25908. * Group of all map series with same mapType
  25909. * @type {boolean}
  25910. */
  25911. seriesGroup: [],
  25912. init: function (option) {
  25913. option = this._fillOption(option, option.map);
  25914. this.option = option;
  25915. MapSeries.superApply(this, 'init', arguments);
  25916. this.updateSelectedMap(option.data);
  25917. },
  25918. getInitialData: function (option) {
  25919. var dimensions = completeDimensions(['value'], option.data || []);
  25920. var list = new List(dimensions, this);
  25921. list.initData(option.data);
  25922. return list;
  25923. },
  25924. mergeOption: function (newOption) {
  25925. if (newOption.data) {
  25926. newOption = this._fillOption(newOption, this.option.map);
  25927. }
  25928. MapSeries.superCall(this, 'mergeOption', newOption);
  25929. this.updateSelectedMap(this.option.data);
  25930. },
  25931. _fillOption: function (option, mapName) {
  25932. // Shallow clone
  25933. option = zrUtil.extend({}, option);
  25934. option.data = geoCreator.getFilledRegions(option.data, mapName);
  25935. return option;
  25936. },
  25937. getRawValue: function (dataIndex) {
  25938. // Use value stored in data instead because it is calculated from multiple series
  25939. // FIXME Provide all value of multiple series ?
  25940. return this._data.get('value', dataIndex);
  25941. },
  25942. /**
  25943. * Get model of region
  25944. * @param {string} name
  25945. * @return {module:echarts/model/Model}
  25946. */
  25947. getRegionModel: function (regionName) {
  25948. var data = this.getData();
  25949. return data.getItemModel(data.indexOfName(regionName));
  25950. },
  25951. /**
  25952. * Map tooltip formatter
  25953. *
  25954. * @param {number} dataIndex
  25955. */
  25956. formatTooltip: function (dataIndex) {
  25957. // FIXME orignalData and data is a bit confusing
  25958. var data = this.getData();
  25959. var formattedValue = addCommas(this.getRawValue(dataIndex));
  25960. var name = data.getName(dataIndex);
  25961. var seriesGroup = this.seriesGroup;
  25962. var seriesNames = [];
  25963. for (var i = 0; i < seriesGroup.length; i++) {
  25964. var otherIndex = seriesGroup[i].originalData.indexOfName(name);
  25965. if (!isNaN(seriesGroup[i].originalData.get('value', otherIndex))) {
  25966. seriesNames.push(
  25967. encodeHTML(seriesGroup[i].name)
  25968. );
  25969. }
  25970. }
  25971. return seriesNames.join(', ') + '<br />'
  25972. + name + ' : ' + formattedValue;
  25973. },
  25974. defaultOption: {
  25975. // 一级层叠
  25976. zlevel: 0,
  25977. // 二级层叠
  25978. z: 2,
  25979. coordinateSystem: 'geo',
  25980. // 各省的 map 暂时都用中文
  25981. map: 'china',
  25982. // 'center' | 'left' | 'right' | 'x%' | {number}
  25983. left: 'center',
  25984. // 'center' | 'top' | 'bottom' | 'x%' | {number}
  25985. top: 'center',
  25986. // right
  25987. // bottom
  25988. // width:
  25989. // height
  25990. // Aspect is width / height. Inited to be geoJson bbox aspect
  25991. // This parameter is used for scale this aspect
  25992. aspectScale: 0.75,
  25993. ///// Layout with center and size
  25994. // If you wan't to put map in a fixed size box with right aspect ratio
  25995. // This two properties may more conveninet
  25996. // layoutCenter: [50%, 50%]
  25997. // layoutSize: 100
  25998. // 数值合并方式,默认加和,可选为:
  25999. // 'sum' | 'average' | 'max' | 'min'
  26000. // mapValueCalculation: 'sum',
  26001. // 地图数值计算结果小数精度
  26002. // mapValuePrecision: 0,
  26003. // 显示图例颜色标识(系列标识的小圆点),图例开启时有效
  26004. showLegendSymbol: true,
  26005. // 选择模式,默认关闭,可选single,multiple
  26006. // selectedMode: false,
  26007. dataRangeHoverLink: true,
  26008. // 是否开启缩放及漫游模式
  26009. // roam: false,
  26010. // Default on center of map
  26011. center: null,
  26012. zoom: 1,
  26013. scaleLimit: null,
  26014. label: {
  26015. normal: {
  26016. show: false,
  26017. textStyle: {
  26018. color: '#000'
  26019. }
  26020. },
  26021. emphasis: {
  26022. show: true,
  26023. textStyle: {
  26024. color: 'rgb(100,0,0)'
  26025. }
  26026. }
  26027. },
  26028. // scaleLimit: null,
  26029. itemStyle: {
  26030. normal: {
  26031. // color: 各异,
  26032. borderWidth: 0.5,
  26033. borderColor: '#444',
  26034. areaColor: '#eee'
  26035. },
  26036. // 也是选中样式
  26037. emphasis: {
  26038. areaColor: 'rgba(255,215,0,0.8)'
  26039. }
  26040. }
  26041. },
  26042. setZoom: function (zoom) {
  26043. this.option.zoom = zoom;
  26044. },
  26045. setCenter: function (center) {
  26046. this.option.center = center;
  26047. }
  26048. });
  26049. zrUtil.mixin(MapSeries, dataSelectableMixin);
  26050. module.exports = MapSeries;
  26051. /***/ },
  26052. /* 163 */
  26053. /***/ function(module, exports, __webpack_require__) {
  26054. var Geo = __webpack_require__(164);
  26055. var layout = __webpack_require__(21);
  26056. var zrUtil = __webpack_require__(4);
  26057. var numberUtil = __webpack_require__(7);
  26058. var mapDataStores = {};
  26059. /**
  26060. * Resize method bound to the geo
  26061. * @param {module:echarts/coord/geo/GeoModel|module:echarts/chart/map/MapModel} geoModel
  26062. * @param {module:echarts/ExtensionAPI} api
  26063. */
  26064. function resizeGeo (geoModel, api) {
  26065. var rect = this.getBoundingRect();
  26066. var boxLayoutOption;
  26067. var center = geoModel.get('layoutCenter');
  26068. var size = geoModel.get('layoutSize');
  26069. var viewWidth = api.getWidth();
  26070. var viewHeight = api.getHeight();
  26071. var aspectScale = geoModel.get('aspectScale') || 0.75;
  26072. var aspect = rect.width / rect.height * aspectScale;
  26073. var useCenterAndSize = false;
  26074. if (center && size) {
  26075. center = [
  26076. numberUtil.parsePercent(center[0], viewWidth),
  26077. numberUtil.parsePercent(center[1], viewHeight)
  26078. ];
  26079. size = numberUtil.parsePercent(size, Math.min(viewWidth, viewHeight));
  26080. if (!isNaN(center[0]) && !isNaN(center[1]) && !isNaN(size)) {
  26081. useCenterAndSize = true;
  26082. }
  26083. else {
  26084. if (true) {
  26085. console.warn('Given layoutCenter or layoutSize data are invalid. Use left/top/width/height instead.');
  26086. }
  26087. }
  26088. }
  26089. var viewRect;
  26090. if (useCenterAndSize) {
  26091. var viewRect = {};
  26092. if (aspect > 1) {
  26093. // Width is same with size
  26094. viewRect.width = size;
  26095. viewRect.height = size / aspect;
  26096. }
  26097. else {
  26098. viewRect.height = size;
  26099. viewRect.width = size * aspect;
  26100. }
  26101. viewRect.y = center[1] - viewRect.height / 2;
  26102. viewRect.x = center[0] - viewRect.width / 2;
  26103. }
  26104. else {
  26105. // Use left/top/width/height
  26106. boxLayoutOption = geoModel.getBoxLayoutParams();
  26107. // 0.75 rate
  26108. boxLayoutOption.aspect = aspect;
  26109. viewRect = layout.getLayoutRect(boxLayoutOption, {
  26110. width: viewWidth,
  26111. height: viewHeight
  26112. });
  26113. }
  26114. this.setViewRect(viewRect.x, viewRect.y, viewRect.width, viewRect.height);
  26115. this.setCenter(geoModel.get('center'));
  26116. this.setZoom(geoModel.get('zoom'));
  26117. }
  26118. /**
  26119. * @param {module:echarts/coord/Geo} geo
  26120. * @param {module:echarts/model/Model} model
  26121. * @inner
  26122. */
  26123. function setGeoCoords(geo, model) {
  26124. zrUtil.each(model.get('geoCoord'), function (geoCoord, name) {
  26125. geo.addGeoCoord(name, geoCoord);
  26126. });
  26127. }
  26128. if (true) {
  26129. var mapNotExistsError = function (name) {
  26130. console.error('Map ' + name + ' not exists. You can download map file on http://echarts.baidu.com/download-map.html');
  26131. };
  26132. }
  26133. var geoCreator = {
  26134. // For deciding which dimensions to use when creating list data
  26135. dimensions: Geo.prototype.dimensions,
  26136. create: function (ecModel, api) {
  26137. var geoList = [];
  26138. // FIXME Create each time may be slow
  26139. ecModel.eachComponent('geo', function (geoModel, idx) {
  26140. var name = geoModel.get('map');
  26141. var mapData = mapDataStores[name];
  26142. if (true) {
  26143. if (!mapData) {
  26144. mapNotExistsError(name);
  26145. }
  26146. }
  26147. var geo = new Geo(
  26148. name + idx, name,
  26149. mapData && mapData.geoJson, mapData && mapData.specialAreas,
  26150. geoModel.get('nameMap')
  26151. );
  26152. geo.zoomLimit = geoModel.get('scaleLimit');
  26153. geoList.push(geo);
  26154. setGeoCoords(geo, geoModel);
  26155. geoModel.coordinateSystem = geo;
  26156. geo.model = geoModel;
  26157. // Inject resize method
  26158. geo.resize = resizeGeo;
  26159. geo.resize(geoModel, api);
  26160. });
  26161. ecModel.eachSeries(function (seriesModel) {
  26162. var coordSys = seriesModel.get('coordinateSystem');
  26163. if (coordSys === 'geo') {
  26164. var geoIndex = seriesModel.get('geoIndex') || 0;
  26165. seriesModel.coordinateSystem = geoList[geoIndex];
  26166. }
  26167. });
  26168. // If has map series
  26169. var mapModelGroupBySeries = {};
  26170. ecModel.eachSeriesByType('map', function (seriesModel) {
  26171. var mapType = seriesModel.get('map');
  26172. mapModelGroupBySeries[mapType] = mapModelGroupBySeries[mapType] || [];
  26173. mapModelGroupBySeries[mapType].push(seriesModel);
  26174. });
  26175. zrUtil.each(mapModelGroupBySeries, function (mapSeries, mapType) {
  26176. var mapData = mapDataStores[mapType];
  26177. if (true) {
  26178. if (!mapData) {
  26179. mapNotExistsError(mapSeries[0].get('map'));
  26180. }
  26181. }
  26182. var nameMapList = zrUtil.map(mapSeries, function (singleMapSeries) {
  26183. return singleMapSeries.get('nameMap');
  26184. });
  26185. var geo = new Geo(
  26186. mapType, mapType,
  26187. mapData && mapData.geoJson, mapData && mapData.specialAreas,
  26188. zrUtil.mergeAll(nameMapList)
  26189. );
  26190. geo.zoomLimit = zrUtil.retrieve.apply(null, zrUtil.map(mapSeries, function (singleMapSeries) {
  26191. return singleMapSeries.get('scaleLimit');
  26192. }));
  26193. geoList.push(geo);
  26194. // Inject resize method
  26195. geo.resize = resizeGeo;
  26196. geo.resize(mapSeries[0], api);
  26197. zrUtil.each(mapSeries, function (singleMapSeries) {
  26198. singleMapSeries.coordinateSystem = geo;
  26199. setGeoCoords(geo, singleMapSeries);
  26200. });
  26201. });
  26202. return geoList;
  26203. },
  26204. /**
  26205. * @param {string} mapName
  26206. * @param {Object|string} geoJson
  26207. * @param {Object} [specialAreas]
  26208. *
  26209. * @example
  26210. * $.get('USA.json', function (geoJson) {
  26211. * echarts.registerMap('USA', geoJson);
  26212. * // Or
  26213. * echarts.registerMap('USA', {
  26214. * geoJson: geoJson,
  26215. * specialAreas: {}
  26216. * })
  26217. * });
  26218. */
  26219. registerMap: function (mapName, geoJson, specialAreas) {
  26220. if (geoJson.geoJson && !geoJson.features) {
  26221. specialAreas = geoJson.specialAreas;
  26222. geoJson = geoJson.geoJson;
  26223. }
  26224. if (typeof geoJson === 'string') {
  26225. geoJson = (typeof JSON !== 'undefined' && JSON.parse)
  26226. ? JSON.parse(geoJson) : (new Function('return (' + geoJson + ');'))();
  26227. }
  26228. mapDataStores[mapName] = {
  26229. geoJson: geoJson,
  26230. specialAreas: specialAreas
  26231. };
  26232. },
  26233. /**
  26234. * @param {string} mapName
  26235. * @return {Object}
  26236. */
  26237. getMap: function (mapName) {
  26238. return mapDataStores[mapName];
  26239. },
  26240. /**
  26241. * Fill given regions array
  26242. * @param {Array.<Object>} originRegionArr
  26243. * @param {string} mapName
  26244. * @return {Array}
  26245. */
  26246. getFilledRegions: function (originRegionArr, mapName) {
  26247. // Not use the original
  26248. var regionsArr = (originRegionArr || []).slice();
  26249. var map = geoCreator.getMap(mapName);
  26250. var geoJson = map && map.geoJson;
  26251. if (!geoJson) {
  26252. if (true) {
  26253. mapNotExistsError(mapName);
  26254. }
  26255. return originRegionArr;
  26256. }
  26257. var dataNameMap = {};
  26258. var features = geoJson.features;
  26259. for (var i = 0; i < regionsArr.length; i++) {
  26260. dataNameMap[regionsArr[i].name] = regionsArr[i];
  26261. }
  26262. for (var i = 0; i < features.length; i++) {
  26263. var name = features[i].properties.name;
  26264. if (!dataNameMap[name]) {
  26265. regionsArr.push({
  26266. name: name
  26267. });
  26268. }
  26269. }
  26270. return regionsArr;
  26271. }
  26272. };
  26273. // Inject methods into echarts
  26274. var echarts = __webpack_require__(1);
  26275. echarts.registerMap = geoCreator.registerMap;
  26276. echarts.getMap = geoCreator.getMap;
  26277. // TODO
  26278. echarts.loadMap = function () {};
  26279. echarts.registerCoordinateSystem('geo', geoCreator);
  26280. module.exports = geoCreator;
  26281. /***/ },
  26282. /* 164 */
  26283. /***/ function(module, exports, __webpack_require__) {
  26284. var parseGeoJson = __webpack_require__(165);
  26285. var zrUtil = __webpack_require__(4);
  26286. var BoundingRect = __webpack_require__(9);
  26287. var View = __webpack_require__(168);
  26288. // Geo fix functions
  26289. var geoFixFuncs = [
  26290. __webpack_require__(169),
  26291. __webpack_require__(170),
  26292. __webpack_require__(171)
  26293. ];
  26294. /**
  26295. * [Geo description]
  26296. * @param {string} name Geo name
  26297. * @param {string} map Map type
  26298. * @param {Object} geoJson
  26299. * @param {Object} [specialAreas]
  26300. * Specify the positioned areas by left, top, width, height
  26301. * @param {Object.<string, string>} [nameMap]
  26302. * Specify name alias
  26303. */
  26304. function Geo(name, map, geoJson, specialAreas, nameMap) {
  26305. View.call(this, name);
  26306. /**
  26307. * Map type
  26308. * @type {string}
  26309. */
  26310. this.map = map;
  26311. this._nameCoordMap = {};
  26312. this.loadGeoJson(geoJson, specialAreas, nameMap);
  26313. }
  26314. Geo.prototype = {
  26315. constructor: Geo,
  26316. type: 'geo',
  26317. /**
  26318. * @param {Array.<string>}
  26319. * @readOnly
  26320. */
  26321. dimensions: ['lng', 'lat'],
  26322. /**
  26323. * If contain given lng,lat coord
  26324. * @param {Array.<number>}
  26325. * @readOnly
  26326. */
  26327. containCoord: function (coord) {
  26328. var regions = this.regions;
  26329. for (var i = 0; i < regions.length; i++) {
  26330. if (regions[i].contain(coord)) {
  26331. return true;
  26332. }
  26333. }
  26334. return false;
  26335. },
  26336. /**
  26337. * @param {Object} geoJson
  26338. * @param {Object} [specialAreas]
  26339. * Specify the positioned areas by left, top, width, height
  26340. * @param {Object.<string, string>} [nameMap]
  26341. * Specify name alias
  26342. */
  26343. loadGeoJson: function (geoJson, specialAreas, nameMap) {
  26344. // https://jsperf.com/try-catch-performance-overhead
  26345. try {
  26346. this.regions = geoJson ? parseGeoJson(geoJson) : [];
  26347. }
  26348. catch (e) {
  26349. throw 'Invalid geoJson format\n' + e;
  26350. }
  26351. specialAreas = specialAreas || {};
  26352. nameMap = nameMap || {};
  26353. var regions = this.regions;
  26354. var regionsMap = {};
  26355. for (var i = 0; i < regions.length; i++) {
  26356. var regionName = regions[i].name;
  26357. // Try use the alias in nameMap
  26358. regionName = nameMap[regionName] || regionName;
  26359. regions[i].name = regionName;
  26360. regionsMap[regionName] = regions[i];
  26361. // Add geoJson
  26362. this.addGeoCoord(regionName, regions[i].center);
  26363. // Some area like Alaska in USA map needs to be tansformed
  26364. // to look better
  26365. var specialArea = specialAreas[regionName];
  26366. if (specialArea) {
  26367. regions[i].transformTo(
  26368. specialArea.left, specialArea.top, specialArea.width, specialArea.height
  26369. );
  26370. }
  26371. }
  26372. this._regionsMap = regionsMap;
  26373. this._rect = null;
  26374. zrUtil.each(geoFixFuncs, function (fixFunc) {
  26375. fixFunc(this);
  26376. }, this);
  26377. },
  26378. // Overwrite
  26379. transformTo: function (x, y, width, height) {
  26380. var rect = this.getBoundingRect();
  26381. rect = rect.clone();
  26382. // Longitute is inverted
  26383. rect.y = -rect.y - rect.height;
  26384. var viewTransform = this._viewTransform;
  26385. viewTransform.transform = rect.calculateTransform(
  26386. new BoundingRect(x, y, width, height)
  26387. );
  26388. viewTransform.decomposeTransform();
  26389. var scale = viewTransform.scale;
  26390. scale[1] = -scale[1];
  26391. viewTransform.updateTransform();
  26392. this._updateTransform();
  26393. },
  26394. /**
  26395. * @param {string} name
  26396. * @return {module:echarts/coord/geo/Region}
  26397. */
  26398. getRegion: function (name) {
  26399. return this._regionsMap[name];
  26400. },
  26401. getRegionByCoord: function (coord) {
  26402. var regions = this.regions;
  26403. for (var i = 0; i < regions.length; i++) {
  26404. if (regions[i].contain(coord)) {
  26405. return regions[i];
  26406. }
  26407. }
  26408. },
  26409. /**
  26410. * Add geoCoord for indexing by name
  26411. * @param {string} name
  26412. * @param {Array.<number>} geoCoord
  26413. */
  26414. addGeoCoord: function (name, geoCoord) {
  26415. this._nameCoordMap[name] = geoCoord;
  26416. },
  26417. /**
  26418. * Get geoCoord by name
  26419. * @param {string} name
  26420. * @return {Array.<number>}
  26421. */
  26422. getGeoCoord: function (name) {
  26423. return this._nameCoordMap[name];
  26424. },
  26425. // Overwrite
  26426. getBoundingRect: function () {
  26427. if (this._rect) {
  26428. return this._rect;
  26429. }
  26430. var rect;
  26431. var regions = this.regions;
  26432. for (var i = 0; i < regions.length; i++) {
  26433. var regionRect = regions[i].getBoundingRect();
  26434. rect = rect || regionRect.clone();
  26435. rect.union(regionRect);
  26436. }
  26437. // FIXME Always return new ?
  26438. return (this._rect = rect || new BoundingRect(0, 0, 0, 0));
  26439. },
  26440. /**
  26441. * Convert series data to a list of points
  26442. * @param {module:echarts/data/List} data
  26443. * @param {boolean} stack
  26444. * @return {Array}
  26445. * Return list of points. For example:
  26446. * `[[10, 10], [20, 20], [30, 30]]`
  26447. */
  26448. dataToPoints: function (data) {
  26449. var item = [];
  26450. return data.mapArray(['lng', 'lat'], function (lon, lat) {
  26451. item[0] = lon;
  26452. item[1] = lat;
  26453. return this.dataToPoint(item);
  26454. }, this);
  26455. },
  26456. // Overwrite
  26457. /**
  26458. * @param {string|Array.<number>} data
  26459. * @return {Array.<number>}
  26460. */
  26461. dataToPoint: function (data) {
  26462. if (typeof data === 'string') {
  26463. // Map area name to geoCoord
  26464. data = this.getGeoCoord(data);
  26465. }
  26466. if (data) {
  26467. return View.prototype.dataToPoint.call(this, data);
  26468. }
  26469. }
  26470. };
  26471. zrUtil.mixin(Geo, View);
  26472. module.exports = Geo;
  26473. /***/ },
  26474. /* 165 */
  26475. /***/ function(module, exports, __webpack_require__) {
  26476. /**
  26477. * Parse and decode geo json
  26478. * @module echarts/coord/geo/parseGeoJson
  26479. */
  26480. var zrUtil = __webpack_require__(4);
  26481. var Region = __webpack_require__(166);
  26482. function decode(json) {
  26483. if (!json.UTF8Encoding) {
  26484. return json;
  26485. }
  26486. var features = json.features;
  26487. for (var f = 0; f < features.length; f++) {
  26488. var feature = features[f];
  26489. var geometry = feature.geometry;
  26490. var coordinates = geometry.coordinates;
  26491. var encodeOffsets = geometry.encodeOffsets;
  26492. for (var c = 0; c < coordinates.length; c++) {
  26493. var coordinate = coordinates[c];
  26494. if (geometry.type === 'Polygon') {
  26495. coordinates[c] = decodePolygon(
  26496. coordinate,
  26497. encodeOffsets[c]
  26498. );
  26499. }
  26500. else if (geometry.type === 'MultiPolygon') {
  26501. for (var c2 = 0; c2 < coordinate.length; c2++) {
  26502. var polygon = coordinate[c2];
  26503. coordinate[c2] = decodePolygon(
  26504. polygon,
  26505. encodeOffsets[c][c2]
  26506. );
  26507. }
  26508. }
  26509. }
  26510. }
  26511. // Has been decoded
  26512. json.UTF8Encoding = false;
  26513. return json;
  26514. }
  26515. function decodePolygon(coordinate, encodeOffsets) {
  26516. var result = [];
  26517. var prevX = encodeOffsets[0];
  26518. var prevY = encodeOffsets[1];
  26519. for (var i = 0; i < coordinate.length; i += 2) {
  26520. var x = coordinate.charCodeAt(i) - 64;
  26521. var y = coordinate.charCodeAt(i + 1) - 64;
  26522. // ZigZag decoding
  26523. x = (x >> 1) ^ (-(x & 1));
  26524. y = (y >> 1) ^ (-(y & 1));
  26525. // Delta deocding
  26526. x += prevX;
  26527. y += prevY;
  26528. prevX = x;
  26529. prevY = y;
  26530. // Dequantize
  26531. result.push([x / 1024, y / 1024]);
  26532. }
  26533. return result;
  26534. }
  26535. /**
  26536. * @inner
  26537. */
  26538. function flattern2D(array) {
  26539. var ret = [];
  26540. for (var i = 0; i < array.length; i++) {
  26541. for (var k = 0; k < array[i].length; k++) {
  26542. ret.push(array[i][k]);
  26543. }
  26544. }
  26545. return ret;
  26546. }
  26547. /**
  26548. * @alias module:echarts/coord/geo/parseGeoJson
  26549. * @param {Object} geoJson
  26550. * @return {module:zrender/container/Group}
  26551. */
  26552. module.exports = function (geoJson) {
  26553. decode(geoJson);
  26554. return zrUtil.map(zrUtil.filter(geoJson.features, function (featureObj) {
  26555. // Output of mapshaper may have geometry null
  26556. return featureObj.geometry && featureObj.properties;
  26557. }), function (featureObj) {
  26558. var properties = featureObj.properties;
  26559. var geometry = featureObj.geometry;
  26560. var coordinates = geometry.coordinates;
  26561. if (geometry.type === 'MultiPolygon') {
  26562. coordinates = flattern2D(coordinates);
  26563. }
  26564. return new Region(
  26565. properties.name,
  26566. coordinates,
  26567. properties.cp
  26568. );
  26569. });
  26570. };
  26571. /***/ },
  26572. /* 166 */
  26573. /***/ function(module, exports, __webpack_require__) {
  26574. /**
  26575. * @module echarts/coord/geo/Region
  26576. */
  26577. var polygonContain = __webpack_require__(167);
  26578. var BoundingRect = __webpack_require__(9);
  26579. var bbox = __webpack_require__(51);
  26580. var vec2 = __webpack_require__(10);
  26581. /**
  26582. * @param {string} name
  26583. * @param {Array} contours
  26584. * @param {Array.<number>} cp
  26585. */
  26586. function Region(name, contours, cp) {
  26587. /**
  26588. * @type {string}
  26589. * @readOnly
  26590. */
  26591. this.name = name;
  26592. /**
  26593. * @type {Array.<Array>}
  26594. * @readOnly
  26595. */
  26596. this.contours = contours;
  26597. if (!cp) {
  26598. var rect = this.getBoundingRect();
  26599. cp = [
  26600. rect.x + rect.width / 2,
  26601. rect.y + rect.height / 2
  26602. ];
  26603. }
  26604. else {
  26605. cp = [cp[0], cp[1]];
  26606. }
  26607. /**
  26608. * @type {Array.<number>}
  26609. */
  26610. this.center = cp;
  26611. }
  26612. Region.prototype = {
  26613. constructor: Region,
  26614. /**
  26615. * @return {module:zrender/core/BoundingRect}
  26616. */
  26617. getBoundingRect: function () {
  26618. var rect = this._rect;
  26619. if (rect) {
  26620. return rect;
  26621. }
  26622. var MAX_NUMBER = Number.MAX_VALUE;
  26623. var min = [MAX_NUMBER, MAX_NUMBER];
  26624. var max = [-MAX_NUMBER, -MAX_NUMBER];
  26625. var min2 = [];
  26626. var max2 = [];
  26627. var contours = this.contours;
  26628. for (var i = 0; i < contours.length; i++) {
  26629. bbox.fromPoints(contours[i], min2, max2);
  26630. vec2.min(min, min, min2);
  26631. vec2.max(max, max, max2);
  26632. }
  26633. // No data
  26634. if (i === 0) {
  26635. min[0] = min[1] = max[0] = max[1] = 0;
  26636. }
  26637. return (this._rect = new BoundingRect(
  26638. min[0], min[1], max[0] - min[0], max[1] - min[1]
  26639. ));
  26640. },
  26641. /**
  26642. * @param {<Array.<number>} coord
  26643. * @return {boolean}
  26644. */
  26645. contain: function (coord) {
  26646. var rect = this.getBoundingRect();
  26647. var contours = this.contours;
  26648. if (rect.contain(coord[0], coord[1])) {
  26649. for (var i = 0, len = contours.length; i < len; i++) {
  26650. if (polygonContain.contain(contours[i], coord[0], coord[1])) {
  26651. return true;
  26652. }
  26653. }
  26654. }
  26655. return false;
  26656. },
  26657. transformTo: function (x, y, width, height) {
  26658. var rect = this.getBoundingRect();
  26659. var aspect = rect.width / rect.height;
  26660. if (!width) {
  26661. width = aspect * height;
  26662. }
  26663. else if (!height) {
  26664. height = width / aspect ;
  26665. }
  26666. var target = new BoundingRect(x, y, width, height);
  26667. var transform = rect.calculateTransform(target);
  26668. var contours = this.contours;
  26669. for (var i = 0; i < contours.length; i++) {
  26670. for (var p = 0; p < contours[i].length; p++) {
  26671. vec2.applyTransform(contours[i][p], contours[i][p], transform);
  26672. }
  26673. }
  26674. rect = this._rect;
  26675. rect.copy(target);
  26676. // Update center
  26677. this.center = [
  26678. rect.x + rect.width / 2,
  26679. rect.y + rect.height / 2
  26680. ];
  26681. }
  26682. };
  26683. module.exports = Region;
  26684. /***/ },
  26685. /* 167 */
  26686. /***/ function(module, exports, __webpack_require__) {
  26687. var windingLine = __webpack_require__(58);
  26688. var EPSILON = 1e-8;
  26689. function isAroundEqual(a, b) {
  26690. return Math.abs(a - b) < EPSILON;
  26691. }
  26692. function contain(points, x, y) {
  26693. var w = 0;
  26694. var p = points[0];
  26695. if (!p) {
  26696. return false;
  26697. }
  26698. for (var i = 1; i < points.length; i++) {
  26699. var p2 = points[i];
  26700. w += windingLine(p[0], p[1], p2[0], p2[1], x, y);
  26701. p = p2;
  26702. }
  26703. // Close polygon
  26704. var p0 = points[0];
  26705. if (!isAroundEqual(p[0], p0[0]) || !isAroundEqual(p[1], p0[1])) {
  26706. w += windingLine(p[0], p[1], p0[0], p0[1], x, y);
  26707. }
  26708. return w !== 0;
  26709. }
  26710. module.exports = {
  26711. contain: contain
  26712. };
  26713. /***/ },
  26714. /* 168 */
  26715. /***/ function(module, exports, __webpack_require__) {
  26716. /**
  26717. * Simple view coordinate system
  26718. * Mapping given x, y to transformd view x, y
  26719. */
  26720. var vector = __webpack_require__(10);
  26721. var matrix = __webpack_require__(11);
  26722. var Transformable = __webpack_require__(34);
  26723. var zrUtil = __webpack_require__(4);
  26724. var BoundingRect = __webpack_require__(9);
  26725. var v2ApplyTransform = vector.applyTransform;
  26726. // Dummy transform node
  26727. function TransformDummy() {
  26728. Transformable.call(this);
  26729. }
  26730. zrUtil.mixin(TransformDummy, Transformable);
  26731. function View(name) {
  26732. /**
  26733. * @type {string}
  26734. */
  26735. this.name = name;
  26736. /**
  26737. * @type {Object}
  26738. */
  26739. this.zoomLimit;
  26740. Transformable.call(this);
  26741. this._roamTransform = new TransformDummy();
  26742. this._viewTransform = new TransformDummy();
  26743. this._center;
  26744. this._zoom;
  26745. }
  26746. View.prototype = {
  26747. constructor: View,
  26748. type: 'view',
  26749. /**
  26750. * @param {Array.<string>}
  26751. * @readOnly
  26752. */
  26753. dimensions: ['x', 'y'],
  26754. /**
  26755. * Set bounding rect
  26756. * @param {number} x
  26757. * @param {number} y
  26758. * @param {number} width
  26759. * @param {number} height
  26760. */
  26761. // PENDING to getRect
  26762. setBoundingRect: function (x, y, width, height) {
  26763. this._rect = new BoundingRect(x, y, width, height);
  26764. return this._rect;
  26765. },
  26766. /**
  26767. * @return {module:zrender/core/BoundingRect}
  26768. */
  26769. // PENDING to getRect
  26770. getBoundingRect: function () {
  26771. return this._rect;
  26772. },
  26773. /**
  26774. * @param {number} x
  26775. * @param {number} y
  26776. * @param {number} width
  26777. * @param {number} height
  26778. */
  26779. setViewRect: function (x, y, width, height) {
  26780. width = width;
  26781. height = height;
  26782. this.transformTo(x, y, width, height);
  26783. this._viewRect = new BoundingRect(x, y, width, height);
  26784. },
  26785. /**
  26786. * Transformed to particular position and size
  26787. * @param {number} x
  26788. * @param {number} y
  26789. * @param {number} width
  26790. * @param {number} height
  26791. */
  26792. transformTo: function (x, y, width, height) {
  26793. var rect = this.getBoundingRect();
  26794. var viewTransform = this._viewTransform;
  26795. viewTransform.transform = rect.calculateTransform(
  26796. new BoundingRect(x, y, width, height)
  26797. );
  26798. viewTransform.decomposeTransform();
  26799. this._updateTransform();
  26800. },
  26801. /**
  26802. * Set center of view
  26803. * @param {Array.<number>} [centerCoord]
  26804. */
  26805. setCenter: function (centerCoord) {
  26806. if (!centerCoord) {
  26807. return;
  26808. }
  26809. this._center = centerCoord;
  26810. this._updateCenterAndZoom();
  26811. },
  26812. /**
  26813. * @param {number} zoom
  26814. */
  26815. setZoom: function (zoom) {
  26816. zoom = zoom || 1;
  26817. var zoomLimit = this.zoomLimit;
  26818. if (zoomLimit) {
  26819. if (zoomLimit.max != null) {
  26820. zoom = Math.min(zoomLimit.max, zoom);
  26821. }
  26822. if (zoomLimit.min != null) {
  26823. zoom = Math.max(zoomLimit.min, zoom);
  26824. }
  26825. }
  26826. this._zoom = zoom;
  26827. this._updateCenterAndZoom();
  26828. },
  26829. /**
  26830. * Get default center without roam
  26831. */
  26832. getDefaultCenter: function () {
  26833. // Rect before any transform
  26834. var rawRect = this.getBoundingRect();
  26835. var cx = rawRect.x + rawRect.width / 2;
  26836. var cy = rawRect.y + rawRect.height / 2;
  26837. return [cx, cy];
  26838. },
  26839. getCenter: function () {
  26840. return this._center || this.getDefaultCenter();
  26841. },
  26842. getZoom: function () {
  26843. return this._zoom || 1;
  26844. },
  26845. /**
  26846. * @return {Array.<number}
  26847. */
  26848. getRoamTransform: function () {
  26849. return this._roamTransform;
  26850. },
  26851. _updateCenterAndZoom: function () {
  26852. // Must update after view transform updated
  26853. var viewTransformMatrix = this._viewTransform.getLocalTransform();
  26854. var roamTransform = this._roamTransform;
  26855. var defaultCenter = this.getDefaultCenter();
  26856. var center = this.getCenter();
  26857. var zoom = this.getZoom();
  26858. center = vector.applyTransform([], center, viewTransformMatrix);
  26859. defaultCenter = vector.applyTransform([], defaultCenter, viewTransformMatrix);
  26860. roamTransform.origin = center;
  26861. roamTransform.position = [
  26862. defaultCenter[0] - center[0],
  26863. defaultCenter[1] - center[1]
  26864. ];
  26865. roamTransform.scale = [zoom, zoom];
  26866. this._updateTransform();
  26867. },
  26868. /**
  26869. * Update transform from roam and mapLocation
  26870. * @private
  26871. */
  26872. _updateTransform: function () {
  26873. var roamTransform = this._roamTransform;
  26874. var viewTransform = this._viewTransform;
  26875. viewTransform.parent = roamTransform;
  26876. roamTransform.updateTransform();
  26877. viewTransform.updateTransform();
  26878. viewTransform.transform
  26879. && matrix.copy(this.transform || (this.transform = []), viewTransform.transform);
  26880. if (this.transform) {
  26881. this.invTransform = this.invTransform || [];
  26882. matrix.invert(this.invTransform, this.transform);
  26883. }
  26884. else {
  26885. this.invTransform = null;
  26886. }
  26887. this.decomposeTransform();
  26888. },
  26889. /**
  26890. * @return {module:zrender/core/BoundingRect}
  26891. */
  26892. getViewRect: function () {
  26893. return this._viewRect;
  26894. },
  26895. /**
  26896. * Get view rect after roam transform
  26897. * @return {module:zrender/core/BoundingRect}
  26898. */
  26899. getViewRectAfterRoam: function () {
  26900. var rect = this.getBoundingRect().clone();
  26901. rect.applyTransform(this.transform);
  26902. return rect;
  26903. },
  26904. /**
  26905. * Convert a single (lon, lat) data item to (x, y) point.
  26906. * @param {Array.<number>} data
  26907. * @return {Array.<number>}
  26908. */
  26909. dataToPoint: function (data) {
  26910. var transform = this.transform;
  26911. return transform
  26912. ? v2ApplyTransform([], data, transform)
  26913. : [data[0], data[1]];
  26914. },
  26915. /**
  26916. * Convert a (x, y) point to (lon, lat) data
  26917. * @param {Array.<number>} point
  26918. * @return {Array.<number>}
  26919. */
  26920. pointToData: function (point) {
  26921. var invTransform = this.invTransform;
  26922. return invTransform
  26923. ? v2ApplyTransform([], point, invTransform)
  26924. : [point[0], point[1]];
  26925. }
  26926. /**
  26927. * @return {number}
  26928. */
  26929. // getScalarScale: function () {
  26930. // // Use determinant square root of transform to mutiply scalar
  26931. // var m = this.transform;
  26932. // var det = Math.sqrt(Math.abs(m[0] * m[3] - m[2] * m[1]));
  26933. // return det;
  26934. // }
  26935. };
  26936. zrUtil.mixin(View, Transformable);
  26937. module.exports = View;
  26938. /***/ },
  26939. /* 169 */
  26940. /***/ function(module, exports, __webpack_require__) {
  26941. // Fix for 南海诸岛
  26942. var Region = __webpack_require__(166);
  26943. var geoCoord = [126, 25];
  26944. var points = [
  26945. [[0,3.5],[7,11.2],[15,11.9],[30,7],[42,0.7],[52,0.7],
  26946. [56,7.7],[59,0.7],[64,0.7],[64,0],[5,0],[0,3.5]],
  26947. [[13,16.1],[19,14.7],[16,21.7],[11,23.1],[13,16.1]],
  26948. [[12,32.2],[14,38.5],[15,38.5],[13,32.2],[12,32.2]],
  26949. [[16,47.6],[12,53.2],[13,53.2],[18,47.6],[16,47.6]],
  26950. [[6,64.4],[8,70],[9,70],[8,64.4],[6,64.4]],
  26951. [[23,82.6],[29,79.8],[30,79.8],[25,82.6],[23,82.6]],
  26952. [[37,70.7],[43,62.3],[44,62.3],[39,70.7],[37,70.7]],
  26953. [[48,51.1],[51,45.5],[53,45.5],[50,51.1],[48,51.1]],
  26954. [[51,35],[51,28.7],[53,28.7],[53,35],[51,35]],
  26955. [[52,22.4],[55,17.5],[56,17.5],[53,22.4],[52,22.4]],
  26956. [[58,12.6],[62,7],[63,7],[60,12.6],[58,12.6]],
  26957. [[0,3.5],[0,93.1],[64,93.1],[64,0],[63,0],[63,92.4],
  26958. [1,92.4],[1,3.5],[0,3.5]]
  26959. ];
  26960. for (var i = 0; i < points.length; i++) {
  26961. for (var k = 0; k < points[i].length; k++) {
  26962. points[i][k][0] /= 10.5;
  26963. points[i][k][1] /= -10.5 / 0.75;
  26964. points[i][k][0] += geoCoord[0];
  26965. points[i][k][1] += geoCoord[1];
  26966. }
  26967. }
  26968. module.exports = function (geo) {
  26969. if (geo.map === 'china') {
  26970. geo.regions.push(new Region(
  26971. '南海诸岛', points, geoCoord
  26972. ));
  26973. }
  26974. };
  26975. /***/ },
  26976. /* 170 */
  26977. /***/ function(module, exports, __webpack_require__) {
  26978. var zrUtil = __webpack_require__(4);
  26979. var coordsOffsetMap = {
  26980. '南海诸岛' : [32, 80],
  26981. // 全国
  26982. '广东': [0, -10],
  26983. '香港': [10, 5],
  26984. '澳门': [-10, 10],
  26985. //'北京': [-10, 0],
  26986. '天津': [5, 5]
  26987. };
  26988. module.exports = function (geo) {
  26989. zrUtil.each(geo.regions, function (region) {
  26990. var coordFix = coordsOffsetMap[region.name];
  26991. if (coordFix) {
  26992. var cp = region.center;
  26993. cp[0] += coordFix[0] / 10.5;
  26994. cp[1] += -coordFix[1] / (10.5 / 0.75);
  26995. }
  26996. });
  26997. };
  26998. /***/ },
  26999. /* 171 */
  27000. /***/ function(module, exports, __webpack_require__) {
  27001. var zrUtil = __webpack_require__(4);
  27002. var geoCoordMap = {
  27003. 'Russia': [100, 60],
  27004. 'United States of America': [-99, 38]
  27005. };
  27006. module.exports = function (geo) {
  27007. zrUtil.each(geo.regions, function (region) {
  27008. var geoCoord = geoCoordMap[region.name];
  27009. if (geoCoord) {
  27010. var cp = region.center;
  27011. cp[0] = geoCoord[0];
  27012. cp[1] = geoCoord[1];
  27013. }
  27014. });
  27015. };
  27016. /***/ },
  27017. /* 172 */
  27018. /***/ function(module, exports, __webpack_require__) {
  27019. // var zrUtil = require('zrender/lib/core/util');
  27020. var graphic = __webpack_require__(43);
  27021. var MapDraw = __webpack_require__(173);
  27022. __webpack_require__(1).extendChartView({
  27023. type: 'map',
  27024. render: function (mapModel, ecModel, api, payload) {
  27025. // Not render if it is an toggleSelect action from self
  27026. if (payload && payload.type === 'mapToggleSelect'
  27027. && payload.from === this.uid
  27028. ) {
  27029. return;
  27030. }
  27031. var group = this.group;
  27032. group.removeAll();
  27033. // Not update map if it is an roam action from self
  27034. if (!(payload && payload.type === 'geoRoam'
  27035. && payload.component === 'series'
  27036. && payload.name === mapModel.name)) {
  27037. if (mapModel.needsDrawMap) {
  27038. var mapDraw = this._mapDraw || new MapDraw(api, true);
  27039. group.add(mapDraw.group);
  27040. mapDraw.draw(mapModel, ecModel, api, this, payload);
  27041. this._mapDraw = mapDraw;
  27042. }
  27043. else {
  27044. // Remove drawed map
  27045. this._mapDraw && this._mapDraw.remove();
  27046. this._mapDraw = null;
  27047. }
  27048. }
  27049. else {
  27050. var mapDraw = this._mapDraw;
  27051. mapDraw && group.add(mapDraw.group);
  27052. }
  27053. mapModel.get('showLegendSymbol') && ecModel.getComponent('legend')
  27054. && this._renderSymbols(mapModel, ecModel, api);
  27055. },
  27056. remove: function () {
  27057. this._mapDraw && this._mapDraw.remove();
  27058. this._mapDraw = null;
  27059. this.group.removeAll();
  27060. },
  27061. _renderSymbols: function (mapModel, ecModel, api) {
  27062. var originalData = mapModel.originalData;
  27063. var group = this.group;
  27064. originalData.each('value', function (value, idx) {
  27065. if (isNaN(value)) {
  27066. return;
  27067. }
  27068. var layout = originalData.getItemLayout(idx);
  27069. if (!layout || !layout.point) {
  27070. // Not exists in map
  27071. return;
  27072. }
  27073. var point = layout.point;
  27074. var offset = layout.offset;
  27075. var circle = new graphic.Circle({
  27076. style: {
  27077. // Because the special of map draw.
  27078. // Which needs statistic of multiple series and draw on one map.
  27079. // And each series also need a symbol with legend color
  27080. //
  27081. // Layout and visual are put one the different data
  27082. fill: mapModel.getData().getVisual('color')
  27083. },
  27084. shape: {
  27085. cx: point[0] + offset * 9,
  27086. cy: point[1],
  27087. r: 3
  27088. },
  27089. silent: true,
  27090. z2: 10
  27091. });
  27092. // First data on the same region
  27093. if (!offset) {
  27094. var fullData = mapModel.mainSeries.getData();
  27095. var name = originalData.getName(idx);
  27096. var labelText = name;
  27097. var fullIndex = fullData.indexOfName(name);
  27098. var itemModel = originalData.getItemModel(idx);
  27099. var labelModel = itemModel.getModel('label.normal');
  27100. var hoverLabelModel = itemModel.getModel('label.emphasis');
  27101. var textStyleModel = labelModel.getModel('textStyle');
  27102. var hoverTextStyleModel = hoverLabelModel.getModel('textStyle');
  27103. var polygonGroups = fullData.getItemGraphicEl(fullIndex);
  27104. circle.setStyle({
  27105. textPosition: 'bottom'
  27106. });
  27107. var onEmphasis = function () {
  27108. circle.setStyle({
  27109. text: hoverLabelModel.get('show') ? labelText : '',
  27110. textFill: hoverTextStyleModel.getTextColor(),
  27111. textFont: hoverTextStyleModel.getFont()
  27112. });
  27113. };
  27114. var onNormal = function () {
  27115. circle.setStyle({
  27116. text: labelModel.get('show') ? labelText : '',
  27117. textFill: textStyleModel.getTextColor(),
  27118. textFont: textStyleModel.getFont()
  27119. });
  27120. };
  27121. polygonGroups.on('mouseover', onEmphasis)
  27122. .on('mouseout', onNormal)
  27123. .on('emphasis', onEmphasis)
  27124. .on('normal', onNormal);
  27125. onNormal();
  27126. }
  27127. group.add(circle);
  27128. });
  27129. }
  27130. });
  27131. /***/ },
  27132. /* 173 */
  27133. /***/ function(module, exports, __webpack_require__) {
  27134. /**
  27135. * @module echarts/component/helper/MapDraw
  27136. */
  27137. var RoamController = __webpack_require__(174);
  27138. var graphic = __webpack_require__(43);
  27139. var zrUtil = __webpack_require__(4);
  27140. function getFixedItemStyle(model, scale) {
  27141. var itemStyle = model.getItemStyle();
  27142. var areaColor = model.get('areaColor');
  27143. if (areaColor) {
  27144. itemStyle.fill = areaColor;
  27145. }
  27146. return itemStyle;
  27147. }
  27148. function updateMapSelectHandler(mapOrGeoModel, group, api, fromView) {
  27149. group.off('click');
  27150. mapOrGeoModel.get('selectedMode')
  27151. && group.on('click', function (e) {
  27152. var el = e.target;
  27153. while (!el.__region) {
  27154. el = el.parent;
  27155. }
  27156. if (!el) {
  27157. return;
  27158. }
  27159. var region = el.__region;
  27160. var action = {
  27161. type: (mapOrGeoModel.mainType === 'geo' ? 'geo' : 'map') + 'ToggleSelect',
  27162. name: region.name,
  27163. from: fromView.uid
  27164. };
  27165. action[mapOrGeoModel.mainType + 'Id'] = mapOrGeoModel.id;
  27166. api.dispatchAction(action);
  27167. updateMapSelected(mapOrGeoModel, group);
  27168. });
  27169. }
  27170. function updateMapSelected(mapOrGeoModel, group) {
  27171. // FIXME
  27172. group.eachChild(function (otherRegionEl) {
  27173. if (otherRegionEl.__region) {
  27174. otherRegionEl.trigger(mapOrGeoModel.isSelected(otherRegionEl.__region.name) ? 'emphasis' : 'normal');
  27175. }
  27176. });
  27177. }
  27178. /**
  27179. * @alias module:echarts/component/helper/MapDraw
  27180. * @param {module:echarts/ExtensionAPI} api
  27181. * @param {boolean} updateGroup
  27182. */
  27183. function MapDraw(api, updateGroup) {
  27184. var group = new graphic.Group();
  27185. /**
  27186. * @type {module:echarts/component/helper/RoamController}
  27187. * @private
  27188. */
  27189. this._controller = new RoamController(
  27190. api.getZr(), updateGroup ? group : null, null
  27191. );
  27192. /**
  27193. * @type {module:zrender/container/Group}
  27194. * @readOnly
  27195. */
  27196. this.group = group;
  27197. /**
  27198. * @type {boolean}
  27199. * @private
  27200. */
  27201. this._updateGroup = updateGroup;
  27202. }
  27203. MapDraw.prototype = {
  27204. constructor: MapDraw,
  27205. draw: function (mapOrGeoModel, ecModel, api, fromView, payload) {
  27206. // geoModel has no data
  27207. var data = mapOrGeoModel.getData && mapOrGeoModel.getData();
  27208. var geo = mapOrGeoModel.coordinateSystem;
  27209. var group = this.group;
  27210. var scale = geo.scale;
  27211. var groupNewProp = {
  27212. position: geo.position,
  27213. scale: scale
  27214. };
  27215. // No animation when first draw or in action
  27216. if (!group.childAt(0) || payload) {
  27217. group.attr(groupNewProp);
  27218. }
  27219. else {
  27220. graphic.updateProps(group, groupNewProp, mapOrGeoModel);
  27221. }
  27222. group.removeAll();
  27223. var itemStyleAccessPath = ['itemStyle', 'normal'];
  27224. var hoverItemStyleAccessPath = ['itemStyle', 'emphasis'];
  27225. var labelAccessPath = ['label', 'normal'];
  27226. var hoverLabelAccessPath = ['label', 'emphasis'];
  27227. zrUtil.each(geo.regions, function (region) {
  27228. var regionGroup = new graphic.Group();
  27229. var compoundPath = new graphic.CompoundPath({
  27230. shape: {
  27231. paths: []
  27232. }
  27233. });
  27234. regionGroup.add(compoundPath);
  27235. var regionModel = mapOrGeoModel.getRegionModel(region.name) || mapOrGeoModel;
  27236. var itemStyleModel = regionModel.getModel(itemStyleAccessPath);
  27237. var hoverItemStyleModel = regionModel.getModel(hoverItemStyleAccessPath);
  27238. var itemStyle = getFixedItemStyle(itemStyleModel, scale);
  27239. var hoverItemStyle = getFixedItemStyle(hoverItemStyleModel, scale);
  27240. var labelModel = regionModel.getModel(labelAccessPath);
  27241. var hoverLabelModel = regionModel.getModel(hoverLabelAccessPath);
  27242. var dataIdx;
  27243. // Use the itemStyle in data if has data
  27244. if (data) {
  27245. dataIdx = data.indexOfName(region.name);
  27246. // Only visual color of each item will be used. It can be encoded by dataRange
  27247. // But visual color of series is used in symbol drawing
  27248. //
  27249. // Visual color for each series is for the symbol draw
  27250. var visualColor = data.getItemVisual(dataIdx, 'color', true);
  27251. if (visualColor) {
  27252. itemStyle.fill = visualColor;
  27253. }
  27254. }
  27255. var textStyleModel = labelModel.getModel('textStyle');
  27256. var hoverTextStyleModel = hoverLabelModel.getModel('textStyle');
  27257. zrUtil.each(region.contours, function (contour) {
  27258. var polygon = new graphic.Polygon({
  27259. shape: {
  27260. points: contour
  27261. }
  27262. });
  27263. compoundPath.shape.paths.push(polygon);
  27264. });
  27265. compoundPath.setStyle(itemStyle);
  27266. compoundPath.style.strokeNoScale = true;
  27267. compoundPath.culling = true;
  27268. // Label
  27269. var showLabel = labelModel.get('show');
  27270. var hoverShowLabel = hoverLabelModel.get('show');
  27271. var isDataNaN = data && isNaN(data.get('value', dataIdx));
  27272. var itemLayout = data && data.getItemLayout(dataIdx);
  27273. // In the following cases label will be drawn
  27274. // 1. In map series and data value is NaN
  27275. // 2. In geo component
  27276. // 4. Region has no series legendSymbol, which will be add a showLabel flag in mapSymbolLayout
  27277. if (
  27278. (!data || isDataNaN && (showLabel || hoverShowLabel))
  27279. || (itemLayout && itemLayout.showLabel)
  27280. ) {
  27281. var query = data ? dataIdx : region.name;
  27282. var formattedStr = mapOrGeoModel.getFormattedLabel(query, 'normal');
  27283. var hoverFormattedStr = mapOrGeoModel.getFormattedLabel(query, 'emphasis');
  27284. var text = new graphic.Text({
  27285. style: {
  27286. text: showLabel ? (formattedStr || region.name) : '',
  27287. fill: textStyleModel.getTextColor(),
  27288. textFont: textStyleModel.getFont(),
  27289. textAlign: 'center',
  27290. textVerticalAlign: 'middle'
  27291. },
  27292. hoverStyle: {
  27293. text: hoverShowLabel ? (hoverFormattedStr || region.name) : '',
  27294. fill: hoverTextStyleModel.getTextColor(),
  27295. textFont: hoverTextStyleModel.getFont()
  27296. },
  27297. position: region.center.slice(),
  27298. scale: [1 / scale[0], 1 / scale[1]],
  27299. z2: 10,
  27300. silent: true
  27301. });
  27302. regionGroup.add(text);
  27303. }
  27304. // setItemGraphicEl, setHoverStyle after all polygons and labels
  27305. // are added to the rigionGroup
  27306. if (data) {
  27307. data.setItemGraphicEl(dataIdx, regionGroup);
  27308. }
  27309. else {
  27310. var regionModel = mapOrGeoModel.getRegionModel(region.name);
  27311. // Package custom mouse event for geo component
  27312. compoundPath.eventData = {
  27313. componentType: 'geo',
  27314. geoIndex: mapOrGeoModel.componentIndex,
  27315. name: region.name,
  27316. region: (regionModel && regionModel.option) || {}
  27317. };
  27318. }
  27319. regionGroup.__region = region;
  27320. graphic.setHoverStyle(regionGroup, hoverItemStyle);
  27321. group.add(regionGroup);
  27322. });
  27323. this._updateController(mapOrGeoModel, ecModel, api);
  27324. updateMapSelectHandler(mapOrGeoModel, group, api, fromView);
  27325. updateMapSelected(mapOrGeoModel, group);
  27326. },
  27327. remove: function () {
  27328. this.group.removeAll();
  27329. this._controller.dispose();
  27330. },
  27331. _updateController: function (mapOrGeoModel, ecModel, api) {
  27332. var geo = mapOrGeoModel.coordinateSystem;
  27333. var controller = this._controller;
  27334. controller.zoomLimit = mapOrGeoModel.get('scaleLimit');
  27335. // Update zoom from model
  27336. controller.zoom = geo.getZoom();
  27337. // roamType is will be set default true if it is null
  27338. controller.enable(mapOrGeoModel.get('roam') || false);
  27339. var mainType = mapOrGeoModel.mainType;
  27340. function makeActionBase() {
  27341. var action = {
  27342. type: 'geoRoam',
  27343. componentType: mainType
  27344. };
  27345. action[mainType + 'Id'] = mapOrGeoModel.id;
  27346. return action;
  27347. }
  27348. controller.off('pan')
  27349. .on('pan', function (dx, dy) {
  27350. api.dispatchAction(zrUtil.extend(makeActionBase(), {
  27351. dx: dx,
  27352. dy: dy
  27353. }));
  27354. });
  27355. controller.off('zoom')
  27356. .on('zoom', function (zoom, mouseX, mouseY) {
  27357. api.dispatchAction(zrUtil.extend(makeActionBase(), {
  27358. zoom: zoom,
  27359. originX: mouseX,
  27360. originY: mouseY
  27361. }));
  27362. if (this._updateGroup) {
  27363. var group = this.group;
  27364. var scale = group.scale;
  27365. group.traverse(function (el) {
  27366. if (el.type === 'text') {
  27367. el.attr('scale', [1 / scale[0], 1 / scale[1]]);
  27368. }
  27369. });
  27370. }
  27371. }, this);
  27372. controller.rectProvider = function () {
  27373. return geo.getViewRectAfterRoam();
  27374. };
  27375. }
  27376. };
  27377. module.exports = MapDraw;
  27378. /***/ },
  27379. /* 174 */
  27380. /***/ function(module, exports, __webpack_require__) {
  27381. /**
  27382. * @module echarts/component/helper/RoamController
  27383. */
  27384. var Eventful = __webpack_require__(33);
  27385. var zrUtil = __webpack_require__(4);
  27386. var eventTool = __webpack_require__(87);
  27387. var interactionMutex = __webpack_require__(175);
  27388. function mousedown(e) {
  27389. if (e.target && e.target.draggable) {
  27390. return;
  27391. }
  27392. var x = e.offsetX;
  27393. var y = e.offsetY;
  27394. var rect = this.rectProvider && this.rectProvider();
  27395. if (rect && rect.contain(x, y)) {
  27396. this._x = x;
  27397. this._y = y;
  27398. this._dragging = true;
  27399. }
  27400. }
  27401. function mousemove(e) {
  27402. if (!this._dragging) {
  27403. return;
  27404. }
  27405. eventTool.stop(e.event);
  27406. if (e.gestureEvent !== 'pinch') {
  27407. if (interactionMutex.isTaken(this._zr, 'globalPan')) {
  27408. return;
  27409. }
  27410. var x = e.offsetX;
  27411. var y = e.offsetY;
  27412. var dx = x - this._x;
  27413. var dy = y - this._y;
  27414. this._x = x;
  27415. this._y = y;
  27416. var target = this.target;
  27417. if (target) {
  27418. var pos = target.position;
  27419. pos[0] += dx;
  27420. pos[1] += dy;
  27421. target.dirty();
  27422. }
  27423. eventTool.stop(e.event);
  27424. this.trigger('pan', dx, dy);
  27425. }
  27426. }
  27427. function mouseup(e) {
  27428. this._dragging = false;
  27429. }
  27430. function mousewheel(e) {
  27431. // Convenience:
  27432. // Mac and VM Windows on Mac: scroll up: zoom out.
  27433. // Windows: scroll up: zoom in.
  27434. var zoomDelta = e.wheelDelta > 0 ? 1.1 : 1 / 1.1;
  27435. zoom.call(this, e, zoomDelta, e.offsetX, e.offsetY);
  27436. }
  27437. function pinch(e) {
  27438. if (interactionMutex.isTaken(this._zr, 'globalPan')) {
  27439. return;
  27440. }
  27441. var zoomDelta = e.pinchScale > 1 ? 1.1 : 1 / 1.1;
  27442. zoom.call(this, e, zoomDelta, e.pinchX, e.pinchY);
  27443. }
  27444. function zoom(e, zoomDelta, zoomX, zoomY) {
  27445. var rect = this.rectProvider && this.rectProvider();
  27446. if (rect && rect.contain(zoomX, zoomY)) {
  27447. // When mouse is out of roamController rect,
  27448. // default befavoius should be be disabled, otherwise
  27449. // page sliding is disabled, contrary to expectation.
  27450. eventTool.stop(e.event);
  27451. var target = this.target;
  27452. var zoomLimit = this.zoomLimit;
  27453. if (target) {
  27454. var pos = target.position;
  27455. var scale = target.scale;
  27456. var newZoom = this.zoom = this.zoom || 1;
  27457. newZoom *= zoomDelta;
  27458. if (zoomLimit) {
  27459. var zoomMin = zoomLimit.min || 0;
  27460. var zoomMax = zoomLimit.max || Infinity;
  27461. newZoom = Math.max(
  27462. Math.min(zoomMax, newZoom),
  27463. zoomMin
  27464. );
  27465. }
  27466. var zoomScale = newZoom / this.zoom;
  27467. this.zoom = newZoom;
  27468. // Keep the mouse center when scaling
  27469. pos[0] -= (zoomX - pos[0]) * (zoomScale - 1);
  27470. pos[1] -= (zoomY - pos[1]) * (zoomScale - 1);
  27471. scale[0] *= zoomScale;
  27472. scale[1] *= zoomScale;
  27473. target.dirty();
  27474. }
  27475. this.trigger('zoom', zoomDelta, zoomX, zoomY);
  27476. }
  27477. }
  27478. /**
  27479. * @alias module:echarts/component/helper/RoamController
  27480. * @constructor
  27481. * @mixin {module:zrender/mixin/Eventful}
  27482. *
  27483. * @param {module:zrender/zrender~ZRender} zr
  27484. * @param {module:zrender/Element} target
  27485. * @param {Function} [rectProvider]
  27486. */
  27487. function RoamController(zr, target, rectProvider) {
  27488. /**
  27489. * @type {module:zrender/Element}
  27490. */
  27491. this.target = target;
  27492. /**
  27493. * @type {Function}
  27494. */
  27495. this.rectProvider = rectProvider;
  27496. /**
  27497. * { min: 1, max: 2 }
  27498. * @type {Object}
  27499. */
  27500. this.zoomLimit;
  27501. /**
  27502. * @type {number}
  27503. */
  27504. this.zoom;
  27505. /**
  27506. * @type {module:zrender}
  27507. */
  27508. this._zr = zr;
  27509. // Avoid two roamController bind the same handler
  27510. var bind = zrUtil.bind;
  27511. var mousedownHandler = bind(mousedown, this);
  27512. var mousemoveHandler = bind(mousemove, this);
  27513. var mouseupHandler = bind(mouseup, this);
  27514. var mousewheelHandler = bind(mousewheel, this);
  27515. var pinchHandler = bind(pinch, this);
  27516. Eventful.call(this);
  27517. /**
  27518. * Notice: only enable needed types. For example, if 'zoom'
  27519. * is not needed, 'zoom' should not be enabled, otherwise
  27520. * default mousewheel behaviour (scroll page) will be disabled.
  27521. *
  27522. * @param {boolean|string} [controlType=true] Specify the control type,
  27523. * which can be null/undefined or true/false
  27524. * or 'pan/move' or 'zoom'/'scale'
  27525. */
  27526. this.enable = function (controlType) {
  27527. // Disable previous first
  27528. this.disable();
  27529. if (controlType == null) {
  27530. controlType = true;
  27531. }
  27532. if (controlType === true || (controlType === 'move' || controlType === 'pan')) {
  27533. zr.on('mousedown', mousedownHandler);
  27534. zr.on('mousemove', mousemoveHandler);
  27535. zr.on('mouseup', mouseupHandler);
  27536. }
  27537. if (controlType === true || (controlType === 'scale' || controlType === 'zoom')) {
  27538. zr.on('mousewheel', mousewheelHandler);
  27539. zr.on('pinch', pinchHandler);
  27540. }
  27541. };
  27542. this.disable = function () {
  27543. zr.off('mousedown', mousedownHandler);
  27544. zr.off('mousemove', mousemoveHandler);
  27545. zr.off('mouseup', mouseupHandler);
  27546. zr.off('mousewheel', mousewheelHandler);
  27547. zr.off('pinch', pinchHandler);
  27548. };
  27549. this.dispose = this.disable;
  27550. this.isDragging = function () {
  27551. return this._dragging;
  27552. };
  27553. this.isPinching = function () {
  27554. return this._pinching;
  27555. };
  27556. }
  27557. zrUtil.mixin(RoamController, Eventful);
  27558. module.exports = RoamController;
  27559. /***/ },
  27560. /* 175 */
  27561. /***/ function(module, exports, __webpack_require__) {
  27562. var ATTR = '\0_ec_interaction_mutex';
  27563. var interactionMutex = {
  27564. take: function (zr, resourceKey, userKey) {
  27565. var store = getStore(zr);
  27566. store[resourceKey] = userKey;
  27567. },
  27568. release: function (zr, resourceKey, userKey) {
  27569. var store = getStore(zr);
  27570. var uKey = store[resourceKey];
  27571. if (uKey === userKey) {
  27572. store[resourceKey] = null;
  27573. }
  27574. },
  27575. isTaken: function (zr, resourceKey) {
  27576. return !!getStore(zr)[resourceKey];
  27577. }
  27578. };
  27579. function getStore(zr) {
  27580. return zr[ATTR] || (zr[ATTR] = {});
  27581. }
  27582. /**
  27583. * payload: {
  27584. * type: 'takeGlobalCursor',
  27585. * key: 'dataZoomSelect', or 'brush', or ...,
  27586. * If no userKey, release global cursor.
  27587. * }
  27588. */
  27589. __webpack_require__(1).registerAction(
  27590. {type: 'takeGlobalCursor', event: 'globalCursorTaken', update: 'update'},
  27591. function () {}
  27592. );
  27593. module.exports = interactionMutex;
  27594. /***/ },
  27595. /* 176 */
  27596. /***/ function(module, exports, __webpack_require__) {
  27597. var zrUtil = __webpack_require__(4);
  27598. var roamHelper = __webpack_require__(177);
  27599. var echarts = __webpack_require__(1);
  27600. /**
  27601. * @payload
  27602. * @property {string} [componentType=series]
  27603. * @property {number} [dx]
  27604. * @property {number} [dy]
  27605. * @property {number} [zoom]
  27606. * @property {number} [originX]
  27607. * @property {number} [originY]
  27608. */
  27609. echarts.registerAction({
  27610. type: 'geoRoam',
  27611. event: 'geoRoam',
  27612. update: 'updateLayout'
  27613. }, function (payload, ecModel) {
  27614. var componentType = payload.componentType || 'series';
  27615. ecModel.eachComponent(
  27616. { mainType: componentType, query: payload },
  27617. function (componentModel) {
  27618. var geo = componentModel.coordinateSystem;
  27619. if (geo.type !== 'geo') {
  27620. return;
  27621. }
  27622. var res = roamHelper.updateCenterAndZoom(
  27623. geo, payload, componentModel.get('scaleLimit')
  27624. );
  27625. componentModel.setCenter
  27626. && componentModel.setCenter(res.center);
  27627. componentModel.setZoom
  27628. && componentModel.setZoom(res.zoom);
  27629. // All map series with same `map` use the same geo coordinate system
  27630. // So the center and zoom must be in sync. Include the series not selected by legend
  27631. if (componentType === 'series') {
  27632. zrUtil.each(componentModel.seriesGroup, function (seriesModel) {
  27633. seriesModel.setCenter(res.center);
  27634. seriesModel.setZoom(res.zoom);
  27635. });
  27636. }
  27637. }
  27638. );
  27639. });
  27640. /***/ },
  27641. /* 177 */
  27642. /***/ function(module, exports) {
  27643. var roamHelper = {};
  27644. /**
  27645. * @param {module:echarts/coord/View} view
  27646. * @param {Object} payload
  27647. * @param {Object} [zoomLimit]
  27648. */
  27649. roamHelper.updateCenterAndZoom = function (
  27650. view, payload, zoomLimit
  27651. ) {
  27652. var previousZoom = view.getZoom();
  27653. var center = view.getCenter();
  27654. var zoom = payload.zoom;
  27655. var point = view.dataToPoint(center);
  27656. if (payload.dx != null && payload.dy != null) {
  27657. point[0] -= payload.dx;
  27658. point[1] -= payload.dy;
  27659. var center = view.pointToData(point);
  27660. view.setCenter(center);
  27661. }
  27662. if (zoom != null) {
  27663. if (zoomLimit) {
  27664. var zoomMin = zoomLimit.min || 0;
  27665. var zoomMax = zoomLimit.max || Infinity;
  27666. zoom = Math.max(
  27667. Math.min(previousZoom * zoom, zoomMax),
  27668. zoomMin
  27669. ) / previousZoom;
  27670. }
  27671. // Zoom on given point(originX, originY)
  27672. view.scale[0] *= zoom;
  27673. view.scale[1] *= zoom;
  27674. var position = view.position;
  27675. var fixX = (payload.originX - position[0]) * (zoom - 1);
  27676. var fixY = (payload.originY - position[1]) * (zoom - 1);
  27677. position[0] -= fixX;
  27678. position[1] -= fixY;
  27679. view.updateTransform();
  27680. // Get the new center
  27681. var center = view.pointToData(point);
  27682. view.setCenter(center);
  27683. view.setZoom(zoom * previousZoom);
  27684. }
  27685. return {
  27686. center: view.getCenter(),
  27687. zoom: view.getZoom()
  27688. };
  27689. };
  27690. module.exports = roamHelper;
  27691. /***/ },
  27692. /* 178 */
  27693. /***/ function(module, exports, __webpack_require__) {
  27694. var zrUtil = __webpack_require__(4);
  27695. module.exports = function (ecModel) {
  27696. var processedMapType = {};
  27697. ecModel.eachSeriesByType('map', function (mapSeries) {
  27698. var mapType = mapSeries.get('map');
  27699. if (processedMapType[mapType]) {
  27700. return;
  27701. }
  27702. var mapSymbolOffsets = {};
  27703. zrUtil.each(mapSeries.seriesGroup, function (subMapSeries) {
  27704. var geo = subMapSeries.coordinateSystem;
  27705. var data = subMapSeries.originalData;
  27706. if (subMapSeries.get('showLegendSymbol') && ecModel.getComponent('legend')) {
  27707. data.each('value', function (value, idx) {
  27708. var name = data.getName(idx);
  27709. var region = geo.getRegion(name);
  27710. // No region or no value
  27711. // In MapSeries data regions will be filled with NaN
  27712. // If they are not in the series.data array.
  27713. // So here must validate if value is NaN
  27714. if (!region || isNaN(value)) {
  27715. return;
  27716. }
  27717. var offset = mapSymbolOffsets[name] || 0;
  27718. var point = geo.dataToPoint(region.center);
  27719. mapSymbolOffsets[name] = offset + 1;
  27720. data.setItemLayout(idx, {
  27721. point: point,
  27722. offset: offset
  27723. });
  27724. });
  27725. }
  27726. });
  27727. // Show label of those region not has legendSymbol(which is offset 0)
  27728. var data = mapSeries.getData();
  27729. data.each(function (idx) {
  27730. var name = data.getName(idx);
  27731. var layout = data.getItemLayout(idx) || {};
  27732. layout.showLabel = !mapSymbolOffsets[name];
  27733. data.setItemLayout(idx, layout);
  27734. });
  27735. processedMapType[mapType] = true;
  27736. });
  27737. };
  27738. /***/ },
  27739. /* 179 */
  27740. /***/ function(module, exports) {
  27741. module.exports = function (ecModel) {
  27742. ecModel.eachSeriesByType('map', function (seriesModel) {
  27743. var colorList = seriesModel.get('color');
  27744. var itemStyleModel = seriesModel.getModel('itemStyle.normal');
  27745. var areaColor = itemStyleModel.get('areaColor');
  27746. var color = itemStyleModel.get('color')
  27747. || colorList[seriesModel.seriesIndex % colorList.length];
  27748. seriesModel.getData().setVisual({
  27749. 'areaColor': areaColor,
  27750. 'color': color
  27751. });
  27752. });
  27753. };
  27754. /***/ },
  27755. /* 180 */
  27756. /***/ function(module, exports, __webpack_require__) {
  27757. var zrUtil = __webpack_require__(4);
  27758. // FIXME 公用?
  27759. /**
  27760. * @param {Array.<module:echarts/data/List>} datas
  27761. * @param {string} statisticType 'average' 'sum'
  27762. * @inner
  27763. */
  27764. function dataStatistics(datas, statisticType) {
  27765. var dataNameMap = {};
  27766. var dims = ['value'];
  27767. for (var i = 0; i < datas.length; i++) {
  27768. datas[i].each(dims, function (value, idx) {
  27769. var name = datas[i].getName(idx);
  27770. dataNameMap[name] = dataNameMap[name] || [];
  27771. if (!isNaN(value)) {
  27772. dataNameMap[name].push(value);
  27773. }
  27774. });
  27775. }
  27776. return datas[0].map(dims, function (value, idx) {
  27777. var name = datas[0].getName(idx);
  27778. var sum = 0;
  27779. var min = Infinity;
  27780. var max = -Infinity;
  27781. var len = dataNameMap[name].length;
  27782. for (var i = 0; i < len; i++) {
  27783. min = Math.min(min, dataNameMap[name][i]);
  27784. max = Math.max(max, dataNameMap[name][i]);
  27785. sum += dataNameMap[name][i];
  27786. }
  27787. var result;
  27788. if (statisticType === 'min') {
  27789. result = min;
  27790. }
  27791. else if (statisticType === 'max') {
  27792. result = max;
  27793. }
  27794. else if (statisticType === 'average') {
  27795. result = sum / len;
  27796. }
  27797. else {
  27798. result = sum;
  27799. }
  27800. return len === 0 ? NaN : result;
  27801. });
  27802. }
  27803. module.exports = function (ecModel) {
  27804. var seriesGroupByMapType = {};
  27805. ecModel.eachSeriesByType('map', function (seriesModel) {
  27806. var mapType = seriesModel.get('map');
  27807. seriesGroupByMapType[mapType] = seriesGroupByMapType[mapType] || [];
  27808. seriesGroupByMapType[mapType].push(seriesModel);
  27809. });
  27810. zrUtil.each(seriesGroupByMapType, function (seriesList, mapType) {
  27811. var data = dataStatistics(
  27812. zrUtil.map(seriesList, function (seriesModel) {
  27813. return seriesModel.getData();
  27814. }),
  27815. seriesList[0].get('mapValueCalculation')
  27816. );
  27817. for (var i = 0; i < seriesList.length; i++) {
  27818. seriesList[i].originalData = seriesList[i].getData();
  27819. }
  27820. // FIXME Put where?
  27821. for (var i = 0; i < seriesList.length; i++) {
  27822. seriesList[i].seriesGroup = seriesList;
  27823. seriesList[i].needsDrawMap = i === 0;
  27824. seriesList[i].setData(data.cloneShallow());
  27825. seriesList[i].mainSeries = seriesList[0];
  27826. }
  27827. });
  27828. };
  27829. /***/ },
  27830. /* 181 */
  27831. /***/ function(module, exports, __webpack_require__) {
  27832. var zrUtil = __webpack_require__(4);
  27833. module.exports = function (option) {
  27834. // Save geoCoord
  27835. var mapSeries = [];
  27836. zrUtil.each(option.series, function (seriesOpt) {
  27837. if (seriesOpt.type === 'map') {
  27838. mapSeries.push(seriesOpt);
  27839. }
  27840. });
  27841. zrUtil.each(mapSeries, function (seriesOpt) {
  27842. seriesOpt.map = seriesOpt.map || seriesOpt.mapType;
  27843. // Put x, y, width, height, x2, y2 in the top level
  27844. zrUtil.defaults(seriesOpt, seriesOpt.mapLocation);
  27845. });
  27846. };
  27847. /***/ },
  27848. /* 182 */
  27849. /***/ function(module, exports, __webpack_require__) {
  27850. var echarts = __webpack_require__(1);
  27851. __webpack_require__(183);
  27852. __webpack_require__(186);
  27853. __webpack_require__(190);
  27854. echarts.registerVisual(__webpack_require__(191));
  27855. echarts.registerLayout(__webpack_require__(193));
  27856. /***/ },
  27857. /* 183 */
  27858. /***/ function(module, exports, __webpack_require__) {
  27859. var SeriesModel = __webpack_require__(28);
  27860. var Tree = __webpack_require__(184);
  27861. var zrUtil = __webpack_require__(4);
  27862. var Model = __webpack_require__(12);
  27863. var formatUtil = __webpack_require__(6);
  27864. var encodeHTML = formatUtil.encodeHTML;
  27865. var addCommas = formatUtil.addCommas;
  27866. module.exports = SeriesModel.extend({
  27867. type: 'series.treemap',
  27868. dependencies: ['grid', 'polar'],
  27869. /**
  27870. * @type {module:echarts/data/Tree~Node}
  27871. */
  27872. _viewRoot: null,
  27873. defaultOption: {
  27874. // Disable progressive rendering
  27875. progressive: 0,
  27876. hoverLayerThreshold: Infinity,
  27877. // center: ['50%', '50%'], // not supported in ec3.
  27878. // size: ['80%', '80%'], // deprecated, compatible with ec2.
  27879. left: 'center',
  27880. top: 'middle',
  27881. right: null,
  27882. bottom: null,
  27883. width: '80%',
  27884. height: '80%',
  27885. sort: true, // Can be null or false or true
  27886. // (order by desc default, asc not supported yet (strange effect))
  27887. clipWindow: 'origin', // Size of clipped window when zooming. 'origin' or 'fullscreen'
  27888. squareRatio: 0.5 * (1 + Math.sqrt(5)), // golden ratio
  27889. leafDepth: null, // Nodes on depth from root are regarded as leaves.
  27890. // Count from zero (zero represents only view root).
  27891. drillDownIcon: '▶', // Use html character temporarily because it is complicated
  27892. // to align specialized icon. ▷▶❒❐▼✚
  27893. visualDimension: 0, // Can be 0, 1, 2, 3.
  27894. zoomToNodeRatio: 0.32 * 0.32, // Be effective when using zoomToNode. Specify the proportion of the
  27895. // target node area in the view area.
  27896. roam: true, // true, false, 'scale' or 'zoom', 'move'.
  27897. nodeClick: 'zoomToNode', // Leaf node click behaviour: 'zoomToNode', 'link', false.
  27898. // If leafDepth is set and clicking a node which has children but
  27899. // be on left depth, the behaviour would be changing root. Otherwise
  27900. // use behavious defined above.
  27901. animation: true,
  27902. animationDurationUpdate: 900,
  27903. animationEasing: 'quinticInOut',
  27904. breadcrumb: {
  27905. show: true,
  27906. height: 22,
  27907. left: 'center',
  27908. top: 'bottom',
  27909. // right
  27910. // bottom
  27911. emptyItemWidth: 25, // Width of empty node.
  27912. itemStyle: {
  27913. normal: {
  27914. color: 'rgba(0,0,0,0.7)', //'#5793f3',
  27915. borderColor: 'rgba(255,255,255,0.7)',
  27916. borderWidth: 1,
  27917. shadowColor: 'rgba(150,150,150,1)',
  27918. shadowBlur: 3,
  27919. shadowOffsetX: 0,
  27920. shadowOffsetY: 0,
  27921. textStyle: {
  27922. color: '#fff'
  27923. }
  27924. },
  27925. emphasis: {
  27926. textStyle: {}
  27927. }
  27928. }
  27929. },
  27930. label: {
  27931. normal: {
  27932. show: true,
  27933. position: 'inside', // Can be [5, '5%'] or position stirng like 'insideTopLeft', ...
  27934. textStyle: {
  27935. color: '#fff',
  27936. ellipsis: true
  27937. }
  27938. }
  27939. },
  27940. itemStyle: {
  27941. normal: {
  27942. color: null, // Can be 'none' if not necessary.
  27943. colorAlpha: null, // Can be 'none' if not necessary.
  27944. colorSaturation: null, // Can be 'none' if not necessary.
  27945. borderWidth: 0,
  27946. gapWidth: 0,
  27947. borderColor: '#fff',
  27948. borderColorSaturation: null // If specified, borderColor will be ineffective, and the
  27949. // border color is evaluated by color of current node and
  27950. // borderColorSaturation.
  27951. },
  27952. emphasis: {
  27953. }
  27954. },
  27955. color: [], // + treemapSeries.color should not be modified. Please only modified
  27956. // level[n].color (if necessary).
  27957. // + Specify color list of each level. level[0].color would be global
  27958. // color list if not specified. (see method `setDefault`).
  27959. // + But set as a empty array to forbid fetch color from global palette
  27960. // when using nodeModel.get('color'), otherwise nodes on deep level
  27961. // will always has color palette set and are not able to inherit color
  27962. // from parent node.
  27963. // + TreemapSeries.color can not be set as 'none', otherwise effect
  27964. // legend color fetching (see seriesColor.js).
  27965. colorAlpha: null, // Array. Specify color alpha range of each level, like [0.2, 0.8]
  27966. colorSaturation: null, // Array. Specify color saturation of each level, like [0.2, 0.5]
  27967. colorMappingBy: 'index', // 'value' or 'index' or 'id'.
  27968. visibleMin: 10, // If area less than this threshold (unit: pixel^2), node will not
  27969. // be rendered. Only works when sort is 'asc' or 'desc'.
  27970. childrenVisibleMin: null, // If area of a node less than this threshold (unit: pixel^2),
  27971. // grandchildren will not show.
  27972. // Why grandchildren? If not grandchildren but children,
  27973. // some siblings show children and some not,
  27974. // the appearance may be mess and not consistent,
  27975. levels: [] // Each item: {
  27976. // visibleMin, itemStyle, visualDimension, label
  27977. // }
  27978. // data: {
  27979. // value: [],
  27980. // children: [],
  27981. // link: 'http://xxx.xxx.xxx',
  27982. // target: 'blank' or 'self'
  27983. // }
  27984. },
  27985. /**
  27986. * @override
  27987. */
  27988. getInitialData: function (option, ecModel) {
  27989. var data = option.data || [];
  27990. var rootName = option.name;
  27991. rootName == null && (rootName = option.name);
  27992. // Create a virtual root.
  27993. var root = {name: rootName, children: option.data};
  27994. var value0 = (data[0] || {}).value;
  27995. completeTreeValue(root, zrUtil.isArray(value0) ? value0.length : -1);
  27996. // FIXME
  27997. // sereis.mergeOption 的 getInitData是否放在merge后,从而能直接获取merege后的结果而非手动判断。
  27998. var levels = option.levels || [];
  27999. levels = option.levels = setDefault(levels, ecModel);
  28000. // Make sure always a new tree is created when setOption,
  28001. // in TreemapView, we check whether oldTree === newTree
  28002. // to choose mappings approach among old shapes and new shapes.
  28003. return Tree.createTree(root, this, levels).data;
  28004. },
  28005. optionUpdated: function () {
  28006. this.resetViewRoot();
  28007. },
  28008. /**
  28009. * @override
  28010. * @param {number} dataIndex
  28011. * @param {boolean} [mutipleSeries=false]
  28012. */
  28013. formatTooltip: function (dataIndex) {
  28014. var data = this.getData();
  28015. var value = this.getRawValue(dataIndex);
  28016. var formattedValue = zrUtil.isArray(value)
  28017. ? addCommas(value[0]) : addCommas(value);
  28018. var name = data.getName(dataIndex);
  28019. return encodeHTML(name) + ': ' + formattedValue;
  28020. },
  28021. /**
  28022. * Add tree path to tooltip param
  28023. *
  28024. * @override
  28025. * @param {number} dataIndex
  28026. * @return {Object}
  28027. */
  28028. getDataParams: function (dataIndex) {
  28029. var params = SeriesModel.prototype.getDataParams.apply(this, arguments);
  28030. var data = this.getData();
  28031. var node = data.tree.getNodeByDataIndex(dataIndex);
  28032. var treePathInfo = params.treePathInfo = [];
  28033. while (node) {
  28034. var nodeDataIndex = node.dataIndex;
  28035. treePathInfo.push({
  28036. name: node.name,
  28037. dataIndex: nodeDataIndex,
  28038. value: this.getRawValue(nodeDataIndex)
  28039. });
  28040. node = node.parentNode;
  28041. }
  28042. treePathInfo.reverse();
  28043. return params;
  28044. },
  28045. /**
  28046. * @public
  28047. * @param {Object} layoutInfo {
  28048. * x: containerGroup x
  28049. * y: containerGroup y
  28050. * width: containerGroup width
  28051. * height: containerGroup height
  28052. * }
  28053. */
  28054. setLayoutInfo: function (layoutInfo) {
  28055. /**
  28056. * @readOnly
  28057. * @type {Object}
  28058. */
  28059. this.layoutInfo = this.layoutInfo || {};
  28060. zrUtil.extend(this.layoutInfo, layoutInfo);
  28061. },
  28062. /**
  28063. * @param {string} id
  28064. * @return {number} index
  28065. */
  28066. mapIdToIndex: function (id) {
  28067. // A feature is implemented:
  28068. // index is monotone increasing with the sequence of
  28069. // input id at the first time.
  28070. // This feature can make sure that each data item and its
  28071. // mapped color have the same index between data list and
  28072. // color list at the beginning, which is useful for user
  28073. // to adjust data-color mapping.
  28074. /**
  28075. * @private
  28076. * @type {Object}
  28077. */
  28078. var idIndexMap = this._idIndexMap;
  28079. if (!idIndexMap) {
  28080. idIndexMap = this._idIndexMap = {};
  28081. /**
  28082. * @private
  28083. * @type {number}
  28084. */
  28085. this._idIndexMapCount = 0;
  28086. }
  28087. var index = idIndexMap[id];
  28088. if (index == null) {
  28089. idIndexMap[id] = index = this._idIndexMapCount++;
  28090. }
  28091. return index;
  28092. },
  28093. getViewRoot: function () {
  28094. return this._viewRoot;
  28095. },
  28096. /**
  28097. * @param {module:echarts/data/Tree~Node} [viewRoot]
  28098. */
  28099. resetViewRoot: function (viewRoot) {
  28100. viewRoot
  28101. ? (this._viewRoot = viewRoot)
  28102. : (viewRoot = this._viewRoot);
  28103. var root = this.getData().tree.root;
  28104. if (!viewRoot
  28105. || (viewRoot !== root && !root.contains(viewRoot))
  28106. ) {
  28107. this._viewRoot = root;
  28108. }
  28109. }
  28110. });
  28111. /**
  28112. * @param {Object} dataNode
  28113. */
  28114. function completeTreeValue(dataNode, arrValueLength) {
  28115. // Postorder travel tree.
  28116. // If value of none-leaf node is not set,
  28117. // calculate it by suming up the value of all children.
  28118. var sum = 0;
  28119. zrUtil.each(dataNode.children, function (child) {
  28120. completeTreeValue(child, arrValueLength);
  28121. var childValue = child.value;
  28122. zrUtil.isArray(childValue) && (childValue = childValue[0]);
  28123. sum += childValue;
  28124. });
  28125. var thisValue = dataNode.value;
  28126. if (arrValueLength >= 0) {
  28127. if (!zrUtil.isArray(thisValue)) {
  28128. dataNode.value = new Array(arrValueLength);
  28129. }
  28130. else {
  28131. thisValue = thisValue[0];
  28132. }
  28133. }
  28134. if (thisValue == null || isNaN(thisValue)) {
  28135. thisValue = sum;
  28136. }
  28137. // Value should not less than 0.
  28138. if (thisValue < 0) {
  28139. thisValue = 0;
  28140. }
  28141. arrValueLength >= 0
  28142. ? (dataNode.value[0] = thisValue)
  28143. : (dataNode.value = thisValue);
  28144. }
  28145. /**
  28146. * set default to level configuration
  28147. */
  28148. function setDefault(levels, ecModel) {
  28149. var globalColorList = ecModel.get('color');
  28150. if (!globalColorList) {
  28151. return;
  28152. }
  28153. levels = levels || [];
  28154. var hasColorDefine;
  28155. zrUtil.each(levels, function (levelDefine) {
  28156. var model = new Model(levelDefine);
  28157. var modelColor = model.get('color');
  28158. if (model.get('itemStyle.normal.color')
  28159. || (modelColor && modelColor !== 'none')
  28160. ) {
  28161. hasColorDefine = true;
  28162. }
  28163. });
  28164. if (!hasColorDefine) {
  28165. var level0 = levels[0] || (levels[0] = {});
  28166. level0.color = globalColorList.slice();
  28167. }
  28168. return levels;
  28169. }
  28170. /***/ },
  28171. /* 184 */
  28172. /***/ function(module, exports, __webpack_require__) {
  28173. /**
  28174. * Tree data structure
  28175. *
  28176. * @module echarts/data/Tree
  28177. */
  28178. var zrUtil = __webpack_require__(4);
  28179. var Model = __webpack_require__(12);
  28180. var List = __webpack_require__(97);
  28181. var linkList = __webpack_require__(185);
  28182. var completeDimensions = __webpack_require__(102);
  28183. /**
  28184. * @constructor module:echarts/data/Tree~TreeNode
  28185. * @param {string} name
  28186. * @param {module:echarts/data/Tree} hostTree
  28187. */
  28188. var TreeNode = function (name, hostTree) {
  28189. /**
  28190. * @type {string}
  28191. */
  28192. this.name = name || '';
  28193. /**
  28194. * Depth of node
  28195. *
  28196. * @type {number}
  28197. * @readOnly
  28198. */
  28199. this.depth = 0;
  28200. /**
  28201. * Height of the subtree rooted at this node.
  28202. * @type {number}
  28203. * @readOnly
  28204. */
  28205. this.height = 0;
  28206. /**
  28207. * @type {module:echarts/data/Tree~TreeNode}
  28208. * @readOnly
  28209. */
  28210. this.parentNode = null;
  28211. /**
  28212. * Reference to list item.
  28213. * Do not persistent dataIndex outside,
  28214. * besause it may be changed by list.
  28215. * If dataIndex -1,
  28216. * this node is logical deleted (filtered) in list.
  28217. *
  28218. * @type {Object}
  28219. * @readOnly
  28220. */
  28221. this.dataIndex = -1;
  28222. /**
  28223. * @type {Array.<module:echarts/data/Tree~TreeNode>}
  28224. * @readOnly
  28225. */
  28226. this.children = [];
  28227. /**
  28228. * @type {Array.<module:echarts/data/Tree~TreeNode>}
  28229. * @pubilc
  28230. */
  28231. this.viewChildren = [];
  28232. /**
  28233. * @type {moduel:echarts/data/Tree}
  28234. * @readOnly
  28235. */
  28236. this.hostTree = hostTree;
  28237. };
  28238. TreeNode.prototype = {
  28239. constructor: TreeNode,
  28240. /**
  28241. * The node is removed.
  28242. * @return {boolean} is removed.
  28243. */
  28244. isRemoved: function () {
  28245. return this.dataIndex < 0;
  28246. },
  28247. /**
  28248. * Travel this subtree (include this node).
  28249. * Usage:
  28250. * node.eachNode(function () { ... }); // preorder
  28251. * node.eachNode('preorder', function () { ... }); // preorder
  28252. * node.eachNode('postorder', function () { ... }); // postorder
  28253. * node.eachNode(
  28254. * {order: 'postorder', attr: 'viewChildren'},
  28255. * function () { ... }
  28256. * ); // postorder
  28257. *
  28258. * @param {(Object|string)} options If string, means order.
  28259. * @param {string=} options.order 'preorder' or 'postorder'
  28260. * @param {string=} options.attr 'children' or 'viewChildren'
  28261. * @param {Function} cb If in preorder and return false,
  28262. * its subtree will not be visited.
  28263. * @param {Object} [context]
  28264. */
  28265. eachNode: function (options, cb, context) {
  28266. if (typeof options === 'function') {
  28267. context = cb;
  28268. cb = options;
  28269. options = null;
  28270. }
  28271. options = options || {};
  28272. if (zrUtil.isString(options)) {
  28273. options = {order: options};
  28274. }
  28275. var order = options.order || 'preorder';
  28276. var children = this[options.attr || 'children'];
  28277. var suppressVisitSub;
  28278. order === 'preorder' && (suppressVisitSub = cb.call(context, this));
  28279. for (var i = 0; !suppressVisitSub && i < children.length; i++) {
  28280. children[i].eachNode(options, cb, context);
  28281. }
  28282. order === 'postorder' && cb.call(context, this);
  28283. },
  28284. /**
  28285. * Update depth and height of this subtree.
  28286. *
  28287. * @param {number} depth
  28288. */
  28289. updateDepthAndHeight: function (depth) {
  28290. var height = 0;
  28291. this.depth = depth;
  28292. for (var i = 0; i < this.children.length; i++) {
  28293. var child = this.children[i];
  28294. child.updateDepthAndHeight(depth + 1);
  28295. if (child.height > height) {
  28296. height = child.height;
  28297. }
  28298. }
  28299. this.height = height + 1;
  28300. },
  28301. /**
  28302. * @param {string} id
  28303. * @return {module:echarts/data/Tree~TreeNode}
  28304. */
  28305. getNodeById: function (id) {
  28306. if (this.getId() === id) {
  28307. return this;
  28308. }
  28309. for (var i = 0, children = this.children, len = children.length; i < len; i++) {
  28310. var res = children[i].getNodeById(id);
  28311. if (res) {
  28312. return res;
  28313. }
  28314. }
  28315. },
  28316. /**
  28317. * @param {module:echarts/data/Tree~TreeNode} node
  28318. * @return {boolean}
  28319. */
  28320. contains: function (node) {
  28321. if (node === this) {
  28322. return true;
  28323. }
  28324. for (var i = 0, children = this.children, len = children.length; i < len; i++) {
  28325. var res = children[i].contains(node);
  28326. if (res) {
  28327. return res;
  28328. }
  28329. }
  28330. },
  28331. /**
  28332. * @param {boolean} includeSelf Default false.
  28333. * @return {Array.<module:echarts/data/Tree~TreeNode>} order: [root, child, grandchild, ...]
  28334. */
  28335. getAncestors: function (includeSelf) {
  28336. var ancestors = [];
  28337. var node = includeSelf ? this : this.parentNode;
  28338. while (node) {
  28339. ancestors.push(node);
  28340. node = node.parentNode;
  28341. }
  28342. ancestors.reverse();
  28343. return ancestors;
  28344. },
  28345. /**
  28346. * @param {string|Array=} [dimension='value'] Default 'value'. can be 0, 1, 2, 3
  28347. * @return {number} Value.
  28348. */
  28349. getValue: function (dimension) {
  28350. var data = this.hostTree.data;
  28351. return data.get(data.getDimension(dimension || 'value'), this.dataIndex);
  28352. },
  28353. /**
  28354. * @param {Object} layout
  28355. * @param {boolean=} [merge=false]
  28356. */
  28357. setLayout: function (layout, merge) {
  28358. this.dataIndex >= 0
  28359. && this.hostTree.data.setItemLayout(this.dataIndex, layout, merge);
  28360. },
  28361. /**
  28362. * @return {Object} layout
  28363. */
  28364. getLayout: function () {
  28365. return this.hostTree.data.getItemLayout(this.dataIndex);
  28366. },
  28367. /**
  28368. * @param {string} path
  28369. * @return {module:echarts/model/Model}
  28370. */
  28371. getModel: function (path) {
  28372. if (this.dataIndex < 0) {
  28373. return;
  28374. }
  28375. var hostTree = this.hostTree;
  28376. var itemModel = hostTree.data.getItemModel(this.dataIndex);
  28377. var levelModel = this.getLevelModel();
  28378. return itemModel.getModel(path, (levelModel || hostTree.hostModel).getModel(path));
  28379. },
  28380. /**
  28381. * @return {module:echarts/model/Model}
  28382. */
  28383. getLevelModel: function () {
  28384. return (this.hostTree.levelModels || [])[this.depth];
  28385. },
  28386. /**
  28387. * @example
  28388. * setItemVisual('color', color);
  28389. * setItemVisual({
  28390. * 'color': color
  28391. * });
  28392. */
  28393. setVisual: function (key, value) {
  28394. this.dataIndex >= 0
  28395. && this.hostTree.data.setItemVisual(this.dataIndex, key, value);
  28396. },
  28397. /**
  28398. * Get item visual
  28399. */
  28400. getVisual: function (key, ignoreParent) {
  28401. return this.hostTree.data.getItemVisual(this.dataIndex, key, ignoreParent);
  28402. },
  28403. /**
  28404. * @public
  28405. * @return {number}
  28406. */
  28407. getRawIndex: function () {
  28408. return this.hostTree.data.getRawIndex(this.dataIndex);
  28409. },
  28410. /**
  28411. * @public
  28412. * @return {string}
  28413. */
  28414. getId: function () {
  28415. return this.hostTree.data.getId(this.dataIndex);
  28416. }
  28417. };
  28418. /**
  28419. * @constructor
  28420. * @alias module:echarts/data/Tree
  28421. * @param {module:echarts/model/Model} hostModel
  28422. * @param {Array.<Object>} levelOptions
  28423. */
  28424. function Tree(hostModel, levelOptions) {
  28425. /**
  28426. * @type {module:echarts/data/Tree~TreeNode}
  28427. * @readOnly
  28428. */
  28429. this.root;
  28430. /**
  28431. * @type {module:echarts/data/List}
  28432. * @readOnly
  28433. */
  28434. this.data;
  28435. /**
  28436. * Index of each item is the same as the raw index of coresponding list item.
  28437. * @private
  28438. * @type {Array.<module:echarts/data/Tree~TreeNode}
  28439. */
  28440. this._nodes = [];
  28441. /**
  28442. * @private
  28443. * @readOnly
  28444. * @type {module:echarts/model/Model}
  28445. */
  28446. this.hostModel = hostModel;
  28447. /**
  28448. * @private
  28449. * @readOnly
  28450. * @type {Array.<module:echarts/model/Model}
  28451. */
  28452. this.levelModels = zrUtil.map(levelOptions || [], function (levelDefine) {
  28453. return new Model(levelDefine, hostModel, hostModel.ecModel);
  28454. });
  28455. }
  28456. Tree.prototype = {
  28457. constructor: Tree,
  28458. type: 'tree',
  28459. /**
  28460. * Travel this subtree (include this node).
  28461. * Usage:
  28462. * node.eachNode(function () { ... }); // preorder
  28463. * node.eachNode('preorder', function () { ... }); // preorder
  28464. * node.eachNode('postorder', function () { ... }); // postorder
  28465. * node.eachNode(
  28466. * {order: 'postorder', attr: 'viewChildren'},
  28467. * function () { ... }
  28468. * ); // postorder
  28469. *
  28470. * @param {(Object|string)} options If string, means order.
  28471. * @param {string=} options.order 'preorder' or 'postorder'
  28472. * @param {string=} options.attr 'children' or 'viewChildren'
  28473. * @param {Function} cb
  28474. * @param {Object} [context]
  28475. */
  28476. eachNode: function(options, cb, context) {
  28477. this.root.eachNode(options, cb, context);
  28478. },
  28479. /**
  28480. * @param {number} dataIndex
  28481. * @return {module:echarts/data/Tree~TreeNode}
  28482. */
  28483. getNodeByDataIndex: function (dataIndex) {
  28484. var rawIndex = this.data.getRawIndex(dataIndex);
  28485. return this._nodes[rawIndex];
  28486. },
  28487. /**
  28488. * @param {string} name
  28489. * @return {module:echarts/data/Tree~TreeNode}
  28490. */
  28491. getNodeByName: function (name) {
  28492. return this.root.getNodeByName(name);
  28493. },
  28494. /**
  28495. * Update item available by list,
  28496. * when list has been performed options like 'filterSelf' or 'map'.
  28497. */
  28498. update: function () {
  28499. var data = this.data;
  28500. var nodes = this._nodes;
  28501. for (var i = 0, len = nodes.length; i < len; i++) {
  28502. nodes[i].dataIndex = -1;
  28503. }
  28504. for (var i = 0, len = data.count(); i < len; i++) {
  28505. nodes[data.getRawIndex(i)].dataIndex = i;
  28506. }
  28507. },
  28508. /**
  28509. * Clear all layouts
  28510. */
  28511. clearLayouts: function () {
  28512. this.data.clearItemLayouts();
  28513. }
  28514. };
  28515. /**
  28516. * data node format:
  28517. * {
  28518. * name: ...
  28519. * value: ...
  28520. * children: [
  28521. * {
  28522. * name: ...
  28523. * value: ...
  28524. * children: ...
  28525. * },
  28526. * ...
  28527. * ]
  28528. * }
  28529. *
  28530. * @static
  28531. * @param {Objec} dataRoot Root node.
  28532. * @param {module:echarts/model/Model} hostModel
  28533. * @param {Array.<Object>} levelOptions
  28534. * @return module:echarts/data/Tree
  28535. */
  28536. Tree.createTree = function (dataRoot, hostModel, levelOptions) {
  28537. var tree = new Tree(hostModel, levelOptions);
  28538. var listData = [];
  28539. buildHierarchy(dataRoot);
  28540. function buildHierarchy(dataNode, parentNode) {
  28541. listData.push(dataNode);
  28542. var node = new TreeNode(dataNode.name, tree);
  28543. parentNode
  28544. ? addChild(node, parentNode)
  28545. : (tree.root = node);
  28546. tree._nodes.push(node);
  28547. var children = dataNode.children;
  28548. if (children) {
  28549. for (var i = 0; i < children.length; i++) {
  28550. buildHierarchy(children[i], node);
  28551. }
  28552. }
  28553. }
  28554. tree.root.updateDepthAndHeight(0);
  28555. var dimensions = completeDimensions([{name: 'value'}], listData);
  28556. var list = new List(dimensions, hostModel);
  28557. list.initData(listData);
  28558. linkList({
  28559. mainData: list,
  28560. struct: tree,
  28561. structAttr: 'tree'
  28562. });
  28563. tree.update();
  28564. return tree;
  28565. };
  28566. /**
  28567. * It is needed to consider the mess of 'list', 'hostModel' when creating a TreeNote,
  28568. * so this function is not ready and not necessary to be public.
  28569. *
  28570. * @param {(module:echarts/data/Tree~TreeNode|Object)} child
  28571. */
  28572. function addChild(child, node) {
  28573. var children = node.children;
  28574. if (child.parentNode === node) {
  28575. return;
  28576. }
  28577. children.push(child);
  28578. child.parentNode = node;
  28579. }
  28580. module.exports = Tree;
  28581. /***/ },
  28582. /* 185 */
  28583. /***/ function(module, exports, __webpack_require__) {
  28584. /**
  28585. * Link lists and struct (graph or tree)
  28586. */
  28587. var zrUtil = __webpack_require__(4);
  28588. var each = zrUtil.each;
  28589. var DATAS = '\0__link_datas';
  28590. var MAIN_DATA = '\0__link_mainData';
  28591. // Caution:
  28592. // In most case, either list or its shallow clones (see list.cloneShallow)
  28593. // is active in echarts process. So considering heap memory consumption,
  28594. // we do not clone tree or graph, but share them among list and its shallow clones.
  28595. // But in some rare case, we have to keep old list (like do animation in chart). So
  28596. // please take care that both the old list and the new list share the same tree/graph.
  28597. /**
  28598. * @param {Object} opt
  28599. * @param {module:echarts/data/List} opt.mainData
  28600. * @param {Object} [opt.struct] For example, instance of Graph or Tree.
  28601. * @param {string} [opt.structAttr] designation: list[structAttr] = struct;
  28602. * @param {Object} [opt.datas] {dataType: data},
  28603. * like: {node: nodeList, edge: edgeList}.
  28604. * Should contain mainData.
  28605. * @param {Object} [opt.datasAttr] {dataType: attr},
  28606. * designation: struct[datasAttr[dataType]] = list;
  28607. */
  28608. function linkList(opt) {
  28609. var mainData = opt.mainData;
  28610. var datas = opt.datas;
  28611. if (!datas) {
  28612. datas = {main: mainData};
  28613. opt.datasAttr = {main: 'data'};
  28614. }
  28615. opt.datas = opt.mainData = null;
  28616. linkAll(mainData, datas, opt);
  28617. // Porxy data original methods.
  28618. each(datas, function (data) {
  28619. each(mainData.TRANSFERABLE_METHODS, function (methodName) {
  28620. data.wrapMethod(methodName, zrUtil.curry(transferInjection, opt));
  28621. });
  28622. });
  28623. // Beyond transfer, additional features should be added to `cloneShallow`.
  28624. mainData.wrapMethod('cloneShallow', zrUtil.curry(cloneShallowInjection, opt));
  28625. // Only mainData trigger change, because struct.update may trigger
  28626. // another changable methods, which may bring about dead lock.
  28627. each(mainData.CHANGABLE_METHODS, function (methodName) {
  28628. mainData.wrapMethod(methodName, zrUtil.curry(changeInjection, opt));
  28629. });
  28630. // Make sure datas contains mainData.
  28631. zrUtil.assert(datas[mainData.dataType] === mainData);
  28632. }
  28633. function transferInjection(opt, res) {
  28634. if (isMainData(this)) {
  28635. // Transfer datas to new main data.
  28636. var datas = zrUtil.extend({}, this[DATAS]);
  28637. datas[this.dataType] = res;
  28638. linkAll(res, datas, opt);
  28639. }
  28640. else {
  28641. // Modify the reference in main data to point newData.
  28642. linkSingle(res, this.dataType, this[MAIN_DATA], opt);
  28643. }
  28644. return res;
  28645. }
  28646. function changeInjection(opt, res) {
  28647. opt.struct && opt.struct.update(this);
  28648. return res;
  28649. }
  28650. function cloneShallowInjection(opt, res) {
  28651. // cloneShallow, which brings about some fragilities, may be inappropriate
  28652. // to be exposed as an API. So for implementation simplicity we can make
  28653. // the restriction that cloneShallow of not-mainData should not be invoked
  28654. // outside, but only be invoked here.
  28655. each(res[DATAS], function (data, dataType) {
  28656. data !== res && linkSingle(data.cloneShallow(), dataType, res, opt);
  28657. });
  28658. return res;
  28659. }
  28660. /**
  28661. * Supplement method to List.
  28662. *
  28663. * @public
  28664. * @param {string} [dataType] If not specified, return mainData.
  28665. * @return {module:echarts/data/List}
  28666. */
  28667. function getLinkedData(dataType) {
  28668. var mainData = this[MAIN_DATA];
  28669. return (dataType == null || mainData == null)
  28670. ? mainData
  28671. : mainData[DATAS][dataType];
  28672. }
  28673. function isMainData(data) {
  28674. return data[MAIN_DATA] === data;
  28675. }
  28676. function linkAll(mainData, datas, opt) {
  28677. mainData[DATAS] = {};
  28678. each(datas, function (data, dataType) {
  28679. linkSingle(data, dataType, mainData, opt);
  28680. });
  28681. }
  28682. function linkSingle(data, dataType, mainData, opt) {
  28683. mainData[DATAS][dataType] = data;
  28684. data[MAIN_DATA] = mainData;
  28685. data.dataType = dataType;
  28686. if (opt.struct) {
  28687. data[opt.structAttr] = opt.struct;
  28688. opt.struct[opt.datasAttr[dataType]] = data;
  28689. }
  28690. // Supplement method.
  28691. data.getLinkedData = getLinkedData;
  28692. }
  28693. module.exports = linkList;
  28694. /***/ },
  28695. /* 186 */
  28696. /***/ function(module, exports, __webpack_require__) {
  28697. var zrUtil = __webpack_require__(4);
  28698. var graphic = __webpack_require__(43);
  28699. var DataDiffer = __webpack_require__(98);
  28700. var helper = __webpack_require__(187);
  28701. var Breadcrumb = __webpack_require__(188);
  28702. var RoamController = __webpack_require__(174);
  28703. var BoundingRect = __webpack_require__(9);
  28704. var matrix = __webpack_require__(11);
  28705. var animationUtil = __webpack_require__(189);
  28706. var bind = zrUtil.bind;
  28707. var Group = graphic.Group;
  28708. var Rect = graphic.Rect;
  28709. var each = zrUtil.each;
  28710. var DRAG_THRESHOLD = 3;
  28711. var PATH_LABEL_NORMAL = ['label', 'normal'];
  28712. var PATH_LABEL_EMPHASIS = ['label', 'emphasis'];
  28713. var Z_BASE = 10; // Should bigger than every z.
  28714. var Z_BG = 1;
  28715. var Z_CONTENT = 2;
  28716. module.exports = __webpack_require__(1).extendChartView({
  28717. type: 'treemap',
  28718. /**
  28719. * @override
  28720. */
  28721. init: function (o, api) {
  28722. /**
  28723. * @private
  28724. * @type {module:zrender/container/Group}
  28725. */
  28726. this._containerGroup;
  28727. /**
  28728. * @private
  28729. * @type {Object.<string, Array.<module:zrender/container/Group>>}
  28730. */
  28731. this._storage = createStorage();
  28732. /**
  28733. * @private
  28734. * @type {module:echarts/data/Tree}
  28735. */
  28736. this._oldTree;
  28737. /**
  28738. * @private
  28739. * @type {module:echarts/chart/treemap/Breadcrumb}
  28740. */
  28741. this._breadcrumb;
  28742. /**
  28743. * @private
  28744. * @type {module:echarts/component/helper/RoamController}
  28745. */
  28746. this._controller;
  28747. /**
  28748. * 'ready', 'animating'
  28749. * @private
  28750. */
  28751. this._state = 'ready';
  28752. /**
  28753. * @private
  28754. * @type {boolean}
  28755. */
  28756. this._mayClick;
  28757. },
  28758. /**
  28759. * @override
  28760. */
  28761. render: function (seriesModel, ecModel, api, payload) {
  28762. var models = ecModel.findComponents({
  28763. mainType: 'series', subType: 'treemap', query: payload
  28764. });
  28765. if (zrUtil.indexOf(models, seriesModel) < 0) {
  28766. return;
  28767. }
  28768. this.seriesModel = seriesModel;
  28769. this.api = api;
  28770. this.ecModel = ecModel;
  28771. var targetInfo = helper.retrieveTargetInfo(payload, seriesModel);
  28772. var payloadType = payload && payload.type;
  28773. var layoutInfo = seriesModel.layoutInfo;
  28774. var isInit = !this._oldTree;
  28775. var thisStorage = this._storage;
  28776. // Mark new root when action is treemapRootToNode.
  28777. var reRoot = (payloadType === 'treemapRootToNode' && targetInfo && thisStorage)
  28778. ? {
  28779. rootNodeGroup: thisStorage.nodeGroup[targetInfo.node.getRawIndex()],
  28780. direction: payload.direction
  28781. }
  28782. : null;
  28783. var containerGroup = this._giveContainerGroup(layoutInfo);
  28784. var renderResult = this._doRender(containerGroup, seriesModel, reRoot);
  28785. (
  28786. !isInit && (
  28787. !payloadType
  28788. || payloadType === 'treemapZoomToNode'
  28789. || payloadType === 'treemapRootToNode'
  28790. )
  28791. )
  28792. ? this._doAnimation(containerGroup, renderResult, seriesModel, reRoot)
  28793. : renderResult.renderFinally();
  28794. this._resetController(api);
  28795. this._renderBreadcrumb(seriesModel, api, targetInfo);
  28796. },
  28797. /**
  28798. * @private
  28799. */
  28800. _giveContainerGroup: function (layoutInfo) {
  28801. var containerGroup = this._containerGroup;
  28802. if (!containerGroup) {
  28803. // FIXME
  28804. // 加一层containerGroup是为了clip,但是现在clip功能并没有实现。
  28805. containerGroup = this._containerGroup = new Group();
  28806. this._initEvents(containerGroup);
  28807. this.group.add(containerGroup);
  28808. }
  28809. containerGroup.attr('position', [layoutInfo.x, layoutInfo.y]);
  28810. return containerGroup;
  28811. },
  28812. /**
  28813. * @private
  28814. */
  28815. _doRender: function (containerGroup, seriesModel, reRoot) {
  28816. var thisTree = seriesModel.getData().tree;
  28817. var oldTree = this._oldTree;
  28818. // Clear last shape records.
  28819. var lastsForAnimation = createStorage();
  28820. var thisStorage = createStorage();
  28821. var oldStorage = this._storage;
  28822. var willInvisibleEls = [];
  28823. var doRenderNode = zrUtil.curry(
  28824. renderNode, seriesModel,
  28825. thisStorage, oldStorage, reRoot,
  28826. lastsForAnimation, willInvisibleEls
  28827. );
  28828. // Notice: when thisTree and oldTree are the same tree (see list.cloneShadow),
  28829. // the oldTree is actually losted, so we can not find all of the old graphic
  28830. // elements from tree. So we use this stragegy: make element storage, move
  28831. // from old storage to new storage, clear old storage.
  28832. dualTravel(
  28833. thisTree.root ? [thisTree.root] : [],
  28834. (oldTree && oldTree.root) ? [oldTree.root] : [],
  28835. containerGroup,
  28836. thisTree === oldTree || !oldTree,
  28837. 0
  28838. );
  28839. // Process all removing.
  28840. var willDeleteEls = clearStorage(oldStorage);
  28841. this._oldTree = thisTree;
  28842. this._storage = thisStorage;
  28843. return {
  28844. lastsForAnimation: lastsForAnimation,
  28845. willDeleteEls: willDeleteEls,
  28846. renderFinally: renderFinally
  28847. };
  28848. function dualTravel(thisViewChildren, oldViewChildren, parentGroup, sameTree, depth) {
  28849. // When 'render' is triggered by action,
  28850. // 'this' and 'old' may be the same tree,
  28851. // we use rawIndex in that case.
  28852. if (sameTree) {
  28853. oldViewChildren = thisViewChildren;
  28854. each(thisViewChildren, function (child, index) {
  28855. !child.isRemoved() && processNode(index, index);
  28856. });
  28857. }
  28858. // Diff hierarchically (diff only in each subtree, but not whole).
  28859. // because, consistency of view is important.
  28860. else {
  28861. (new DataDiffer(oldViewChildren, thisViewChildren, getKey, getKey))
  28862. .add(processNode)
  28863. .update(processNode)
  28864. .remove(zrUtil.curry(processNode, null))
  28865. .execute();
  28866. }
  28867. function getKey(node) {
  28868. // Identify by name or raw index.
  28869. return node.getId();
  28870. }
  28871. function processNode(newIndex, oldIndex) {
  28872. var thisNode = newIndex != null ? thisViewChildren[newIndex] : null;
  28873. var oldNode = oldIndex != null ? oldViewChildren[oldIndex] : null;
  28874. var group = doRenderNode(thisNode, oldNode, parentGroup, depth);
  28875. group && dualTravel(
  28876. thisNode && thisNode.viewChildren || [],
  28877. oldNode && oldNode.viewChildren || [],
  28878. group,
  28879. sameTree,
  28880. depth + 1
  28881. );
  28882. }
  28883. }
  28884. function clearStorage(storage) {
  28885. var willDeleteEls = createStorage();
  28886. storage && each(storage, function (store, storageName) {
  28887. var delEls = willDeleteEls[storageName];
  28888. each(store, function (el) {
  28889. el && (delEls.push(el), el.__tmWillDelete = 1);
  28890. });
  28891. });
  28892. return willDeleteEls;
  28893. }
  28894. function renderFinally() {
  28895. each(willDeleteEls, function (els) {
  28896. each(els, function (el) {
  28897. el.parent && el.parent.remove(el);
  28898. });
  28899. });
  28900. each(willInvisibleEls, function (el) {
  28901. el.invisible = true;
  28902. // Setting invisible is for optimizing, so no need to set dirty,
  28903. // just mark as invisible.
  28904. el.dirty();
  28905. });
  28906. }
  28907. },
  28908. /**
  28909. * @private
  28910. */
  28911. _doAnimation: function (containerGroup, renderResult, seriesModel, reRoot) {
  28912. if (!seriesModel.get('animation')) {
  28913. return;
  28914. }
  28915. var duration = seriesModel.get('animationDurationUpdate');
  28916. var easing = seriesModel.get('animationEasing');
  28917. var animationWrap = animationUtil.createWrap();
  28918. // Make delete animations.
  28919. each(renderResult.willDeleteEls, function (store, storageName) {
  28920. each(store, function (el, rawIndex) {
  28921. if (el.invisible) {
  28922. return;
  28923. }
  28924. var parent = el.parent; // Always has parent, and parent is nodeGroup.
  28925. var target;
  28926. if (reRoot && reRoot.direction === 'drillDown') {
  28927. target = parent === reRoot.rootNodeGroup
  28928. // This is the content element of view root.
  28929. // Only `content` will enter this branch, because
  28930. // `background` and `nodeGroup` will not be deleted.
  28931. ? {
  28932. shape: {
  28933. x: 0,
  28934. y: 0,
  28935. width: parent.__tmNodeWidth,
  28936. height: parent.__tmNodeHeight
  28937. },
  28938. style: {
  28939. opacity: 0
  28940. }
  28941. }
  28942. // Others.
  28943. : {style: {opacity: 0}};
  28944. }
  28945. else {
  28946. var targetX = 0;
  28947. var targetY = 0;
  28948. if (!parent.__tmWillDelete) {
  28949. // Let node animate to right-bottom corner, cooperating with fadeout,
  28950. // which is appropriate for user understanding.
  28951. // Divided by 2 for reRoot rolling up effect.
  28952. targetX = parent.__tmNodeWidth / 2;
  28953. targetY = parent.__tmNodeHeight / 2;
  28954. }
  28955. target = storageName === 'nodeGroup'
  28956. ? {position: [targetX, targetY], style: {opacity: 0}}
  28957. : {
  28958. shape: {x: targetX, y: targetY, width: 0, height: 0},
  28959. style: {opacity: 0}
  28960. };
  28961. }
  28962. target && animationWrap.add(el, target, duration, easing);
  28963. });
  28964. });
  28965. // Make other animations
  28966. each(this._storage, function (store, storageName) {
  28967. each(store, function (el, rawIndex) {
  28968. var last = renderResult.lastsForAnimation[storageName][rawIndex];
  28969. var target = {};
  28970. if (!last) {
  28971. return;
  28972. }
  28973. if (storageName === 'nodeGroup') {
  28974. if (last.old) {
  28975. target.position = el.position.slice();
  28976. el.attr('position', last.old);
  28977. }
  28978. }
  28979. else {
  28980. if (last.old) {
  28981. target.shape = zrUtil.extend({}, el.shape);
  28982. el.setShape(last.old);
  28983. }
  28984. if (last.fadein) {
  28985. el.setStyle('opacity', 0);
  28986. target.style = {opacity: 1};
  28987. }
  28988. // When animation is stopped for succedent animation starting,
  28989. // el.style.opacity might not be 1
  28990. else if (el.style.opacity !== 1) {
  28991. target.style = {opacity: 1};
  28992. }
  28993. }
  28994. animationWrap.add(el, target, duration, easing);
  28995. });
  28996. }, this);
  28997. this._state = 'animating';
  28998. animationWrap
  28999. .done(bind(function () {
  29000. this._state = 'ready';
  29001. renderResult.renderFinally();
  29002. }, this))
  29003. .start();
  29004. },
  29005. /**
  29006. * @private
  29007. */
  29008. _resetController: function (api) {
  29009. var controller = this._controller;
  29010. // Init controller.
  29011. if (!controller) {
  29012. controller = this._controller = new RoamController(api.getZr());
  29013. controller.enable(this.seriesModel.get('roam'));
  29014. controller.on('pan', bind(this._onPan, this));
  29015. controller.on('zoom', bind(this._onZoom, this));
  29016. }
  29017. var rect = new BoundingRect(0, 0, api.getWidth(), api.getHeight());
  29018. controller.rectProvider = function () {
  29019. return rect;
  29020. };
  29021. },
  29022. /**
  29023. * @private
  29024. */
  29025. _clearController: function () {
  29026. var controller = this._controller;
  29027. if (controller) {
  29028. controller.off('pan').off('zoom');
  29029. controller = null;
  29030. }
  29031. },
  29032. /**
  29033. * @private
  29034. */
  29035. _onPan: function (dx, dy) {
  29036. this._mayClick = false;
  29037. if (this._state !== 'animating'
  29038. && (Math.abs(dx) > DRAG_THRESHOLD || Math.abs(dy) > DRAG_THRESHOLD)
  29039. ) {
  29040. // These param must not be cached.
  29041. var root = this.seriesModel.getData().tree.root;
  29042. if (!root) {
  29043. return;
  29044. }
  29045. var rootLayout = root.getLayout();
  29046. if (!rootLayout) {
  29047. return;
  29048. }
  29049. this.api.dispatchAction({
  29050. type: 'treemapMove',
  29051. from: this.uid,
  29052. seriesId: this.seriesModel.id,
  29053. rootRect: {
  29054. x: rootLayout.x + dx, y: rootLayout.y + dy,
  29055. width: rootLayout.width, height: rootLayout.height
  29056. }
  29057. });
  29058. }
  29059. },
  29060. /**
  29061. * @private
  29062. */
  29063. _onZoom: function (scale, mouseX, mouseY) {
  29064. this._mayClick = false;
  29065. if (this._state !== 'animating') {
  29066. // These param must not be cached.
  29067. var root = this.seriesModel.getData().tree.root;
  29068. if (!root) {
  29069. return;
  29070. }
  29071. var rootLayout = root.getLayout();
  29072. if (!rootLayout) {
  29073. return;
  29074. }
  29075. var rect = new BoundingRect(
  29076. rootLayout.x, rootLayout.y, rootLayout.width, rootLayout.height
  29077. );
  29078. var layoutInfo = this.seriesModel.layoutInfo;
  29079. // Transform mouse coord from global to containerGroup.
  29080. mouseX -= layoutInfo.x;
  29081. mouseY -= layoutInfo.y;
  29082. // Scale root bounding rect.
  29083. var m = matrix.create();
  29084. matrix.translate(m, m, [-mouseX, -mouseY]);
  29085. matrix.scale(m, m, [scale, scale]);
  29086. matrix.translate(m, m, [mouseX, mouseY]);
  29087. rect.applyTransform(m);
  29088. this.api.dispatchAction({
  29089. type: 'treemapRender',
  29090. from: this.uid,
  29091. seriesId: this.seriesModel.id,
  29092. rootRect: {
  29093. x: rect.x, y: rect.y,
  29094. width: rect.width, height: rect.height
  29095. }
  29096. });
  29097. }
  29098. },
  29099. /**
  29100. * @private
  29101. */
  29102. _initEvents: function (containerGroup) {
  29103. // FIXME
  29104. // 不用click以及silent的原因是,animate时视图设置silent true来避免click生效,
  29105. // 但是animate中,按下鼠标,animate结束后(silent设回为false)松开鼠标,
  29106. // 还是会触发click,期望是不触发。
  29107. // Mousedown occurs when drag start, and mouseup occurs when drag end,
  29108. // click event should not be triggered in that case.
  29109. containerGroup.on('mousedown', function (e) {
  29110. this._state === 'ready' && (this._mayClick = true);
  29111. }, this);
  29112. containerGroup.on('mouseup', function (e) {
  29113. if (this._mayClick) {
  29114. this._mayClick = false;
  29115. this._state === 'ready' && onClick.call(this, e);
  29116. }
  29117. }, this);
  29118. function onClick(e) {
  29119. var nodeClick = this.seriesModel.get('nodeClick', true);
  29120. if (!nodeClick) {
  29121. return;
  29122. }
  29123. var targetInfo = this.findTarget(e.offsetX, e.offsetY);
  29124. if (!targetInfo) {
  29125. return;
  29126. }
  29127. var node = targetInfo.node;
  29128. if (node.getLayout().isLeafRoot) {
  29129. this._rootToNode(targetInfo);
  29130. }
  29131. else {
  29132. if (nodeClick === 'zoomToNode') {
  29133. this._zoomToNode(targetInfo);
  29134. }
  29135. else if (nodeClick === 'link') {
  29136. var itemModel = node.hostTree.data.getItemModel(node.dataIndex);
  29137. var link = itemModel.get('link', true);
  29138. var linkTarget = itemModel.get('target', true) || 'blank';
  29139. link && window.open(link, linkTarget);
  29140. }
  29141. }
  29142. }
  29143. },
  29144. /**
  29145. * @private
  29146. */
  29147. _renderBreadcrumb: function (seriesModel, api, targetInfo) {
  29148. if (!targetInfo) {
  29149. // Find breadcrumb tail on center of containerGroup.
  29150. targetInfo = this.findTarget(api.getWidth() / 2, api.getHeight() / 2);
  29151. if (!targetInfo) {
  29152. targetInfo = {node: seriesModel.getData().tree.root};
  29153. }
  29154. }
  29155. (this._breadcrumb || (this._breadcrumb = new Breadcrumb(this.group, bind(onSelect, this))))
  29156. .render(seriesModel, api, targetInfo.node);
  29157. function onSelect(node) {
  29158. if (this._state !== 'animating') {
  29159. helper.aboveViewRoot(seriesModel.getViewRoot(), node)
  29160. ? this._rootToNode({node: node})
  29161. : this._zoomToNode({node: node});
  29162. }
  29163. }
  29164. },
  29165. /**
  29166. * @override
  29167. */
  29168. remove: function () {
  29169. this._clearController();
  29170. this._containerGroup && this._containerGroup.removeAll();
  29171. this._storage = createStorage();
  29172. this._state = 'ready';
  29173. this._breadcrumb && this._breadcrumb.remove();
  29174. },
  29175. dispose: function () {
  29176. this._clearController();
  29177. },
  29178. /**
  29179. * @private
  29180. */
  29181. _zoomToNode: function (targetInfo) {
  29182. this.api.dispatchAction({
  29183. type: 'treemapZoomToNode',
  29184. from: this.uid,
  29185. seriesId: this.seriesModel.id,
  29186. targetNode: targetInfo.node
  29187. });
  29188. },
  29189. /**
  29190. * @private
  29191. */
  29192. _rootToNode: function (targetInfo) {
  29193. this.api.dispatchAction({
  29194. type: 'treemapRootToNode',
  29195. from: this.uid,
  29196. seriesId: this.seriesModel.id,
  29197. targetNode: targetInfo.node
  29198. });
  29199. },
  29200. /**
  29201. * @public
  29202. * @param {number} x Global coord x.
  29203. * @param {number} y Global coord y.
  29204. * @return {Object} info If not found, return undefined;
  29205. * @return {number} info.node Target node.
  29206. * @return {number} info.offsetX x refer to target node.
  29207. * @return {number} info.offsetY y refer to target node.
  29208. */
  29209. findTarget: function (x, y) {
  29210. var targetInfo;
  29211. var viewRoot = this.seriesModel.getViewRoot();
  29212. viewRoot.eachNode({attr: 'viewChildren', order: 'preorder'}, function (node) {
  29213. var bgEl = this._storage.background[node.getRawIndex()];
  29214. // If invisible, there might be no element.
  29215. if (bgEl) {
  29216. var point = bgEl.transformCoordToLocal(x, y);
  29217. var shape = bgEl.shape;
  29218. // For performance consideration, dont use 'getBoundingRect'.
  29219. if (shape.x <= point[0]
  29220. && point[0] <= shape.x + shape.width
  29221. && shape.y <= point[1]
  29222. && point[1] <= shape.y + shape.height
  29223. ) {
  29224. targetInfo = {node: node, offsetX: point[0], offsetY: point[1]};
  29225. }
  29226. else {
  29227. return false; // Suppress visit subtree.
  29228. }
  29229. }
  29230. }, this);
  29231. return targetInfo;
  29232. }
  29233. });
  29234. /**
  29235. * @inner
  29236. */
  29237. function createStorage() {
  29238. return {nodeGroup: [], background: [], content: []};
  29239. }
  29240. /**
  29241. * @inner
  29242. * @return Return undefined means do not travel further.
  29243. */
  29244. function renderNode(
  29245. seriesModel, thisStorage, oldStorage, reRoot,
  29246. lastsForAnimation, willInvisibleEls,
  29247. thisNode, oldNode, parentGroup, depth
  29248. ) {
  29249. // Whether under viewRoot.
  29250. if (!thisNode) {
  29251. // Deleting nodes will be performed finally. This method just find
  29252. // element from old storage, or create new element, set them to new
  29253. // storage, and set styles.
  29254. return;
  29255. }
  29256. var thisLayout = thisNode.getLayout();
  29257. if (!thisLayout || !thisLayout.isInView) {
  29258. return;
  29259. }
  29260. var thisWidth = thisLayout.width;
  29261. var thisHeight = thisLayout.height;
  29262. var thisInvisible = thisLayout.invisible;
  29263. var thisRawIndex = thisNode.getRawIndex();
  29264. var oldRawIndex = oldNode && oldNode.getRawIndex();
  29265. // Node group
  29266. var group = giveGraphic('nodeGroup', Group);
  29267. if (!group) {
  29268. return;
  29269. }
  29270. parentGroup.add(group);
  29271. // x,y are not set when el is above view root.
  29272. group.attr('position', [thisLayout.x || 0, thisLayout.y || 0]);
  29273. group.__tmNodeWidth = thisWidth;
  29274. group.__tmNodeHeight = thisHeight;
  29275. if (thisLayout.isAboveViewRoot) {
  29276. return group;
  29277. }
  29278. // Background
  29279. var bg = giveGraphic('background', Rect, depth, Z_BG);
  29280. if (bg) {
  29281. bg.setShape({x: 0, y: 0, width: thisWidth, height: thisHeight});
  29282. updateStyle(bg, function () {
  29283. bg.setStyle('fill', thisNode.getVisual('borderColor', true));
  29284. });
  29285. group.add(bg);
  29286. }
  29287. var thisViewChildren = thisNode.viewChildren;
  29288. // No children, render content.
  29289. if (!thisViewChildren || !thisViewChildren.length) {
  29290. var content = giveGraphic('content', Rect, depth, Z_CONTENT);
  29291. content && renderContent(group);
  29292. }
  29293. return group;
  29294. // ----------------------------
  29295. // | Procedures in renderNode |
  29296. // ----------------------------
  29297. function renderContent(group) {
  29298. // For tooltip.
  29299. content.dataIndex = thisNode.dataIndex;
  29300. content.seriesIndex = seriesModel.seriesIndex;
  29301. var borderWidth = thisLayout.borderWidth;
  29302. var contentWidth = Math.max(thisWidth - 2 * borderWidth, 0);
  29303. var contentHeight = Math.max(thisHeight - 2 * borderWidth, 0);
  29304. content.culling = true;
  29305. content.setShape({
  29306. x: borderWidth,
  29307. y: borderWidth,
  29308. width: contentWidth,
  29309. height: contentHeight
  29310. });
  29311. var visualColor = thisNode.getVisual('color', true);
  29312. updateStyle(content, function () {
  29313. var normalStyle = {fill: visualColor};
  29314. var emphasisStyle = thisNode.getModel('itemStyle.emphasis').getItemStyle();
  29315. prepareText(normalStyle, emphasisStyle, visualColor, contentWidth, contentHeight);
  29316. content.setStyle(normalStyle);
  29317. graphic.setHoverStyle(content, emphasisStyle);
  29318. });
  29319. group.add(content);
  29320. }
  29321. function updateStyle(element, cb) {
  29322. if (!thisInvisible) {
  29323. // If invisible, do not set visual, otherwise the element will
  29324. // change immediately before animation. We think it is OK to
  29325. // remain its origin color when moving out of the view window.
  29326. cb();
  29327. if (!element.__tmWillVisible) {
  29328. element.invisible = false;
  29329. }
  29330. }
  29331. else {
  29332. // Delay invisible setting utill animation finished,
  29333. // avoid element vanish suddenly before animation.
  29334. !element.invisible && willInvisibleEls.push(element);
  29335. }
  29336. }
  29337. function prepareText(normalStyle, emphasisStyle, visualColor, contentWidth, contentHeight) {
  29338. var nodeModel = thisNode.getModel();
  29339. var text = nodeModel.get('name');
  29340. if (thisLayout.isLeafRoot) {
  29341. var iconChar = seriesModel.get('drillDownIcon', true);
  29342. text = iconChar ? iconChar + ' ' + text : test;
  29343. }
  29344. setText(
  29345. text, normalStyle, nodeModel, PATH_LABEL_NORMAL,
  29346. visualColor, contentWidth, contentHeight
  29347. );
  29348. setText(
  29349. text, emphasisStyle, nodeModel, PATH_LABEL_EMPHASIS,
  29350. visualColor, contentWidth, contentHeight
  29351. );
  29352. }
  29353. function setText(text, style, nodeModel, labelPath, visualColor, contentWidth, contentHeight) {
  29354. var labelModel = nodeModel.getModel(labelPath);
  29355. var labelTextStyleModel = labelModel.getModel('textStyle');
  29356. graphic.setText(style, labelModel, visualColor);
  29357. // text.align and text.baseline is not included by graphic.setText,
  29358. // because in most cases the two attributes are not exposed to user,
  29359. // except in treemap.
  29360. style.textAlign = labelTextStyleModel.get('align');
  29361. style.textVerticalAlign = labelTextStyleModel.get('baseline');
  29362. var textRect = labelTextStyleModel.getTextRect(text);
  29363. if (!labelModel.getShallow('show') || textRect.height > contentHeight) {
  29364. style.text = '';
  29365. }
  29366. else if (textRect.width > contentWidth) {
  29367. style.text = labelTextStyleModel.get('ellipsis')
  29368. ? labelTextStyleModel.truncateText(
  29369. text, contentWidth, null, {minChar: 2}
  29370. )
  29371. : '';
  29372. }
  29373. else {
  29374. style.text = text;
  29375. }
  29376. }
  29377. function giveGraphic(storageName, Ctor, depth, z) {
  29378. var element = oldRawIndex != null && oldStorage[storageName][oldRawIndex];
  29379. var lasts = lastsForAnimation[storageName];
  29380. if (element) {
  29381. // Remove from oldStorage
  29382. oldStorage[storageName][oldRawIndex] = null;
  29383. prepareAnimationWhenHasOld(lasts, element, storageName);
  29384. }
  29385. // If invisible and no old element, do not create new element (for optimizing).
  29386. else if (!thisInvisible) {
  29387. element = new Ctor({z: calculateZ(depth, z)});
  29388. element.__tmDepth = depth;
  29389. element.__tmStorageName = storageName;
  29390. prepareAnimationWhenNoOld(lasts, element, storageName);
  29391. }
  29392. // Set to thisStorage
  29393. return (thisStorage[storageName][thisRawIndex] = element);
  29394. }
  29395. function prepareAnimationWhenHasOld(lasts, element, storageName) {
  29396. var lastCfg = lasts[thisRawIndex] = {};
  29397. lastCfg.old = storageName === 'nodeGroup'
  29398. ? element.position.slice()
  29399. : zrUtil.extend({}, element.shape);
  29400. }
  29401. // If a element is new, we need to find the animation start point carefully,
  29402. // otherwise it will looks strange when 'zoomToNode'.
  29403. function prepareAnimationWhenNoOld(lasts, element, storageName) {
  29404. var lastCfg = lasts[thisRawIndex] = {};
  29405. var parentNode = thisNode.parentNode;
  29406. if (parentNode && (!reRoot || reRoot.direction === 'drillDown')) {
  29407. var parentOldX = 0;
  29408. var parentOldY = 0;
  29409. // New nodes appear from right-bottom corner in 'zoomToNode' animation.
  29410. // For convenience, get old bounding rect from background.
  29411. var parentOldBg = lastsForAnimation.background[parentNode.getRawIndex()];
  29412. if (!reRoot && parentOldBg && parentOldBg.old) {
  29413. parentOldX = parentOldBg.old.width;
  29414. parentOldY = parentOldBg.old.height;
  29415. }
  29416. // When no parent old shape found, its parent is new too,
  29417. // so we can just use {x:0, y:0}.
  29418. lastCfg.old = storageName === 'nodeGroup'
  29419. ? [0, parentOldY]
  29420. : {x: parentOldX, y: parentOldY, width: 0, height: 0};
  29421. }
  29422. // Fade in, user can be aware that these nodes are new.
  29423. lastCfg.fadein = storageName !== 'nodeGroup';
  29424. }
  29425. }
  29426. // We can not set all backgroud with the same z, Because the behaviour of
  29427. // drill down and roll up differ background creation sequence from tree
  29428. // hierarchy sequence, which cause that lowser background element overlap
  29429. // upper ones. So we calculate z based on depth.
  29430. // Moreover, we try to shrink down z interval to [0, 1] to avoid that
  29431. // treemap with large z overlaps other components.
  29432. function calculateZ(depth, zInLevel) {
  29433. var zb = depth * Z_BASE + zInLevel;
  29434. return (zb - 1) / zb;
  29435. }
  29436. /***/ },
  29437. /* 187 */
  29438. /***/ function(module, exports, __webpack_require__) {
  29439. var zrUtil = __webpack_require__(4);
  29440. var helper = {
  29441. retrieveTargetInfo: function (payload, seriesModel) {
  29442. if (payload
  29443. && (
  29444. payload.type === 'treemapZoomToNode'
  29445. || payload.type === 'treemapRootToNode'
  29446. )
  29447. ) {
  29448. var root = seriesModel.getData().tree.root;
  29449. var targetNode = payload.targetNode;
  29450. if (targetNode && root.contains(targetNode)) {
  29451. return {node: targetNode};
  29452. }
  29453. var targetNodeId = payload.targetNodeId;
  29454. if (targetNodeId != null && (targetNode = root.getNodeById(targetNodeId))) {
  29455. return {node: targetNode};
  29456. }
  29457. }
  29458. },
  29459. // Not includes the given node at the last item.
  29460. getPathToRoot: function (node) {
  29461. var path = [];
  29462. while (node) {
  29463. node = node.parentNode;
  29464. node && path.push(node);
  29465. }
  29466. return path.reverse();
  29467. },
  29468. aboveViewRoot: function (viewRoot, node) {
  29469. var viewPath = helper.getPathToRoot(viewRoot);
  29470. return zrUtil.indexOf(viewPath, node) >= 0;
  29471. }
  29472. };
  29473. module.exports = helper;
  29474. /***/ },
  29475. /* 188 */
  29476. /***/ function(module, exports, __webpack_require__) {
  29477. var graphic = __webpack_require__(43);
  29478. var layout = __webpack_require__(21);
  29479. var zrUtil = __webpack_require__(4);
  29480. var TEXT_PADDING = 8;
  29481. var ITEM_GAP = 8;
  29482. var ARRAY_LENGTH = 5;
  29483. function Breadcrumb(containerGroup, onSelect) {
  29484. /**
  29485. * @private
  29486. * @type {module:zrender/container/Group}
  29487. */
  29488. this.group = new graphic.Group();
  29489. containerGroup.add(this.group);
  29490. /**
  29491. * @private
  29492. * @type {Function}
  29493. */
  29494. this._onSelect = onSelect || zrUtil.noop;
  29495. }
  29496. Breadcrumb.prototype = {
  29497. constructor: Breadcrumb,
  29498. render: function (seriesModel, api, targetNode) {
  29499. var model = seriesModel.getModel('breadcrumb');
  29500. var thisGroup = this.group;
  29501. thisGroup.removeAll();
  29502. if (!model.get('show') || !targetNode) {
  29503. return;
  29504. }
  29505. var normalStyleModel = model.getModel('itemStyle.normal');
  29506. // var emphasisStyleModel = model.getModel('itemStyle.emphasis');
  29507. var textStyleModel = normalStyleModel.getModel('textStyle');
  29508. var layoutParam = {
  29509. pos: {
  29510. left: model.get('left'),
  29511. right: model.get('right'),
  29512. top: model.get('top'),
  29513. bottom: model.get('bottom')
  29514. },
  29515. box: {
  29516. width: api.getWidth(),
  29517. height: api.getHeight()
  29518. },
  29519. emptyItemWidth: model.get('emptyItemWidth'),
  29520. totalWidth: 0,
  29521. renderList: []
  29522. };
  29523. this._prepare(
  29524. model, targetNode, layoutParam, textStyleModel
  29525. );
  29526. this._renderContent(
  29527. model, targetNode, layoutParam, normalStyleModel, textStyleModel
  29528. );
  29529. layout.positionGroup(thisGroup, layoutParam.pos, layoutParam.box);
  29530. },
  29531. /**
  29532. * Prepare render list and total width
  29533. * @private
  29534. */
  29535. _prepare: function (model, targetNode, layoutParam, textStyleModel) {
  29536. for (var node = targetNode; node; node = node.parentNode) {
  29537. var text = node.getModel().get('name');
  29538. var textRect = textStyleModel.getTextRect(text);
  29539. var itemWidth = Math.max(
  29540. textRect.width + TEXT_PADDING * 2,
  29541. layoutParam.emptyItemWidth
  29542. );
  29543. layoutParam.totalWidth += itemWidth + ITEM_GAP;
  29544. layoutParam.renderList.push({node: node, text: text, width: itemWidth});
  29545. }
  29546. },
  29547. /**
  29548. * @private
  29549. */
  29550. _renderContent: function (
  29551. model, targetNode, layoutParam, normalStyleModel, textStyleModel
  29552. ) {
  29553. // Start rendering.
  29554. var lastX = 0;
  29555. var emptyItemWidth = layoutParam.emptyItemWidth;
  29556. var height = model.get('height');
  29557. var availableSize = layout.getAvailableSize(layoutParam.pos, layoutParam.box);
  29558. var totalWidth = layoutParam.totalWidth;
  29559. var renderList = layoutParam.renderList;
  29560. for (var i = renderList.length - 1; i >= 0; i--) {
  29561. var item = renderList[i];
  29562. var itemWidth = item.width;
  29563. var text = item.text;
  29564. // Hdie text and shorten width if necessary.
  29565. if (totalWidth > availableSize.width) {
  29566. totalWidth -= itemWidth - emptyItemWidth;
  29567. itemWidth = emptyItemWidth;
  29568. text = '';
  29569. }
  29570. this.group.add(new graphic.Polygon({
  29571. shape: {
  29572. points: makeItemPoints(
  29573. lastX, 0, itemWidth, height,
  29574. i === renderList.length - 1, i === 0
  29575. )
  29576. },
  29577. style: zrUtil.defaults(
  29578. normalStyleModel.getItemStyle(),
  29579. {
  29580. lineJoin: 'bevel',
  29581. text: text,
  29582. textFill: textStyleModel.getTextColor(),
  29583. textFont: textStyleModel.getFont()
  29584. }
  29585. ),
  29586. z: 10,
  29587. onclick: zrUtil.bind(this._onSelect, this, item.node)
  29588. }));
  29589. lastX += itemWidth + ITEM_GAP;
  29590. }
  29591. },
  29592. /**
  29593. * @override
  29594. */
  29595. remove: function () {
  29596. this.group.removeAll();
  29597. }
  29598. };
  29599. function makeItemPoints(x, y, itemWidth, itemHeight, head, tail) {
  29600. var points = [
  29601. [head ? x : x - ARRAY_LENGTH, y],
  29602. [x + itemWidth, y],
  29603. [x + itemWidth, y + itemHeight],
  29604. [head ? x : x - ARRAY_LENGTH, y + itemHeight]
  29605. ];
  29606. !tail && points.splice(2, 0, [x + itemWidth + ARRAY_LENGTH, y + itemHeight / 2]);
  29607. !head && points.push([x, y + itemHeight / 2]);
  29608. return points;
  29609. }
  29610. module.exports = Breadcrumb;
  29611. /***/ },
  29612. /* 189 */
  29613. /***/ function(module, exports, __webpack_require__) {
  29614. var zrUtil = __webpack_require__(4);
  29615. /**
  29616. * @param {number} [time=500] Time in ms
  29617. * @param {string} [easing='linear']
  29618. * @param {number} [delay=0]
  29619. * @param {Function} [callback]
  29620. *
  29621. * @example
  29622. * // Animate position
  29623. * animation
  29624. * .createWrap()
  29625. * .add(el1, {position: [10, 10]})
  29626. * .add(el2, {shape: {width: 500}, style: {fill: 'red'}}, 400)
  29627. * .done(function () { // done })
  29628. * .start('cubicOut');
  29629. */
  29630. function createWrap() {
  29631. var storage = [];
  29632. var elExistsMap = {};
  29633. var doneCallback;
  29634. return {
  29635. /**
  29636. * Caution: a el can only be added once, otherwise 'done'
  29637. * might not be called. This method checks this (by el.id),
  29638. * suppresses adding and returns false when existing el found.
  29639. *
  29640. * @param {modele:zrender/Element} el
  29641. * @param {Object} target
  29642. * @param {number} [time=500]
  29643. * @param {number} [delay=0]
  29644. * @param {string} [easing='linear']
  29645. * @return {boolean} Whether adding succeeded.
  29646. *
  29647. * @example
  29648. * add(el, target, time, delay, easing);
  29649. * add(el, target, time, easing);
  29650. * add(el, target, time);
  29651. * add(el, target);
  29652. */
  29653. add: function (el, target, time, delay, easing) {
  29654. if (zrUtil.isString(delay)) {
  29655. easing = delay;
  29656. delay = 0;
  29657. }
  29658. if (elExistsMap[el.id]) {
  29659. return false;
  29660. }
  29661. elExistsMap[el.id] = 1;
  29662. storage.push(
  29663. {el: el, target: target, time: time, delay: delay, easing: easing}
  29664. );
  29665. return true;
  29666. },
  29667. /**
  29668. * Only execute when animation finished. Will not execute when any
  29669. * of 'stop' or 'stopAnimation' called.
  29670. *
  29671. * @param {Function} callback
  29672. */
  29673. done: function (callback) {
  29674. doneCallback = callback;
  29675. return this;
  29676. },
  29677. /**
  29678. * Will stop exist animation firstly.
  29679. */
  29680. start: function () {
  29681. var count = storage.length;
  29682. for (var i = 0, len = storage.length; i < len; i++) {
  29683. var item = storage[i];
  29684. item.el.animateTo(item.target, item.time, item.delay, item.easing, done);
  29685. }
  29686. return this;
  29687. function done() {
  29688. count--;
  29689. if (!count) {
  29690. storage.length = 0;
  29691. elExistsMap = {};
  29692. doneCallback && doneCallback();
  29693. }
  29694. }
  29695. }
  29696. };
  29697. }
  29698. module.exports = {createWrap: createWrap};
  29699. /***/ },
  29700. /* 190 */
  29701. /***/ function(module, exports, __webpack_require__) {
  29702. /**
  29703. * @file Treemap action
  29704. */
  29705. var echarts = __webpack_require__(1);
  29706. var helper = __webpack_require__(187);
  29707. var noop = function () {};
  29708. var actionTypes = [
  29709. 'treemapZoomToNode',
  29710. 'treemapRender',
  29711. 'treemapMove'
  29712. ];
  29713. for (var i = 0; i < actionTypes.length; i++) {
  29714. echarts.registerAction({type: actionTypes[i], update: 'updateView'}, noop);
  29715. }
  29716. echarts.registerAction(
  29717. {type: 'treemapRootToNode', update: 'updateView'},
  29718. function (payload, ecModel) {
  29719. ecModel.eachComponent(
  29720. {mainType: 'series', subType: 'treemap', query: payload},
  29721. handleRootToNode
  29722. );
  29723. function handleRootToNode(model, index) {
  29724. var targetInfo = helper.retrieveTargetInfo(payload, model);
  29725. if (targetInfo) {
  29726. var originViewRoot = model.getViewRoot();
  29727. if (originViewRoot) {
  29728. payload.direction = helper.aboveViewRoot(originViewRoot, targetInfo.node)
  29729. ? 'rollUp' : 'drillDown';
  29730. }
  29731. model.resetViewRoot(targetInfo.node);
  29732. }
  29733. }
  29734. }
  29735. );
  29736. /***/ },
  29737. /* 191 */
  29738. /***/ function(module, exports, __webpack_require__) {
  29739. var VisualMapping = __webpack_require__(192);
  29740. var zrColor = __webpack_require__(39);
  29741. var zrUtil = __webpack_require__(4);
  29742. var isArray = zrUtil.isArray;
  29743. var ITEM_STYLE_NORMAL = 'itemStyle.normal';
  29744. module.exports = function (ecModel, api, payload) {
  29745. var condition = {mainType: 'series', subType: 'treemap', query: payload};
  29746. ecModel.eachComponent(condition, function (seriesModel) {
  29747. var tree = seriesModel.getData().tree;
  29748. var root = tree.root;
  29749. var seriesItemStyleModel = seriesModel.getModel(ITEM_STYLE_NORMAL);
  29750. if (root.isRemoved()) {
  29751. return;
  29752. }
  29753. var levelItemStyles = zrUtil.map(tree.levelModels, function (levelModel) {
  29754. return levelModel ? levelModel.get(ITEM_STYLE_NORMAL) : null;
  29755. });
  29756. travelTree(
  29757. root, // Visual should calculate from tree root but not view root.
  29758. {},
  29759. levelItemStyles,
  29760. seriesItemStyleModel,
  29761. seriesModel.getViewRoot().getAncestors(),
  29762. seriesModel
  29763. );
  29764. });
  29765. };
  29766. function travelTree(
  29767. node, designatedVisual, levelItemStyles, seriesItemStyleModel,
  29768. viewRootAncestors, seriesModel
  29769. ) {
  29770. var nodeModel = node.getModel();
  29771. var nodeLayout = node.getLayout();
  29772. // Optimize
  29773. if (!nodeLayout || nodeLayout.invisible || !nodeLayout.isInView) {
  29774. return;
  29775. }
  29776. var nodeItemStyleModel = node.getModel(ITEM_STYLE_NORMAL);
  29777. var levelItemStyle = levelItemStyles[node.depth];
  29778. var visuals = buildVisuals(
  29779. nodeItemStyleModel, designatedVisual, levelItemStyle, seriesItemStyleModel
  29780. );
  29781. // calculate border color
  29782. var borderColor = nodeItemStyleModel.get('borderColor');
  29783. var borderColorSaturation = nodeItemStyleModel.get('borderColorSaturation');
  29784. var thisNodeColor;
  29785. if (borderColorSaturation != null) {
  29786. // For performance, do not always execute 'calculateColor'.
  29787. thisNodeColor = calculateColor(visuals, node);
  29788. borderColor = calculateBorderColor(borderColorSaturation, thisNodeColor);
  29789. }
  29790. node.setVisual('borderColor', borderColor);
  29791. var viewChildren = node.viewChildren;
  29792. if (!viewChildren || !viewChildren.length) {
  29793. thisNodeColor = calculateColor(visuals, node);
  29794. // Apply visual to this node.
  29795. node.setVisual('color', thisNodeColor);
  29796. }
  29797. else {
  29798. var mapping = buildVisualMapping(
  29799. node, nodeModel, nodeLayout, nodeItemStyleModel, visuals, viewChildren
  29800. );
  29801. // Designate visual to children.
  29802. zrUtil.each(viewChildren, function (child, index) {
  29803. // If higher than viewRoot, only ancestors of viewRoot is needed to visit.
  29804. if (child.depth >= viewRootAncestors.length
  29805. || child === viewRootAncestors[child.depth]
  29806. ) {
  29807. var childVisual = mapVisual(
  29808. nodeModel, visuals, child, index, mapping, seriesModel
  29809. );
  29810. travelTree(
  29811. child, childVisual, levelItemStyles, seriesItemStyleModel,
  29812. viewRootAncestors, seriesModel
  29813. );
  29814. }
  29815. });
  29816. }
  29817. }
  29818. function buildVisuals(
  29819. nodeItemStyleModel, designatedVisual, levelItemStyle, seriesItemStyleModel
  29820. ) {
  29821. var visuals = zrUtil.extend({}, designatedVisual);
  29822. zrUtil.each(['color', 'colorAlpha', 'colorSaturation'], function (visualName) {
  29823. // Priority: thisNode > thisLevel > parentNodeDesignated > seriesModel
  29824. var val = nodeItemStyleModel.get(visualName, true); // Ignore parent
  29825. val == null && levelItemStyle && (val = levelItemStyle[visualName]);
  29826. val == null && (val = designatedVisual[visualName]);
  29827. val == null && (val = seriesItemStyleModel.get(visualName));
  29828. val != null && (visuals[visualName] = val);
  29829. });
  29830. return visuals;
  29831. }
  29832. function calculateColor(visuals) {
  29833. var color = getValueVisualDefine(visuals, 'color');
  29834. if (color) {
  29835. var colorAlpha = getValueVisualDefine(visuals, 'colorAlpha');
  29836. var colorSaturation = getValueVisualDefine(visuals, 'colorSaturation');
  29837. if (colorSaturation) {
  29838. color = zrColor.modifyHSL(color, null, null, colorSaturation);
  29839. }
  29840. if (colorAlpha) {
  29841. color = zrColor.modifyAlpha(color, colorAlpha);
  29842. }
  29843. return color;
  29844. }
  29845. }
  29846. function calculateBorderColor(borderColorSaturation, thisNodeColor) {
  29847. return thisNodeColor != null
  29848. ? zrColor.modifyHSL(thisNodeColor, null, null, borderColorSaturation)
  29849. : null;
  29850. }
  29851. function getValueVisualDefine(visuals, name) {
  29852. var value = visuals[name];
  29853. if (value != null && value !== 'none') {
  29854. return value;
  29855. }
  29856. }
  29857. function buildVisualMapping(
  29858. node, nodeModel, nodeLayout, nodeItemStyleModel, visuals, viewChildren
  29859. ) {
  29860. if (!viewChildren || !viewChildren.length) {
  29861. return;
  29862. }
  29863. var rangeVisual = getRangeVisual(nodeModel, 'color')
  29864. || (
  29865. visuals.color != null
  29866. && visuals.color !== 'none'
  29867. && (
  29868. getRangeVisual(nodeModel, 'colorAlpha')
  29869. || getRangeVisual(nodeModel, 'colorSaturation')
  29870. )
  29871. );
  29872. if (!rangeVisual) {
  29873. return;
  29874. }
  29875. var colorMappingBy = nodeModel.get('colorMappingBy');
  29876. var opt = {
  29877. type: rangeVisual.name,
  29878. dataExtent: nodeLayout.dataExtent,
  29879. visual: rangeVisual.range
  29880. };
  29881. if (opt.type === 'color'
  29882. && (colorMappingBy === 'index' || colorMappingBy === 'id')
  29883. ) {
  29884. opt.mappingMethod = 'category';
  29885. opt.loop = true;
  29886. // categories is ordinal, so do not set opt.categories.
  29887. }
  29888. else {
  29889. opt.mappingMethod = 'linear';
  29890. }
  29891. var mapping = new VisualMapping(opt);
  29892. mapping.__drColorMappingBy = colorMappingBy;
  29893. return mapping;
  29894. }
  29895. // Notice: If we dont have the attribute 'colorRange', but only use
  29896. // attribute 'color' to represent both concepts of 'colorRange' and 'color',
  29897. // (It means 'colorRange' when 'color' is Array, means 'color' when not array),
  29898. // this problem will be encountered:
  29899. // If a level-1 node dont have children, and its siblings has children,
  29900. // and colorRange is set on level-1, then the node can not be colored.
  29901. // So we separate 'colorRange' and 'color' to different attributes.
  29902. function getRangeVisual(nodeModel, name) {
  29903. // 'colorRange', 'colorARange', 'colorSRange'.
  29904. // If not exsits on this node, fetch from levels and series.
  29905. var range = nodeModel.get(name);
  29906. return (isArray(range) && range.length) ? {name: name, range: range} : null;
  29907. }
  29908. function mapVisual(nodeModel, visuals, child, index, mapping, seriesModel) {
  29909. var childVisuals = zrUtil.extend({}, visuals);
  29910. if (mapping) {
  29911. var mappingType = mapping.type;
  29912. var colorMappingBy = mappingType === 'color' && mapping.__drColorMappingBy;
  29913. var value =
  29914. colorMappingBy === 'index'
  29915. ? index
  29916. : colorMappingBy === 'id'
  29917. ? seriesModel.mapIdToIndex(child.getId())
  29918. : child.getValue(nodeModel.get('visualDimension'));
  29919. childVisuals[mappingType] = mapping.mapValueToVisual(value);
  29920. }
  29921. return childVisuals;
  29922. }
  29923. /***/ },
  29924. /* 192 */
  29925. /***/ function(module, exports, __webpack_require__) {
  29926. /**
  29927. * @file Visual mapping.
  29928. */
  29929. var zrUtil = __webpack_require__(4);
  29930. var zrColor = __webpack_require__(39);
  29931. var linearMap = __webpack_require__(7).linearMap;
  29932. var each = zrUtil.each;
  29933. var isObject = zrUtil.isObject;
  29934. var CATEGORY_DEFAULT_VISUAL_INDEX = -1;
  29935. /**
  29936. * @param {Object} option
  29937. * @param {string} [option.type] See visualHandlers.
  29938. * @param {string} [option.mappingMethod] 'linear' or 'piecewise' or 'category' or 'fixed'
  29939. * @param {Array.<number>=} [option.dataExtent] [minExtent, maxExtent],
  29940. * required when mappingMethod is 'linear'
  29941. * @param {Array.<Object>=} [option.pieceList] [
  29942. * {value: someValue},
  29943. * {interval: [min1, max1], visual: {...}},
  29944. * {interval: [min2, max2]}
  29945. * ],
  29946. * required when mappingMethod is 'piecewise'.
  29947. * Visual for only each piece can be specified.
  29948. * @param {Array.<string|Object>=} [option.categories] ['cate1', 'cate2']
  29949. * required when mappingMethod is 'category'.
  29950. * If no option.categories, categories is set
  29951. * as [0, 1, 2, ...].
  29952. * @param {boolean} [option.loop=false] Whether loop mapping when mappingMethod is 'category'.
  29953. * @param {(Array|Object|*)} [option.visual] Visual data.
  29954. * when mappingMethod is 'category',
  29955. * visual data can be array or object
  29956. * (like: {cate1: '#222', none: '#fff'})
  29957. * or primary types (which represents
  29958. * defualt category visual), otherwise visual
  29959. * can be array or primary (which will be
  29960. * normalized to array).
  29961. *
  29962. */
  29963. var VisualMapping = function (option) {
  29964. var mappingMethod = option.mappingMethod;
  29965. var visualType = option.type;
  29966. /**
  29967. * @readOnly
  29968. * @type {Object}
  29969. */
  29970. var thisOption = this.option = zrUtil.clone(option);
  29971. /**
  29972. * @readOnly
  29973. * @type {string}
  29974. */
  29975. this.type = visualType;
  29976. /**
  29977. * @readOnly
  29978. * @type {string}
  29979. */
  29980. this.mappingMethod = mappingMethod;
  29981. /**
  29982. * @private
  29983. * @type {Function}
  29984. */
  29985. this._normalizeData = normalizers[mappingMethod];
  29986. var visualHandler = visualHandlers[visualType];
  29987. /**
  29988. * @public
  29989. * @type {Function}
  29990. */
  29991. this.applyVisual = visualHandler.applyVisual;
  29992. /**
  29993. * @public
  29994. * @type {Function}
  29995. */
  29996. this.getColorMapper = visualHandler.getColorMapper;
  29997. /**
  29998. * @private
  29999. * @type {Function}
  30000. */
  30001. this._doMap = visualHandler._doMap[mappingMethod];
  30002. if (mappingMethod === 'piecewise') {
  30003. normalizeVisualRange(thisOption);
  30004. preprocessForPiecewise(thisOption);
  30005. }
  30006. else if (mappingMethod === 'category') {
  30007. thisOption.categories
  30008. ? preprocessForSpecifiedCategory(thisOption)
  30009. // categories is ordinal when thisOption.categories not specified,
  30010. // which need no more preprocess except normalize visual.
  30011. : normalizeVisualRange(thisOption, true);
  30012. }
  30013. else { // mappingMethod === 'linear' or 'fixed'
  30014. zrUtil.assert(mappingMethod !== 'linear' || thisOption.dataExtent);
  30015. normalizeVisualRange(thisOption);
  30016. }
  30017. };
  30018. VisualMapping.prototype = {
  30019. constructor: VisualMapping,
  30020. mapValueToVisual: function (value) {
  30021. var normalized = this._normalizeData(value);
  30022. return this._doMap(normalized, value);
  30023. },
  30024. getNormalizer: function () {
  30025. return zrUtil.bind(this._normalizeData, this);
  30026. }
  30027. };
  30028. var visualHandlers = VisualMapping.visualHandlers = {
  30029. color: {
  30030. applyVisual: makeApplyVisual('color'),
  30031. /**
  30032. * Create a mapper function
  30033. * @return {Function}
  30034. */
  30035. getColorMapper: function () {
  30036. var thisOption = this.option;
  30037. var parsedVisual = zrUtil.map(thisOption.visual, zrColor.parse);
  30038. return zrUtil.bind(
  30039. thisOption.mappingMethod === 'category'
  30040. ? function (value, isNormalized) {
  30041. !isNormalized && (value = this._normalizeData(value));
  30042. return doMapCategory(this, value);
  30043. }
  30044. : function (value, isNormalized, out) {
  30045. // If output rgb array
  30046. // which will be much faster and useful in pixel manipulation
  30047. var returnRGBArray = !!out;
  30048. !isNormalized && (value = this._normalizeData(value));
  30049. out = zrColor.fastMapToColor(value, parsedVisual, out);
  30050. return returnRGBArray ? out : zrUtil.stringify(out, 'rgba');
  30051. },
  30052. this
  30053. );
  30054. },
  30055. _doMap: {
  30056. linear: function (normalized) {
  30057. return zrColor.mapToColor(normalized, this.option.visual);
  30058. },
  30059. category: doMapCategory,
  30060. piecewise: function (normalized, value) {
  30061. var result = getSpecifiedVisual.call(this, value);
  30062. if (result == null) {
  30063. result = zrColor.mapToColor(normalized, this.option.visual);
  30064. }
  30065. return result;
  30066. },
  30067. fixed: doMapFixed
  30068. }
  30069. },
  30070. colorHue: makePartialColorVisualHandler(function (color, value) {
  30071. return zrColor.modifyHSL(color, value);
  30072. }),
  30073. colorSaturation: makePartialColorVisualHandler(function (color, value) {
  30074. return zrColor.modifyHSL(color, null, value);
  30075. }),
  30076. colorLightness: makePartialColorVisualHandler(function (color, value) {
  30077. return zrColor.modifyHSL(color, null, null, value);
  30078. }),
  30079. colorAlpha: makePartialColorVisualHandler(function (color, value) {
  30080. return zrColor.modifyAlpha(color, value);
  30081. }),
  30082. opacity: {
  30083. applyVisual: makeApplyVisual('opacity'),
  30084. _doMap: makeDoMap([0, 1])
  30085. },
  30086. symbol: {
  30087. applyVisual: function (value, getter, setter) {
  30088. var symbolCfg = this.mapValueToVisual(value);
  30089. if (zrUtil.isString(symbolCfg)) {
  30090. setter('symbol', symbolCfg);
  30091. }
  30092. else if (isObject(symbolCfg)) {
  30093. for (var name in symbolCfg) {
  30094. if (symbolCfg.hasOwnProperty(name)) {
  30095. setter(name, symbolCfg[name]);
  30096. }
  30097. }
  30098. }
  30099. },
  30100. _doMap: {
  30101. linear: doMapToArray,
  30102. category: doMapCategory,
  30103. piecewise: function (normalized, value) {
  30104. var result = getSpecifiedVisual.call(this, value);
  30105. if (result == null) {
  30106. result = doMapToArray.call(this, normalized);
  30107. }
  30108. return result;
  30109. },
  30110. fixed: doMapFixed
  30111. }
  30112. },
  30113. symbolSize: {
  30114. applyVisual: makeApplyVisual('symbolSize'),
  30115. _doMap: makeDoMap([0, 1])
  30116. }
  30117. };
  30118. function preprocessForPiecewise(thisOption) {
  30119. var pieceList = thisOption.pieceList;
  30120. thisOption.hasSpecialVisual = false;
  30121. zrUtil.each(pieceList, function (piece, index) {
  30122. piece.originIndex = index;
  30123. // piece.visual is "result visual value" but not
  30124. // a visual range, so it does not need to be normalized.
  30125. if (piece.visual != null) {
  30126. thisOption.hasSpecialVisual = true;
  30127. }
  30128. });
  30129. }
  30130. function preprocessForSpecifiedCategory(thisOption) {
  30131. // Hash categories.
  30132. var categories = thisOption.categories;
  30133. var visual = thisOption.visual;
  30134. var categoryMap = thisOption.categoryMap = {};
  30135. each(categories, function (cate, index) {
  30136. categoryMap[cate] = index;
  30137. });
  30138. // Process visual map input.
  30139. if (!zrUtil.isArray(visual)) {
  30140. var visualArr = [];
  30141. if (zrUtil.isObject(visual)) {
  30142. each(visual, function (v, cate) {
  30143. var index = categoryMap[cate];
  30144. visualArr[index != null ? index : CATEGORY_DEFAULT_VISUAL_INDEX] = v;
  30145. });
  30146. }
  30147. else { // Is primary type, represents default visual.
  30148. visualArr[CATEGORY_DEFAULT_VISUAL_INDEX] = visual;
  30149. }
  30150. visual = thisOption.visual = visualArr;
  30151. }
  30152. // Remove categories that has no visual,
  30153. // then we can mapping them to CATEGORY_DEFAULT_VISUAL_INDEX.
  30154. for (var i = categories.length - 1; i >= 0; i--) {
  30155. if (visual[i] == null) {
  30156. delete categoryMap[categories[i]];
  30157. categories.pop();
  30158. }
  30159. }
  30160. }
  30161. function normalizeVisualRange(thisOption, isCategory) {
  30162. var visual = thisOption.visual;
  30163. var visualArr = [];
  30164. if (zrUtil.isObject(visual)) {
  30165. each(visual, function (v) {
  30166. visualArr.push(v);
  30167. });
  30168. }
  30169. else if (visual != null) {
  30170. visualArr.push(visual);
  30171. }
  30172. var doNotNeedPair = {color: 1, symbol: 1};
  30173. if (!isCategory
  30174. && visualArr.length === 1
  30175. && !(thisOption.type in doNotNeedPair)
  30176. ) {
  30177. // Do not care visualArr.length === 0, which is illegal.
  30178. visualArr[1] = visualArr[0];
  30179. }
  30180. thisOption.visual = visualArr;
  30181. }
  30182. function makePartialColorVisualHandler(applyValue) {
  30183. return {
  30184. applyVisual: function (value, getter, setter) {
  30185. value = this.mapValueToVisual(value);
  30186. // Must not be array value
  30187. setter('color', applyValue(getter('color'), value));
  30188. },
  30189. _doMap: makeDoMap([0, 1])
  30190. };
  30191. }
  30192. function doMapToArray(arr, normalized) {
  30193. var visual = this.option.visual;
  30194. return visual[
  30195. Math.round(linearMap(normalized, [0, 1], [0, visual.length - 1], true))
  30196. ] || {};
  30197. }
  30198. function makeApplyVisual(visualType) {
  30199. return function (value, getter, setter) {
  30200. setter(visualType, this.mapValueToVisual(value));
  30201. };
  30202. }
  30203. function doMapCategory(normalized) {
  30204. var visual = this.option.visual;
  30205. return visual[
  30206. (this.option.loop && normalized !== CATEGORY_DEFAULT_VISUAL_INDEX)
  30207. ? normalized % visual.length
  30208. : normalized
  30209. ];
  30210. }
  30211. function doMapFixed() {
  30212. return this.option.visual[0];
  30213. }
  30214. function makeDoMap(sourceExtent) {
  30215. return {
  30216. linear: function (normalized) {
  30217. return linearMap(normalized, sourceExtent, this.option.visual, true);
  30218. },
  30219. category: doMapCategory,
  30220. piecewise: function (normalized, value) {
  30221. var result = getSpecifiedVisual.call(this, value);
  30222. if (result == null) {
  30223. result = linearMap(normalized, sourceExtent, this.option.visual, true);
  30224. }
  30225. return result;
  30226. },
  30227. fixed: doMapFixed
  30228. };
  30229. }
  30230. function getSpecifiedVisual(value) {
  30231. var thisOption = this.option;
  30232. var pieceList = thisOption.pieceList;
  30233. if (thisOption.hasSpecialVisual) {
  30234. var pieceIndex = VisualMapping.findPieceIndex(value, pieceList);
  30235. var piece = pieceList[pieceIndex];
  30236. if (piece && piece.visual) {
  30237. return piece.visual[this.type];
  30238. }
  30239. }
  30240. }
  30241. /**
  30242. * Normalizers by mapping methods.
  30243. */
  30244. var normalizers = {
  30245. linear: function (value) {
  30246. return linearMap(value, this.option.dataExtent, [0, 1], true);
  30247. },
  30248. piecewise: function (value) {
  30249. var pieceList = this.option.pieceList;
  30250. var pieceIndex = VisualMapping.findPieceIndex(value, pieceList, true);
  30251. if (pieceIndex != null) {
  30252. return linearMap(pieceIndex, [0, pieceList.length - 1], [0, 1], true);
  30253. }
  30254. },
  30255. category: function (value) {
  30256. var index = this.option.categories
  30257. ? this.option.categoryMap[value]
  30258. : value; // ordinal
  30259. return index == null ? CATEGORY_DEFAULT_VISUAL_INDEX : index;
  30260. },
  30261. fixed: zrUtil.noop
  30262. };
  30263. /**
  30264. * @public
  30265. */
  30266. VisualMapping.addVisualHandler = function (name, handler) {
  30267. visualHandlers[name] = handler;
  30268. };
  30269. /**
  30270. * @public
  30271. */
  30272. VisualMapping.isValidType = function (visualType) {
  30273. return visualHandlers.hasOwnProperty(visualType);
  30274. };
  30275. /**
  30276. * Convinent method.
  30277. * Visual can be Object or Array or primary type.
  30278. *
  30279. * @public
  30280. */
  30281. VisualMapping.eachVisual = function (visual, callback, context) {
  30282. if (zrUtil.isObject(visual)) {
  30283. zrUtil.each(visual, callback, context);
  30284. }
  30285. else {
  30286. callback.call(context, visual);
  30287. }
  30288. };
  30289. VisualMapping.mapVisual = function (visual, callback, context) {
  30290. var isPrimary;
  30291. var newVisual = zrUtil.isArray(visual)
  30292. ? []
  30293. : zrUtil.isObject(visual)
  30294. ? {}
  30295. : (isPrimary = true, null);
  30296. VisualMapping.eachVisual(visual, function (v, key) {
  30297. var newVal = callback.call(context, v, key);
  30298. isPrimary ? (newVisual = newVal) : (newVisual[key] = newVal);
  30299. });
  30300. return newVisual;
  30301. };
  30302. /**
  30303. * @public
  30304. * @param {Object} obj
  30305. * @return {Oject} new object containers visual values.
  30306. * If no visuals, return null.
  30307. */
  30308. VisualMapping.retrieveVisuals = function (obj) {
  30309. var ret = {};
  30310. var hasVisual;
  30311. obj && each(visualHandlers, function (h, visualType) {
  30312. if (obj.hasOwnProperty(visualType)) {
  30313. ret[visualType] = obj[visualType];
  30314. hasVisual = true;
  30315. }
  30316. });
  30317. return hasVisual ? ret : null;
  30318. };
  30319. /**
  30320. * Give order to visual types, considering colorSaturation, colorAlpha depends on color.
  30321. *
  30322. * @public
  30323. * @param {(Object|Array)} visualTypes If Object, like: {color: ..., colorSaturation: ...}
  30324. * IF Array, like: ['color', 'symbol', 'colorSaturation']
  30325. * @return {Array.<string>} Sorted visual types.
  30326. */
  30327. VisualMapping.prepareVisualTypes = function (visualTypes) {
  30328. if (isObject(visualTypes)) {
  30329. var types = [];
  30330. each(visualTypes, function (item, type) {
  30331. types.push(type);
  30332. });
  30333. visualTypes = types;
  30334. }
  30335. else if (zrUtil.isArray(visualTypes)) {
  30336. visualTypes = visualTypes.slice();
  30337. }
  30338. else {
  30339. return [];
  30340. }
  30341. visualTypes.sort(function (type1, type2) {
  30342. // color should be front of colorSaturation, colorAlpha, ...
  30343. // symbol and symbolSize do not matter.
  30344. return (type2 === 'color' && type1 !== 'color' && type1.indexOf('color') === 0)
  30345. ? 1 : -1;
  30346. });
  30347. return visualTypes;
  30348. };
  30349. /**
  30350. * 'color', 'colorSaturation', 'colorAlpha', ... are depends on 'color'.
  30351. * Other visuals are only depends on themself.
  30352. *
  30353. * @public
  30354. * @param {string} visualType1
  30355. * @param {string} visualType2
  30356. * @return {boolean}
  30357. */
  30358. VisualMapping.dependsOn = function (visualType1, visualType2) {
  30359. return visualType2 === 'color'
  30360. ? !!(visualType1 && visualType1.indexOf(visualType2) === 0)
  30361. : visualType1 === visualType2;
  30362. };
  30363. /**
  30364. * @param {number} value
  30365. * @param {Array.<Object>} pieceList [{value: ..., interval: [min, max]}, ...]
  30366. * Always from small to big.
  30367. * @param {boolean} [findClosestWhenOutside=false]
  30368. * @return {number} index
  30369. */
  30370. VisualMapping.findPieceIndex = function (value, pieceList, findClosestWhenOutside) {
  30371. var possibleI;
  30372. var abs = Infinity;
  30373. // value has the higher priority.
  30374. for (var i = 0, len = pieceList.length; i < len; i++) {
  30375. var pieceValue = pieceList[i].value;
  30376. if (pieceValue != null) {
  30377. if (pieceValue === value) {
  30378. return i;
  30379. }
  30380. findClosestWhenOutside && updatePossible(pieceValue, i);
  30381. }
  30382. }
  30383. for (var i = 0, len = pieceList.length; i < len; i++) {
  30384. var piece = pieceList[i];
  30385. var interval = piece.interval;
  30386. var close = piece.close;
  30387. if (interval) {
  30388. if (interval[0] === -Infinity) {
  30389. if (littleThan(close[1], value, interval[1])) {
  30390. return i;
  30391. }
  30392. }
  30393. else if (interval[1] === Infinity) {
  30394. if (littleThan(close[0], interval[0], value)) {
  30395. return i;
  30396. }
  30397. }
  30398. else if (
  30399. littleThan(close[0], interval[0], value)
  30400. && littleThan(close[1], value, interval[1])
  30401. ) {
  30402. return i;
  30403. }
  30404. findClosestWhenOutside && updatePossible(interval[0], i);
  30405. findClosestWhenOutside && updatePossible(interval[1], i);
  30406. }
  30407. }
  30408. if (findClosestWhenOutside) {
  30409. return value === Infinity
  30410. ? pieceList.length - 1
  30411. : value === -Infinity
  30412. ? 0
  30413. : possibleI;
  30414. }
  30415. function updatePossible(val, index) {
  30416. var newAbs = Math.abs(val - value);
  30417. if (newAbs < abs) {
  30418. abs = newAbs;
  30419. possibleI = index;
  30420. }
  30421. }
  30422. };
  30423. function littleThan(close, a, b) {
  30424. return close ? a <= b : a < b;
  30425. }
  30426. module.exports = VisualMapping;
  30427. /***/ },
  30428. /* 193 */
  30429. /***/ function(module, exports, __webpack_require__) {
  30430. var zrUtil = __webpack_require__(4);
  30431. var numberUtil = __webpack_require__(7);
  30432. var layout = __webpack_require__(21);
  30433. var helper = __webpack_require__(187);
  30434. var BoundingRect = __webpack_require__(9);
  30435. var helper = __webpack_require__(187);
  30436. var mathMax = Math.max;
  30437. var mathMin = Math.min;
  30438. var parsePercent = numberUtil.parsePercent;
  30439. var retrieveValue = zrUtil.retrieve;
  30440. var each = zrUtil.each;
  30441. /**
  30442. * @public
  30443. */
  30444. function update(ecModel, api, payload) {
  30445. // Layout result in each node:
  30446. // {x, y, width, height, area, borderWidth}
  30447. var condition = {mainType: 'series', subType: 'treemap', query: payload};
  30448. ecModel.eachComponent(condition, function (seriesModel) {
  30449. var ecWidth = api.getWidth();
  30450. var ecHeight = api.getHeight();
  30451. var seriesOption = seriesModel.option;
  30452. var size = seriesOption.size || []; // Compatible with ec2.
  30453. var containerWidth = parsePercent(
  30454. retrieveValue(seriesOption.width, size[0]),
  30455. ecWidth
  30456. );
  30457. var containerHeight = parsePercent(
  30458. retrieveValue(seriesOption.height, size[1]),
  30459. ecHeight
  30460. );
  30461. var layoutInfo = layout.getLayoutRect(
  30462. seriesModel.getBoxLayoutParams(),
  30463. {
  30464. width: api.getWidth(),
  30465. height: api.getHeight()
  30466. }
  30467. );
  30468. // Fetch payload info.
  30469. var payloadType = payload && payload.type;
  30470. var targetInfo = helper.retrieveTargetInfo(payload, seriesModel);
  30471. var rootRect = (payloadType === 'treemapRender' || payloadType === 'treemapMove')
  30472. ? payload.rootRect : null;
  30473. var viewRoot = seriesModel.getViewRoot();
  30474. var viewAbovePath = helper.getPathToRoot(viewRoot);
  30475. if (payloadType !== 'treemapMove') {
  30476. var rootSize = payloadType === 'treemapZoomToNode'
  30477. ? estimateRootSize(
  30478. seriesModel, targetInfo, viewRoot, containerWidth, containerHeight
  30479. )
  30480. : rootRect
  30481. ? [rootRect.width, rootRect.height]
  30482. : [containerWidth, containerHeight];
  30483. var sort = seriesOption.sort;
  30484. if (sort && sort !== 'asc' && sort !== 'desc') {
  30485. sort = 'desc';
  30486. }
  30487. var options = {
  30488. squareRatio: seriesOption.squareRatio,
  30489. sort: sort,
  30490. leafDepth: seriesOption.leafDepth
  30491. };
  30492. // layout should be cleared because using updateView but not update.
  30493. viewRoot.hostTree.clearLayouts();
  30494. // TODO
  30495. // optimize: if out of view clip, do not layout.
  30496. // But take care that if do not render node out of view clip,
  30497. // how to calculate start po
  30498. var viewRootLayout = {
  30499. x: 0, y: 0,
  30500. width: rootSize[0], height: rootSize[1],
  30501. area: rootSize[0] * rootSize[1]
  30502. };
  30503. viewRoot.setLayout(viewRootLayout);
  30504. squarify(viewRoot, options, false, 0);
  30505. // Supplement layout.
  30506. var viewRootLayout = viewRoot.getLayout();
  30507. each(viewAbovePath, function (node, index) {
  30508. var childValue = (viewAbovePath[index + 1] || viewRoot).getValue();
  30509. node.setLayout(zrUtil.extend(
  30510. {dataExtent: [childValue, childValue], borderWidth: 0},
  30511. viewRootLayout
  30512. ));
  30513. });
  30514. }
  30515. var treeRoot = seriesModel.getData().tree.root;
  30516. treeRoot.setLayout(
  30517. calculateRootPosition(layoutInfo, rootRect, targetInfo),
  30518. true
  30519. );
  30520. seriesModel.setLayoutInfo(layoutInfo);
  30521. // FIXME
  30522. // 现在没有clip功能,暂时取ec高宽。
  30523. prunning(
  30524. treeRoot,
  30525. // Transform to base element coordinate system.
  30526. new BoundingRect(-layoutInfo.x, -layoutInfo.y, ecWidth, ecHeight),
  30527. viewAbovePath,
  30528. viewRoot,
  30529. 0
  30530. );
  30531. });
  30532. }
  30533. /**
  30534. * Layout treemap with squarify algorithm.
  30535. * @see https://graphics.ethz.ch/teaching/scivis_common/Literature/squarifiedTreeMaps.pdf
  30536. * @see https://github.com/mbostock/d3/blob/master/src/layout/treemap.js
  30537. *
  30538. * @protected
  30539. * @param {module:echarts/data/Tree~TreeNode} node
  30540. * @param {Object} options
  30541. * @param {string} options.sort 'asc' or 'desc'
  30542. * @param {number} options.squareRatio
  30543. * @param {boolean} hideChildren
  30544. * @param {number} depth
  30545. */
  30546. function squarify(node, options, hideChildren, depth) {
  30547. var width;
  30548. var height;
  30549. if (node.isRemoved()) {
  30550. return;
  30551. }
  30552. var thisLayout = node.getLayout();
  30553. width = thisLayout.width;
  30554. height = thisLayout.height;
  30555. // Considering border and gap
  30556. var itemStyleModel = node.getModel('itemStyle.normal');
  30557. var borderWidth = itemStyleModel.get('borderWidth');
  30558. var halfGapWidth = itemStyleModel.get('gapWidth') / 2;
  30559. var layoutOffset = borderWidth - halfGapWidth;
  30560. var nodeModel = node.getModel();
  30561. node.setLayout({borderWidth: borderWidth}, true);
  30562. width = mathMax(width - 2 * layoutOffset, 0);
  30563. height = mathMax(height - 2 * layoutOffset, 0);
  30564. var totalArea = width * height;
  30565. var viewChildren = initChildren(
  30566. node, nodeModel, totalArea, options, hideChildren, depth
  30567. );
  30568. if (!viewChildren.length) {
  30569. return;
  30570. }
  30571. var rect = {x: layoutOffset, y: layoutOffset, width: width, height: height};
  30572. var rowFixedLength = mathMin(width, height);
  30573. var best = Infinity; // the best row score so far
  30574. var row = [];
  30575. row.area = 0;
  30576. for (var i = 0, len = viewChildren.length; i < len;) {
  30577. var child = viewChildren[i];
  30578. row.push(child);
  30579. row.area += child.getLayout().area;
  30580. var score = worst(row, rowFixedLength, options.squareRatio);
  30581. // continue with this orientation
  30582. if (score <= best) {
  30583. i++;
  30584. best = score;
  30585. }
  30586. // abort, and try a different orientation
  30587. else {
  30588. row.area -= row.pop().getLayout().area;
  30589. position(row, rowFixedLength, rect, halfGapWidth, false);
  30590. rowFixedLength = mathMin(rect.width, rect.height);
  30591. row.length = row.area = 0;
  30592. best = Infinity;
  30593. }
  30594. }
  30595. if (row.length) {
  30596. position(row, rowFixedLength, rect, halfGapWidth, true);
  30597. }
  30598. if (!hideChildren) {
  30599. var childrenVisibleMin = nodeModel.get('childrenVisibleMin');
  30600. if (childrenVisibleMin != null && totalArea < childrenVisibleMin) {
  30601. hideChildren = true;
  30602. }
  30603. }
  30604. for (var i = 0, len = viewChildren.length; i < len; i++) {
  30605. squarify(viewChildren[i], options, hideChildren, depth + 1);
  30606. }
  30607. }
  30608. /**
  30609. * Set area to each child, and calculate data extent for visual coding.
  30610. */
  30611. function initChildren(node, nodeModel, totalArea, options, hideChildren, depth) {
  30612. var viewChildren = node.children || [];
  30613. var orderBy = options.sort;
  30614. orderBy !== 'asc' && orderBy !== 'desc' && (orderBy = null);
  30615. var overLeafDepth = options.leafDepth != null && options.leafDepth <= depth;
  30616. // leafDepth has higher priority.
  30617. if (hideChildren && !overLeafDepth) {
  30618. return (node.viewChildren = []);
  30619. }
  30620. // Sort children, order by desc.
  30621. viewChildren = zrUtil.filter(viewChildren, function (child) {
  30622. return !child.isRemoved();
  30623. });
  30624. sort(viewChildren, orderBy);
  30625. var info = statistic(nodeModel, viewChildren, orderBy);
  30626. if (info.sum === 0) {
  30627. return (node.viewChildren = []);
  30628. }
  30629. info.sum = filterByThreshold(nodeModel, totalArea, info.sum, orderBy, viewChildren);
  30630. if (info.sum === 0) {
  30631. return (node.viewChildren = []);
  30632. }
  30633. // Set area to each child.
  30634. for (var i = 0, len = viewChildren.length; i < len; i++) {
  30635. var area = viewChildren[i].getValue() / info.sum * totalArea;
  30636. // Do not use setLayout({...}, true), because it is needed to clear last layout.
  30637. viewChildren[i].setLayout({area: area});
  30638. }
  30639. if (overLeafDepth) {
  30640. viewChildren.length && node.setLayout({isLeafRoot: true}, true);
  30641. viewChildren.length = 0;
  30642. }
  30643. node.viewChildren = viewChildren;
  30644. node.setLayout({dataExtent: info.dataExtent}, true);
  30645. return viewChildren;
  30646. }
  30647. /**
  30648. * Consider 'visibleMin'. Modify viewChildren and get new sum.
  30649. */
  30650. function filterByThreshold(nodeModel, totalArea, sum, orderBy, orderedChildren) {
  30651. // visibleMin is not supported yet when no option.sort.
  30652. if (!orderBy) {
  30653. return sum;
  30654. }
  30655. var visibleMin = nodeModel.get('visibleMin');
  30656. var len = orderedChildren.length;
  30657. var deletePoint = len;
  30658. // Always travel from little value to big value.
  30659. for (var i = len - 1; i >= 0; i--) {
  30660. var value = orderedChildren[
  30661. orderBy === 'asc' ? len - i - 1 : i
  30662. ].getValue();
  30663. if (value / sum * totalArea < visibleMin) {
  30664. deletePoint = i;
  30665. sum -= value;
  30666. }
  30667. }
  30668. orderBy === 'asc'
  30669. ? orderedChildren.splice(0, len - deletePoint)
  30670. : orderedChildren.splice(deletePoint, len - deletePoint);
  30671. return sum;
  30672. }
  30673. /**
  30674. * Sort
  30675. */
  30676. function sort(viewChildren, orderBy) {
  30677. if (orderBy) {
  30678. viewChildren.sort(function (a, b) {
  30679. return orderBy === 'asc'
  30680. ? a.getValue() - b.getValue() : b.getValue() - a.getValue();
  30681. });
  30682. }
  30683. return viewChildren;
  30684. }
  30685. /**
  30686. * Statistic
  30687. */
  30688. function statistic(nodeModel, children, orderBy) {
  30689. // Calculate sum.
  30690. var sum = 0;
  30691. for (var i = 0, len = children.length; i < len; i++) {
  30692. sum += children[i].getValue();
  30693. }
  30694. // Statistic data extent for latter visual coding.
  30695. // Notice: data extent should be calculate based on raw children
  30696. // but not filtered view children, otherwise visual mapping will not
  30697. // be stable when zoom (where children is filtered by visibleMin).
  30698. var dimension = nodeModel.get('visualDimension');
  30699. var dataExtent;
  30700. // The same as area dimension.
  30701. if (!children || !children.length) {
  30702. dataExtent = [NaN, NaN];
  30703. }
  30704. else if (dimension === 'value' && orderBy) {
  30705. dataExtent = [
  30706. children[children.length - 1].getValue(),
  30707. children[0].getValue()
  30708. ];
  30709. orderBy === 'asc' && dataExtent.reverse();
  30710. }
  30711. // Other dimension.
  30712. else {
  30713. var dataExtent = [Infinity, -Infinity];
  30714. each(children, function (child) {
  30715. var value = child.getValue(dimension);
  30716. value < dataExtent[0] && (dataExtent[0] = value);
  30717. value > dataExtent[1] && (dataExtent[1] = value);
  30718. });
  30719. }
  30720. return {sum: sum, dataExtent: dataExtent};
  30721. }
  30722. /**
  30723. * Computes the score for the specified row,
  30724. * as the worst aspect ratio.
  30725. */
  30726. function worst(row, rowFixedLength, ratio) {
  30727. var areaMax = 0;
  30728. var areaMin = Infinity;
  30729. for (var i = 0, area, len = row.length; i < len; i++) {
  30730. area = row[i].getLayout().area;
  30731. if (area) {
  30732. area < areaMin && (areaMin = area);
  30733. area > areaMax && (areaMax = area);
  30734. }
  30735. }
  30736. var squareArea = row.area * row.area;
  30737. var f = rowFixedLength * rowFixedLength * ratio;
  30738. return squareArea
  30739. ? mathMax(
  30740. (f * areaMax) / squareArea,
  30741. squareArea / (f * areaMin)
  30742. )
  30743. : Infinity;
  30744. }
  30745. /**
  30746. * Positions the specified row of nodes. Modifies `rect`.
  30747. */
  30748. function position(row, rowFixedLength, rect, halfGapWidth, flush) {
  30749. // When rowFixedLength === rect.width,
  30750. // it is horizontal subdivision,
  30751. // rowFixedLength is the width of the subdivision,
  30752. // rowOtherLength is the height of the subdivision,
  30753. // and nodes will be positioned from left to right.
  30754. // wh[idx0WhenH] means: when horizontal,
  30755. // wh[idx0WhenH] => wh[0] => 'width'.
  30756. // xy[idx1WhenH] => xy[1] => 'y'.
  30757. var idx0WhenH = rowFixedLength === rect.width ? 0 : 1;
  30758. var idx1WhenH = 1 - idx0WhenH;
  30759. var xy = ['x', 'y'];
  30760. var wh = ['width', 'height'];
  30761. var last = rect[xy[idx0WhenH]];
  30762. var rowOtherLength = rowFixedLength
  30763. ? row.area / rowFixedLength : 0;
  30764. if (flush || rowOtherLength > rect[wh[idx1WhenH]]) {
  30765. rowOtherLength = rect[wh[idx1WhenH]]; // over+underflow
  30766. }
  30767. for (var i = 0, rowLen = row.length; i < rowLen; i++) {
  30768. var node = row[i];
  30769. var nodeLayout = {};
  30770. var step = rowOtherLength
  30771. ? node.getLayout().area / rowOtherLength : 0;
  30772. var wh1 = nodeLayout[wh[idx1WhenH]] = mathMax(rowOtherLength - 2 * halfGapWidth, 0);
  30773. // We use Math.max/min to avoid negative width/height when considering gap width.
  30774. var remain = rect[xy[idx0WhenH]] + rect[wh[idx0WhenH]] - last;
  30775. var modWH = (i === rowLen - 1 || remain < step) ? remain : step;
  30776. var wh0 = nodeLayout[wh[idx0WhenH]] = mathMax(modWH - 2 * halfGapWidth, 0);
  30777. nodeLayout[xy[idx1WhenH]] = rect[xy[idx1WhenH]] + mathMin(halfGapWidth, wh1 / 2);
  30778. nodeLayout[xy[idx0WhenH]] = last + mathMin(halfGapWidth, wh0 / 2);
  30779. last += modWH;
  30780. node.setLayout(nodeLayout, true);
  30781. }
  30782. rect[xy[idx1WhenH]] += rowOtherLength;
  30783. rect[wh[idx1WhenH]] -= rowOtherLength;
  30784. }
  30785. // Return [containerWidth, containerHeight] as defualt.
  30786. function estimateRootSize(seriesModel, targetInfo, viewRoot, containerWidth, containerHeight) {
  30787. // If targetInfo.node exists, we zoom to the node,
  30788. // so estimate whold width and heigth by target node.
  30789. var currNode = (targetInfo || {}).node;
  30790. var defaultSize = [containerWidth, containerHeight];
  30791. if (!currNode || currNode === viewRoot) {
  30792. return defaultSize;
  30793. }
  30794. var parent;
  30795. var viewArea = containerWidth * containerHeight;
  30796. var area = viewArea * seriesModel.option.zoomToNodeRatio;
  30797. while (parent = currNode.parentNode) { // jshint ignore:line
  30798. var sum = 0;
  30799. var siblings = parent.children;
  30800. for (var i = 0, len = siblings.length; i < len; i++) {
  30801. sum += siblings[i].getValue();
  30802. }
  30803. var currNodeValue = currNode.getValue();
  30804. if (currNodeValue === 0) {
  30805. return defaultSize;
  30806. }
  30807. area *= sum / currNodeValue;
  30808. var borderWidth = parent.getModel('itemStyle.normal').get('borderWidth');
  30809. if (isFinite(borderWidth)) {
  30810. // Considering border, suppose aspect ratio is 1.
  30811. area += 4 * borderWidth * borderWidth + 4 * borderWidth * Math.pow(area, 0.5);
  30812. }
  30813. area > numberUtil.MAX_SAFE_INTEGER && (area = numberUtil.MAX_SAFE_INTEGER);
  30814. currNode = parent;
  30815. }
  30816. area < viewArea && (area = viewArea);
  30817. var scale = Math.pow(area / viewArea, 0.5);
  30818. return [containerWidth * scale, containerHeight * scale];
  30819. }
  30820. // Root postion base on coord of containerGroup
  30821. function calculateRootPosition(layoutInfo, rootRect, targetInfo) {
  30822. if (rootRect) {
  30823. return {x: rootRect.x, y: rootRect.y};
  30824. }
  30825. var defaultPosition = {x: 0, y: 0};
  30826. if (!targetInfo) {
  30827. return defaultPosition;
  30828. }
  30829. // If targetInfo is fetched by 'retrieveTargetInfo',
  30830. // old tree and new tree are the same tree,
  30831. // so the node still exists and we can visit it.
  30832. var targetNode = targetInfo.node;
  30833. var layout = targetNode.getLayout();
  30834. if (!layout) {
  30835. return defaultPosition;
  30836. }
  30837. // Transform coord from local to container.
  30838. var targetCenter = [layout.width / 2, layout.height / 2];
  30839. var node = targetNode;
  30840. while (node) {
  30841. var nodeLayout = node.getLayout();
  30842. targetCenter[0] += nodeLayout.x;
  30843. targetCenter[1] += nodeLayout.y;
  30844. node = node.parentNode;
  30845. }
  30846. return {
  30847. x: layoutInfo.width / 2 - targetCenter[0],
  30848. y: layoutInfo.height / 2 - targetCenter[1]
  30849. };
  30850. }
  30851. // Mark nodes visible for prunning when visual coding and rendering.
  30852. // Prunning depends on layout and root position, so we have to do it after layout.
  30853. function prunning(node, clipRect, viewAbovePath, viewRoot, depth) {
  30854. var nodeLayout = node.getLayout();
  30855. var nodeInViewAbovePath = viewAbovePath[depth];
  30856. var isAboveViewRoot = nodeInViewAbovePath && nodeInViewAbovePath === node;
  30857. if (
  30858. (nodeInViewAbovePath && !isAboveViewRoot)
  30859. || (depth === viewAbovePath.length && node !== viewRoot)
  30860. ) {
  30861. return;
  30862. }
  30863. node.setLayout({
  30864. // isInView means: viewRoot sub tree + viewAbovePath
  30865. isInView: true,
  30866. // invisible only means: outside view clip so that the node can not
  30867. // see but still layout for animation preparation but not render.
  30868. invisible: !isAboveViewRoot && !clipRect.intersect(nodeLayout),
  30869. isAboveViewRoot: isAboveViewRoot
  30870. }, true);
  30871. // Transform to child coordinate.
  30872. var childClipRect = new BoundingRect(
  30873. clipRect.x - nodeLayout.x,
  30874. clipRect.y - nodeLayout.y,
  30875. clipRect.width,
  30876. clipRect.height
  30877. );
  30878. each(node.viewChildren || [], function (child) {
  30879. prunning(child, childClipRect, viewAbovePath, viewRoot, depth + 1);
  30880. });
  30881. }
  30882. module.exports = update;
  30883. /***/ },
  30884. /* 194 */
  30885. /***/ function(module, exports, __webpack_require__) {
  30886. var echarts = __webpack_require__(1);
  30887. var zrUtil = __webpack_require__(4);
  30888. __webpack_require__(195);
  30889. __webpack_require__(198);
  30890. __webpack_require__(203);
  30891. echarts.registerProcessor(__webpack_require__(204));
  30892. echarts.registerVisual(zrUtil.curry(
  30893. __webpack_require__(109), 'graph', 'circle', null
  30894. ));
  30895. echarts.registerVisual(__webpack_require__(205));
  30896. echarts.registerVisual(__webpack_require__(206));
  30897. echarts.registerLayout(__webpack_require__(207));
  30898. echarts.registerLayout(__webpack_require__(210));
  30899. echarts.registerLayout(__webpack_require__(212));
  30900. // Graph view coordinate system
  30901. echarts.registerCoordinateSystem('graphView', {
  30902. create: __webpack_require__(214)
  30903. });
  30904. /***/ },
  30905. /* 195 */
  30906. /***/ function(module, exports, __webpack_require__) {
  30907. 'use strict';
  30908. var List = __webpack_require__(97);
  30909. var zrUtil = __webpack_require__(4);
  30910. var modelUtil = __webpack_require__(5);
  30911. var Model = __webpack_require__(12);
  30912. var createGraphFromNodeEdge = __webpack_require__(196);
  30913. var GraphSeries = __webpack_require__(1).extendSeriesModel({
  30914. type: 'series.graph',
  30915. init: function (option) {
  30916. GraphSeries.superApply(this, 'init', arguments);
  30917. // Provide data for legend select
  30918. this.legendDataProvider = function () {
  30919. return this._categoriesData;
  30920. };
  30921. this.fillDataTextStyle(option.edges || option.links);
  30922. this._updateCategoriesData();
  30923. },
  30924. mergeOption: function (option) {
  30925. GraphSeries.superApply(this, 'mergeOption', arguments);
  30926. this.fillDataTextStyle(option.edges || option.links);
  30927. this._updateCategoriesData();
  30928. },
  30929. mergeDefaultAndTheme: function (option) {
  30930. GraphSeries.superApply(this, 'mergeDefaultAndTheme', arguments);
  30931. modelUtil.defaultEmphasis(option.edgeLabel, modelUtil.LABEL_OPTIONS);
  30932. },
  30933. getInitialData: function (option, ecModel) {
  30934. var edges = option.edges || option.links || [];
  30935. var nodes = option.data || option.nodes || [];
  30936. var self = this;
  30937. if (nodes && edges) {
  30938. return createGraphFromNodeEdge(nodes, edges, this, true, beforeLink).data;
  30939. }
  30940. function beforeLink(nodeData, edgeData) {
  30941. // Overwrite nodeData.getItemModel to
  30942. nodeData.wrapMethod('getItemModel', function (model) {
  30943. var categoriesModels = self._categoriesModels;
  30944. var categoryIdx = model.getShallow('category');
  30945. var categoryModel = categoriesModels[categoryIdx];
  30946. if (categoryModel) {
  30947. categoryModel.parentModel = model.parentModel;
  30948. model.parentModel = categoryModel;
  30949. }
  30950. return model;
  30951. });
  30952. var edgeLabelModel = self.getModel('edgeLabel');
  30953. var wrappedGetEdgeModel = function (path, parentModel) {
  30954. var pathArr = (path || '').split('.');
  30955. if (pathArr[0] === 'label') {
  30956. parentModel = parentModel
  30957. || edgeLabelModel.getModel(pathArr.slice(1));
  30958. }
  30959. var model = Model.prototype.getModel.call(this, pathArr, parentModel);
  30960. model.getModel = wrappedGetEdgeModel;
  30961. return model;
  30962. };
  30963. edgeData.wrapMethod('getItemModel', function (model) {
  30964. // FIXME Wrap get method ?
  30965. model.getModel = wrappedGetEdgeModel;
  30966. return model;
  30967. });
  30968. }
  30969. },
  30970. /**
  30971. * @return {module:echarts/data/Graph}
  30972. */
  30973. getGraph: function () {
  30974. return this.getData().graph;
  30975. },
  30976. /**
  30977. * @return {module:echarts/data/List}
  30978. */
  30979. getEdgeData: function () {
  30980. return this.getGraph().edgeData;
  30981. },
  30982. /**
  30983. * @return {module:echarts/data/List}
  30984. */
  30985. getCategoriesData: function () {
  30986. return this._categoriesData;
  30987. },
  30988. /**
  30989. * @override
  30990. */
  30991. formatTooltip: function (dataIndex, multipleSeries, dataType) {
  30992. if (dataType === 'edge') {
  30993. var nodeData = this.getData();
  30994. var params = this.getDataParams(dataIndex, dataType);
  30995. var edge = nodeData.graph.getEdgeByIndex(dataIndex);
  30996. var sourceName = nodeData.getName(edge.node1.dataIndex);
  30997. var targetName = nodeData.getName(edge.node2.dataIndex);
  30998. var html = sourceName + ' > ' + targetName;
  30999. if (params.value) {
  31000. html += ' : ' + params.value;
  31001. }
  31002. return html;
  31003. }
  31004. else { // dataType === 'node' or empty
  31005. return GraphSeries.superApply(this, 'formatTooltip', arguments);
  31006. }
  31007. },
  31008. _updateCategoriesData: function () {
  31009. var categories = zrUtil.map(this.option.categories || [], function (category) {
  31010. // Data must has value
  31011. return category.value != null ? category : zrUtil.extend({
  31012. value: 0
  31013. }, category);
  31014. });
  31015. var categoriesData = new List(['value'], this);
  31016. categoriesData.initData(categories);
  31017. this._categoriesData = categoriesData;
  31018. this._categoriesModels = categoriesData.mapArray(function (idx) {
  31019. return categoriesData.getItemModel(idx, true);
  31020. });
  31021. },
  31022. setZoom: function (zoom) {
  31023. this.option.zoom = zoom;
  31024. },
  31025. setCenter: function (center) {
  31026. this.option.center = center;
  31027. },
  31028. defaultOption: {
  31029. zlevel: 0,
  31030. z: 2,
  31031. coordinateSystem: 'view',
  31032. // Default option for all coordinate systems
  31033. xAxisIndex: 0,
  31034. yAxisIndex: 0,
  31035. polarIndex: 0,
  31036. geoIndex: 0,
  31037. legendHoverLink: true,
  31038. hoverAnimation: true,
  31039. layout: null,
  31040. focusNodeAdjacency: false,
  31041. // Configuration of force
  31042. force: {
  31043. initLayout: null,
  31044. repulsion: 50,
  31045. gravity: 0.1,
  31046. edgeLength: 30,
  31047. layoutAnimation: true
  31048. },
  31049. left: 'center',
  31050. top: 'center',
  31051. // right: null,
  31052. // bottom: null,
  31053. // width: '80%',
  31054. // height: '80%',
  31055. symbol: 'circle',
  31056. symbolSize: 10,
  31057. edgeSymbol: ['none', 'none'],
  31058. edgeSymbolSize: 10,
  31059. edgeLabel: {
  31060. normal: {
  31061. position: 'middle'
  31062. },
  31063. emphasis: {}
  31064. },
  31065. draggable: false,
  31066. roam: false,
  31067. // Default on center of graph
  31068. center: null,
  31069. zoom: 1,
  31070. // Symbol size scale ratio in roam
  31071. nodeScaleRatio: 0.6,
  31072. // categories: [],
  31073. // data: []
  31074. // Or
  31075. // nodes: []
  31076. //
  31077. // links: []
  31078. // Or
  31079. // edges: []
  31080. label: {
  31081. normal: {
  31082. show: false,
  31083. formatter: '{b}'
  31084. },
  31085. emphasis: {
  31086. show: true
  31087. }
  31088. },
  31089. itemStyle: {
  31090. normal: {},
  31091. emphasis: {}
  31092. },
  31093. lineStyle: {
  31094. normal: {
  31095. color: '#aaa',
  31096. width: 1,
  31097. curveness: 0,
  31098. opacity: 0.5
  31099. },
  31100. emphasis: {}
  31101. }
  31102. }
  31103. });
  31104. module.exports = GraphSeries;
  31105. /***/ },
  31106. /* 196 */
  31107. /***/ function(module, exports, __webpack_require__) {
  31108. var List = __webpack_require__(97);
  31109. var Graph = __webpack_require__(197);
  31110. var linkList = __webpack_require__(185);
  31111. var completeDimensions = __webpack_require__(102);
  31112. var CoordinateSystem = __webpack_require__(26);
  31113. var zrUtil = __webpack_require__(4);
  31114. var createListFromArray = __webpack_require__(101);
  31115. module.exports = function (nodes, edges, hostModel, directed, beforeLink) {
  31116. var graph = new Graph(directed);
  31117. for (var i = 0; i < nodes.length; i++) {
  31118. graph.addNode(zrUtil.retrieve(
  31119. // Id, name, dataIndex
  31120. nodes[i].id, nodes[i].name, i
  31121. ), i);
  31122. }
  31123. var linkNameList = [];
  31124. var validEdges = [];
  31125. for (var i = 0; i < edges.length; i++) {
  31126. var link = edges[i];
  31127. var source = link.source;
  31128. var target = link.target;
  31129. // addEdge may fail when source or target not exists
  31130. if (graph.addEdge(source, target, i)) {
  31131. validEdges.push(link);
  31132. linkNameList.push(zrUtil.retrieve(link.id, source + ' > ' + target));
  31133. }
  31134. }
  31135. var coordSys = hostModel.get('coordinateSystem');
  31136. var nodeData;
  31137. if (coordSys === 'cartesian2d' || coordSys === 'polar') {
  31138. nodeData = createListFromArray(nodes, hostModel, hostModel.ecModel);
  31139. }
  31140. else {
  31141. // FIXME
  31142. var coordSysCtor = CoordinateSystem.get(coordSys);
  31143. // FIXME
  31144. var dimensionNames = completeDimensions(
  31145. ((coordSysCtor && coordSysCtor.type !== 'view') ? (coordSysCtor.dimensions || []) : []).concat(['value']),
  31146. nodes
  31147. );
  31148. nodeData = new List(dimensionNames, hostModel);
  31149. nodeData.initData(nodes);
  31150. }
  31151. var edgeData = new List(['value'], hostModel);
  31152. edgeData.initData(validEdges, linkNameList);
  31153. beforeLink && beforeLink(nodeData, edgeData);
  31154. linkList({
  31155. mainData: nodeData,
  31156. struct: graph,
  31157. structAttr: 'graph',
  31158. datas: {node: nodeData, edge: edgeData},
  31159. datasAttr: {node: 'data', edge: 'edgeData'}
  31160. });
  31161. // Update dataIndex of nodes and edges because invalid edge may be removed
  31162. graph.update();
  31163. return graph;
  31164. };
  31165. /***/ },
  31166. /* 197 */
  31167. /***/ function(module, exports, __webpack_require__) {
  31168. 'use strict';
  31169. /**
  31170. * Graph data structure
  31171. *
  31172. * @module echarts/data/Graph
  31173. * @author Yi Shen(https://www.github.com/pissang)
  31174. */
  31175. var zrUtil = __webpack_require__(4);
  31176. /**
  31177. * @alias module:echarts/data/Graph
  31178. * @constructor
  31179. * @param {boolean} directed
  31180. */
  31181. var Graph = function(directed) {
  31182. /**
  31183. * 是否是有向图
  31184. * @type {boolean}
  31185. * @private
  31186. */
  31187. this._directed = directed || false;
  31188. /**
  31189. * @type {Array.<module:echarts/data/Graph.Node>}
  31190. * @readOnly
  31191. */
  31192. this.nodes = [];
  31193. /**
  31194. * @type {Array.<module:echarts/data/Graph.Edge>}
  31195. * @readOnly
  31196. */
  31197. this.edges = [];
  31198. /**
  31199. * @type {Object.<string, module:echarts/data/Graph.Node>}
  31200. * @private
  31201. */
  31202. this._nodesMap = {};
  31203. /**
  31204. * @type {Object.<string, module:echarts/data/Graph.Edge>}
  31205. * @private
  31206. */
  31207. this._edgesMap = {};
  31208. /**
  31209. * @type {module:echarts/data/List}
  31210. * @readOnly
  31211. */
  31212. this.data;
  31213. /**
  31214. * @type {module:echarts/data/List}
  31215. * @readOnly
  31216. */
  31217. this.edgeData;
  31218. };
  31219. var graphProto = Graph.prototype;
  31220. /**
  31221. * @type {string}
  31222. */
  31223. graphProto.type = 'graph';
  31224. /**
  31225. * If is directed graph
  31226. * @return {boolean}
  31227. */
  31228. graphProto.isDirected = function () {
  31229. return this._directed;
  31230. };
  31231. /**
  31232. * Add a new node
  31233. * @param {string} id
  31234. * @param {number} [dataIndex]
  31235. */
  31236. graphProto.addNode = function (id, dataIndex) {
  31237. id = id || ('' + dataIndex);
  31238. var nodesMap = this._nodesMap;
  31239. if (nodesMap[id]) {
  31240. return;
  31241. }
  31242. var node = new Node(id, dataIndex);
  31243. node.hostGraph = this;
  31244. this.nodes.push(node);
  31245. nodesMap[id] = node;
  31246. return node;
  31247. };
  31248. /**
  31249. * Get node by data index
  31250. * @param {number} dataIndex
  31251. * @return {module:echarts/data/Graph~Node}
  31252. */
  31253. graphProto.getNodeByIndex = function (dataIndex) {
  31254. var rawIdx = this.data.getRawIndex(dataIndex);
  31255. return this.nodes[rawIdx];
  31256. };
  31257. /**
  31258. * Get node by id
  31259. * @param {string} id
  31260. * @return {module:echarts/data/Graph.Node}
  31261. */
  31262. graphProto.getNodeById = function (id) {
  31263. return this._nodesMap[id];
  31264. };
  31265. /**
  31266. * Add a new edge
  31267. * @param {number|string|module:echarts/data/Graph.Node} n1
  31268. * @param {number|string|module:echarts/data/Graph.Node} n2
  31269. * @param {number} [dataIndex=-1]
  31270. * @return {module:echarts/data/Graph.Edge}
  31271. */
  31272. graphProto.addEdge = function (n1, n2, dataIndex) {
  31273. var nodesMap = this._nodesMap;
  31274. var edgesMap = this._edgesMap;
  31275. // PNEDING
  31276. if (typeof n1 === 'number') {
  31277. n1 = this.nodes[n1];
  31278. }
  31279. if (typeof n2 === 'number') {
  31280. n2 = this.nodes[n2];
  31281. }
  31282. if (!(n1 instanceof Node)) {
  31283. n1 = nodesMap[n1];
  31284. }
  31285. if (!(n2 instanceof Node)) {
  31286. n2 = nodesMap[n2];
  31287. }
  31288. if (!n1 || !n2) {
  31289. return;
  31290. }
  31291. var key = n1.id + '-' + n2.id;
  31292. // PENDING
  31293. if (edgesMap[key]) {
  31294. return;
  31295. }
  31296. var edge = new Edge(n1, n2, dataIndex);
  31297. edge.hostGraph = this;
  31298. if (this._directed) {
  31299. n1.outEdges.push(edge);
  31300. n2.inEdges.push(edge);
  31301. }
  31302. n1.edges.push(edge);
  31303. if (n1 !== n2) {
  31304. n2.edges.push(edge);
  31305. }
  31306. this.edges.push(edge);
  31307. edgesMap[key] = edge;
  31308. return edge;
  31309. };
  31310. /**
  31311. * Get edge by data index
  31312. * @param {number} dataIndex
  31313. * @return {module:echarts/data/Graph~Node}
  31314. */
  31315. graphProto.getEdgeByIndex = function (dataIndex) {
  31316. var rawIdx = this.edgeData.getRawIndex(dataIndex);
  31317. return this.edges[rawIdx];
  31318. };
  31319. /**
  31320. * Get edge by two linked nodes
  31321. * @param {module:echarts/data/Graph.Node|string} n1
  31322. * @param {module:echarts/data/Graph.Node|string} n2
  31323. * @return {module:echarts/data/Graph.Edge}
  31324. */
  31325. graphProto.getEdge = function (n1, n2) {
  31326. if (n1 instanceof Node) {
  31327. n1 = n1.id;
  31328. }
  31329. if (n2 instanceof Node) {
  31330. n2 = n2.id;
  31331. }
  31332. var edgesMap = this._edgesMap;
  31333. if (this._directed) {
  31334. return edgesMap[n1 + '-' + n2];
  31335. } else {
  31336. return edgesMap[n1 + '-' + n2]
  31337. || edgesMap[n2 + '-' + n1];
  31338. }
  31339. };
  31340. /**
  31341. * Iterate all nodes
  31342. * @param {Function} cb
  31343. * @param {*} [context]
  31344. */
  31345. graphProto.eachNode = function (cb, context) {
  31346. var nodes = this.nodes;
  31347. var len = nodes.length;
  31348. for (var i = 0; i < len; i++) {
  31349. if (nodes[i].dataIndex >= 0) {
  31350. cb.call(context, nodes[i], i);
  31351. }
  31352. }
  31353. };
  31354. /**
  31355. * Iterate all edges
  31356. * @param {Function} cb
  31357. * @param {*} [context]
  31358. */
  31359. graphProto.eachEdge = function (cb, context) {
  31360. var edges = this.edges;
  31361. var len = edges.length;
  31362. for (var i = 0; i < len; i++) {
  31363. if (edges[i].dataIndex >= 0
  31364. && edges[i].node1.dataIndex >= 0
  31365. && edges[i].node2.dataIndex >= 0
  31366. ) {
  31367. cb.call(context, edges[i], i);
  31368. }
  31369. }
  31370. };
  31371. /**
  31372. * Breadth first traverse
  31373. * @param {Function} cb
  31374. * @param {module:echarts/data/Graph.Node} startNode
  31375. * @param {string} [direction='none'] 'none'|'in'|'out'
  31376. * @param {*} [context]
  31377. */
  31378. graphProto.breadthFirstTraverse = function (
  31379. cb, startNode, direction, context
  31380. ) {
  31381. if (!(startNode instanceof Node)) {
  31382. startNode = this._nodesMap[startNode];
  31383. }
  31384. if (!startNode) {
  31385. return;
  31386. }
  31387. var edgeType = direction === 'out'
  31388. ? 'outEdges' : (direction === 'in' ? 'inEdges' : 'edges');
  31389. for (var i = 0; i < this.nodes.length; i++) {
  31390. this.nodes[i].__visited = false;
  31391. }
  31392. if (cb.call(context, startNode, null)) {
  31393. return;
  31394. }
  31395. var queue = [startNode];
  31396. while (queue.length) {
  31397. var currentNode = queue.shift();
  31398. var edges = currentNode[edgeType];
  31399. for (var i = 0; i < edges.length; i++) {
  31400. var e = edges[i];
  31401. var otherNode = e.node1 === currentNode
  31402. ? e.node2 : e.node1;
  31403. if (!otherNode.__visited) {
  31404. if (cb.call(otherNode, otherNode, currentNode)) {
  31405. // Stop traversing
  31406. return;
  31407. }
  31408. queue.push(otherNode);
  31409. otherNode.__visited = true;
  31410. }
  31411. }
  31412. }
  31413. };
  31414. // TODO
  31415. // graphProto.depthFirstTraverse = function (
  31416. // cb, startNode, direction, context
  31417. // ) {
  31418. // };
  31419. // Filter update
  31420. graphProto.update = function () {
  31421. var data = this.data;
  31422. var edgeData = this.edgeData;
  31423. var nodes = this.nodes;
  31424. var edges = this.edges;
  31425. for (var i = 0, len = nodes.length; i < len; i++) {
  31426. nodes[i].dataIndex = -1;
  31427. }
  31428. for (var i = 0, len = data.count(); i < len; i++) {
  31429. nodes[data.getRawIndex(i)].dataIndex = i;
  31430. }
  31431. edgeData.filterSelf(function (idx) {
  31432. var edge = edges[edgeData.getRawIndex(idx)];
  31433. return edge.node1.dataIndex >= 0 && edge.node2.dataIndex >= 0;
  31434. });
  31435. // Update edge
  31436. for (var i = 0, len = edges.length; i < len; i++) {
  31437. edges[i].dataIndex = -1;
  31438. }
  31439. for (var i = 0, len = edgeData.count(); i < len; i++) {
  31440. edges[edgeData.getRawIndex(i)].dataIndex = i;
  31441. }
  31442. };
  31443. /**
  31444. * @return {module:echarts/data/Graph}
  31445. */
  31446. graphProto.clone = function () {
  31447. var graph = new Graph(this._directed);
  31448. var nodes = this.nodes;
  31449. var edges = this.edges;
  31450. for (var i = 0; i < nodes.length; i++) {
  31451. graph.addNode(nodes[i].id, nodes[i].dataIndex);
  31452. }
  31453. for (var i = 0; i < edges.length; i++) {
  31454. var e = edges[i];
  31455. graph.addEdge(e.node1.id, e.node2.id, e.dataIndex);
  31456. }
  31457. return graph;
  31458. };
  31459. /**
  31460. * @alias module:echarts/data/Graph.Node
  31461. */
  31462. function Node(id, dataIndex) {
  31463. /**
  31464. * @type {string}
  31465. */
  31466. this.id = id == null ? '' : id;
  31467. /**
  31468. * @type {Array.<module:echarts/data/Graph.Edge>}
  31469. */
  31470. this.inEdges = [];
  31471. /**
  31472. * @type {Array.<module:echarts/data/Graph.Edge>}
  31473. */
  31474. this.outEdges = [];
  31475. /**
  31476. * @type {Array.<module:echarts/data/Graph.Edge>}
  31477. */
  31478. this.edges = [];
  31479. /**
  31480. * @type {module:echarts/data/Graph}
  31481. */
  31482. this.hostGraph;
  31483. /**
  31484. * @type {number}
  31485. */
  31486. this.dataIndex = dataIndex == null ? -1 : dataIndex;
  31487. }
  31488. Node.prototype = {
  31489. constructor: Node,
  31490. /**
  31491. * @return {number}
  31492. */
  31493. degree: function () {
  31494. return this.edges.length;
  31495. },
  31496. /**
  31497. * @return {number}
  31498. */
  31499. inDegree: function () {
  31500. return this.inEdges.length;
  31501. },
  31502. /**
  31503. * @return {number}
  31504. */
  31505. outDegree: function () {
  31506. return this.outEdges.length;
  31507. },
  31508. /**
  31509. * @param {string} [path]
  31510. * @return {module:echarts/model/Model}
  31511. */
  31512. getModel: function (path) {
  31513. if (this.dataIndex < 0) {
  31514. return;
  31515. }
  31516. var graph = this.hostGraph;
  31517. var itemModel = graph.data.getItemModel(this.dataIndex);
  31518. return itemModel.getModel(path);
  31519. }
  31520. };
  31521. /**
  31522. * 图边
  31523. * @alias module:echarts/data/Graph.Edge
  31524. * @param {module:echarts/data/Graph.Node} n1
  31525. * @param {module:echarts/data/Graph.Node} n2
  31526. * @param {number} [dataIndex=-1]
  31527. */
  31528. function Edge(n1, n2, dataIndex) {
  31529. /**
  31530. * 节点1,如果是有向图则为源节点
  31531. * @type {module:echarts/data/Graph.Node}
  31532. */
  31533. this.node1 = n1;
  31534. /**
  31535. * 节点2,如果是有向图则为目标节点
  31536. * @type {module:echarts/data/Graph.Node}
  31537. */
  31538. this.node2 = n2;
  31539. this.dataIndex = dataIndex == null ? -1 : dataIndex;
  31540. }
  31541. /**
  31542. * @param {string} [path]
  31543. * @return {module:echarts/model/Model}
  31544. */
  31545. Edge.prototype.getModel = function (path) {
  31546. if (this.dataIndex < 0) {
  31547. return;
  31548. }
  31549. var graph = this.hostGraph;
  31550. var itemModel = graph.edgeData.getItemModel(this.dataIndex);
  31551. return itemModel.getModel(path);
  31552. };
  31553. var createGraphDataProxyMixin = function (hostName, dataName) {
  31554. return {
  31555. /**
  31556. * @param {string=} [dimension='value'] Default 'value'. can be 'a', 'b', 'c', 'd', 'e'.
  31557. * @return {number}
  31558. */
  31559. getValue: function (dimension) {
  31560. var data = this[hostName][dataName];
  31561. return data.get(data.getDimension(dimension || 'value'), this.dataIndex);
  31562. },
  31563. /**
  31564. * @param {Object|string} key
  31565. * @param {*} [value]
  31566. */
  31567. setVisual: function (key, value) {
  31568. this.dataIndex >= 0
  31569. && this[hostName][dataName].setItemVisual(this.dataIndex, key, value);
  31570. },
  31571. /**
  31572. * @param {string} key
  31573. * @return {boolean}
  31574. */
  31575. getVisual: function (key, ignoreParent) {
  31576. return this[hostName][dataName].getItemVisual(this.dataIndex, key, ignoreParent);
  31577. },
  31578. /**
  31579. * @param {Object} layout
  31580. * @return {boolean} [merge=false]
  31581. */
  31582. setLayout: function (layout, merge) {
  31583. this.dataIndex >= 0
  31584. && this[hostName][dataName].setItemLayout(this.dataIndex, layout, merge);
  31585. },
  31586. /**
  31587. * @return {Object}
  31588. */
  31589. getLayout: function () {
  31590. return this[hostName][dataName].getItemLayout(this.dataIndex);
  31591. },
  31592. /**
  31593. * @return {module:zrender/Element}
  31594. */
  31595. getGraphicEl: function () {
  31596. return this[hostName][dataName].getItemGraphicEl(this.dataIndex);
  31597. },
  31598. /**
  31599. * @return {number}
  31600. */
  31601. getRawIndex: function () {
  31602. return this[hostName][dataName].getRawIndex(this.dataIndex);
  31603. }
  31604. };
  31605. };
  31606. zrUtil.mixin(Node, createGraphDataProxyMixin('hostGraph', 'data'));
  31607. zrUtil.mixin(Edge, createGraphDataProxyMixin('hostGraph', 'edgeData'));
  31608. Graph.Node = Node;
  31609. Graph.Edge = Edge;
  31610. module.exports = Graph;
  31611. /***/ },
  31612. /* 198 */
  31613. /***/ function(module, exports, __webpack_require__) {
  31614. var SymbolDraw = __webpack_require__(104);
  31615. var LineDraw = __webpack_require__(199);
  31616. var RoamController = __webpack_require__(174);
  31617. var graphic = __webpack_require__(43);
  31618. var adjustEdge = __webpack_require__(202);
  31619. var zrUtil = __webpack_require__(4);
  31620. var nodeOpacityPath = ['itemStyle', 'normal', 'opacity'];
  31621. var lineOpacityPath = ['lineStyle', 'normal', 'opacity'];
  31622. function getItemOpacity(item, opacityPath) {
  31623. return item.getVisual('opacity') || item.getModel().get(opacityPath);
  31624. }
  31625. __webpack_require__(1).extendChartView({
  31626. type: 'graph',
  31627. init: function (ecModel, api) {
  31628. var symbolDraw = new SymbolDraw();
  31629. var lineDraw = new LineDraw();
  31630. var group = this.group;
  31631. var controller = new RoamController(api.getZr(), group);
  31632. group.add(symbolDraw.group);
  31633. group.add(lineDraw.group);
  31634. this._symbolDraw = symbolDraw;
  31635. this._lineDraw = lineDraw;
  31636. this._controller = controller;
  31637. this._firstRender = true;
  31638. },
  31639. render: function (seriesModel, ecModel, api) {
  31640. var coordSys = seriesModel.coordinateSystem;
  31641. this._model = seriesModel;
  31642. this._nodeScaleRatio = seriesModel.get('nodeScaleRatio');
  31643. var symbolDraw = this._symbolDraw;
  31644. var lineDraw = this._lineDraw;
  31645. var group = this.group;
  31646. if (coordSys.type === 'view') {
  31647. var groupNewProp = {
  31648. position: coordSys.position,
  31649. scale: coordSys.scale
  31650. };
  31651. if (this._firstRender) {
  31652. group.attr(groupNewProp);
  31653. }
  31654. else {
  31655. graphic.updateProps(group, groupNewProp, seriesModel);
  31656. }
  31657. }
  31658. // Fix edge contact point with node
  31659. adjustEdge(seriesModel.getGraph(), this._getNodeGlobalScale(seriesModel));
  31660. var data = seriesModel.getData();
  31661. symbolDraw.updateData(data);
  31662. var edgeData = seriesModel.getEdgeData();
  31663. lineDraw.updateData(edgeData);
  31664. this._updateNodeAndLinkScale();
  31665. this._updateController(seriesModel, api);
  31666. clearTimeout(this._layoutTimeout);
  31667. var forceLayout = seriesModel.forceLayout;
  31668. var layoutAnimation = seriesModel.get('force.layoutAnimation');
  31669. if (forceLayout) {
  31670. this._startForceLayoutIteration(forceLayout, layoutAnimation);
  31671. }
  31672. data.eachItemGraphicEl(function (el, idx) {
  31673. var itemModel = data.getItemModel(idx);
  31674. // Update draggable
  31675. el.off('drag').off('dragend');
  31676. var draggable = data.getItemModel(idx).get('draggable');
  31677. if (draggable) {
  31678. el.on('drag', function () {
  31679. if (forceLayout) {
  31680. forceLayout.warmUp();
  31681. !this._layouting
  31682. && this._startForceLayoutIteration(forceLayout, layoutAnimation);
  31683. forceLayout.setFixed(idx);
  31684. // Write position back to layout
  31685. data.setItemLayout(idx, el.position);
  31686. }
  31687. }, this).on('dragend', function () {
  31688. if (forceLayout) {
  31689. forceLayout.setUnfixed(idx);
  31690. }
  31691. }, this);
  31692. }
  31693. el.setDraggable(draggable && forceLayout);
  31694. el.off('mouseover', this._focusNodeAdjacency);
  31695. el.off('mouseout', this._unfocusAll);
  31696. if (itemModel.get('focusNodeAdjacency')) {
  31697. el.on('mouseover', this._focusNodeAdjacency, this);
  31698. el.on('mouseout', this._unfocusAll, this);
  31699. }
  31700. }, this);
  31701. this._firstRender = false;
  31702. },
  31703. _focusNodeAdjacency: function (e) {
  31704. var data = this._model.getData();
  31705. var graph = data.graph;
  31706. var el = e.target;
  31707. var dataIndex = el.dataIndex;
  31708. var dataType = el.dataType;
  31709. function fadeOutItem(item, opacityPath) {
  31710. var opacity = getItemOpacity(item, opacityPath);
  31711. var el = item.getGraphicEl();
  31712. if (opacity == null) {
  31713. opacity = 1;
  31714. }
  31715. el.traverse(function (child) {
  31716. child.trigger('normal');
  31717. if (child.type !== 'group') {
  31718. child.setStyle('opacity', opacity * 0.1);
  31719. }
  31720. });
  31721. }
  31722. function fadeInItem(item, opacityPath) {
  31723. var opacity = getItemOpacity(item, opacityPath);
  31724. var el = item.getGraphicEl();
  31725. el.traverse(function (child) {
  31726. child.trigger('emphasis');
  31727. if (child.type !== 'group') {
  31728. child.setStyle('opacity', opacity);
  31729. }
  31730. });
  31731. }
  31732. if (dataIndex !== null && dataType !== 'edge') {
  31733. graph.eachNode(function (node) {
  31734. fadeOutItem(node, nodeOpacityPath);
  31735. });
  31736. graph.eachEdge(function (edge) {
  31737. fadeOutItem(edge, lineOpacityPath);
  31738. });
  31739. var node = graph.getNodeByIndex(dataIndex);
  31740. fadeInItem(node, nodeOpacityPath);
  31741. zrUtil.each(node.edges, function (edge) {
  31742. if (edge.dataIndex < 0) {
  31743. return;
  31744. }
  31745. fadeInItem(edge, lineOpacityPath);
  31746. fadeInItem(edge.node1, nodeOpacityPath);
  31747. fadeInItem(edge.node2, nodeOpacityPath);
  31748. });
  31749. }
  31750. },
  31751. _unfocusAll: function () {
  31752. var data = this._model.getData();
  31753. var graph = data.graph;
  31754. graph.eachNode(function (node) {
  31755. var opacity = getItemOpacity(node, nodeOpacityPath);
  31756. node.getGraphicEl().traverse(function (child) {
  31757. child.trigger('normal');
  31758. if (child.type !== 'group') {
  31759. child.setStyle('opacity', opacity);
  31760. }
  31761. });
  31762. });
  31763. graph.eachEdge(function (edge) {
  31764. var opacity = getItemOpacity(edge, lineOpacityPath);
  31765. edge.getGraphicEl().traverse(function (child) {
  31766. child.trigger('normal');
  31767. if (child.type !== 'group') {
  31768. child.setStyle('opacity', opacity);
  31769. }
  31770. });
  31771. });
  31772. },
  31773. _startForceLayoutIteration: function (forceLayout, layoutAnimation) {
  31774. var self = this;
  31775. (function step() {
  31776. forceLayout.step(function (stopped) {
  31777. self.updateLayout(self._model);
  31778. (self._layouting = !stopped) && (
  31779. layoutAnimation
  31780. ? (self._layoutTimeout = setTimeout(step, 16))
  31781. : step()
  31782. );
  31783. });
  31784. })();
  31785. },
  31786. _updateController: function (seriesModel, api) {
  31787. var controller = this._controller;
  31788. var group = this.group;
  31789. controller.rectProvider = function () {
  31790. var rect = group.getBoundingRect();
  31791. rect.applyTransform(group.transform);
  31792. return rect;
  31793. };
  31794. if (seriesModel.coordinateSystem.type !== 'view') {
  31795. controller.disable();
  31796. return;
  31797. }
  31798. controller.enable(seriesModel.get('roam'));
  31799. controller.zoomLimit = seriesModel.get('scaleLimit');
  31800. // Update zoom from model
  31801. controller.zoom = seriesModel.coordinateSystem.getZoom();
  31802. controller
  31803. .off('pan')
  31804. .off('zoom')
  31805. .on('pan', function (dx, dy) {
  31806. api.dispatchAction({
  31807. seriesId: seriesModel.id,
  31808. type: 'graphRoam',
  31809. dx: dx,
  31810. dy: dy
  31811. });
  31812. })
  31813. .on('zoom', function (zoom, mouseX, mouseY) {
  31814. api.dispatchAction({
  31815. seriesId: seriesModel.id,
  31816. type: 'graphRoam',
  31817. zoom: zoom,
  31818. originX: mouseX,
  31819. originY: mouseY
  31820. });
  31821. this._updateNodeAndLinkScale();
  31822. adjustEdge(seriesModel.getGraph(), this._getNodeGlobalScale(seriesModel));
  31823. this._lineDraw.updateLayout();
  31824. }, this);
  31825. },
  31826. _updateNodeAndLinkScale: function () {
  31827. var seriesModel = this._model;
  31828. var data = seriesModel.getData();
  31829. var nodeScale = this._getNodeGlobalScale(seriesModel);
  31830. var invScale = [nodeScale, nodeScale];
  31831. data.eachItemGraphicEl(function (el, idx) {
  31832. el.attr('scale', invScale);
  31833. });
  31834. },
  31835. _getNodeGlobalScale: function (seriesModel) {
  31836. var coordSys = seriesModel.coordinateSystem;
  31837. if (coordSys.type !== 'view') {
  31838. return 1;
  31839. }
  31840. var nodeScaleRatio = this._nodeScaleRatio;
  31841. var groupScale = coordSys.scale;
  31842. var groupZoom = (groupScale && groupScale[0]) || 1;
  31843. // Scale node when zoom changes
  31844. var roamZoom = coordSys.getZoom();
  31845. var nodeScale = (roamZoom - 1) * nodeScaleRatio + 1;
  31846. return nodeScale / groupZoom;
  31847. },
  31848. updateLayout: function (seriesModel) {
  31849. adjustEdge(seriesModel.getGraph(), this._getNodeGlobalScale(seriesModel));
  31850. this._symbolDraw.updateLayout();
  31851. this._lineDraw.updateLayout();
  31852. },
  31853. remove: function (ecModel, api) {
  31854. this._symbolDraw && this._symbolDraw.remove();
  31855. this._lineDraw && this._lineDraw.remove();
  31856. }
  31857. });
  31858. /***/ },
  31859. /* 199 */
  31860. /***/ function(module, exports, __webpack_require__) {
  31861. /**
  31862. * @module echarts/chart/helper/LineDraw
  31863. */
  31864. var graphic = __webpack_require__(43);
  31865. var LineGroup = __webpack_require__(200);
  31866. function isPointNaN(pt) {
  31867. return isNaN(pt[0]) || isNaN(pt[1]);
  31868. }
  31869. function lineNeedsDraw(pts) {
  31870. return !isPointNaN(pts[0]) && !isPointNaN(pts[1]);
  31871. }
  31872. /**
  31873. * @alias module:echarts/component/marker/LineDraw
  31874. * @constructor
  31875. */
  31876. function LineDraw(ctor) {
  31877. this._ctor = ctor || LineGroup;
  31878. this.group = new graphic.Group();
  31879. }
  31880. var lineDrawProto = LineDraw.prototype;
  31881. /**
  31882. * @param {module:echarts/data/List} lineData
  31883. */
  31884. lineDrawProto.updateData = function (lineData) {
  31885. var oldLineData = this._lineData;
  31886. var group = this.group;
  31887. var LineCtor = this._ctor;
  31888. var hostModel = lineData.hostModel;
  31889. var seriesScope = {
  31890. lineStyle: hostModel.getModel('lineStyle.normal').getLineStyle(),
  31891. hoverLineStyle: hostModel.getModel('lineStyle.emphasis').getLineStyle(),
  31892. labelModel: hostModel.getModel('label.normal'),
  31893. hoverLabelModel: hostModel.getModel('label.emphasis')
  31894. };
  31895. lineData.diff(oldLineData)
  31896. .add(function (idx) {
  31897. if (!lineNeedsDraw(lineData.getItemLayout(idx))) {
  31898. return;
  31899. }
  31900. var lineGroup = new LineCtor(lineData, idx, seriesScope);
  31901. lineData.setItemGraphicEl(idx, lineGroup);
  31902. group.add(lineGroup);
  31903. })
  31904. .update(function (newIdx, oldIdx) {
  31905. var lineGroup = oldLineData.getItemGraphicEl(oldIdx);
  31906. if (!lineNeedsDraw(lineData.getItemLayout(newIdx))) {
  31907. group.remove(lineGroup);
  31908. return;
  31909. }
  31910. if (!lineGroup) {
  31911. lineGroup = new LineCtor(lineData, newIdx, seriesScope);
  31912. }
  31913. else {
  31914. lineGroup.updateData(lineData, newIdx, seriesScope);
  31915. }
  31916. lineData.setItemGraphicEl(newIdx, lineGroup);
  31917. group.add(lineGroup);
  31918. })
  31919. .remove(function (idx) {
  31920. group.remove(oldLineData.getItemGraphicEl(idx));
  31921. })
  31922. .execute();
  31923. this._lineData = lineData;
  31924. };
  31925. lineDrawProto.updateLayout = function () {
  31926. var lineData = this._lineData;
  31927. lineData.eachItemGraphicEl(function (el, idx) {
  31928. el.updateLayout(lineData, idx);
  31929. }, this);
  31930. };
  31931. lineDrawProto.remove = function () {
  31932. this.group.removeAll();
  31933. };
  31934. module.exports = LineDraw;
  31935. /***/ },
  31936. /* 200 */
  31937. /***/ function(module, exports, __webpack_require__) {
  31938. /**
  31939. * @module echarts/chart/helper/Line
  31940. */
  31941. var symbolUtil = __webpack_require__(106);
  31942. var vector = __webpack_require__(10);
  31943. // var matrix = require('zrender/lib/core/matrix');
  31944. var LinePath = __webpack_require__(201);
  31945. var graphic = __webpack_require__(43);
  31946. var zrUtil = __webpack_require__(4);
  31947. var numberUtil = __webpack_require__(7);
  31948. var SYMBOL_CATEGORIES = ['fromSymbol', 'toSymbol'];
  31949. function makeSymbolTypeKey(symbolCategory) {
  31950. return '_' + symbolCategory + 'Type';
  31951. }
  31952. /**
  31953. * @inner
  31954. */
  31955. function createSymbol(name, lineData, idx) {
  31956. var color = lineData.getItemVisual(idx, 'color');
  31957. var symbolType = lineData.getItemVisual(idx, name);
  31958. var symbolSize = lineData.getItemVisual(idx, name + 'Size');
  31959. if (!symbolType || symbolType === 'none') {
  31960. return;
  31961. }
  31962. if (!zrUtil.isArray(symbolSize)) {
  31963. symbolSize = [symbolSize, symbolSize];
  31964. }
  31965. var symbolPath = symbolUtil.createSymbol(
  31966. symbolType, -symbolSize[0] / 2, -symbolSize[1] / 2,
  31967. symbolSize[0], symbolSize[1], color
  31968. );
  31969. symbolPath.name = name;
  31970. return symbolPath;
  31971. }
  31972. function createLine(points) {
  31973. var line = new LinePath({
  31974. name: 'line'
  31975. });
  31976. setLinePoints(line.shape, points);
  31977. return line;
  31978. }
  31979. function setLinePoints(targetShape, points) {
  31980. var p1 = points[0];
  31981. var p2 = points[1];
  31982. var cp1 = points[2];
  31983. targetShape.x1 = p1[0];
  31984. targetShape.y1 = p1[1];
  31985. targetShape.x2 = p2[0];
  31986. targetShape.y2 = p2[1];
  31987. targetShape.percent = 1;
  31988. if (cp1) {
  31989. targetShape.cpx1 = cp1[0];
  31990. targetShape.cpy1 = cp1[1];
  31991. }
  31992. }
  31993. function updateSymbolAndLabelBeforeLineUpdate () {
  31994. var lineGroup = this;
  31995. var symbolFrom = lineGroup.childOfName('fromSymbol');
  31996. var symbolTo = lineGroup.childOfName('toSymbol');
  31997. var label = lineGroup.childOfName('label');
  31998. // Quick reject
  31999. if (!symbolFrom && !symbolTo && label.ignore) {
  32000. return;
  32001. }
  32002. var invScale = 1;
  32003. var parentNode = this.parent;
  32004. while (parentNode) {
  32005. if (parentNode.scale) {
  32006. invScale /= parentNode.scale[0];
  32007. }
  32008. parentNode = parentNode.parent;
  32009. }
  32010. var line = lineGroup.childOfName('line');
  32011. // If line not changed
  32012. // FIXME Parent scale changed
  32013. if (!this.__dirty && !line.__dirty) {
  32014. return;
  32015. }
  32016. var percent = line.shape.percent;
  32017. var fromPos = line.pointAt(0);
  32018. var toPos = line.pointAt(percent);
  32019. var d = vector.sub([], toPos, fromPos);
  32020. vector.normalize(d, d);
  32021. if (symbolFrom) {
  32022. symbolFrom.attr('position', fromPos);
  32023. var tangent = line.tangentAt(0);
  32024. symbolFrom.attr('rotation', Math.PI / 2 - Math.atan2(
  32025. tangent[1], tangent[0]
  32026. ));
  32027. symbolFrom.attr('scale', [invScale * percent, invScale * percent]);
  32028. }
  32029. if (symbolTo) {
  32030. symbolTo.attr('position', toPos);
  32031. var tangent = line.tangentAt(1);
  32032. symbolTo.attr('rotation', -Math.PI / 2 - Math.atan2(
  32033. tangent[1], tangent[0]
  32034. ));
  32035. symbolTo.attr('scale', [invScale * percent, invScale * percent]);
  32036. }
  32037. if (!label.ignore) {
  32038. label.attr('position', toPos);
  32039. var textPosition;
  32040. var textAlign;
  32041. var textVerticalAlign;
  32042. var distance = 5 * invScale;
  32043. // End
  32044. if (label.__position === 'end') {
  32045. textPosition = [d[0] * distance + toPos[0], d[1] * distance + toPos[1]];
  32046. textAlign = d[0] > 0.8 ? 'left' : (d[0] < -0.8 ? 'right' : 'center');
  32047. textVerticalAlign = d[1] > 0.8 ? 'top' : (d[1] < -0.8 ? 'bottom' : 'middle');
  32048. }
  32049. // Middle
  32050. else if (label.__position === 'middle') {
  32051. var halfPercent = percent / 2;
  32052. var tangent = line.tangentAt(halfPercent);
  32053. var n = [tangent[1], -tangent[0]];
  32054. var cp = line.pointAt(halfPercent);
  32055. if (n[1] > 0) {
  32056. n[0] = -n[0];
  32057. n[1] = -n[1];
  32058. }
  32059. textPosition = [cp[0] + n[0] * distance, cp[1] + n[1] * distance];
  32060. textAlign = 'center';
  32061. textVerticalAlign = 'bottom';
  32062. var rotation = -Math.atan2(tangent[1], tangent[0]);
  32063. if (toPos[0] < fromPos[0]) {
  32064. rotation = Math.PI + rotation;
  32065. }
  32066. label.attr('rotation', rotation);
  32067. }
  32068. // Start
  32069. else {
  32070. textPosition = [-d[0] * distance + fromPos[0], -d[1] * distance + fromPos[1]];
  32071. textAlign = d[0] > 0.8 ? 'right' : (d[0] < -0.8 ? 'left' : 'center');
  32072. textVerticalAlign = d[1] > 0.8 ? 'bottom' : (d[1] < -0.8 ? 'top' : 'middle');
  32073. }
  32074. label.attr({
  32075. style: {
  32076. // Use the user specified text align and baseline first
  32077. textVerticalAlign: label.__verticalAlign || textVerticalAlign,
  32078. textAlign: label.__textAlign || textAlign
  32079. },
  32080. position: textPosition,
  32081. scale: [invScale, invScale]
  32082. });
  32083. }
  32084. }
  32085. /**
  32086. * @constructor
  32087. * @extends {module:zrender/graphic/Group}
  32088. * @alias {module:echarts/chart/helper/Line}
  32089. */
  32090. function Line(lineData, idx, seriesScope) {
  32091. graphic.Group.call(this);
  32092. this._createLine(lineData, idx, seriesScope);
  32093. }
  32094. var lineProto = Line.prototype;
  32095. // Update symbol position and rotation
  32096. lineProto.beforeUpdate = updateSymbolAndLabelBeforeLineUpdate;
  32097. lineProto._createLine = function (lineData, idx, seriesScope) {
  32098. var seriesModel = lineData.hostModel;
  32099. var linePoints = lineData.getItemLayout(idx);
  32100. var line = createLine(linePoints);
  32101. line.shape.percent = 0;
  32102. graphic.initProps(line, {
  32103. shape: {
  32104. percent: 1
  32105. }
  32106. }, seriesModel, idx);
  32107. this.add(line);
  32108. var label = new graphic.Text({
  32109. name: 'label'
  32110. });
  32111. this.add(label);
  32112. zrUtil.each(SYMBOL_CATEGORIES, function (symbolCategory) {
  32113. var symbol = createSymbol(symbolCategory, lineData, idx);
  32114. // symbols must added after line to make sure
  32115. // it will be updated after line#update.
  32116. // Or symbol position and rotation update in line#beforeUpdate will be one frame slow
  32117. this.add(symbol);
  32118. this[makeSymbolTypeKey(symbolCategory)] = lineData.getItemVisual(idx, symbolCategory);
  32119. }, this);
  32120. this._updateCommonStl(lineData, idx, seriesScope);
  32121. };
  32122. lineProto.updateData = function (lineData, idx, seriesScope) {
  32123. var seriesModel = lineData.hostModel;
  32124. var line = this.childOfName('line');
  32125. var linePoints = lineData.getItemLayout(idx);
  32126. var target = {
  32127. shape: {}
  32128. };
  32129. setLinePoints(target.shape, linePoints);
  32130. graphic.updateProps(line, target, seriesModel, idx);
  32131. zrUtil.each(SYMBOL_CATEGORIES, function (symbolCategory) {
  32132. var symbolType = lineData.getItemVisual(idx, symbolCategory);
  32133. var key = makeSymbolTypeKey(symbolCategory);
  32134. // Symbol changed
  32135. if (this[key] !== symbolType) {
  32136. this.remove(this.childOfName(symbolCategory));
  32137. var symbol = createSymbol(symbolCategory, lineData, idx);
  32138. this.add(symbol);
  32139. }
  32140. this[key] = symbolType;
  32141. }, this);
  32142. this._updateCommonStl(lineData, idx, seriesScope);
  32143. };
  32144. lineProto._updateCommonStl = function (lineData, idx, seriesScope) {
  32145. var seriesModel = lineData.hostModel;
  32146. var line = this.childOfName('line');
  32147. var lineStyle = seriesScope && seriesScope.lineStyle;
  32148. var hoverLineStyle = seriesScope && seriesScope.hoverLineStyle;
  32149. var labelModel = seriesScope && seriesScope.labelModel;
  32150. var hoverLabelModel = seriesScope && seriesScope.hoverLabelModel;
  32151. // Optimization for large dataset
  32152. if (!seriesScope || lineData.hasItemOption) {
  32153. var itemModel = lineData.getItemModel(idx);
  32154. lineStyle = itemModel.getModel('lineStyle.normal').getLineStyle();
  32155. hoverLineStyle = itemModel.getModel('lineStyle.emphasis').getLineStyle();
  32156. labelModel = itemModel.getModel('label.normal');
  32157. hoverLabelModel = itemModel.getModel('label.emphasis');
  32158. }
  32159. var visualColor = lineData.getItemVisual(idx, 'color');
  32160. if (isNaN(defaultText)) {
  32161. // Use name
  32162. defaultText = lineData.getName(idx);
  32163. }
  32164. line.useStyle(zrUtil.defaults(
  32165. {
  32166. strokeNoScale: true,
  32167. fill: 'none',
  32168. stroke: visualColor
  32169. },
  32170. lineStyle
  32171. ));
  32172. line.hoverStyle = hoverLineStyle;
  32173. var showLabel = labelModel.getShallow('show');
  32174. var hoverShowLabel = hoverLabelModel.getShallow('show');
  32175. var defaultText;
  32176. var label = this.childOfName('label');
  32177. var defaultLabelColor;
  32178. if (showLabel || hoverShowLabel) {
  32179. defaultText = numberUtil.round(seriesModel.getRawValue(idx));
  32180. defaultLabelColor = visualColor || '#000';
  32181. }
  32182. // label.afterUpdate = lineAfterUpdate;
  32183. if (showLabel) {
  32184. var textStyleModel = labelModel.getModel('textStyle');
  32185. label.setStyle({
  32186. text: zrUtil.retrieve(
  32187. seriesModel.getFormattedLabel(idx, 'normal', lineData.dataType),
  32188. defaultText
  32189. ),
  32190. textFont: textStyleModel.getFont(),
  32191. fill: textStyleModel.getTextColor() || defaultLabelColor
  32192. });
  32193. label.__textAlign = textStyleModel.get('align');
  32194. label.__verticalAlign = textStyleModel.get('baseline');
  32195. label.__position = labelModel.get('position');
  32196. }
  32197. else {
  32198. label.setStyle('text', '');
  32199. }
  32200. if (hoverShowLabel) {
  32201. var textStyleHoverModel = hoverLabelModel.getModel('textStyle');
  32202. label.hoverStyle = {
  32203. text: zrUtil.retrieve(
  32204. seriesModel.getFormattedLabel(idx, 'emphasis', lineData.dataType),
  32205. defaultText
  32206. ),
  32207. textFont: textStyleHoverModel.getFont(),
  32208. fill: textStyleHoverModel.getTextColor() || defaultLabelColor
  32209. };
  32210. }
  32211. else {
  32212. label.hoverStyle = {
  32213. text: ''
  32214. };
  32215. }
  32216. label.ignore = !showLabel && !hoverShowLabel;
  32217. graphic.setHoverStyle(this);
  32218. };
  32219. lineProto.updateLayout = function (lineData, idx) {
  32220. this.setLinePoints(lineData.getItemLayout(idx));
  32221. };
  32222. lineProto.setLinePoints = function (points) {
  32223. var linePath = this.childOfName('line');
  32224. setLinePoints(linePath.shape, points);
  32225. linePath.dirty();
  32226. };
  32227. zrUtil.inherits(Line, graphic.Group);
  32228. module.exports = Line;
  32229. /***/ },
  32230. /* 201 */
  32231. /***/ function(module, exports, __webpack_require__) {
  32232. /**
  32233. * Line path for bezier and straight line draw
  32234. */
  32235. var graphic = __webpack_require__(43);
  32236. var vec2 = __webpack_require__(10);
  32237. var straightLineProto = graphic.Line.prototype;
  32238. var bezierCurveProto = graphic.BezierCurve.prototype;
  32239. function isLine(shape) {
  32240. return shape.cpx1 == null || shape.cpy1 == null;
  32241. }
  32242. module.exports = graphic.extendShape({
  32243. type: 'ec-line',
  32244. style: {
  32245. stroke: '#000',
  32246. fill: null
  32247. },
  32248. shape: {
  32249. x1: 0,
  32250. y1: 0,
  32251. x2: 0,
  32252. y2: 0,
  32253. percent: 1,
  32254. cpx1: null,
  32255. cpy1: null
  32256. },
  32257. buildPath: function (ctx, shape) {
  32258. (isLine(shape) ? straightLineProto : bezierCurveProto).buildPath(ctx, shape);
  32259. },
  32260. pointAt: function (t) {
  32261. return isLine(this.shape)
  32262. ? straightLineProto.pointAt.call(this, t)
  32263. : bezierCurveProto.pointAt.call(this, t);
  32264. },
  32265. tangentAt: function (t) {
  32266. var shape = this.shape;
  32267. var p = isLine(shape)
  32268. ? [shape.x2 - shape.x1, shape.y2 - shape.y1]
  32269. : bezierCurveProto.tangentAt.call(this, t);
  32270. return vec2.normalize(p, p);
  32271. }
  32272. });
  32273. /***/ },
  32274. /* 202 */
  32275. /***/ function(module, exports, __webpack_require__) {
  32276. var curveTool = __webpack_require__(50);
  32277. var vec2 = __webpack_require__(10);
  32278. var v1 = [];
  32279. var v2 = [];
  32280. var v3 = [];
  32281. var quadraticAt = curveTool.quadraticAt;
  32282. var v2DistSquare = vec2.distSquare;
  32283. var mathAbs = Math.abs;
  32284. function intersectCurveCircle(curvePoints, center, radius) {
  32285. var p0 = curvePoints[0];
  32286. var p1 = curvePoints[1];
  32287. var p2 = curvePoints[2];
  32288. var d = Infinity;
  32289. var t;
  32290. var radiusSquare = radius * radius;
  32291. var interval = 0.1;
  32292. for (var _t = 0.1; _t <= 0.9; _t += 0.1) {
  32293. v1[0] = quadraticAt(p0[0], p1[0], p2[0], _t);
  32294. v1[1] = quadraticAt(p0[1], p1[1], p2[1], _t);
  32295. var diff = mathAbs(v2DistSquare(v1, center) - radiusSquare);
  32296. if (diff < d) {
  32297. d = diff;
  32298. t = _t;
  32299. }
  32300. }
  32301. // Assume the segment is monotone,Find root through Bisection method
  32302. // At most 32 iteration
  32303. for (var i = 0; i < 32; i++) {
  32304. // var prev = t - interval;
  32305. var next = t + interval;
  32306. // v1[0] = quadraticAt(p0[0], p1[0], p2[0], prev);
  32307. // v1[1] = quadraticAt(p0[1], p1[1], p2[1], prev);
  32308. v2[0] = quadraticAt(p0[0], p1[0], p2[0], t);
  32309. v2[1] = quadraticAt(p0[1], p1[1], p2[1], t);
  32310. v3[0] = quadraticAt(p0[0], p1[0], p2[0], next);
  32311. v3[1] = quadraticAt(p0[1], p1[1], p2[1], next);
  32312. var diff = v2DistSquare(v2, center) - radiusSquare;
  32313. if (mathAbs(diff) < 1e-2) {
  32314. break;
  32315. }
  32316. // var prevDiff = v2DistSquare(v1, center) - radiusSquare;
  32317. var nextDiff = v2DistSquare(v3, center) - radiusSquare;
  32318. interval /= 2;
  32319. if (diff < 0) {
  32320. if (nextDiff >= 0) {
  32321. t = t + interval;
  32322. }
  32323. else {
  32324. t = t - interval;
  32325. }
  32326. }
  32327. else {
  32328. if (nextDiff >= 0) {
  32329. t = t - interval;
  32330. }
  32331. else {
  32332. t = t + interval;
  32333. }
  32334. }
  32335. }
  32336. return t;
  32337. }
  32338. // Adjust edge to avoid
  32339. module.exports = function (graph, scale) {
  32340. var tmp0 = [];
  32341. var quadraticSubdivide = curveTool.quadraticSubdivide;
  32342. var pts = [[], [], []];
  32343. var pts2 = [[], []];
  32344. var v = [];
  32345. scale /= 2;
  32346. graph.eachEdge(function (edge, idx) {
  32347. var linePoints = edge.getLayout();
  32348. var fromSymbol = edge.getVisual('fromSymbol');
  32349. var toSymbol = edge.getVisual('toSymbol');
  32350. if (!linePoints.__original) {
  32351. linePoints.__original = [
  32352. vec2.clone(linePoints[0]),
  32353. vec2.clone(linePoints[1])
  32354. ];
  32355. if (linePoints[2]) {
  32356. linePoints.__original.push(vec2.clone(linePoints[2]));
  32357. }
  32358. }
  32359. var originalPoints = linePoints.__original;
  32360. // Quadratic curve
  32361. if (linePoints[2] != null) {
  32362. vec2.copy(pts[0], originalPoints[0]);
  32363. vec2.copy(pts[1], originalPoints[2]);
  32364. vec2.copy(pts[2], originalPoints[1]);
  32365. if (fromSymbol && fromSymbol != 'none') {
  32366. var symbolSize = edge.node1.getVisual('symbolSize');
  32367. if (symbolSize instanceof Array) {
  32368. symbolSize = (symbolSize[0] + symbolSize[1]) / 2;
  32369. }
  32370. var t = intersectCurveCircle(pts, originalPoints[0], symbolSize * scale);
  32371. // Subdivide and get the second
  32372. quadraticSubdivide(pts[0][0], pts[1][0], pts[2][0], t, tmp0);
  32373. pts[0][0] = tmp0[3];
  32374. pts[1][0] = tmp0[4];
  32375. quadraticSubdivide(pts[0][1], pts[1][1], pts[2][1], t, tmp0);
  32376. pts[0][1] = tmp0[3];
  32377. pts[1][1] = tmp0[4];
  32378. }
  32379. if (toSymbol && toSymbol != 'none') {
  32380. var symbolSize = edge.node1.getVisual('symbolSize');
  32381. if (symbolSize instanceof Array) {
  32382. symbolSize = (symbolSize[0] + symbolSize[1]) / 2;
  32383. }
  32384. var t = intersectCurveCircle(pts, originalPoints[1], symbolSize * scale);
  32385. // Subdivide and get the first
  32386. quadraticSubdivide(pts[0][0], pts[1][0], pts[2][0], t, tmp0);
  32387. pts[1][0] = tmp0[1];
  32388. pts[2][0] = tmp0[2];
  32389. quadraticSubdivide(pts[0][1], pts[1][1], pts[2][1], t, tmp0);
  32390. pts[1][1] = tmp0[1];
  32391. pts[2][1] = tmp0[2];
  32392. }
  32393. // Copy back to layout
  32394. vec2.copy(linePoints[0], pts[0]);
  32395. vec2.copy(linePoints[1], pts[2]);
  32396. vec2.copy(linePoints[2], pts[1]);
  32397. }
  32398. // Line
  32399. else {
  32400. vec2.copy(pts2[0], originalPoints[0]);
  32401. vec2.copy(pts2[1], originalPoints[1]);
  32402. vec2.sub(v, pts2[1], pts2[0]);
  32403. vec2.normalize(v, v);
  32404. if (fromSymbol && fromSymbol != 'none') {
  32405. vec2.scaleAndAdd(pts2[0], pts2[0], v, edge.node1.getVisual('symbolSize') * scale);
  32406. }
  32407. if (toSymbol && toSymbol != 'none') {
  32408. vec2.scaleAndAdd(pts2[1], pts2[1], v, -edge.node2.getVisual('symbolSize') * scale);
  32409. }
  32410. vec2.copy(linePoints[0], pts2[0]);
  32411. vec2.copy(linePoints[1], pts2[1]);
  32412. }
  32413. });
  32414. };
  32415. /***/ },
  32416. /* 203 */
  32417. /***/ function(module, exports, __webpack_require__) {
  32418. var echarts = __webpack_require__(1);
  32419. var roamHelper = __webpack_require__(177);
  32420. var actionInfo = {
  32421. type: 'graphRoam',
  32422. event: 'graphRoam',
  32423. update: 'none'
  32424. };
  32425. /**
  32426. * @payload
  32427. * @property {string} name Series name
  32428. * @property {number} [dx]
  32429. * @property {number} [dy]
  32430. * @property {number} [zoom]
  32431. * @property {number} [originX]
  32432. * @property {number} [originY]
  32433. */
  32434. echarts.registerAction(actionInfo, function (payload, ecModel) {
  32435. ecModel.eachComponent({mainType: 'series', query: payload}, function (seriesModel) {
  32436. var coordSys = seriesModel.coordinateSystem;
  32437. var res = roamHelper.updateCenterAndZoom(coordSys, payload);
  32438. seriesModel.setCenter
  32439. && seriesModel.setCenter(res.center);
  32440. seriesModel.setZoom
  32441. && seriesModel.setZoom(res.zoom);
  32442. });
  32443. });
  32444. /***/ },
  32445. /* 204 */
  32446. /***/ function(module, exports) {
  32447. module.exports = function (ecModel) {
  32448. var legendModels = ecModel.findComponents({
  32449. mainType: 'legend'
  32450. });
  32451. if (!legendModels || !legendModels.length) {
  32452. return;
  32453. }
  32454. ecModel.eachSeriesByType('graph', function (graphSeries) {
  32455. var categoriesData = graphSeries.getCategoriesData();
  32456. var graph = graphSeries.getGraph();
  32457. var data = graph.data;
  32458. var categoryNames = categoriesData.mapArray(categoriesData.getName);
  32459. data.filterSelf(function (idx) {
  32460. var model = data.getItemModel(idx);
  32461. var category = model.getShallow('category');
  32462. if (category != null) {
  32463. if (typeof category === 'number') {
  32464. category = categoryNames[category];
  32465. }
  32466. // If in any legend component the status is not selected.
  32467. for (var i = 0; i < legendModels.length; i++) {
  32468. if (!legendModels[i].isSelected(category)) {
  32469. return false;
  32470. }
  32471. }
  32472. }
  32473. return true;
  32474. });
  32475. }, this);
  32476. };
  32477. /***/ },
  32478. /* 205 */
  32479. /***/ function(module, exports) {
  32480. module.exports = function (ecModel) {
  32481. ecModel.eachSeriesByType('graph', function (seriesModel) {
  32482. var categoriesData = seriesModel.getCategoriesData();
  32483. var data = seriesModel.getData();
  32484. var categoryNameIdxMap = {};
  32485. categoriesData.each(function (idx) {
  32486. var name = categoriesData.getName(idx);
  32487. categoryNameIdxMap[name] = idx;
  32488. var itemModel = categoriesData.getItemModel(idx);
  32489. var color = itemModel.get('itemStyle.normal.color')
  32490. || seriesModel.getColorFromPalette(name);
  32491. categoriesData.setItemVisual(idx, 'color', color);
  32492. });
  32493. // Assign category color to visual
  32494. if (categoriesData.count()) {
  32495. data.each(function (idx) {
  32496. var model = data.getItemModel(idx);
  32497. var category = model.getShallow('category');
  32498. if (category != null) {
  32499. if (typeof category === 'string') {
  32500. category = categoryNameIdxMap[category];
  32501. }
  32502. if (!data.getItemVisual(idx, 'color', true)) {
  32503. data.setItemVisual(
  32504. idx, 'color',
  32505. categoriesData.getItemVisual(category, 'color')
  32506. );
  32507. }
  32508. }
  32509. });
  32510. }
  32511. });
  32512. };
  32513. /***/ },
  32514. /* 206 */
  32515. /***/ function(module, exports) {
  32516. function normalize(a) {
  32517. if (!(a instanceof Array)) {
  32518. a = [a, a];
  32519. }
  32520. return a;
  32521. }
  32522. module.exports = function (ecModel) {
  32523. ecModel.eachSeriesByType('graph', function (seriesModel) {
  32524. var graph = seriesModel.getGraph();
  32525. var edgeData = seriesModel.getEdgeData();
  32526. var symbolType = normalize(seriesModel.get('edgeSymbol'));
  32527. var symbolSize = normalize(seriesModel.get('edgeSymbolSize'));
  32528. edgeData.setVisual('fromSymbol', symbolType && symbolType[0]);
  32529. edgeData.setVisual('toSymbol', symbolType && symbolType[1]);
  32530. edgeData.setVisual('fromSymbolSize', symbolSize && symbolSize[0]);
  32531. edgeData.setVisual('toSymbolSize', symbolSize && symbolSize[1]);
  32532. edgeData.setVisual('color', seriesModel.get('lineStyle.normal.color'));
  32533. edgeData.each(function (idx) {
  32534. var itemModel = edgeData.getItemModel(idx);
  32535. var edge = graph.getEdgeByIndex(idx);
  32536. var symbolType = normalize(itemModel.getShallow('symbol', true));
  32537. var symbolSize = normalize(itemModel.getShallow('symbolSize', true));
  32538. // Edge visual must after node visual
  32539. var color = itemModel.get('lineStyle.normal.color');
  32540. switch (color) {
  32541. case 'source':
  32542. color = edge.node1.getVisual('color');
  32543. break;
  32544. case 'target':
  32545. color = edge.node2.getVisual('color');
  32546. break;
  32547. }
  32548. symbolType[0] && edge.setVisual('fromSymbol', symbolType[0]);
  32549. symbolType[1] && edge.setVisual('toSymbol', symbolType[1]);
  32550. symbolSize[0] && edge.setVisual('fromSymbolSize', symbolSize[0]);
  32551. symbolSize[1] && edge.setVisual('toSymbolSize', symbolSize[1]);
  32552. edge.setVisual('color', color);
  32553. });
  32554. });
  32555. };
  32556. /***/ },
  32557. /* 207 */
  32558. /***/ function(module, exports, __webpack_require__) {
  32559. var simpleLayoutHelper = __webpack_require__(208);
  32560. var simpleLayoutEdge = __webpack_require__(209);
  32561. module.exports = function (ecModel, api) {
  32562. ecModel.eachSeriesByType('graph', function (seriesModel) {
  32563. var layout = seriesModel.get('layout');
  32564. var coordSys = seriesModel.coordinateSystem;
  32565. if (coordSys && coordSys.type !== 'view') {
  32566. var data = seriesModel.getData();
  32567. data.each(coordSys.dimensions, function (x, y, idx) {
  32568. if (!isNaN(x) && !isNaN(y)) {
  32569. data.setItemLayout(idx, coordSys.dataToPoint([x, y]));
  32570. }
  32571. else {
  32572. // Also {Array.<number>}, not undefined to avoid if...else... statement
  32573. data.setItemLayout(idx, [NaN, NaN]);
  32574. }
  32575. });
  32576. simpleLayoutEdge(data.graph);
  32577. }
  32578. else if (!layout || layout === 'none') {
  32579. simpleLayoutHelper(seriesModel);
  32580. }
  32581. });
  32582. };
  32583. /***/ },
  32584. /* 208 */
  32585. /***/ function(module, exports, __webpack_require__) {
  32586. var simpleLayoutEdge = __webpack_require__(209);
  32587. module.exports = function (seriesModel) {
  32588. var coordSys = seriesModel.coordinateSystem;
  32589. if (coordSys && coordSys.type !== 'view') {
  32590. return;
  32591. }
  32592. var graph = seriesModel.getGraph();
  32593. graph.eachNode(function (node) {
  32594. var model = node.getModel();
  32595. node.setLayout([+model.get('x'), +model.get('y')]);
  32596. });
  32597. simpleLayoutEdge(graph);
  32598. };
  32599. /***/ },
  32600. /* 209 */
  32601. /***/ function(module, exports, __webpack_require__) {
  32602. var vec2 = __webpack_require__(10);
  32603. module.exports = function (graph) {
  32604. graph.eachEdge(function (edge) {
  32605. var curveness = edge.getModel().get('lineStyle.normal.curveness') || 0;
  32606. var p1 = vec2.clone(edge.node1.getLayout());
  32607. var p2 = vec2.clone(edge.node2.getLayout());
  32608. var points = [p1, p2];
  32609. if (curveness > 0) {
  32610. points.push([
  32611. (p1[0] + p2[0]) / 2 - (p1[1] - p2[1]) * curveness,
  32612. (p1[1] + p2[1]) / 2 - (p2[0] - p1[0]) * curveness
  32613. ]);
  32614. }
  32615. edge.setLayout(points);
  32616. });
  32617. };
  32618. /***/ },
  32619. /* 210 */
  32620. /***/ function(module, exports, __webpack_require__) {
  32621. var circularLayoutHelper = __webpack_require__(211);
  32622. module.exports = function (ecModel) {
  32623. ecModel.eachSeriesByType('graph', function (seriesModel) {
  32624. if (seriesModel.get('layout') === 'circular') {
  32625. circularLayoutHelper(seriesModel);
  32626. }
  32627. });
  32628. };
  32629. /***/ },
  32630. /* 211 */
  32631. /***/ function(module, exports, __webpack_require__) {
  32632. var vec2 = __webpack_require__(10);
  32633. module.exports = function (seriesModel) {
  32634. var coordSys = seriesModel.coordinateSystem;
  32635. if (coordSys && coordSys.type !== 'view') {
  32636. return;
  32637. }
  32638. var rect = coordSys.getBoundingRect();
  32639. var nodeData = seriesModel.getData();
  32640. var graph = nodeData.graph;
  32641. var angle = 0;
  32642. var sum = nodeData.getSum('value');
  32643. var unitAngle = Math.PI * 2 / (sum || nodeData.count());
  32644. var cx = rect.width / 2 + rect.x;
  32645. var cy = rect.height / 2 + rect.y;
  32646. var r = Math.min(rect.width, rect.height) / 2;
  32647. graph.eachNode(function (node) {
  32648. var value = node.getValue('value');
  32649. angle += unitAngle * (sum ? value : 2) / 2;
  32650. node.setLayout([
  32651. r * Math.cos(angle) + cx,
  32652. r * Math.sin(angle) + cy
  32653. ]);
  32654. angle += unitAngle * (sum ? value : 2) / 2;
  32655. });
  32656. graph.eachEdge(function (edge) {
  32657. var curveness = edge.getModel().get('lineStyle.normal.curveness') || 0;
  32658. var p1 = vec2.clone(edge.node1.getLayout());
  32659. var p2 = vec2.clone(edge.node2.getLayout());
  32660. var cp1;
  32661. var x12 = (p1[0] + p2[0]) / 2;
  32662. var y12 = (p1[1] + p2[1]) / 2;
  32663. if (curveness > 0) {
  32664. curveness *= 3;
  32665. cp1 = [
  32666. cx * curveness + x12 * (1 - curveness),
  32667. cy * curveness + y12 * (1 - curveness)
  32668. ];
  32669. }
  32670. edge.setLayout([p1, p2, cp1]);
  32671. });
  32672. };
  32673. /***/ },
  32674. /* 212 */
  32675. /***/ function(module, exports, __webpack_require__) {
  32676. var forceHelper = __webpack_require__(213);
  32677. var numberUtil = __webpack_require__(7);
  32678. var simpleLayoutHelper = __webpack_require__(208);
  32679. var circularLayoutHelper = __webpack_require__(211);
  32680. var vec2 = __webpack_require__(10);
  32681. module.exports = function (ecModel) {
  32682. ecModel.eachSeriesByType('graph', function (graphSeries) {
  32683. var coordSys = graphSeries.coordinateSystem;
  32684. if (coordSys && coordSys.type !== 'view') {
  32685. return;
  32686. }
  32687. if (graphSeries.get('layout') === 'force') {
  32688. var preservedPoints = graphSeries.preservedPoints || {};
  32689. var graph = graphSeries.getGraph();
  32690. var nodeData = graph.data;
  32691. var edgeData = graph.edgeData;
  32692. var forceModel = graphSeries.getModel('force');
  32693. var initLayout = forceModel.get('initLayout');
  32694. if (graphSeries.preservedPoints) {
  32695. nodeData.each(function (idx) {
  32696. var id = nodeData.getId(idx);
  32697. nodeData.setItemLayout(idx, preservedPoints[id] || [NaN, NaN]);
  32698. });
  32699. }
  32700. else if (!initLayout || initLayout === 'none') {
  32701. simpleLayoutHelper(graphSeries);
  32702. }
  32703. else if (initLayout === 'circular') {
  32704. circularLayoutHelper(graphSeries);
  32705. }
  32706. var nodeDataExtent = nodeData.getDataExtent('value');
  32707. // var edgeDataExtent = edgeData.getDataExtent('value');
  32708. var repulsion = forceModel.get('repulsion');
  32709. var edgeLength = forceModel.get('edgeLength');
  32710. var nodes = nodeData.mapArray('value', function (value, idx) {
  32711. var point = nodeData.getItemLayout(idx);
  32712. // var w = numberUtil.linearMap(value, nodeDataExtent, [0, 50]);
  32713. var rep = numberUtil.linearMap(value, nodeDataExtent, [0, repulsion]) || (repulsion / 2);
  32714. return {
  32715. w: rep,
  32716. rep: rep,
  32717. p: (!point || isNaN(point[0]) || isNaN(point[1])) ? null : point
  32718. };
  32719. });
  32720. var edges = edgeData.mapArray('value', function (value, idx) {
  32721. var edge = graph.getEdgeByIndex(idx);
  32722. // var w = numberUtil.linearMap(value, edgeDataExtent, [0, 100]);
  32723. return {
  32724. n1: nodes[edge.node1.dataIndex],
  32725. n2: nodes[edge.node2.dataIndex],
  32726. d: edgeLength,
  32727. curveness: edge.getModel().get('lineStyle.normal.curveness') || 0
  32728. };
  32729. });
  32730. var coordSys = graphSeries.coordinateSystem;
  32731. var rect = coordSys.getBoundingRect();
  32732. var forceInstance = forceHelper(nodes, edges, {
  32733. rect: rect,
  32734. gravity: forceModel.get('gravity')
  32735. });
  32736. var oldStep = forceInstance.step;
  32737. forceInstance.step = function (cb) {
  32738. for (var i = 0, l = nodes.length; i < l; i++) {
  32739. if (nodes[i].fixed) {
  32740. // Write back to layout instance
  32741. vec2.copy(nodes[i].p, graph.getNodeByIndex(i).getLayout());
  32742. }
  32743. }
  32744. oldStep(function (nodes, edges, stopped) {
  32745. for (var i = 0, l = nodes.length; i < l; i++) {
  32746. if (!nodes[i].fixed) {
  32747. graph.getNodeByIndex(i).setLayout(nodes[i].p);
  32748. }
  32749. preservedPoints[nodeData.getId(i)] = nodes[i].p;
  32750. }
  32751. for (var i = 0, l = edges.length; i < l; i++) {
  32752. var e = edges[i];
  32753. var edge = graph.getEdgeByIndex(i);
  32754. var p1 = e.n1.p;
  32755. var p2 = e.n2.p;
  32756. var points = edge.getLayout();
  32757. points = points ? points.slice() : [];
  32758. points[0] = points[0] || [];
  32759. points[1] = points[1] || [];
  32760. vec2.copy(points[0], p1);
  32761. vec2.copy(points[1], p2);
  32762. if (e.curveness > 0) {
  32763. points[2] = [
  32764. (p1[0] + p2[0]) / 2 - (p1[1] - p2[1]) * e.curveness,
  32765. (p1[1] + p2[1]) / 2 - (p2[0] - p1[0]) * e.curveness
  32766. ];
  32767. }
  32768. edge.setLayout(points);
  32769. }
  32770. // Update layout
  32771. cb && cb(stopped);
  32772. });
  32773. };
  32774. graphSeries.forceLayout = forceInstance;
  32775. graphSeries.preservedPoints = preservedPoints;
  32776. // Step to get the layout
  32777. forceInstance.step();
  32778. }
  32779. else {
  32780. // Remove prev injected forceLayout instance
  32781. graphSeries.forceLayout = null;
  32782. }
  32783. });
  32784. };
  32785. /***/ },
  32786. /* 213 */
  32787. /***/ function(module, exports, __webpack_require__) {
  32788. var vec2 = __webpack_require__(10);
  32789. var scaleAndAdd = vec2.scaleAndAdd;
  32790. // function adjacentNode(n, e) {
  32791. // return e.n1 === n ? e.n2 : e.n1;
  32792. // }
  32793. module.exports = function (nodes, edges, opts) {
  32794. var rect = opts.rect;
  32795. var width = rect.width;
  32796. var height = rect.height;
  32797. var center = [rect.x + width / 2, rect.y + height / 2];
  32798. // var scale = opts.scale || 1;
  32799. var gravity = opts.gravity == null ? 0.1 : opts.gravity;
  32800. // for (var i = 0; i < edges.length; i++) {
  32801. // var e = edges[i];
  32802. // var n1 = e.n1;
  32803. // var n2 = e.n2;
  32804. // n1.edges = n1.edges || [];
  32805. // n2.edges = n2.edges || [];
  32806. // n1.edges.push(e);
  32807. // n2.edges.push(e);
  32808. // }
  32809. // Init position
  32810. for (var i = 0; i < nodes.length; i++) {
  32811. var n = nodes[i];
  32812. if (!n.p) {
  32813. // Use the position from first adjecent node with defined position
  32814. // Or use a random position
  32815. // From d3
  32816. // if (n.edges) {
  32817. // var j = -1;
  32818. // while (++j < n.edges.length) {
  32819. // var e = n.edges[j];
  32820. // var other = adjacentNode(n, e);
  32821. // if (other.p) {
  32822. // n.p = vec2.clone(other.p);
  32823. // break;
  32824. // }
  32825. // }
  32826. // }
  32827. // if (!n.p) {
  32828. n.p = vec2.create(
  32829. width * (Math.random() - 0.5) + center[0],
  32830. height * (Math.random() - 0.5) + center[1]
  32831. );
  32832. // }
  32833. }
  32834. n.pp = vec2.clone(n.p);
  32835. n.edges = null;
  32836. }
  32837. // Formula in 'Graph Drawing by Force-directed Placement'
  32838. // var k = scale * Math.sqrt(width * height / nodes.length);
  32839. // var k2 = k * k;
  32840. var friction = 0.6;
  32841. return {
  32842. warmUp: function () {
  32843. friction = 0.5;
  32844. },
  32845. setFixed: function (idx) {
  32846. nodes[idx].fixed = true;
  32847. },
  32848. setUnfixed: function (idx) {
  32849. nodes[idx].fixed = false;
  32850. },
  32851. step: function (cb) {
  32852. var v12 = [];
  32853. var nLen = nodes.length;
  32854. for (var i = 0; i < edges.length; i++) {
  32855. var e = edges[i];
  32856. var n1 = e.n1;
  32857. var n2 = e.n2;
  32858. vec2.sub(v12, n2.p, n1.p);
  32859. var d = vec2.len(v12) - e.d;
  32860. var w = n2.w / (n1.w + n2.w);
  32861. vec2.normalize(v12, v12);
  32862. !n1.fixed && scaleAndAdd(n1.p, n1.p, v12, w * d * friction);
  32863. !n2.fixed && scaleAndAdd(n2.p, n2.p, v12, -(1 - w) * d * friction);
  32864. }
  32865. // Gravity
  32866. for (var i = 0; i < nLen; i++) {
  32867. var n = nodes[i];
  32868. if (!n.fixed) {
  32869. vec2.sub(v12, center, n.p);
  32870. // var d = vec2.len(v12);
  32871. // vec2.scale(v12, v12, 1 / d);
  32872. // var gravityFactor = gravity;
  32873. vec2.scaleAndAdd(n.p, n.p, v12, gravity * friction);
  32874. }
  32875. }
  32876. // Repulsive
  32877. // PENDING
  32878. for (var i = 0; i < nLen; i++) {
  32879. var n1 = nodes[i];
  32880. for (var j = i + 1; j < nLen; j++) {
  32881. var n2 = nodes[j];
  32882. vec2.sub(v12, n2.p, n1.p);
  32883. var d = vec2.len(v12);
  32884. if (d === 0) {
  32885. // Random repulse
  32886. vec2.set(v12, Math.random() - 0.5, Math.random() - 0.5);
  32887. d = 1;
  32888. }
  32889. var repFact = (n1.rep + n2.rep) / d / d;
  32890. !n1.fixed && scaleAndAdd(n1.pp, n1.pp, v12, repFact);
  32891. !n2.fixed && scaleAndAdd(n2.pp, n2.pp, v12, -repFact);
  32892. }
  32893. }
  32894. var v = [];
  32895. for (var i = 0; i < nLen; i++) {
  32896. var n = nodes[i];
  32897. if (!n.fixed) {
  32898. vec2.sub(v, n.p, n.pp);
  32899. vec2.scaleAndAdd(n.p, n.p, v, friction);
  32900. vec2.copy(n.pp, n.p);
  32901. }
  32902. }
  32903. friction = friction * 0.992;
  32904. cb && cb(nodes, edges, friction < 0.01);
  32905. }
  32906. };
  32907. };
  32908. /***/ },
  32909. /* 214 */
  32910. /***/ function(module, exports, __webpack_require__) {
  32911. // FIXME Where to create the simple view coordinate system
  32912. var View = __webpack_require__(168);
  32913. var layout = __webpack_require__(21);
  32914. var bbox = __webpack_require__(51);
  32915. function getViewRect(seriesModel, api, aspect) {
  32916. var option = seriesModel.getBoxLayoutParams();
  32917. option.aspect = aspect;
  32918. return layout.getLayoutRect(option, {
  32919. width: api.getWidth(),
  32920. height: api.getHeight()
  32921. });
  32922. }
  32923. module.exports = function (ecModel, api) {
  32924. var viewList = [];
  32925. ecModel.eachSeriesByType('graph', function (seriesModel) {
  32926. var coordSysType = seriesModel.get('coordinateSystem');
  32927. if (!coordSysType || coordSysType === 'view') {
  32928. var viewCoordSys = new View();
  32929. viewList.push(viewCoordSys);
  32930. var data = seriesModel.getData();
  32931. var positions = data.mapArray(function (idx) {
  32932. var itemModel = data.getItemModel(idx);
  32933. return [+itemModel.get('x'), +itemModel.get('y')];
  32934. });
  32935. var min = [];
  32936. var max = [];
  32937. bbox.fromPoints(positions, min, max);
  32938. // If width or height is 0
  32939. if (max[0] - min[0] === 0) {
  32940. max[0] += 1;
  32941. min[0] -= 1;
  32942. }
  32943. if (max[1] - min[1] === 0) {
  32944. max[1] += 1;
  32945. min[1] -= 1;
  32946. }
  32947. var aspect = (max[0] - min[0]) / (max[1] - min[1]);
  32948. // FIXME If get view rect after data processed?
  32949. var viewRect = getViewRect(seriesModel, api, aspect);
  32950. // Position may be NaN, use view rect instead
  32951. if (isNaN(aspect)) {
  32952. min = [viewRect.x, viewRect.y];
  32953. max = [viewRect.x + viewRect.width, viewRect.y + viewRect.height];
  32954. }
  32955. var bbWidth = max[0] - min[0];
  32956. var bbHeight = max[1] - min[1];
  32957. var viewWidth = viewRect.width;
  32958. var viewHeight = viewRect.height;
  32959. viewCoordSys = seriesModel.coordinateSystem = new View();
  32960. viewCoordSys.zoomLimit = seriesModel.get('scaleLimit');
  32961. viewCoordSys.setBoundingRect(
  32962. min[0], min[1], bbWidth, bbHeight
  32963. );
  32964. viewCoordSys.setViewRect(
  32965. viewRect.x, viewRect.y, viewWidth, viewHeight
  32966. );
  32967. // Update roam info
  32968. viewCoordSys.setCenter(seriesModel.get('center'));
  32969. viewCoordSys.setZoom(seriesModel.get('zoom'));
  32970. }
  32971. });
  32972. return viewList;
  32973. };
  32974. /***/ },
  32975. /* 215 */
  32976. /***/ function(module, exports, __webpack_require__) {
  32977. __webpack_require__(216);
  32978. __webpack_require__(217);
  32979. /***/ },
  32980. /* 216 */
  32981. /***/ function(module, exports, __webpack_require__) {
  32982. var List = __webpack_require__(97);
  32983. var SeriesModel = __webpack_require__(28);
  32984. var zrUtil = __webpack_require__(4);
  32985. var GaugeSeries = SeriesModel.extend({
  32986. type: 'series.gauge',
  32987. getInitialData: function (option, ecModel) {
  32988. var list = new List(['value'], this);
  32989. var dataOpt = option.data || [];
  32990. if (!zrUtil.isArray(dataOpt)) {
  32991. dataOpt = [dataOpt];
  32992. }
  32993. // Only use the first data item
  32994. list.initData(dataOpt);
  32995. return list;
  32996. },
  32997. defaultOption: {
  32998. zlevel: 0,
  32999. z: 2,
  33000. // 默认全局居中
  33001. center: ['50%', '50%'],
  33002. legendHoverLink: true,
  33003. radius: '75%',
  33004. startAngle: 225,
  33005. endAngle: -45,
  33006. clockwise: true,
  33007. // 最小值
  33008. min: 0,
  33009. // 最大值
  33010. max: 100,
  33011. // 分割段数,默认为10
  33012. splitNumber: 10,
  33013. // 坐标轴线
  33014. axisLine: {
  33015. // 默认显示,属性show控制显示与否
  33016. show: true,
  33017. lineStyle: { // 属性lineStyle控制线条样式
  33018. color: [[0.2, '#91c7ae'], [0.8, '#63869e'], [1, '#c23531']],
  33019. width: 30
  33020. }
  33021. },
  33022. // 分隔线
  33023. splitLine: {
  33024. // 默认显示,属性show控制显示与否
  33025. show: true,
  33026. // 属性length控制线长
  33027. length: 30,
  33028. // 属性lineStyle(详见lineStyle)控制线条样式
  33029. lineStyle: {
  33030. color: '#eee',
  33031. width: 2,
  33032. type: 'solid'
  33033. }
  33034. },
  33035. // 坐标轴小标记
  33036. axisTick: {
  33037. // 属性show控制显示与否,默认不显示
  33038. show: true,
  33039. // 每份split细分多少段
  33040. splitNumber: 5,
  33041. // 属性length控制线长
  33042. length: 8,
  33043. // 属性lineStyle控制线条样式
  33044. lineStyle: {
  33045. color: '#eee',
  33046. width: 1,
  33047. type: 'solid'
  33048. }
  33049. },
  33050. axisLabel: {
  33051. show: true,
  33052. distance: 5,
  33053. // formatter: null,
  33054. textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  33055. color: 'auto'
  33056. }
  33057. },
  33058. pointer: {
  33059. show: true,
  33060. length: '80%',
  33061. width: 8
  33062. },
  33063. itemStyle: {
  33064. normal: {
  33065. color: 'auto'
  33066. }
  33067. },
  33068. title: {
  33069. show: true,
  33070. // x, y,单位px
  33071. offsetCenter: [0, '-40%'],
  33072. // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  33073. textStyle: {
  33074. color: '#333',
  33075. fontSize: 15
  33076. }
  33077. },
  33078. detail: {
  33079. show: true,
  33080. backgroundColor: 'rgba(0,0,0,0)',
  33081. borderWidth: 0,
  33082. borderColor: '#ccc',
  33083. width: 100,
  33084. height: 40,
  33085. // x, y,单位px
  33086. offsetCenter: [0, '40%'],
  33087. // formatter: null,
  33088. // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  33089. textStyle: {
  33090. color: 'auto',
  33091. fontSize: 30
  33092. }
  33093. }
  33094. }
  33095. });
  33096. module.exports = GaugeSeries;
  33097. /***/ },
  33098. /* 217 */
  33099. /***/ function(module, exports, __webpack_require__) {
  33100. var PointerPath = __webpack_require__(218);
  33101. var graphic = __webpack_require__(43);
  33102. var numberUtil = __webpack_require__(7);
  33103. var parsePercent = numberUtil.parsePercent;
  33104. function parsePosition(seriesModel, api) {
  33105. var center = seriesModel.get('center');
  33106. var width = api.getWidth();
  33107. var height = api.getHeight();
  33108. var size = Math.min(width, height);
  33109. var cx = parsePercent(center[0], api.getWidth());
  33110. var cy = parsePercent(center[1], api.getHeight());
  33111. var r = parsePercent(seriesModel.get('radius'), size / 2);
  33112. return {
  33113. cx: cx,
  33114. cy: cy,
  33115. r: r
  33116. };
  33117. }
  33118. function formatLabel(label, labelFormatter) {
  33119. if (labelFormatter) {
  33120. if (typeof labelFormatter === 'string') {
  33121. label = labelFormatter.replace('{value}', label);
  33122. }
  33123. else if (typeof labelFormatter === 'function') {
  33124. label = labelFormatter(label);
  33125. }
  33126. }
  33127. return label;
  33128. }
  33129. var PI2 = Math.PI * 2;
  33130. var GaugeView = __webpack_require__(42).extend({
  33131. type: 'gauge',
  33132. render: function (seriesModel, ecModel, api) {
  33133. this.group.removeAll();
  33134. var colorList = seriesModel.get('axisLine.lineStyle.color');
  33135. var posInfo = parsePosition(seriesModel, api);
  33136. this._renderMain(
  33137. seriesModel, ecModel, api, colorList, posInfo
  33138. );
  33139. },
  33140. _renderMain: function (seriesModel, ecModel, api, colorList, posInfo) {
  33141. var group = this.group;
  33142. var axisLineModel = seriesModel.getModel('axisLine');
  33143. var lineStyleModel = axisLineModel.getModel('lineStyle');
  33144. var clockwise = seriesModel.get('clockwise');
  33145. var startAngle = -seriesModel.get('startAngle') / 180 * Math.PI;
  33146. var endAngle = -seriesModel.get('endAngle') / 180 * Math.PI;
  33147. var angleRangeSpan = (endAngle - startAngle) % PI2;
  33148. var prevEndAngle = startAngle;
  33149. var axisLineWidth = lineStyleModel.get('width');
  33150. for (var i = 0; i < colorList.length; i++) {
  33151. // Clamp
  33152. var percent = Math.min(Math.max(colorList[i][0], 0), 1);
  33153. var endAngle = startAngle + angleRangeSpan * percent;
  33154. var sector = new graphic.Sector({
  33155. shape: {
  33156. startAngle: prevEndAngle,
  33157. endAngle: endAngle,
  33158. cx: posInfo.cx,
  33159. cy: posInfo.cy,
  33160. clockwise: clockwise,
  33161. r0: posInfo.r - axisLineWidth,
  33162. r: posInfo.r
  33163. },
  33164. silent: true
  33165. });
  33166. sector.setStyle({
  33167. fill: colorList[i][1]
  33168. });
  33169. sector.setStyle(lineStyleModel.getLineStyle(
  33170. // Because we use sector to simulate arc
  33171. // so the properties for stroking are useless
  33172. ['color', 'borderWidth', 'borderColor']
  33173. ));
  33174. group.add(sector);
  33175. prevEndAngle = endAngle;
  33176. }
  33177. var getColor = function (percent) {
  33178. // Less than 0
  33179. if (percent <= 0) {
  33180. return colorList[0][1];
  33181. }
  33182. for (var i = 0; i < colorList.length; i++) {
  33183. if (colorList[i][0] >= percent
  33184. && (i === 0 ? 0 : colorList[i - 1][0]) < percent
  33185. ) {
  33186. return colorList[i][1];
  33187. }
  33188. }
  33189. // More than 1
  33190. return colorList[i - 1][1];
  33191. };
  33192. if (!clockwise) {
  33193. var tmp = startAngle;
  33194. startAngle = endAngle;
  33195. endAngle = tmp;
  33196. }
  33197. this._renderTicks(
  33198. seriesModel, ecModel, api, getColor, posInfo,
  33199. startAngle, endAngle, clockwise
  33200. );
  33201. this._renderPointer(
  33202. seriesModel, ecModel, api, getColor, posInfo,
  33203. startAngle, endAngle, clockwise
  33204. );
  33205. this._renderTitle(
  33206. seriesModel, ecModel, api, getColor, posInfo
  33207. );
  33208. this._renderDetail(
  33209. seriesModel, ecModel, api, getColor, posInfo
  33210. );
  33211. },
  33212. _renderTicks: function (
  33213. seriesModel, ecModel, api, getColor, posInfo,
  33214. startAngle, endAngle, clockwise
  33215. ) {
  33216. var group = this.group;
  33217. var cx = posInfo.cx;
  33218. var cy = posInfo.cy;
  33219. var r = posInfo.r;
  33220. var minVal = seriesModel.get('min');
  33221. var maxVal = seriesModel.get('max');
  33222. var splitLineModel = seriesModel.getModel('splitLine');
  33223. var tickModel = seriesModel.getModel('axisTick');
  33224. var labelModel = seriesModel.getModel('axisLabel');
  33225. var splitNumber = seriesModel.get('splitNumber');
  33226. var subSplitNumber = tickModel.get('splitNumber');
  33227. var splitLineLen = parsePercent(
  33228. splitLineModel.get('length'), r
  33229. );
  33230. var tickLen = parsePercent(
  33231. tickModel.get('length'), r
  33232. );
  33233. var angle = startAngle;
  33234. var step = (endAngle - startAngle) / splitNumber;
  33235. var subStep = step / subSplitNumber;
  33236. var splitLineStyle = splitLineModel.getModel('lineStyle').getLineStyle();
  33237. var tickLineStyle = tickModel.getModel('lineStyle').getLineStyle();
  33238. var textStyleModel = labelModel.getModel('textStyle');
  33239. for (var i = 0; i <= splitNumber; i++) {
  33240. var unitX = Math.cos(angle);
  33241. var unitY = Math.sin(angle);
  33242. // Split line
  33243. if (splitLineModel.get('show')) {
  33244. var splitLine = new graphic.Line({
  33245. shape: {
  33246. x1: unitX * r + cx,
  33247. y1: unitY * r + cy,
  33248. x2: unitX * (r - splitLineLen) + cx,
  33249. y2: unitY * (r - splitLineLen) + cy
  33250. },
  33251. style: splitLineStyle,
  33252. silent: true
  33253. });
  33254. if (splitLineStyle.stroke === 'auto') {
  33255. splitLine.setStyle({
  33256. stroke: getColor(i / splitNumber)
  33257. });
  33258. }
  33259. group.add(splitLine);
  33260. }
  33261. // Label
  33262. if (labelModel.get('show')) {
  33263. var label = formatLabel(
  33264. numberUtil.round(i / splitNumber * (maxVal - minVal) + minVal),
  33265. labelModel.get('formatter')
  33266. );
  33267. var distance = labelModel.get('distance');
  33268. var text = new graphic.Text({
  33269. style: {
  33270. text: label,
  33271. x: unitX * (r - splitLineLen - distance) + cx,
  33272. y: unitY * (r - splitLineLen - distance) + cy,
  33273. fill: textStyleModel.getTextColor(),
  33274. textFont: textStyleModel.getFont(),
  33275. textVerticalAlign: unitY < -0.4 ? 'top' : (unitY > 0.4 ? 'bottom' : 'middle'),
  33276. textAlign: unitX < -0.4 ? 'left' : (unitX > 0.4 ? 'right' : 'center')
  33277. },
  33278. silent: true
  33279. });
  33280. if (text.style.fill === 'auto') {
  33281. text.setStyle({
  33282. fill: getColor(i / splitNumber)
  33283. });
  33284. }
  33285. group.add(text);
  33286. }
  33287. // Axis tick
  33288. if (tickModel.get('show') && i !== splitNumber) {
  33289. for (var j = 0; j <= subSplitNumber; j++) {
  33290. var unitX = Math.cos(angle);
  33291. var unitY = Math.sin(angle);
  33292. var tickLine = new graphic.Line({
  33293. shape: {
  33294. x1: unitX * r + cx,
  33295. y1: unitY * r + cy,
  33296. x2: unitX * (r - tickLen) + cx,
  33297. y2: unitY * (r - tickLen) + cy
  33298. },
  33299. silent: true,
  33300. style: tickLineStyle
  33301. });
  33302. if (tickLineStyle.stroke === 'auto') {
  33303. tickLine.setStyle({
  33304. stroke: getColor((i + j / subSplitNumber) / splitNumber)
  33305. });
  33306. }
  33307. group.add(tickLine);
  33308. angle += subStep;
  33309. }
  33310. angle -= subStep;
  33311. }
  33312. else {
  33313. angle += step;
  33314. }
  33315. }
  33316. },
  33317. _renderPointer: function (
  33318. seriesModel, ecModel, api, getColor, posInfo,
  33319. startAngle, endAngle, clockwise
  33320. ) {
  33321. var valueExtent = [+seriesModel.get('min'), +seriesModel.get('max')];
  33322. var angleExtent = [startAngle, endAngle];
  33323. if (!clockwise) {
  33324. angleExtent = angleExtent.reverse();
  33325. }
  33326. var data = seriesModel.getData();
  33327. var oldData = this._data;
  33328. var group = this.group;
  33329. data.diff(oldData)
  33330. .add(function (idx) {
  33331. var pointer = new PointerPath({
  33332. shape: {
  33333. angle: startAngle
  33334. }
  33335. });
  33336. graphic.updateProps(pointer, {
  33337. shape: {
  33338. angle: numberUtil.linearMap(data.get('value', idx), valueExtent, angleExtent, true)
  33339. }
  33340. }, seriesModel);
  33341. group.add(pointer);
  33342. data.setItemGraphicEl(idx, pointer);
  33343. })
  33344. .update(function (newIdx, oldIdx) {
  33345. var pointer = oldData.getItemGraphicEl(oldIdx);
  33346. graphic.updateProps(pointer, {
  33347. shape: {
  33348. angle: numberUtil.linearMap(data.get('value', newIdx), valueExtent, angleExtent, true)
  33349. }
  33350. }, seriesModel);
  33351. group.add(pointer);
  33352. data.setItemGraphicEl(newIdx, pointer);
  33353. })
  33354. .remove(function (idx) {
  33355. var pointer = oldData.getItemGraphicEl(idx);
  33356. group.remove(pointer);
  33357. })
  33358. .execute();
  33359. data.eachItemGraphicEl(function (pointer, idx) {
  33360. var itemModel = data.getItemModel(idx);
  33361. var pointerModel = itemModel.getModel('pointer');
  33362. pointer.setShape({
  33363. x: posInfo.cx,
  33364. y: posInfo.cy,
  33365. width: parsePercent(
  33366. pointerModel.get('width'), posInfo.r
  33367. ),
  33368. r: parsePercent(pointerModel.get('length'), posInfo.r)
  33369. });
  33370. pointer.useStyle(itemModel.getModel('itemStyle.normal').getItemStyle());
  33371. if (pointer.style.fill === 'auto') {
  33372. pointer.setStyle('fill', getColor(
  33373. (data.get('value', idx) - valueExtent[0]) / (valueExtent[1] - valueExtent[0])
  33374. ));
  33375. }
  33376. graphic.setHoverStyle(
  33377. pointer, itemModel.getModel('itemStyle.emphasis').getItemStyle()
  33378. );
  33379. });
  33380. this._data = data;
  33381. },
  33382. _renderTitle: function (
  33383. seriesModel, ecModel, api, getColor, posInfo
  33384. ) {
  33385. var titleModel = seriesModel.getModel('title');
  33386. if (titleModel.get('show')) {
  33387. var textStyleModel = titleModel.getModel('textStyle');
  33388. var offsetCenter = titleModel.get('offsetCenter');
  33389. var x = posInfo.cx + parsePercent(offsetCenter[0], posInfo.r);
  33390. var y = posInfo.cy + parsePercent(offsetCenter[1], posInfo.r);
  33391. var text = new graphic.Text({
  33392. style: {
  33393. x: x,
  33394. y: y,
  33395. // FIXME First data name ?
  33396. text: seriesModel.getData().getName(0),
  33397. fill: textStyleModel.getTextColor(),
  33398. textFont: textStyleModel.getFont(),
  33399. textAlign: 'center',
  33400. textVerticalAlign: 'middle'
  33401. }
  33402. });
  33403. this.group.add(text);
  33404. }
  33405. },
  33406. _renderDetail: function (
  33407. seriesModel, ecModel, api, getColor, posInfo
  33408. ) {
  33409. var detailModel = seriesModel.getModel('detail');
  33410. var minVal = seriesModel.get('min');
  33411. var maxVal = seriesModel.get('max');
  33412. if (detailModel.get('show')) {
  33413. var textStyleModel = detailModel.getModel('textStyle');
  33414. var offsetCenter = detailModel.get('offsetCenter');
  33415. var x = posInfo.cx + parsePercent(offsetCenter[0], posInfo.r);
  33416. var y = posInfo.cy + parsePercent(offsetCenter[1], posInfo.r);
  33417. var width = parsePercent(detailModel.get('width'), posInfo.r);
  33418. var height = parsePercent(detailModel.get('height'), posInfo.r);
  33419. var value = seriesModel.getData().get('value', 0);
  33420. var rect = new graphic.Rect({
  33421. shape: {
  33422. x: x - width / 2,
  33423. y: y - height / 2,
  33424. width: width,
  33425. height: height
  33426. },
  33427. style: {
  33428. text: formatLabel(
  33429. // FIXME First data name ?
  33430. value, detailModel.get('formatter')
  33431. ),
  33432. fill: detailModel.get('backgroundColor'),
  33433. textFill: textStyleModel.getTextColor(),
  33434. textFont: textStyleModel.getFont()
  33435. }
  33436. });
  33437. if (rect.style.textFill === 'auto') {
  33438. rect.setStyle('textFill', getColor(
  33439. numberUtil.linearMap(value, [minVal, maxVal], [0, 1], true)
  33440. ));
  33441. }
  33442. rect.setStyle(detailModel.getItemStyle(['color']));
  33443. this.group.add(rect);
  33444. }
  33445. }
  33446. });
  33447. module.exports = GaugeView;
  33448. /***/ },
  33449. /* 218 */
  33450. /***/ function(module, exports, __webpack_require__) {
  33451. module.exports = __webpack_require__(45).extend({
  33452. type: 'echartsGaugePointer',
  33453. shape: {
  33454. angle: 0,
  33455. width: 10,
  33456. r: 10,
  33457. x: 0,
  33458. y: 0
  33459. },
  33460. buildPath: function (ctx, shape) {
  33461. var mathCos = Math.cos;
  33462. var mathSin = Math.sin;
  33463. var r = shape.r;
  33464. var width = shape.width;
  33465. var angle = shape.angle;
  33466. var x = shape.x - mathCos(angle) * width * (width >= r / 3 ? 1 : 2);
  33467. var y = shape.y - mathSin(angle) * width * (width >= r / 3 ? 1 : 2);
  33468. angle = shape.angle - Math.PI / 2;
  33469. ctx.moveTo(x, y);
  33470. ctx.lineTo(
  33471. shape.x + mathCos(angle) * width,
  33472. shape.y + mathSin(angle) * width
  33473. );
  33474. ctx.lineTo(
  33475. shape.x + mathCos(shape.angle) * r,
  33476. shape.y + mathSin(shape.angle) * r
  33477. );
  33478. ctx.lineTo(
  33479. shape.x - mathCos(angle) * width,
  33480. shape.y - mathSin(angle) * width
  33481. );
  33482. ctx.lineTo(x, y);
  33483. return;
  33484. }
  33485. });
  33486. /***/ },
  33487. /* 219 */
  33488. /***/ function(module, exports, __webpack_require__) {
  33489. var zrUtil = __webpack_require__(4);
  33490. var echarts = __webpack_require__(1);
  33491. __webpack_require__(220);
  33492. __webpack_require__(221);
  33493. echarts.registerVisual(zrUtil.curry(__webpack_require__(143), 'funnel'));
  33494. echarts.registerLayout(__webpack_require__(222));
  33495. echarts.registerProcessor(zrUtil.curry(__webpack_require__(146), 'funnel'));
  33496. /***/ },
  33497. /* 220 */
  33498. /***/ function(module, exports, __webpack_require__) {
  33499. 'use strict';
  33500. var List = __webpack_require__(97);
  33501. var modelUtil = __webpack_require__(5);
  33502. var completeDimensions = __webpack_require__(102);
  33503. var FunnelSeries = __webpack_require__(1).extendSeriesModel({
  33504. type: 'series.funnel',
  33505. init: function (option) {
  33506. FunnelSeries.superApply(this, 'init', arguments);
  33507. // Enable legend selection for each data item
  33508. // Use a function instead of direct access because data reference may changed
  33509. this.legendDataProvider = function () {
  33510. return this._dataBeforeProcessed;
  33511. };
  33512. // Extend labelLine emphasis
  33513. this._defaultLabelLine(option);
  33514. },
  33515. getInitialData: function (option, ecModel) {
  33516. var dimensions = completeDimensions(['value'], option.data);
  33517. var list = new List(dimensions, this);
  33518. list.initData(option.data);
  33519. return list;
  33520. },
  33521. _defaultLabelLine: function (option) {
  33522. // Extend labelLine emphasis
  33523. modelUtil.defaultEmphasis(option.labelLine, ['show']);
  33524. var labelLineNormalOpt = option.labelLine.normal;
  33525. var labelLineEmphasisOpt = option.labelLine.emphasis;
  33526. // Not show label line if `label.normal.show = false`
  33527. labelLineNormalOpt.show = labelLineNormalOpt.show
  33528. && option.label.normal.show;
  33529. labelLineEmphasisOpt.show = labelLineEmphasisOpt.show
  33530. && option.label.emphasis.show;
  33531. },
  33532. defaultOption: {
  33533. zlevel: 0, // 一级层叠
  33534. z: 2, // 二级层叠
  33535. legendHoverLink: true,
  33536. left: 80,
  33537. top: 60,
  33538. right: 80,
  33539. bottom: 60,
  33540. // width: {totalWidth} - left - right,
  33541. // height: {totalHeight} - top - bottom,
  33542. // 默认取数据最小最大值
  33543. // min: 0,
  33544. // max: 100,
  33545. minSize: '0%',
  33546. maxSize: '100%',
  33547. sort: 'descending', // 'ascending', 'descending'
  33548. gap: 0,
  33549. funnelAlign: 'center',
  33550. label: {
  33551. normal: {
  33552. show: true,
  33553. position: 'outer'
  33554. // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  33555. // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
  33556. },
  33557. emphasis: {
  33558. show: true
  33559. }
  33560. },
  33561. labelLine: {
  33562. normal: {
  33563. show: true,
  33564. length: 20,
  33565. lineStyle: {
  33566. // color: 各异,
  33567. width: 1,
  33568. type: 'solid'
  33569. }
  33570. },
  33571. emphasis: {}
  33572. },
  33573. itemStyle: {
  33574. normal: {
  33575. // color: 各异,
  33576. borderColor: '#fff',
  33577. borderWidth: 1
  33578. },
  33579. emphasis: {
  33580. // color: 各异,
  33581. }
  33582. }
  33583. }
  33584. });
  33585. module.exports = FunnelSeries;
  33586. /***/ },
  33587. /* 221 */
  33588. /***/ function(module, exports, __webpack_require__) {
  33589. var graphic = __webpack_require__(43);
  33590. var zrUtil = __webpack_require__(4);
  33591. /**
  33592. * Piece of pie including Sector, Label, LabelLine
  33593. * @constructor
  33594. * @extends {module:zrender/graphic/Group}
  33595. */
  33596. function FunnelPiece(data, idx) {
  33597. graphic.Group.call(this);
  33598. var polygon = new graphic.Polygon();
  33599. var labelLine = new graphic.Polyline();
  33600. var text = new graphic.Text();
  33601. this.add(polygon);
  33602. this.add(labelLine);
  33603. this.add(text);
  33604. this.updateData(data, idx, true);
  33605. // Hover to change label and labelLine
  33606. function onEmphasis() {
  33607. labelLine.ignore = labelLine.hoverIgnore;
  33608. text.ignore = text.hoverIgnore;
  33609. }
  33610. function onNormal() {
  33611. labelLine.ignore = labelLine.normalIgnore;
  33612. text.ignore = text.normalIgnore;
  33613. }
  33614. this.on('emphasis', onEmphasis)
  33615. .on('normal', onNormal)
  33616. .on('mouseover', onEmphasis)
  33617. .on('mouseout', onNormal);
  33618. }
  33619. var funnelPieceProto = FunnelPiece.prototype;
  33620. function getLabelStyle(data, idx, state, labelModel) {
  33621. var textStyleModel = labelModel.getModel('textStyle');
  33622. var position = labelModel.get('position');
  33623. var isLabelInside = position === 'inside' || position === 'inner' || position === 'center';
  33624. return {
  33625. fill: textStyleModel.getTextColor()
  33626. || (isLabelInside ? '#fff' : data.getItemVisual(idx, 'color')),
  33627. textFont: textStyleModel.getFont(),
  33628. text: zrUtil.retrieve(
  33629. data.hostModel.getFormattedLabel(idx, state),
  33630. data.getName(idx)
  33631. )
  33632. };
  33633. }
  33634. var opacityAccessPath = ['itemStyle', 'normal', 'opacity'];
  33635. funnelPieceProto.updateData = function (data, idx, firstCreate) {
  33636. var polygon = this.childAt(0);
  33637. var seriesModel = data.hostModel;
  33638. var itemModel = data.getItemModel(idx);
  33639. var layout = data.getItemLayout(idx);
  33640. var opacity = data.getItemModel(idx).get(opacityAccessPath);
  33641. opacity = opacity == null ? 1 : opacity;
  33642. // Reset style
  33643. polygon.useStyle({});
  33644. if (firstCreate) {
  33645. polygon.setShape({
  33646. points: layout.points
  33647. });
  33648. polygon.setStyle({ opacity : 0 });
  33649. graphic.initProps(polygon, {
  33650. style: {
  33651. opacity: opacity
  33652. }
  33653. }, seriesModel, idx);
  33654. }
  33655. else {
  33656. graphic.updateProps(polygon, {
  33657. style: {
  33658. opacity: opacity
  33659. },
  33660. shape: {
  33661. points: layout.points
  33662. }
  33663. }, seriesModel, idx);
  33664. }
  33665. // Update common style
  33666. var itemStyleModel = itemModel.getModel('itemStyle');
  33667. var visualColor = data.getItemVisual(idx, 'color');
  33668. polygon.setStyle(
  33669. zrUtil.defaults(
  33670. {
  33671. lineJoin: 'round',
  33672. fill: visualColor
  33673. },
  33674. itemStyleModel.getModel('normal').getItemStyle(['opacity'])
  33675. )
  33676. );
  33677. polygon.hoverStyle = itemStyleModel.getModel('emphasis').getItemStyle();
  33678. this._updateLabel(data, idx);
  33679. graphic.setHoverStyle(this);
  33680. };
  33681. funnelPieceProto._updateLabel = function (data, idx) {
  33682. var labelLine = this.childAt(1);
  33683. var labelText = this.childAt(2);
  33684. var seriesModel = data.hostModel;
  33685. var itemModel = data.getItemModel(idx);
  33686. var layout = data.getItemLayout(idx);
  33687. var labelLayout = layout.label;
  33688. var visualColor = data.getItemVisual(idx, 'color');
  33689. graphic.updateProps(labelLine, {
  33690. shape: {
  33691. points: labelLayout.linePoints || labelLayout.linePoints
  33692. }
  33693. }, seriesModel, idx);
  33694. graphic.updateProps(labelText, {
  33695. style: {
  33696. x: labelLayout.x,
  33697. y: labelLayout.y
  33698. }
  33699. }, seriesModel, idx);
  33700. labelText.attr({
  33701. style: {
  33702. textAlign: labelLayout.textAlign,
  33703. textVerticalAlign: labelLayout.verticalAlign,
  33704. textFont: labelLayout.font
  33705. },
  33706. rotation: labelLayout.rotation,
  33707. origin: [labelLayout.x, labelLayout.y],
  33708. z2: 10
  33709. });
  33710. var labelModel = itemModel.getModel('label.normal');
  33711. var labelHoverModel = itemModel.getModel('label.emphasis');
  33712. var labelLineModel = itemModel.getModel('labelLine.normal');
  33713. var labelLineHoverModel = itemModel.getModel('labelLine.emphasis');
  33714. labelText.setStyle(getLabelStyle(data, idx, 'normal', labelModel));
  33715. labelText.ignore = labelText.normalIgnore = !labelModel.get('show');
  33716. labelText.hoverIgnore = !labelHoverModel.get('show');
  33717. labelLine.ignore = labelLine.normalIgnore = !labelLineModel.get('show');
  33718. labelLine.hoverIgnore = !labelLineHoverModel.get('show');
  33719. // Default use item visual color
  33720. labelLine.setStyle({
  33721. stroke: visualColor
  33722. });
  33723. labelLine.setStyle(labelLineModel.getModel('lineStyle').getLineStyle());
  33724. labelText.hoverStyle = getLabelStyle(data, idx, 'emphasis', labelHoverModel);
  33725. labelLine.hoverStyle = labelLineHoverModel.getModel('lineStyle').getLineStyle();
  33726. };
  33727. zrUtil.inherits(FunnelPiece, graphic.Group);
  33728. var Funnel = __webpack_require__(42).extend({
  33729. type: 'funnel',
  33730. render: function (seriesModel, ecModel, api) {
  33731. var data = seriesModel.getData();
  33732. var oldData = this._data;
  33733. var group = this.group;
  33734. data.diff(oldData)
  33735. .add(function (idx) {
  33736. var funnelPiece = new FunnelPiece(data, idx);
  33737. data.setItemGraphicEl(idx, funnelPiece);
  33738. group.add(funnelPiece);
  33739. })
  33740. .update(function (newIdx, oldIdx) {
  33741. var piePiece = oldData.getItemGraphicEl(oldIdx);
  33742. piePiece.updateData(data, newIdx);
  33743. group.add(piePiece);
  33744. data.setItemGraphicEl(newIdx, piePiece);
  33745. })
  33746. .remove(function (idx) {
  33747. var piePiece = oldData.getItemGraphicEl(idx);
  33748. group.remove(piePiece);
  33749. })
  33750. .execute();
  33751. this._data = data;
  33752. },
  33753. remove: function () {
  33754. this.group.removeAll();
  33755. this._data = null;
  33756. }
  33757. });
  33758. module.exports = Funnel;
  33759. /***/ },
  33760. /* 222 */
  33761. /***/ function(module, exports, __webpack_require__) {
  33762. var layout = __webpack_require__(21);
  33763. var number = __webpack_require__(7);
  33764. var parsePercent = number.parsePercent;
  33765. function getViewRect(seriesModel, api) {
  33766. return layout.getLayoutRect(
  33767. seriesModel.getBoxLayoutParams(), {
  33768. width: api.getWidth(),
  33769. height: api.getHeight()
  33770. }
  33771. );
  33772. }
  33773. function getSortedIndices(data, sort) {
  33774. var valueArr = data.mapArray('value', function (val) {
  33775. return val;
  33776. });
  33777. var indices = [];
  33778. var isAscending = sort === 'ascending';
  33779. for (var i = 0, len = data.count(); i < len; i++) {
  33780. indices[i] = i;
  33781. }
  33782. indices.sort(function (a, b) {
  33783. return isAscending ? valueArr[a] - valueArr[b] : valueArr[b] - valueArr[a];
  33784. });
  33785. return indices;
  33786. }
  33787. function labelLayout (data) {
  33788. data.each(function (idx) {
  33789. var itemModel = data.getItemModel(idx);
  33790. var labelModel = itemModel.getModel('label.normal');
  33791. var labelPosition = labelModel.get('position');
  33792. var labelLineModel = itemModel.getModel('labelLine.normal');
  33793. var layout = data.getItemLayout(idx);
  33794. var points = layout.points;
  33795. var isLabelInside = labelPosition === 'inner'
  33796. || labelPosition === 'inside' || labelPosition === 'center';
  33797. var textAlign;
  33798. var textX;
  33799. var textY;
  33800. var linePoints;
  33801. if (isLabelInside) {
  33802. textX = (points[0][0] + points[1][0] + points[2][0] + points[3][0]) / 4;
  33803. textY = (points[0][1] + points[1][1] + points[2][1] + points[3][1]) / 4;
  33804. textAlign = 'center';
  33805. linePoints = [
  33806. [textX, textY], [textX, textY]
  33807. ];
  33808. }
  33809. else {
  33810. var x1;
  33811. var y1;
  33812. var x2;
  33813. var labelLineLen = labelLineModel.get('length');
  33814. if (labelPosition === 'left') {
  33815. // Left side
  33816. x1 = (points[3][0] + points[0][0]) / 2;
  33817. y1 = (points[3][1] + points[0][1]) / 2;
  33818. x2 = x1 - labelLineLen;
  33819. textX = x2 - 5;
  33820. textAlign = 'right';
  33821. }
  33822. else {
  33823. // Right side
  33824. x1 = (points[1][0] + points[2][0]) / 2;
  33825. y1 = (points[1][1] + points[2][1]) / 2;
  33826. x2 = x1 + labelLineLen;
  33827. textX = x2 + 5;
  33828. textAlign = 'left';
  33829. }
  33830. var y2 = y1;
  33831. linePoints = [[x1, y1], [x2, y2]];
  33832. textY = y2;
  33833. }
  33834. layout.label = {
  33835. linePoints: linePoints,
  33836. x: textX,
  33837. y: textY,
  33838. verticalAlign: 'middle',
  33839. textAlign: textAlign,
  33840. inside: isLabelInside
  33841. };
  33842. });
  33843. }
  33844. module.exports = function (ecModel, api, payload) {
  33845. ecModel.eachSeriesByType('funnel', function (seriesModel) {
  33846. var data = seriesModel.getData();
  33847. var sort = seriesModel.get('sort');
  33848. var viewRect = getViewRect(seriesModel, api);
  33849. var indices = getSortedIndices(data, sort);
  33850. var sizeExtent = [
  33851. parsePercent(seriesModel.get('minSize'), viewRect.width),
  33852. parsePercent(seriesModel.get('maxSize'), viewRect.width)
  33853. ];
  33854. var dataExtent = data.getDataExtent('value');
  33855. var min = seriesModel.get('min');
  33856. var max = seriesModel.get('max');
  33857. if (min == null) {
  33858. min = Math.min(dataExtent[0], 0);
  33859. }
  33860. if (max == null) {
  33861. max = dataExtent[1];
  33862. }
  33863. var funnelAlign = seriesModel.get('funnelAlign');
  33864. var gap = seriesModel.get('gap');
  33865. var itemHeight = (viewRect.height - gap * (data.count() - 1)) / data.count();
  33866. var y = viewRect.y;
  33867. var getLinePoints = function (idx, offY) {
  33868. // End point index is data.count() and we assign it 0
  33869. var val = data.get('value', idx) || 0;
  33870. var itemWidth = number.linearMap(val, [min, max], sizeExtent, true);
  33871. var x0;
  33872. switch (funnelAlign) {
  33873. case 'left':
  33874. x0 = viewRect.x;
  33875. break;
  33876. case 'center':
  33877. x0 = viewRect.x + (viewRect.width - itemWidth) / 2;
  33878. break;
  33879. case 'right':
  33880. x0 = viewRect.x + viewRect.width - itemWidth;
  33881. break;
  33882. }
  33883. return [
  33884. [x0, offY],
  33885. [x0 + itemWidth, offY]
  33886. ];
  33887. };
  33888. if (sort === 'ascending') {
  33889. // From bottom to top
  33890. itemHeight = -itemHeight;
  33891. gap = -gap;
  33892. y += viewRect.height;
  33893. indices = indices.reverse();
  33894. }
  33895. for (var i = 0; i < indices.length; i++) {
  33896. var idx = indices[i];
  33897. var nextIdx = indices[i + 1];
  33898. var start = getLinePoints(idx, y);
  33899. var end = getLinePoints(nextIdx, y + itemHeight);
  33900. y += itemHeight + gap;
  33901. data.setItemLayout(idx, {
  33902. points: start.concat(end.slice().reverse())
  33903. });
  33904. }
  33905. labelLayout(data);
  33906. });
  33907. };
  33908. /***/ },
  33909. /* 223 */
  33910. /***/ function(module, exports, __webpack_require__) {
  33911. var echarts = __webpack_require__(1);
  33912. __webpack_require__(224);
  33913. __webpack_require__(235);
  33914. __webpack_require__(236);
  33915. echarts.registerVisual(__webpack_require__(237));
  33916. /***/ },
  33917. /* 224 */
  33918. /***/ function(module, exports, __webpack_require__) {
  33919. __webpack_require__(225);
  33920. __webpack_require__(228);
  33921. __webpack_require__(230);
  33922. var echarts = __webpack_require__(1);
  33923. var zrUtil = __webpack_require__(4);
  33924. var CLICK_THRESHOLD = 5; // > 4
  33925. // Parallel view
  33926. echarts.extendComponentView({
  33927. type: 'parallel',
  33928. render: function (parallelModel, ecModel, api) {
  33929. var zr = api.getZr();
  33930. if (!this.__onMouseDown) {
  33931. // FIXME
  33932. // click: mousemove check. otherwise confilct with drag brush.
  33933. var mousedownPoint;
  33934. zr.on('mousedown', this.__onMouseDown = function (e) {
  33935. mousedownPoint = [e.offsetX, e.offsetY];
  33936. });
  33937. zr.on('mouseup', this.__onMouseUp = function (e) {
  33938. var point = [e.offsetX, e.offsetY];
  33939. var dist = Math.pow(mousedownPoint[0] - point[0], 2)
  33940. + Math.pow(mousedownPoint[1] - point[1], 2);
  33941. if (!parallelModel.get('axisExpandable') || dist > CLICK_THRESHOLD) {
  33942. return;
  33943. }
  33944. var coordSys = parallelModel.coordinateSystem;
  33945. var closestDim = coordSys.findClosestAxisDim(point);
  33946. if (closestDim) {
  33947. var axisIndex = zrUtil.indexOf(coordSys.dimensions, closestDim);
  33948. api.dispatchAction({
  33949. type: 'parallelAxisExpand',
  33950. axisExpandCenter: axisIndex
  33951. });
  33952. }
  33953. });
  33954. }
  33955. },
  33956. dispose: function (ecModel, api) {
  33957. api.getZr().off(this.__onMouseDown);
  33958. api.getZr().off(this.__onMouseUp);
  33959. }
  33960. });
  33961. echarts.registerPreprocessor(
  33962. __webpack_require__(234)
  33963. );
  33964. /***/ },
  33965. /* 225 */
  33966. /***/ function(module, exports, __webpack_require__) {
  33967. /**
  33968. * Parallel coordinate system creater.
  33969. */
  33970. var Parallel = __webpack_require__(226);
  33971. function create(ecModel, api) {
  33972. var coordSysList = [];
  33973. ecModel.eachComponent('parallel', function (parallelModel, idx) {
  33974. var coordSys = new Parallel(parallelModel, ecModel, api);
  33975. coordSys.name = 'parallel_' + idx;
  33976. coordSys.resize(parallelModel, api);
  33977. parallelModel.coordinateSystem = coordSys;
  33978. coordSys.model = parallelModel;
  33979. coordSysList.push(coordSys);
  33980. });
  33981. // Inject the coordinateSystems into seriesModel
  33982. ecModel.eachSeries(function (seriesModel) {
  33983. if (seriesModel.get('coordinateSystem') === 'parallel') {
  33984. var parallelIndex = seriesModel.get('parallelIndex');
  33985. seriesModel.coordinateSystem = coordSysList[parallelIndex];
  33986. }
  33987. });
  33988. return coordSysList;
  33989. }
  33990. __webpack_require__(26).register('parallel', {create: create});
  33991. /***/ },
  33992. /* 226 */
  33993. /***/ function(module, exports, __webpack_require__) {
  33994. /**
  33995. * Parallel Coordinates
  33996. * <https://en.wikipedia.org/wiki/Parallel_coordinates>
  33997. */
  33998. var layout = __webpack_require__(21);
  33999. var axisHelper = __webpack_require__(114);
  34000. var zrUtil = __webpack_require__(4);
  34001. var ParallelAxis = __webpack_require__(227);
  34002. var graphic = __webpack_require__(43);
  34003. var matrix = __webpack_require__(11);
  34004. var each = zrUtil.each;
  34005. var PI = Math.PI;
  34006. function Parallel(parallelModel, ecModel, api) {
  34007. /**
  34008. * key: dimension
  34009. * @type {Object.<string, module:echarts/coord/parallel/Axis>}
  34010. * @private
  34011. */
  34012. this._axesMap = {};
  34013. /**
  34014. * key: dimension
  34015. * value: {position: [], rotation, }
  34016. * @type {Object.<string, Object>}
  34017. * @private
  34018. */
  34019. this._axesLayout = {};
  34020. /**
  34021. * Always follow axis order.
  34022. * @type {Array.<string>}
  34023. * @readOnly
  34024. */
  34025. this.dimensions = parallelModel.dimensions;
  34026. /**
  34027. * @type {module:zrender/core/BoundingRect}
  34028. */
  34029. this._rect;
  34030. /**
  34031. * @type {module:echarts/coord/parallel/ParallelModel}
  34032. */
  34033. this._model = parallelModel;
  34034. this._init(parallelModel, ecModel, api);
  34035. }
  34036. Parallel.prototype = {
  34037. type: 'parallel',
  34038. constructor: Parallel,
  34039. /**
  34040. * Initialize cartesian coordinate systems
  34041. * @private
  34042. */
  34043. _init: function (parallelModel, ecModel, api) {
  34044. var dimensions = parallelModel.dimensions;
  34045. var parallelAxisIndex = parallelModel.parallelAxisIndex;
  34046. each(dimensions, function (dim, idx) {
  34047. var axisIndex = parallelAxisIndex[idx];
  34048. var axisModel = ecModel.getComponent('parallelAxis', axisIndex);
  34049. var axis = this._axesMap[dim] = new ParallelAxis(
  34050. dim,
  34051. axisHelper.createScaleByModel(axisModel),
  34052. [0, 0],
  34053. axisModel.get('type'),
  34054. axisIndex
  34055. );
  34056. var isCategory = axis.type === 'category';
  34057. axis.onBand = isCategory && axisModel.get('boundaryGap');
  34058. axis.inverse = axisModel.get('inverse');
  34059. // Inject axis into axisModel
  34060. axisModel.axis = axis;
  34061. // Inject axisModel into axis
  34062. axis.model = axisModel;
  34063. }, this);
  34064. },
  34065. /**
  34066. * Update axis scale after data processed
  34067. * @param {module:echarts/model/Global} ecModel
  34068. * @param {module:echarts/ExtensionAPI} api
  34069. */
  34070. update: function (ecModel, api) {
  34071. this._updateAxesFromSeries(this._model, ecModel);
  34072. },
  34073. /**
  34074. * Update properties from series
  34075. * @private
  34076. */
  34077. _updateAxesFromSeries: function (parallelModel, ecModel) {
  34078. ecModel.eachSeries(function (seriesModel) {
  34079. if (!parallelModel.contains(seriesModel, ecModel)) {
  34080. return;
  34081. }
  34082. var data = seriesModel.getData();
  34083. each(this.dimensions, function (dim) {
  34084. var axis = this._axesMap[dim];
  34085. axis.scale.unionExtent(data.getDataExtent(dim));
  34086. axisHelper.niceScaleExtent(axis, axis.model);
  34087. }, this);
  34088. }, this);
  34089. },
  34090. /**
  34091. * Resize the parallel coordinate system.
  34092. * @param {module:echarts/coord/parallel/ParallelModel} parallelModel
  34093. * @param {module:echarts/ExtensionAPI} api
  34094. */
  34095. resize: function (parallelModel, api) {
  34096. this._rect = layout.getLayoutRect(
  34097. parallelModel.getBoxLayoutParams(),
  34098. {
  34099. width: api.getWidth(),
  34100. height: api.getHeight()
  34101. }
  34102. );
  34103. this._layoutAxes(parallelModel);
  34104. },
  34105. /**
  34106. * @return {module:zrender/core/BoundingRect}
  34107. */
  34108. getRect: function () {
  34109. return this._rect;
  34110. },
  34111. /**
  34112. * @private
  34113. */
  34114. _layoutAxes: function (parallelModel) {
  34115. var rect = this._rect;
  34116. var layout = parallelModel.get('layout');
  34117. var axes = this._axesMap;
  34118. var dimensions = this.dimensions;
  34119. var size = [rect.width, rect.height];
  34120. var sizeIdx = layout === 'horizontal' ? 0 : 1;
  34121. var layoutLength = size[sizeIdx];
  34122. var axisLength = size[1 - sizeIdx];
  34123. var axisExtent = [0, axisLength];
  34124. each(axes, function (axis) {
  34125. var idx = axis.inverse ? 1 : 0;
  34126. axis.setExtent(axisExtent[idx], axisExtent[1 - idx]);
  34127. });
  34128. var axisExpandable = parallelModel.get('axisExpandable');
  34129. var axisExpandWidth = parallelModel.get('axisExpandWidth');
  34130. var axisExpandCenter = parallelModel.get('axisExpandCenter');
  34131. var axisExpandCount = parallelModel.get('axisExpandCount') || 0;
  34132. var axisExpandWindow;
  34133. if (axisExpandCenter != null) {
  34134. // Clamp
  34135. var left = Math.max(0, Math.floor(axisExpandCenter - (axisExpandCount - 1) / 2));
  34136. var right = left + axisExpandCount - 1;
  34137. if (right >= dimensions.length) {
  34138. right = dimensions.length - 1;
  34139. left = Math.max(0, Math.floor(right - axisExpandCount + 1));
  34140. }
  34141. axisExpandWindow = [left, right];
  34142. }
  34143. var calcPos = (axisExpandable && axisExpandWindow && axisExpandWidth)
  34144. ? function (axisIndex, layoutLength, axisCount) {
  34145. var peekIntervalCount = axisExpandWindow[1] - axisExpandWindow[0];
  34146. var otherWidth = (
  34147. layoutLength - axisExpandWidth * peekIntervalCount
  34148. ) / (axisCount - 1 - peekIntervalCount);
  34149. var position;
  34150. if (axisIndex < axisExpandWindow[0]) {
  34151. position = (axisIndex - 1) * otherWidth;
  34152. }
  34153. else if (axisIndex <= axisExpandWindow[1]) {
  34154. position = axisExpandWindow[0] * otherWidth
  34155. + (axisIndex - axisExpandWindow[0]) * axisExpandWidth;
  34156. }
  34157. else if (axisIndex === axisCount - 1) {
  34158. position = layoutLength;
  34159. }
  34160. else {
  34161. position = axisExpandWindow[0] * otherWidth
  34162. + peekIntervalCount * axisExpandWidth
  34163. + (axisIndex - axisExpandWindow[1]) * otherWidth;
  34164. }
  34165. return {
  34166. position: position,
  34167. axisNameAvailableWidth: (
  34168. axisExpandWindow[0] < axisIndex && axisIndex < axisExpandWindow[1]
  34169. ) ? axisExpandWidth : otherWidth
  34170. };
  34171. }
  34172. : function (axisIndex, layoutLength, axisCount) {
  34173. var step = layoutLength / (axisCount - 1);
  34174. return {
  34175. position: step * axisIndex,
  34176. axisNameAvailableWidth: step
  34177. };
  34178. };
  34179. each(dimensions, function (dim, idx) {
  34180. var posInfo = calcPos(idx, layoutLength, dimensions.length);
  34181. var positionTable = {
  34182. horizontal: {
  34183. x: posInfo.position,
  34184. y: axisLength
  34185. },
  34186. vertical: {
  34187. x: 0,
  34188. y: posInfo.position
  34189. }
  34190. };
  34191. var rotationTable = {
  34192. horizontal: PI / 2,
  34193. vertical: 0
  34194. };
  34195. var position = [
  34196. positionTable[layout].x + rect.x,
  34197. positionTable[layout].y + rect.y
  34198. ];
  34199. var rotation = rotationTable[layout];
  34200. var transform = matrix.create();
  34201. matrix.rotate(transform, transform, rotation);
  34202. matrix.translate(transform, transform, position);
  34203. // TODO
  34204. // tick等排布信息。
  34205. // TODO
  34206. // 根据axis order 更新 dimensions顺序。
  34207. this._axesLayout[dim] = {
  34208. position: position,
  34209. rotation: rotation,
  34210. transform: transform,
  34211. axisNameAvailableWidth: posInfo.axisNameAvailableWidth,
  34212. tickDirection: 1,
  34213. labelDirection: 1,
  34214. axisExpandWindow: axisExpandWindow
  34215. };
  34216. }, this);
  34217. },
  34218. /**
  34219. * Get axis by dim.
  34220. * @param {string} dim
  34221. * @return {module:echarts/coord/parallel/ParallelAxis} [description]
  34222. */
  34223. getAxis: function (dim) {
  34224. return this._axesMap[dim];
  34225. },
  34226. /**
  34227. * Convert a dim value of a single item of series data to Point.
  34228. * @param {*} value
  34229. * @param {string} dim
  34230. * @return {Array}
  34231. */
  34232. dataToPoint: function (value, dim) {
  34233. return this.axisCoordToPoint(
  34234. this._axesMap[dim].dataToCoord(value),
  34235. dim
  34236. );
  34237. },
  34238. /**
  34239. * Travel data for one time, get activeState of each data item.
  34240. * @param {module:echarts/data/List} data
  34241. * @param {Functio} cb param: {string} activeState 'active' or 'inactive' or 'normal'
  34242. * {number} dataIndex
  34243. * @param {Object} context
  34244. */
  34245. eachActiveState: function (data, callback, context) {
  34246. var dimensions = this.dimensions;
  34247. var axesMap = this._axesMap;
  34248. var hasActiveSet = this.hasAxisbrushed();
  34249. for (var i = 0, len = data.count(); i < len; i++) {
  34250. var values = data.getValues(dimensions, i);
  34251. var activeState;
  34252. if (!hasActiveSet) {
  34253. activeState = 'normal';
  34254. }
  34255. else {
  34256. activeState = 'active';
  34257. for (var j = 0, lenj = dimensions.length; j < lenj; j++) {
  34258. var dimName = dimensions[j];
  34259. var state = axesMap[dimName].model.getActiveState(values[j], j);
  34260. if (state === 'inactive') {
  34261. activeState = 'inactive';
  34262. break;
  34263. }
  34264. }
  34265. }
  34266. callback.call(context, activeState, i);
  34267. }
  34268. },
  34269. /**
  34270. * Whether has any activeSet.
  34271. * @return {boolean}
  34272. */
  34273. hasAxisbrushed: function () {
  34274. var dimensions = this.dimensions;
  34275. var axesMap = this._axesMap;
  34276. var hasActiveSet = false;
  34277. for (var j = 0, lenj = dimensions.length; j < lenj; j++) {
  34278. if (axesMap[dimensions[j]].model.getActiveState() !== 'normal') {
  34279. hasActiveSet = true;
  34280. }
  34281. }
  34282. return hasActiveSet;
  34283. },
  34284. /**
  34285. * Convert coords of each axis to Point.
  34286. * Return point. For example: [10, 20]
  34287. * @param {Array.<number>} coords
  34288. * @param {string} dim
  34289. * @return {Array.<number>}
  34290. */
  34291. axisCoordToPoint: function (coord, dim) {
  34292. var axisLayout = this._axesLayout[dim];
  34293. return graphic.applyTransform([coord, 0], axisLayout.transform);
  34294. },
  34295. /**
  34296. * Get axis layout.
  34297. */
  34298. getAxisLayout: function (dim) {
  34299. return zrUtil.clone(this._axesLayout[dim]);
  34300. },
  34301. findClosestAxisDim: function (point) {
  34302. var axisDim;
  34303. var minDist = Infinity;
  34304. zrUtil.each(this._axesLayout, function (axisLayout, dim) {
  34305. var localPoint = graphic.applyTransform(point, axisLayout.transform, true);
  34306. var extent = this._axesMap[dim].getExtent();
  34307. if (localPoint[0] < extent[0] || localPoint[0] > extent[1]) {
  34308. return;
  34309. }
  34310. var dist = Math.abs(localPoint[1]);
  34311. if (dist < minDist) {
  34312. minDist = dist;
  34313. axisDim = dim;
  34314. }
  34315. }, this);
  34316. return axisDim;
  34317. }
  34318. };
  34319. module.exports = Parallel;
  34320. /***/ },
  34321. /* 227 */
  34322. /***/ function(module, exports, __webpack_require__) {
  34323. var zrUtil = __webpack_require__(4);
  34324. var Axis = __webpack_require__(123);
  34325. /**
  34326. * @constructor module:echarts/coord/parallel/ParallelAxis
  34327. * @extends {module:echarts/coord/Axis}
  34328. * @param {string} dim
  34329. * @param {*} scale
  34330. * @param {Array.<number>} coordExtent
  34331. * @param {string} axisType
  34332. */
  34333. var ParallelAxis = function (dim, scale, coordExtent, axisType, axisIndex) {
  34334. Axis.call(this, dim, scale, coordExtent);
  34335. /**
  34336. * Axis type
  34337. * - 'category'
  34338. * - 'value'
  34339. * - 'time'
  34340. * - 'log'
  34341. * @type {string}
  34342. */
  34343. this.type = axisType || 'value';
  34344. /**
  34345. * @type {number}
  34346. * @readOnly
  34347. */
  34348. this.axisIndex = axisIndex;
  34349. };
  34350. ParallelAxis.prototype = {
  34351. constructor: ParallelAxis,
  34352. /**
  34353. * Axis model
  34354. * @param {module:echarts/coord/parallel/AxisModel}
  34355. */
  34356. model: null
  34357. };
  34358. zrUtil.inherits(ParallelAxis, Axis);
  34359. module.exports = ParallelAxis;
  34360. /***/ },
  34361. /* 228 */
  34362. /***/ function(module, exports, __webpack_require__) {
  34363. var zrUtil = __webpack_require__(4);
  34364. var Component = __webpack_require__(19);
  34365. __webpack_require__(229);
  34366. Component.extend({
  34367. type: 'parallel',
  34368. dependencies: ['parallelAxis'],
  34369. /**
  34370. * @type {module:echarts/coord/parallel/Parallel}
  34371. */
  34372. coordinateSystem: null,
  34373. /**
  34374. * Each item like: 'dim0', 'dim1', 'dim2', ...
  34375. * @type {Array.<string>}
  34376. * @readOnly
  34377. */
  34378. dimensions: null,
  34379. /**
  34380. * Coresponding to dimensions.
  34381. * @type {Array.<number>}
  34382. * @readOnly
  34383. */
  34384. parallelAxisIndex: null,
  34385. layoutMode: 'box',
  34386. defaultOption: {
  34387. zlevel: 0,
  34388. z: 0,
  34389. left: 80,
  34390. top: 60,
  34391. right: 80,
  34392. bottom: 60,
  34393. // width: {totalWidth} - left - right,
  34394. // height: {totalHeight} - top - bottom,
  34395. layout: 'horizontal', // 'horizontal' or 'vertical'
  34396. // FIXME
  34397. // naming?
  34398. axisExpandable: false,
  34399. axisExpandCenter: null,
  34400. axisExpandCount: 0,
  34401. axisExpandWidth: 50, // FIXME '10%' ?
  34402. parallelAxisDefault: null
  34403. },
  34404. /**
  34405. * @override
  34406. */
  34407. init: function () {
  34408. Component.prototype.init.apply(this, arguments);
  34409. this.mergeOption({});
  34410. },
  34411. /**
  34412. * @override
  34413. */
  34414. mergeOption: function (newOption) {
  34415. var thisOption = this.option;
  34416. newOption && zrUtil.merge(thisOption, newOption, true);
  34417. this._initDimensions();
  34418. },
  34419. /**
  34420. * Whether series or axis is in this coordinate system.
  34421. * @param {module:echarts/model/Series|module:echarts/coord/parallel/AxisModel} model
  34422. * @param {module:echarts/model/Global} ecModel
  34423. */
  34424. contains: function (model, ecModel) {
  34425. var parallelIndex = model.get('parallelIndex');
  34426. return parallelIndex != null
  34427. && ecModel.getComponent('parallel', parallelIndex) === this;
  34428. },
  34429. setAxisExpand: function (opt) {
  34430. zrUtil.each(
  34431. ['axisExpandable', 'axisExpandCenter', 'axisExpandCount', 'axisExpandWidth'],
  34432. function (name) {
  34433. if (opt.hasOwnProperty(name)) {
  34434. this.option[name] = opt[name];
  34435. }
  34436. },
  34437. this
  34438. );
  34439. },
  34440. /**
  34441. * @private
  34442. */
  34443. _initDimensions: function () {
  34444. var dimensions = this.dimensions = [];
  34445. var parallelAxisIndex = this.parallelAxisIndex = [];
  34446. var axisModels = zrUtil.filter(this.dependentModels.parallelAxis, function (axisModel) {
  34447. // Can not use this.contains here, because
  34448. // initialization has not been completed yet.
  34449. return axisModel.get('parallelIndex') === this.componentIndex;
  34450. });
  34451. zrUtil.each(axisModels, function (axisModel) {
  34452. dimensions.push('dim' + axisModel.get('dim'));
  34453. parallelAxisIndex.push(axisModel.componentIndex);
  34454. });
  34455. }
  34456. });
  34457. /***/ },
  34458. /* 229 */
  34459. /***/ function(module, exports, __webpack_require__) {
  34460. var ComponentModel = __webpack_require__(19);
  34461. var zrUtil = __webpack_require__(4);
  34462. var makeStyleMapper = __webpack_require__(15);
  34463. var axisModelCreator = __webpack_require__(127);
  34464. var numberUtil = __webpack_require__(7);
  34465. var AxisModel = ComponentModel.extend({
  34466. type: 'baseParallelAxis',
  34467. /**
  34468. * @type {module:echarts/coord/parallel/Axis}
  34469. */
  34470. axis: null,
  34471. /**
  34472. * @type {Array.<Array.<number>}
  34473. * @readOnly
  34474. */
  34475. activeIntervals: [],
  34476. /**
  34477. * @return {Object}
  34478. */
  34479. getAreaSelectStyle: function () {
  34480. return makeStyleMapper(
  34481. [
  34482. ['fill', 'color'],
  34483. ['lineWidth', 'borderWidth'],
  34484. ['stroke', 'borderColor'],
  34485. ['width', 'width'],
  34486. ['opacity', 'opacity']
  34487. ]
  34488. ).call(this.getModel('areaSelectStyle'));
  34489. },
  34490. /**
  34491. * The code of this feature is put on AxisModel but not ParallelAxis,
  34492. * because axisModel can be alive after echarts updating but instance of
  34493. * ParallelAxis having been disposed. this._activeInterval should be kept
  34494. * when action dispatched (i.e. legend click).
  34495. *
  34496. * @param {Array.<Array<number>>} intervals interval.length === 0
  34497. * means set all active.
  34498. * @public
  34499. */
  34500. setActiveIntervals: function (intervals) {
  34501. var activeIntervals = this.activeIntervals = zrUtil.clone(intervals);
  34502. // Normalize
  34503. if (activeIntervals) {
  34504. for (var i = activeIntervals.length - 1; i >= 0; i--) {
  34505. numberUtil.asc(activeIntervals[i]);
  34506. }
  34507. }
  34508. },
  34509. /**
  34510. * @param {number|string} [value] When attempting to detect 'no activeIntervals set',
  34511. * value can not be input.
  34512. * @return {string} 'normal': no activeIntervals set,
  34513. * 'active',
  34514. * 'inactive'.
  34515. * @public
  34516. */
  34517. getActiveState: function (value) {
  34518. var activeIntervals = this.activeIntervals;
  34519. if (!activeIntervals.length) {
  34520. return 'normal';
  34521. }
  34522. if (value == null) {
  34523. return 'inactive';
  34524. }
  34525. for (var i = 0, len = activeIntervals.length; i < len; i++) {
  34526. if (activeIntervals[i][0] <= value && value <= activeIntervals[i][1]) {
  34527. return 'active';
  34528. }
  34529. }
  34530. return 'inactive';
  34531. }
  34532. });
  34533. var defaultOption = {
  34534. type: 'value',
  34535. /**
  34536. * @type {Array.<number>}
  34537. */
  34538. dim: null, // 0, 1, 2, ...
  34539. parallelIndex: null,
  34540. areaSelectStyle: {
  34541. width: 20,
  34542. borderWidth: 1,
  34543. borderColor: 'rgba(160,197,232)',
  34544. color: 'rgba(160,197,232)',
  34545. opacity: 0.3
  34546. },
  34547. realtime: true, // Whether realtime update view when select.
  34548. z: 10
  34549. };
  34550. zrUtil.merge(AxisModel.prototype, __webpack_require__(129));
  34551. function getAxisType(axisName, option) {
  34552. return option.type || (option.data ? 'category' : 'value');
  34553. }
  34554. axisModelCreator('parallel', AxisModel, getAxisType, defaultOption);
  34555. module.exports = AxisModel;
  34556. /***/ },
  34557. /* 230 */
  34558. /***/ function(module, exports, __webpack_require__) {
  34559. __webpack_require__(225);
  34560. __webpack_require__(231);
  34561. __webpack_require__(232);
  34562. /***/ },
  34563. /* 231 */
  34564. /***/ function(module, exports, __webpack_require__) {
  34565. var echarts = __webpack_require__(1);
  34566. /**
  34567. * @payload
  34568. * @property {string} parallelAxisId
  34569. * @property {Array.<Array.<number>>} intervals
  34570. */
  34571. var actionInfo = {
  34572. type: 'axisAreaSelect',
  34573. event: 'axisAreaSelected',
  34574. update: 'updateVisual'
  34575. };
  34576. echarts.registerAction(actionInfo, function (payload, ecModel) {
  34577. ecModel.eachComponent(
  34578. {mainType: 'parallelAxis', query: payload},
  34579. function (parallelAxisModel) {
  34580. parallelAxisModel.axis.model.setActiveIntervals(payload.intervals);
  34581. }
  34582. );
  34583. });
  34584. /**
  34585. * @payload
  34586. */
  34587. echarts.registerAction('parallelAxisExpand', function (payload, ecModel) {
  34588. ecModel.eachComponent(
  34589. {mainType: 'parallel', query: payload},
  34590. function (parallelModel) {
  34591. parallelModel.setAxisExpand(payload);
  34592. }
  34593. );
  34594. });
  34595. /***/ },
  34596. /* 232 */
  34597. /***/ function(module, exports, __webpack_require__) {
  34598. var zrUtil = __webpack_require__(4);
  34599. var AxisBuilder = __webpack_require__(132);
  34600. var BrushController = __webpack_require__(233);
  34601. var graphic = __webpack_require__(43);
  34602. var elementList = ['axisLine', 'axisLabel', 'axisTick', 'axisName'];
  34603. var AxisView = __webpack_require__(1).extendComponentView({
  34604. type: 'parallelAxis',
  34605. /**
  34606. * @override
  34607. */
  34608. init: function (ecModel, api) {
  34609. AxisView.superApply(this, 'init', arguments);
  34610. /**
  34611. * @type {module:echarts/component/helper/BrushController}
  34612. */
  34613. (this._brushController = new BrushController(api.getZr()))
  34614. .on('brush', zrUtil.bind(this._onBrush, this));
  34615. },
  34616. /**
  34617. * @override
  34618. */
  34619. render: function (axisModel, ecModel, api, payload) {
  34620. if (fromAxisAreaSelect(axisModel, ecModel, payload)) {
  34621. return;
  34622. }
  34623. this.axisModel = axisModel;
  34624. this.api = api;
  34625. this.group.removeAll();
  34626. var oldAxisGroup = this._axisGroup;
  34627. this._axisGroup = new graphic.Group();
  34628. this.group.add(this._axisGroup);
  34629. if (!axisModel.get('show')) {
  34630. return;
  34631. }
  34632. var coordSys = ecModel.getComponent(
  34633. 'parallel', axisModel.get('parallelIndex')
  34634. ).coordinateSystem;
  34635. var areaSelectStyle = axisModel.getAreaSelectStyle();
  34636. var areaWidth = areaSelectStyle.width;
  34637. var dim = axisModel.axis.dim;
  34638. var axisLayout = coordSys.getAxisLayout(dim);
  34639. // Fetch from axisModel by default.
  34640. var axisLabelShow;
  34641. var axisIndex = zrUtil.indexOf(coordSys.dimensions, dim);
  34642. var axisExpandWindow = axisLayout.axisExpandWindow;
  34643. if (axisExpandWindow
  34644. && (axisIndex <= axisExpandWindow[0] || axisIndex >= axisExpandWindow[1])
  34645. ) {
  34646. axisLabelShow = false;
  34647. }
  34648. var builderOpt = zrUtil.extend(
  34649. {
  34650. axisLabelShow: axisLabelShow,
  34651. strokeContainThreshold: areaWidth
  34652. },
  34653. axisLayout
  34654. );
  34655. var axisBuilder = new AxisBuilder(axisModel, builderOpt);
  34656. zrUtil.each(elementList, axisBuilder.add, axisBuilder);
  34657. this._axisGroup.add(axisBuilder.getGroup());
  34658. this._refreshBrushController(builderOpt, areaSelectStyle, axisModel, areaWidth);
  34659. graphic.groupTransition(oldAxisGroup, this._axisGroup, axisModel);
  34660. },
  34661. _refreshBrushController: function (builderOpt, areaSelectStyle, axisModel, areaWidth) {
  34662. // After filtering, axis may change, select area needs to be update.
  34663. var axis = axisModel.axis;
  34664. var coverInfoList = zrUtil.map(axisModel.activeIntervals, function (interval) {
  34665. return {
  34666. brushType: 'lineX',
  34667. panelId: 'pl',
  34668. range: [
  34669. axis.dataToCoord(interval[0], true),
  34670. axis.dataToCoord(interval[1], true)
  34671. ]
  34672. };
  34673. });
  34674. var extent = axis.getExtent();
  34675. var extra = 30; // Arbitrary value.
  34676. var rect = {
  34677. x: extent[0] - extra,
  34678. y: -areaWidth / 2,
  34679. width: extent[1] - extent[0] + 2 * extra,
  34680. height: areaWidth
  34681. };
  34682. this._brushController
  34683. .mount({
  34684. enableGlobalPan: true,
  34685. rotation: builderOpt.rotation,
  34686. position: builderOpt.position
  34687. })
  34688. .setPanels([{
  34689. panelId: 'pl',
  34690. rect: rect
  34691. }])
  34692. .enableBrush({
  34693. brushType: 'lineX',
  34694. brushStyle: areaSelectStyle,
  34695. removeOnClick: true
  34696. })
  34697. .updateCovers(coverInfoList);
  34698. },
  34699. _onBrush: function (coverInfoList, opt) {
  34700. // Do not cache these object, because the mey be changed.
  34701. var axisModel = this.axisModel;
  34702. var axis = axisModel.axis;
  34703. var intervals = zrUtil.map(coverInfoList, function (coverInfo) {
  34704. return [
  34705. axis.coordToData(coverInfo.range[0], true),
  34706. axis.coordToData(coverInfo.range[1], true)
  34707. ];
  34708. });
  34709. // If realtime is true, action is not dispatched on drag end, because
  34710. // the drag end emits the same params with the last drag move event,
  34711. // and may have some delay when using touch pad.
  34712. if (!axisModel.option.realtime === opt.isEnd || opt.removeOnClick) { // jshint ignore:line
  34713. this.api.dispatchAction({
  34714. type: 'axisAreaSelect',
  34715. parallelAxisId: axisModel.id,
  34716. intervals: intervals
  34717. });
  34718. }
  34719. },
  34720. /**
  34721. * @override
  34722. */
  34723. dispose: function () {
  34724. this._brushController.dispose();
  34725. }
  34726. });
  34727. function fromAxisAreaSelect(axisModel, ecModel, payload) {
  34728. return payload
  34729. && payload.type === 'axisAreaSelect'
  34730. && ecModel.findComponents(
  34731. {mainType: 'parallelAxis', query: payload}
  34732. )[0] === axisModel;
  34733. }
  34734. module.exports = AxisView;
  34735. /***/ },
  34736. /* 233 */
  34737. /***/ function(module, exports, __webpack_require__) {
  34738. /**
  34739. * Box selection tool.
  34740. *
  34741. * @module echarts/component/helper/BrushController
  34742. */
  34743. var Eventful = __webpack_require__(33);
  34744. var zrUtil = __webpack_require__(4);
  34745. var graphic = __webpack_require__(43);
  34746. var interactionMutex = __webpack_require__(175);
  34747. var DataDiffer = __webpack_require__(98);
  34748. var curry = zrUtil.curry;
  34749. var each = zrUtil.each;
  34750. var map = zrUtil.map;
  34751. var mathMin = Math.min;
  34752. var mathMax = Math.max;
  34753. var mathPow = Math.pow;
  34754. var COVER_Z = 10000;
  34755. var UNSELECT_THRESHOLD = 6;
  34756. var MIN_RESIZE_LINE_WIDTH = 6;
  34757. var MUTEX_RESOURCE_KEY = 'globalPan';
  34758. var DIRECTION_MAP = {
  34759. w: [0, 0],
  34760. e: [0, 1],
  34761. n: [1, 0],
  34762. s: [1, 1]
  34763. };
  34764. var CURSOR_MAP = {
  34765. w: 'ew',
  34766. e: 'ew',
  34767. n: 'ns',
  34768. s: 'ns',
  34769. ne: 'nesw',
  34770. sw: 'nesw',
  34771. nw: 'nwse',
  34772. se: 'nwse'
  34773. };
  34774. var DEFAULT_BRUSH_OPT = {
  34775. brushStyle: {
  34776. lineWidth: 2,
  34777. stroke: 'rgba(0,0,0,0.3)',
  34778. fill: 'rgba(0,0,0,0.1)'
  34779. },
  34780. transformable: true,
  34781. brushMode: 'single',
  34782. removeOnClick: false
  34783. };
  34784. var baseUID = 0;
  34785. /**
  34786. * @alias module:echarts/component/helper/BrushController
  34787. * @constructor
  34788. * @mixin {module:zrender/mixin/Eventful}
  34789. * @event module:echarts/component/helper/BrushController#brush
  34790. * params:
  34791. * areas: Array.<Array>, coord relates to container group,
  34792. * If no container specified, to global.
  34793. * opt {
  34794. * isEnd: boolean,
  34795. * removeOnClick: boolean
  34796. * }
  34797. *
  34798. * @param {module:zrender/zrender~ZRender} zr
  34799. */
  34800. function BrushController(zr) {
  34801. if (true) {
  34802. zrUtil.assert(zr);
  34803. }
  34804. Eventful.call(this);
  34805. /**
  34806. * @type {module:zrender/zrender~ZRender}
  34807. * @private
  34808. */
  34809. this._zr = zr;
  34810. /**
  34811. * @type {module:zrender/container/Group}
  34812. * @readOnly
  34813. */
  34814. this.group = new graphic.Group();
  34815. /**
  34816. * Only for drawing (after enabledBrush).
  34817. * @private
  34818. * @type {string}
  34819. */
  34820. this._brushType;
  34821. /**
  34822. * Only for drawing (after enabledBrush).
  34823. * @private
  34824. * @type {Object}
  34825. */
  34826. this._brushOption;
  34827. /**
  34828. * @private
  34829. * @type {Object}
  34830. */
  34831. this._panels;
  34832. /**
  34833. * @private
  34834. * @type {Array.<nubmer>}
  34835. */
  34836. this._track = [];
  34837. /**
  34838. * @private
  34839. * @type {boolean}
  34840. */
  34841. this._dragging;
  34842. /**
  34843. * @private
  34844. * @type {Array}
  34845. */
  34846. this._covers = [];
  34847. /**
  34848. * @private
  34849. * @type {moudule:zrender/container/Group}
  34850. */
  34851. this._creatingCover;
  34852. /**
  34853. * true means global panel
  34854. * @private
  34855. * @type {module:zrender/container/Group|boolean}
  34856. */
  34857. this._creatingPanel;
  34858. /**
  34859. * @private
  34860. * @type {boolean}
  34861. */
  34862. this._enableGlobalPan;
  34863. /**
  34864. * @private
  34865. * @type {boolean}
  34866. */
  34867. if (true) {
  34868. this._mounted;
  34869. }
  34870. /**
  34871. * @private
  34872. * @type {string}
  34873. */
  34874. this._uid = 'brushController_' + baseUID++;
  34875. /**
  34876. * @private
  34877. * @type {Object}
  34878. */
  34879. this._handlers = {};
  34880. each(mouseHandlers, function (handler, eventName) {
  34881. this._handlers[eventName] = zrUtil.bind(handler, this);
  34882. }, this);
  34883. }
  34884. BrushController.prototype = {
  34885. constructor: BrushController,
  34886. /**
  34887. * If set to null/undefined/false, select disabled.
  34888. * @param {Object} brushOption
  34889. * @param {string|boolean} brushOption.brushType 'line', 'rect', 'polygon' or false
  34890. * If pass false/null/undefined, disable brush.
  34891. * @param {number} [brushOption.brushMode='single'] 'single' or 'multiple'
  34892. * @param {boolean} [brushOption.transformable=true]
  34893. * @param {boolean} [brushOption.removeOnClick=false]
  34894. * @param {Object} [brushOption.brushStyle]
  34895. * @param {number} [brushOption.brushStyle.width]
  34896. * @param {number} [brushOption.brushStyle.lineWidth]
  34897. * @param {string} [brushOption.brushStyle.stroke]
  34898. * @param {string} [brushOption.brushStyle.fill]
  34899. */
  34900. enableBrush: function (brushOption) {
  34901. if (true) {
  34902. zrUtil.assert(this._mounted);
  34903. }
  34904. this._brushType && doDisableBrush(this);
  34905. brushOption.brushType && doEnableBrush(this, brushOption);
  34906. return this;
  34907. },
  34908. /**
  34909. * @param {Array.<Object>} panelOpts If not pass, it is global brush.
  34910. * Each items: {panelId, rect}
  34911. */
  34912. setPanels: function (panelOpts) {
  34913. var oldPanels = this._panels || {};
  34914. var newPanels = this._panels = panelOpts && panelOpts.length && {};
  34915. var thisGroup = this.group;
  34916. newPanels && each(panelOpts, function (panelOpt) {
  34917. var panelId = panelOpt.panelId;
  34918. var panel = oldPanels[panelId];
  34919. if (!panel) {
  34920. panel = new graphic.Rect({
  34921. silent: true,
  34922. invisible: true
  34923. });
  34924. thisGroup.add(panel);
  34925. }
  34926. panel.attr('shape', panelOpt.rect);
  34927. panel.__brushPanelId = panelId;
  34928. newPanels[panelId] = panel;
  34929. oldPanels[panelId] = null;
  34930. });
  34931. each(oldPanels, function (panel) {
  34932. panel && thisGroup.remove(panel);
  34933. });
  34934. return this;
  34935. },
  34936. /**
  34937. * @param {Object} [opt]
  34938. * @return {boolean} [opt.enableGlobalPan=false]
  34939. * @return {boolean} [opt.position=[0, 0]]
  34940. * @return {boolean} [opt.rotation=0]
  34941. * @return {boolean} [opt.scale=[1, 1]]
  34942. */
  34943. mount: function (opt) {
  34944. opt = opt || {};
  34945. if (true) {
  34946. this._mounted = true; // should be at first.
  34947. }
  34948. this._enableGlobalPan = opt.enableGlobalPan;
  34949. var thisGroup = this.group;
  34950. this._zr.add(thisGroup);
  34951. thisGroup.attr({
  34952. position: opt.position || [0, 0],
  34953. rotation: opt.rotation || 0,
  34954. scale: opt.scale || [1, 1]
  34955. });
  34956. return this;
  34957. },
  34958. eachCover: function (cb, context) {
  34959. each(this._covers, cb, context);
  34960. },
  34961. /**
  34962. * Update covers.
  34963. * @param {Array.<Object>} brushOptionList Like:
  34964. * [
  34965. * {id: 'xx', brushType: 'line', range: [23, 44], brushStyle, transformable},
  34966. * {id: 'yy', brushType: 'rect', range: [[23, 44], [23, 54]]},
  34967. * ...
  34968. * ]
  34969. * `brushType` is required in each cover info.
  34970. * `id` is not mandatory.
  34971. * `brushStyle`, `transformable` is not mandatory, use DEFAULT_BRUSH_OPT by default.
  34972. * If brushOptionList is null/undefined, all covers removed.
  34973. */
  34974. updateCovers: function (brushOptionList) {
  34975. if (true) {
  34976. zrUtil.assert(this._mounted);
  34977. }
  34978. brushOptionList = zrUtil.map(brushOptionList, function (brushOption) {
  34979. return zrUtil.merge(zrUtil.clone(DEFAULT_BRUSH_OPT), brushOption, true);
  34980. });
  34981. var tmpIdPrefix = '\0-brush-index-';
  34982. var oldCovers = this._covers;
  34983. var newCovers = this._covers = [];
  34984. var controller = this;
  34985. var creatingCover = this._creatingCover;
  34986. (new DataDiffer(oldCovers, brushOptionList, oldGetKey, getKey))
  34987. .add(addOrUpdate)
  34988. .update(addOrUpdate)
  34989. .remove(remove)
  34990. .execute();
  34991. return this;
  34992. function getKey(brushOption, index) {
  34993. return (brushOption.id != null ? brushOption.id : tmpIdPrefix + index)
  34994. + '-' + brushOption.brushType;
  34995. }
  34996. function oldGetKey(cover, index) {
  34997. return getKey(cover.__brushOption, index);
  34998. }
  34999. function addOrUpdate(newIndex, oldIndex) {
  35000. var newBrushOption = brushOptionList[newIndex];
  35001. // Consider setOption in event listener of brushSelect,
  35002. // where updating cover when creating should be forbiden.
  35003. if (oldIndex != null && oldCovers[oldIndex] === creatingCover) {
  35004. newCovers[newIndex] = oldCovers[oldIndex];
  35005. }
  35006. else {
  35007. var cover = newCovers[newIndex] = oldIndex != null
  35008. ? (
  35009. oldCovers[oldIndex].__brushOption = newBrushOption,
  35010. oldCovers[oldIndex]
  35011. )
  35012. : endCreating(controller, createCover(controller, newBrushOption));
  35013. updateCoverAfterCreation(controller, cover);
  35014. }
  35015. }
  35016. function remove(oldIndex) {
  35017. if (oldCovers[oldIndex] !== creatingCover) {
  35018. controller.group.remove(oldCovers[oldIndex]);
  35019. }
  35020. }
  35021. },
  35022. unmount: function () {
  35023. this.enableBrush(false);
  35024. // container may 'removeAll' outside.
  35025. clearCovers(this);
  35026. this._zr.remove(this.group);
  35027. if (true) {
  35028. this._mounted = false; // should be at last.
  35029. }
  35030. return this;
  35031. },
  35032. dispose: function () {
  35033. this.unmount();
  35034. this.off();
  35035. }
  35036. };
  35037. zrUtil.mixin(BrushController, Eventful);
  35038. function doEnableBrush(controller, brushOption) {
  35039. var zr = controller._zr;
  35040. // Consider roam, which takes globalPan too.
  35041. if (!controller._enableGlobalPan) {
  35042. interactionMutex.take(zr, MUTEX_RESOURCE_KEY, controller._uid);
  35043. }
  35044. each(controller._handlers, function (handler, eventName) {
  35045. zr.on(eventName, handler);
  35046. });
  35047. controller._brushType = brushOption.brushType;
  35048. controller._brushOption = zrUtil.merge(zrUtil.clone(DEFAULT_BRUSH_OPT), brushOption, true);
  35049. }
  35050. function doDisableBrush(controller) {
  35051. var zr = controller._zr;
  35052. interactionMutex.release(zr, MUTEX_RESOURCE_KEY, controller._uid);
  35053. each(controller._handlers, function (handler, eventName) {
  35054. zr.off(eventName, handler);
  35055. });
  35056. controller._brushType = controller._brushOption = null;
  35057. }
  35058. function createCover(controller, brushOption) {
  35059. var cover = coverRenderers[brushOption.brushType].createCover(controller, brushOption);
  35060. updateZ(cover);
  35061. cover.__brushOption = brushOption;
  35062. controller.group.add(cover);
  35063. return cover;
  35064. }
  35065. function endCreating(controller, creatingCover) {
  35066. var coverRenderer = getCoverRenderer(creatingCover);
  35067. if (coverRenderer.endCreating) {
  35068. coverRenderer.endCreating(controller, creatingCover);
  35069. updateZ(creatingCover);
  35070. }
  35071. return creatingCover;
  35072. }
  35073. function updateCoverShape(controller, cover) {
  35074. var brushOption = cover.__brushOption;
  35075. getCoverRenderer(cover).updateCoverShape(
  35076. controller, cover, brushOption.range, brushOption
  35077. );
  35078. }
  35079. function updateZ(group) {
  35080. group.traverse(function (el) {
  35081. el.z = COVER_Z;
  35082. el.z2 = COVER_Z; // Consider in given container.
  35083. });
  35084. }
  35085. function updateCoverAfterCreation(controller, cover) {
  35086. getCoverRenderer(cover).updateCommon(controller, cover);
  35087. updateCoverShape(controller, cover);
  35088. }
  35089. function getCoverRenderer(cover) {
  35090. return coverRenderers[cover.__brushOption.brushType];
  35091. }
  35092. function getPanelByPoint(controller, x, y) {
  35093. var panels = controller._panels;
  35094. if (!panels) {
  35095. return true; // Global panel
  35096. }
  35097. var panel;
  35098. each(panels, function (pn) {
  35099. pn.contain(x, y) && (panel = pn);
  35100. });
  35101. return panel;
  35102. }
  35103. function getPanelByCover(controller, cover) {
  35104. var panels = controller._panels;
  35105. if (!panels) {
  35106. return true; // Global panel
  35107. }
  35108. var panelId = cover.__brushOption.panelId;
  35109. // User may give cover without coord sys info,
  35110. // which is then treated as global panel.
  35111. return panelId != null ? panels[panelId] : true;
  35112. }
  35113. function clearCovers(controller) {
  35114. var covers = controller._covers;
  35115. var originalLength = covers.length;
  35116. each(covers, function (cover) {
  35117. controller.group.remove(cover);
  35118. }, controller);
  35119. covers.length = 0;
  35120. return !!originalLength;
  35121. }
  35122. function trigger(controller, opt) {
  35123. var areas = map(controller._covers, function (cover) {
  35124. var brushOption = cover.__brushOption;
  35125. var range = zrUtil.clone(brushOption.range);
  35126. return {
  35127. brushType: brushOption.brushType,
  35128. panelId: brushOption.panelId,
  35129. range: range
  35130. };
  35131. });
  35132. controller.trigger('brush', areas, {
  35133. isEnd: !!opt.isEnd,
  35134. removeOnClick: !!opt.removeOnClick
  35135. });
  35136. }
  35137. function shouldShowCover(controller) {
  35138. var track = controller._track;
  35139. if (!track.length) {
  35140. return false;
  35141. }
  35142. var p2 = track[track.length - 1];
  35143. var p1 = track[0];
  35144. var dx = p2[0] - p1[0];
  35145. var dy = p2[1] - p1[1];
  35146. var dist = mathPow(dx * dx + dy * dy, 0.5);
  35147. return dist > UNSELECT_THRESHOLD;
  35148. }
  35149. function getTrackEnds(track) {
  35150. var tail = track.length - 1;
  35151. tail < 0 && (tail = 0);
  35152. return [track[0], track[tail]];
  35153. }
  35154. function createBaseRectCover(doDrift, controller, brushOption, edgeNames) {
  35155. var cover = new graphic.Group();
  35156. cover.add(new graphic.Rect({
  35157. name: 'main',
  35158. style: makeStyle(brushOption),
  35159. silent: true,
  35160. draggable: true,
  35161. cursor: 'move',
  35162. drift: curry(doDrift, controller, cover, 'nswe'),
  35163. ondragend: curry(trigger, controller, {isEnd: true})
  35164. }));
  35165. each(
  35166. edgeNames,
  35167. function (name) {
  35168. cover.add(new graphic.Rect({
  35169. name: name,
  35170. style: {opacity: 0},
  35171. draggable: true,
  35172. silent: true,
  35173. invisible: true,
  35174. drift: curry(doDrift, controller, cover, name),
  35175. ondragend: curry(trigger, controller, {isEnd: true})
  35176. }));
  35177. }
  35178. );
  35179. return cover;
  35180. }
  35181. function updateBaseRect(controller, cover, localRange, brushOption) {
  35182. var lineWidth = brushOption.brushStyle.lineWidth || 0;
  35183. var handleSize = mathMax(lineWidth, MIN_RESIZE_LINE_WIDTH);
  35184. var x = localRange[0][0];
  35185. var y = localRange[1][0];
  35186. var xa = x - lineWidth / 2;
  35187. var ya = y - lineWidth / 2;
  35188. var x2 = localRange[0][1];
  35189. var y2 = localRange[1][1];
  35190. var x2a = x2 - handleSize + lineWidth / 2;
  35191. var y2a = y2 - handleSize + lineWidth / 2;
  35192. var width = x2 - x;
  35193. var height = y2 - y;
  35194. var widtha = width + lineWidth;
  35195. var heighta = height + lineWidth;
  35196. updateRectShape(controller, cover, 'main', x, y, width, height);
  35197. if (brushOption.transformable) {
  35198. updateRectShape(controller, cover, 'w', xa, ya, handleSize, heighta);
  35199. updateRectShape(controller, cover, 'e', x2a, ya, handleSize, heighta);
  35200. updateRectShape(controller, cover, 'n', xa, ya, widtha, handleSize);
  35201. updateRectShape(controller, cover, 's', xa, y2a, widtha, handleSize);
  35202. updateRectShape(controller, cover, 'nw', xa, ya, handleSize, handleSize);
  35203. updateRectShape(controller, cover, 'ne', x2a, ya, handleSize, handleSize);
  35204. updateRectShape(controller, cover, 'sw', xa, y2a, handleSize, handleSize);
  35205. updateRectShape(controller, cover, 'se', x2a, y2a, handleSize, handleSize);
  35206. }
  35207. }
  35208. function updateCommon(controller, cover) {
  35209. var brushOption = cover.__brushOption;
  35210. var transformable = brushOption.transformable;
  35211. var mainEl = cover.childAt(0);
  35212. mainEl.useStyle(makeStyle(brushOption));
  35213. mainEl.attr({
  35214. silent: !transformable,
  35215. cursor: transformable ? 'move' : 'default'
  35216. });
  35217. each(
  35218. ['w', 'e', 'n', 's', 'se', 'sw', 'ne', 'nw'],
  35219. function (name) {
  35220. var el = cover.childOfName(name);
  35221. var globalDir = getGlobalDirection(controller, name);
  35222. el && el.attr({
  35223. silent: !transformable,
  35224. invisible: !transformable,
  35225. cursor: transformable ? CURSOR_MAP[globalDir] + '-resize' : null
  35226. });
  35227. }
  35228. );
  35229. }
  35230. function updateRectShape(controller, cover, name, x, y, w, h) {
  35231. var el = cover.childOfName(name);
  35232. el && el.setShape(pointsToRect(
  35233. clipByPanel(controller, cover, [[x, y], [x + w, y + h]])
  35234. ));
  35235. }
  35236. function makeStyle(brushOption) {
  35237. return zrUtil.defaults({strokeNoScale: true}, brushOption.brushStyle);
  35238. }
  35239. function formatRectRange(x, y, x2, y2) {
  35240. var min = [mathMin(x, x2), mathMin(y, y2)];
  35241. var max = [mathMax(x, x2), mathMax(y, y2)];
  35242. return [
  35243. [min[0], max[0]], // x range
  35244. [min[1], max[1]] // y range
  35245. ];
  35246. }
  35247. function getTransform(controller) {
  35248. return graphic.getTransform(controller.group);
  35249. }
  35250. function getGlobalDirection(controller, localDirection) {
  35251. if (localDirection.length > 1) {
  35252. localDirection = localDirection.split('');
  35253. var globalDir = [
  35254. getGlobalDirection(controller, localDirection[0]),
  35255. getGlobalDirection(controller, localDirection[1])
  35256. ];
  35257. (globalDir[0] === 'e' || globalDir[0] === 'w') && globalDir.reverse();
  35258. return globalDir.join('');
  35259. }
  35260. else {
  35261. var map = {w: 'left', e: 'right', n: 'top', s: 'bottom'};
  35262. var inverseMap = {left: 'w', right: 'e', top: 'n', bottom: 's'};
  35263. var globalDir = graphic.transformDirection(
  35264. map[localDirection], getTransform(controller)
  35265. );
  35266. return inverseMap[globalDir];
  35267. }
  35268. }
  35269. function driftRect(toRectRange, fromRectRange, controller, cover, name, dx, dy, e) {
  35270. var brushOption = cover.__brushOption;
  35271. var rectRange = toRectRange(brushOption.range);
  35272. var localDelta = toLocalDelta(controller, dx, dy);
  35273. each(name.split(''), function (namePart) {
  35274. var ind = DIRECTION_MAP[namePart];
  35275. rectRange[ind[0]][ind[1]] += localDelta[ind[0]];
  35276. });
  35277. brushOption.range = fromRectRange(formatRectRange(
  35278. rectRange[0][0], rectRange[1][0], rectRange[0][1], rectRange[1][1]
  35279. ));
  35280. updateCoverAfterCreation(controller, cover);
  35281. trigger(controller, {isEnd: false});
  35282. }
  35283. function driftPolygon(controller, cover, dx, dy, e) {
  35284. var range = cover.__brushOption.range;
  35285. var localDelta = toLocalDelta(controller, dx, dy);
  35286. each(range, function (point) {
  35287. point[0] += localDelta[0];
  35288. point[1] += localDelta[1];
  35289. });
  35290. updateCoverAfterCreation(controller, cover);
  35291. trigger(controller, {isEnd: false});
  35292. }
  35293. function toLocalDelta(controller, dx, dy) {
  35294. var thisGroup = controller.group;
  35295. var localD = thisGroup.transformCoordToLocal(dx, dy);
  35296. var localZero = thisGroup.transformCoordToLocal(0, 0);
  35297. return [localD[0] - localZero[0], localD[1] - localZero[1]];
  35298. }
  35299. function clipByPanel(controller, cover, data) {
  35300. var panel = getPanelByCover(controller, cover);
  35301. if (panel === true) { // Global panel
  35302. return zrUtil.clone(data);
  35303. }
  35304. var panelRect = panel.getBoundingRect();
  35305. return zrUtil.map(data, function (point) {
  35306. var x = point[0];
  35307. x = mathMax(x, panelRect.x);
  35308. x = mathMin(x, panelRect.x + panelRect.width);
  35309. var y = point[1];
  35310. y = mathMax(y, panelRect.y);
  35311. y = mathMin(y, panelRect.y + panelRect.height);
  35312. return [x, y];
  35313. });
  35314. }
  35315. function pointsToRect(points) {
  35316. var xmin = mathMin(points[0][0], points[1][0]);
  35317. var ymin = mathMin(points[0][1], points[1][1]);
  35318. var xmax = mathMax(points[0][0], points[1][0]);
  35319. var ymax = mathMax(points[0][1], points[1][1]);
  35320. return {
  35321. x: xmin,
  35322. y: ymin,
  35323. width: xmax - xmin,
  35324. height: ymax - ymin
  35325. };
  35326. }
  35327. function resetCursor(controller, e) {
  35328. var x = e.offsetX;
  35329. var y = e.offsetY;
  35330. var zr = controller._zr;
  35331. if (controller._brushType) { // If active
  35332. var panels = controller._panels;
  35333. var covers = controller._covers;
  35334. var inCover;
  35335. for (var i = 0; i < covers.length; i++) {
  35336. if (coverRenderers[covers[i].__brushOption.brushType].contain(covers[i], x, y)) {
  35337. inCover = true;
  35338. break;
  35339. }
  35340. }
  35341. if (!inCover) {
  35342. if (panels) { // Brush on panels
  35343. each(panels, function (panel) {
  35344. panel.contain(x, y) && zr.setCursorStyle('crosshair');
  35345. });
  35346. }
  35347. else { // Global brush
  35348. zr.setCursorStyle('crosshair');
  35349. }
  35350. }
  35351. }
  35352. }
  35353. function preventDefault(e) {
  35354. var rawE = e.event;
  35355. rawE.preventDefault && rawE.preventDefault();
  35356. }
  35357. function mainShapeContain(cover, x, y) {
  35358. return cover.childOfName('main').contain(x, y);
  35359. }
  35360. function updateCoverByMouse(controller, e, isEnd) {
  35361. var x = e.offsetX;
  35362. var y = e.offsetY;
  35363. var creatingCover = controller._creatingCover;
  35364. var panel = controller._creatingPanel;
  35365. var thisBrushOption = controller._brushOption;
  35366. var eventParams;
  35367. controller._track.push(controller.group.transformCoordToLocal(x, y));
  35368. if (shouldShowCover(controller) || creatingCover) {
  35369. if (panel && !creatingCover) {
  35370. thisBrushOption.brushMode === 'single' && clearCovers(controller);
  35371. var brushOption = zrUtil.clone(thisBrushOption);
  35372. brushOption.panelId = panel === true ? null : panel.__brushPanelId;
  35373. creatingCover = controller._creatingCover = createCover(controller, brushOption);
  35374. controller._covers.push(creatingCover);
  35375. }
  35376. if (creatingCover) {
  35377. var coverRenderer = coverRenderers[controller._brushType];
  35378. var coverBrushOption = creatingCover.__brushOption;
  35379. coverBrushOption.range = coverRenderer.getCreatingRange(
  35380. clipByPanel(controller, creatingCover, controller._track)
  35381. );
  35382. if (isEnd) {
  35383. endCreating(controller, creatingCover);
  35384. coverRenderer.updateCommon(controller, creatingCover);
  35385. }
  35386. updateCoverShape(controller, creatingCover);
  35387. eventParams = {isEnd: isEnd};
  35388. }
  35389. }
  35390. else if (
  35391. isEnd
  35392. && thisBrushOption.brushMode === 'single'
  35393. && thisBrushOption.removeOnClick
  35394. ) {
  35395. // Help user to remove covers easily, only by a tiny drag, in 'single' mode.
  35396. // But a single click do not clear covers, because user may have casual
  35397. // clicks (for example, click on other component and do not expect covers
  35398. // disappear).
  35399. // Only some cover removed, trigger action, but not every click trigger action.
  35400. if (getPanelByPoint(controller, x, y) && clearCovers(controller)) {
  35401. eventParams = {isEnd: isEnd, removeOnClick: true};
  35402. }
  35403. }
  35404. return eventParams;
  35405. }
  35406. var mouseHandlers = {
  35407. mousedown: function (e) {
  35408. if (this._dragging) {
  35409. // In case some browser do not support globalOut,
  35410. // and release mose out side the browser.
  35411. handleDragEnd.call(this, e);
  35412. }
  35413. else if (!e.target || !e.target.draggable) {
  35414. preventDefault(e);
  35415. var x = e.offsetX;
  35416. var y = e.offsetY;
  35417. this._creatingCover = null;
  35418. var panel = this._creatingPanel = getPanelByPoint(this, x, y);
  35419. if (panel) {
  35420. this._dragging = true;
  35421. this._track = [this.group.transformCoordToLocal(x, y)];
  35422. }
  35423. }
  35424. },
  35425. mousemove: function (e) {
  35426. // set Cursor
  35427. resetCursor(this, e);
  35428. if (this._dragging) {
  35429. preventDefault(e);
  35430. var eventParams = updateCoverByMouse(this, e, false);
  35431. eventParams && trigger(this, eventParams);
  35432. }
  35433. },
  35434. mouseup: handleDragEnd //,
  35435. // FIXME
  35436. // in tooltip, globalout should not be triggered.
  35437. // globalout: handleDragEnd
  35438. };
  35439. function handleDragEnd(e) {
  35440. if (this._dragging) {
  35441. preventDefault(e);
  35442. var eventParams = updateCoverByMouse(this, e, true);
  35443. this._dragging = false;
  35444. this._track = [];
  35445. this._creatingCover = null;
  35446. // trigger event shoule be at final, after procedure will be nested.
  35447. eventParams && trigger(this, eventParams);
  35448. }
  35449. }
  35450. /**
  35451. * key: brushType
  35452. * @type {Object}
  35453. */
  35454. var coverRenderers = {
  35455. lineX: getLineRenderer(0),
  35456. lineY: getLineRenderer(1),
  35457. rect: {
  35458. createCover: function (controller, brushOption) {
  35459. return createBaseRectCover(
  35460. curry(
  35461. driftRect,
  35462. function (range) {
  35463. return range;
  35464. },
  35465. function (range) {
  35466. return range;
  35467. }
  35468. ),
  35469. controller,
  35470. brushOption,
  35471. ['w', 'e', 'n', 's', 'se', 'sw', 'ne', 'nw']
  35472. );
  35473. },
  35474. getCreatingRange: function (localTrack) {
  35475. var ends = getTrackEnds(localTrack);
  35476. return formatRectRange(ends[1][0], ends[1][1], ends[0][0], ends[0][1]);
  35477. },
  35478. updateCoverShape: function (controller, cover, localRange, brushOption) {
  35479. updateBaseRect(controller, cover, localRange, brushOption);
  35480. },
  35481. updateCommon: updateCommon,
  35482. contain: mainShapeContain
  35483. },
  35484. polygon: {
  35485. createCover: function (controller, brushOption) {
  35486. var cover = new graphic.Group();
  35487. // Do not use graphic.Polygon because graphic.Polyline do not close the
  35488. // border of the shape when drawing, which is a better experience for user.
  35489. cover.add(new graphic.Polyline({
  35490. name: 'main',
  35491. style: makeStyle(brushOption),
  35492. silent: true
  35493. }));
  35494. return cover;
  35495. },
  35496. getCreatingRange: function (localTrack) {
  35497. return localTrack;
  35498. },
  35499. endCreating: function (controller, cover) {
  35500. cover.remove(cover.childAt(0));
  35501. // Use graphic.Polygon close the shape.
  35502. cover.add(new graphic.Polygon({
  35503. name: 'main',
  35504. draggable: true,
  35505. drift: curry(driftPolygon, controller, cover),
  35506. ondragend: curry(trigger, controller, {isEnd: true})
  35507. }));
  35508. },
  35509. updateCoverShape: function (controller, cover, localRange, brushOption) {
  35510. cover.childAt(0).setShape({
  35511. points: clipByPanel(controller, cover, localRange)
  35512. });
  35513. },
  35514. updateCommon: updateCommon,
  35515. contain: mainShapeContain
  35516. }
  35517. };
  35518. function getLineRenderer(xyIndex) {
  35519. return {
  35520. createCover: function (controller, brushOption) {
  35521. return createBaseRectCover(
  35522. curry(
  35523. driftRect,
  35524. function (range) {
  35525. var rectRange = [range, [0, 100]];
  35526. xyIndex && rectRange.reverse();
  35527. return rectRange;
  35528. },
  35529. function (rectRange) {
  35530. return rectRange[xyIndex];
  35531. }
  35532. ),
  35533. controller,
  35534. brushOption,
  35535. [['w', 'e'], ['n', 's']][xyIndex]
  35536. );
  35537. },
  35538. getCreatingRange: function (localTrack) {
  35539. var ends = getTrackEnds(localTrack);
  35540. var min = mathMin(ends[0][xyIndex], ends[1][xyIndex]);
  35541. var max = mathMax(ends[0][xyIndex], ends[1][xyIndex]);
  35542. return [min, max];
  35543. },
  35544. updateCoverShape: function (controller, cover, localRange, brushOption) {
  35545. var brushWidth = brushOption.brushStyle.width;
  35546. var otherExtent;
  35547. // If brushWidth not specified, fit the panel.
  35548. if (brushWidth == null) {
  35549. var panel = getPanelByCover(controller, cover);
  35550. var base = 0;
  35551. if (panel !== true) {
  35552. var rect = panel.getBoundingRect();
  35553. brushWidth = xyIndex ? rect.width : rect.height;
  35554. base = xyIndex ? rect.x : rect.y;
  35555. }
  35556. // FIXME
  35557. // do not support global panel yet.
  35558. otherExtent = [base, base + (brushWidth || 0)];
  35559. }
  35560. else {
  35561. otherExtent = [-brushWidth / 2, brushWidth / 2];
  35562. }
  35563. var rectRange = [localRange, otherExtent];
  35564. xyIndex && rectRange.reverse();
  35565. updateBaseRect(controller, cover, rectRange, brushOption);
  35566. },
  35567. updateCommon: updateCommon,
  35568. contain: mainShapeContain
  35569. };
  35570. }
  35571. module.exports = BrushController;
  35572. /***/ },
  35573. /* 234 */
  35574. /***/ function(module, exports, __webpack_require__) {
  35575. var zrUtil = __webpack_require__(4);
  35576. var modelUtil = __webpack_require__(5);
  35577. module.exports = function (option) {
  35578. createParallelIfNeeded(option);
  35579. mergeAxisOptionFromParallel(option);
  35580. };
  35581. /**
  35582. * Create a parallel coordinate if not exists.
  35583. * @inner
  35584. */
  35585. function createParallelIfNeeded(option) {
  35586. if (option.parallel) {
  35587. return;
  35588. }
  35589. var hasParallelSeries = false;
  35590. zrUtil.each(option.series, function (seriesOpt) {
  35591. if (seriesOpt && seriesOpt.type === 'parallel') {
  35592. hasParallelSeries = true;
  35593. }
  35594. });
  35595. if (hasParallelSeries) {
  35596. option.parallel = [{}];
  35597. }
  35598. }
  35599. /**
  35600. * Merge aixs definition from parallel option (if exists) to axis option.
  35601. * @inner
  35602. */
  35603. function mergeAxisOptionFromParallel(option) {
  35604. var axes = modelUtil.normalizeToArray(option.parallelAxis);
  35605. zrUtil.each(axes, function (axisOption) {
  35606. if (!zrUtil.isObject(axisOption)) {
  35607. return;
  35608. }
  35609. var parallelIndex = axisOption.parallelIndex || 0;
  35610. var parallelOption = modelUtil.normalizeToArray(option.parallel)[parallelIndex];
  35611. if (parallelOption && parallelOption.parallelAxisDefault) {
  35612. zrUtil.merge(axisOption, parallelOption.parallelAxisDefault, false);
  35613. }
  35614. });
  35615. }
  35616. /***/ },
  35617. /* 235 */
  35618. /***/ function(module, exports, __webpack_require__) {
  35619. var List = __webpack_require__(97);
  35620. var zrUtil = __webpack_require__(4);
  35621. var SeriesModel = __webpack_require__(28);
  35622. var completeDimensions = __webpack_require__(102);
  35623. module.exports = SeriesModel.extend({
  35624. type: 'series.parallel',
  35625. dependencies: ['parallel'],
  35626. getInitialData: function (option, ecModel) {
  35627. var parallelModel = ecModel.getComponent(
  35628. 'parallel', this.get('parallelIndex')
  35629. );
  35630. var parallelAxisIndices = parallelModel.parallelAxisIndex;
  35631. var rawData = option.data;
  35632. var modelDims = parallelModel.dimensions;
  35633. var dataDims = generateDataDims(modelDims, rawData);
  35634. var dataDimsInfo = zrUtil.map(dataDims, function (dim, dimIndex) {
  35635. var modelDimsIndex = zrUtil.indexOf(modelDims, dim);
  35636. var axisModel = modelDimsIndex >= 0 && ecModel.getComponent(
  35637. 'parallelAxis', parallelAxisIndices[modelDimsIndex]
  35638. );
  35639. if (axisModel && axisModel.get('type') === 'category') {
  35640. translateCategoryValue(axisModel, dim, rawData);
  35641. return {name: dim, type: 'ordinal'};
  35642. }
  35643. else if (modelDimsIndex < 0) {
  35644. return completeDimensions.guessOrdinal(rawData, dimIndex)
  35645. ? {name: dim, type: 'ordinal'}
  35646. : dim;
  35647. }
  35648. else {
  35649. return dim;
  35650. }
  35651. });
  35652. var list = new List(dataDimsInfo, this);
  35653. list.initData(rawData);
  35654. // Anication is forbiden in progressive data mode.
  35655. if (this.option.progressive) {
  35656. this.option.animation = false;
  35657. }
  35658. return list;
  35659. },
  35660. /**
  35661. * User can get data raw indices on 'axisAreaSelected' event received.
  35662. *
  35663. * @public
  35664. * @param {string} activeState 'active' or 'inactive' or 'normal'
  35665. * @return {Array.<number>} Raw indices
  35666. */
  35667. getRawIndicesByActiveState: function (activeState) {
  35668. var coordSys = this.coordinateSystem;
  35669. var data = this.getData();
  35670. var indices = [];
  35671. coordSys.eachActiveState(data, function (theActiveState, dataIndex) {
  35672. if (activeState === theActiveState) {
  35673. indices.push(data.getRawIndex(dataIndex));
  35674. }
  35675. });
  35676. return indices;
  35677. },
  35678. defaultOption: {
  35679. zlevel: 0, // 一级层叠
  35680. z: 2, // 二级层叠
  35681. coordinateSystem: 'parallel',
  35682. parallelIndex: 0,
  35683. label: {
  35684. normal: {
  35685. show: false
  35686. },
  35687. emphasis: {
  35688. show: false
  35689. }
  35690. },
  35691. inactiveOpacity: 0.05,
  35692. activeOpacity: 1,
  35693. lineStyle: {
  35694. normal: {
  35695. width: 1,
  35696. opacity: 0.45,
  35697. type: 'solid'
  35698. }
  35699. },
  35700. progressive: false, // 100
  35701. smooth: false,
  35702. animationEasing: 'linear'
  35703. }
  35704. });
  35705. function translateCategoryValue(axisModel, dim, rawData) {
  35706. var axisData = axisModel.get('data');
  35707. var numberDim = convertDimNameToNumber(dim);
  35708. if (axisData && axisData.length) {
  35709. zrUtil.each(rawData, function (dataItem) {
  35710. if (!dataItem) {
  35711. return;
  35712. }
  35713. // FIXME
  35714. // time consuming, should use hash?
  35715. var index = zrUtil.indexOf(axisData, dataItem[numberDim]);
  35716. dataItem[numberDim] = index >= 0 ? index : NaN;
  35717. });
  35718. }
  35719. // FIXME
  35720. // 如果没有设置axis data, 应自动算出,或者提示。
  35721. }
  35722. function convertDimNameToNumber(dimName) {
  35723. return +dimName.replace('dim', '');
  35724. }
  35725. function generateDataDims(modelDims, rawData) {
  35726. // parallelModel.dimension should not be regarded as data
  35727. // dimensions. Consider dimensions = ['dim4', 'dim2', 'dim6'];
  35728. // We detect max dim by parallelModel.dimensions and fist
  35729. // item in rawData arbitrarily.
  35730. var maxDimNum = 0;
  35731. zrUtil.each(modelDims, function (dimName) {
  35732. var numberDim = convertDimNameToNumber(dimName);
  35733. numberDim > maxDimNum && (maxDimNum = numberDim);
  35734. });
  35735. var firstItem = rawData[0];
  35736. if (firstItem && firstItem.length - 1 > maxDimNum) {
  35737. maxDimNum = firstItem.length - 1;
  35738. }
  35739. var dataDims = [];
  35740. for (var i = 0; i <= maxDimNum; i++) {
  35741. dataDims.push('dim' + i);
  35742. }
  35743. return dataDims;
  35744. }
  35745. /***/ },
  35746. /* 236 */
  35747. /***/ function(module, exports, __webpack_require__) {
  35748. var graphic = __webpack_require__(43);
  35749. var zrUtil = __webpack_require__(4);
  35750. var SMOOTH = 0.3;
  35751. var ParallelView = __webpack_require__(42).extend({
  35752. type: 'parallel',
  35753. init: function () {
  35754. /**
  35755. * @type {module:zrender/container/Group}
  35756. * @private
  35757. */
  35758. this._dataGroup = new graphic.Group();
  35759. this.group.add(this._dataGroup);
  35760. /**
  35761. * @type {module:echarts/data/List}
  35762. */
  35763. this._data;
  35764. },
  35765. /**
  35766. * @override
  35767. */
  35768. render: function (seriesModel, ecModel, api, payload) {
  35769. this._renderForNormal(seriesModel);
  35770. // this[
  35771. // seriesModel.option.progressive
  35772. // ? '_renderForProgressive'
  35773. // : '_renderForNormal'
  35774. // ](seriesModel);
  35775. },
  35776. /**
  35777. * @private
  35778. */
  35779. _renderForNormal: function (seriesModel) {
  35780. var dataGroup = this._dataGroup;
  35781. var data = seriesModel.getData();
  35782. var oldData = this._data;
  35783. var coordSys = seriesModel.coordinateSystem;
  35784. var dimensions = coordSys.dimensions;
  35785. var option = seriesModel.option;
  35786. var smooth = option.smooth ? SMOOTH : null;
  35787. // Consider switch between progressive and not.
  35788. // oldData && oldData.__plProgressive && dataGroup.removeAll();
  35789. data.diff(oldData)
  35790. .add(add)
  35791. .update(update)
  35792. .remove(remove)
  35793. .execute();
  35794. // Update style
  35795. updateElCommon(data, smooth);
  35796. // First create
  35797. if (!this._data) {
  35798. var clipPath = createGridClipShape(
  35799. coordSys, seriesModel, function () {
  35800. // Callback will be invoked immediately if there is no animation
  35801. setTimeout(function () {
  35802. dataGroup.removeClipPath();
  35803. });
  35804. }
  35805. );
  35806. dataGroup.setClipPath(clipPath);
  35807. }
  35808. this._data = data;
  35809. function add(newDataIndex) {
  35810. addEl(data, dataGroup, newDataIndex, dimensions, coordSys, null, smooth);
  35811. }
  35812. function update(newDataIndex, oldDataIndex) {
  35813. var line = oldData.getItemGraphicEl(oldDataIndex);
  35814. var points = createLinePoints(data, newDataIndex, dimensions, coordSys);
  35815. data.setItemGraphicEl(newDataIndex, line);
  35816. graphic.updateProps(line, {shape: {points: points}}, seriesModel, newDataIndex);
  35817. }
  35818. function remove(oldDataIndex) {
  35819. var line = oldData.getItemGraphicEl(oldDataIndex);
  35820. dataGroup.remove(line);
  35821. }
  35822. },
  35823. /**
  35824. * @private
  35825. */
  35826. // _renderForProgressive: function (seriesModel) {
  35827. // var dataGroup = this._dataGroup;
  35828. // var data = seriesModel.getData();
  35829. // var oldData = this._data;
  35830. // var coordSys = seriesModel.coordinateSystem;
  35831. // var dimensions = coordSys.dimensions;
  35832. // var option = seriesModel.option;
  35833. // var progressive = option.progressive;
  35834. // var smooth = option.smooth ? SMOOTH : null;
  35835. // // In progressive animation is disabled, so use simple data diff,
  35836. // // which effects performance less.
  35837. // // (Typically performance for data with length 7000+ like:
  35838. // // simpleDiff: 60ms, addEl: 184ms,
  35839. // // in RMBP 2.4GHz intel i7, OSX 10.9 chrome 50.0.2661.102 (64-bit))
  35840. // if (simpleDiff(oldData, data, dimensions)) {
  35841. // dataGroup.removeAll();
  35842. // data.each(function (dataIndex) {
  35843. // addEl(data, dataGroup, dataIndex, dimensions, coordSys);
  35844. // });
  35845. // }
  35846. // updateElCommon(data, progressive, smooth);
  35847. // // Consider switch between progressive and not.
  35848. // data.__plProgressive = true;
  35849. // this._data = data;
  35850. // },
  35851. /**
  35852. * @override
  35853. */
  35854. remove: function () {
  35855. this._dataGroup && this._dataGroup.removeAll();
  35856. this._data = null;
  35857. }
  35858. });
  35859. function createGridClipShape(coordSys, seriesModel, cb) {
  35860. var parallelModel = coordSys.model;
  35861. var rect = coordSys.getRect();
  35862. var rectEl = new graphic.Rect({
  35863. shape: {
  35864. x: rect.x,
  35865. y: rect.y,
  35866. width: rect.width,
  35867. height: rect.height
  35868. }
  35869. });
  35870. var dim = parallelModel.get('layout') === 'horizontal' ? 'width' : 'height';
  35871. rectEl.setShape(dim, 0);
  35872. graphic.initProps(rectEl, {
  35873. shape: {
  35874. width: rect.width,
  35875. height: rect.height
  35876. }
  35877. }, seriesModel, cb);
  35878. return rectEl;
  35879. }
  35880. function createLinePoints(data, dataIndex, dimensions, coordSys) {
  35881. var points = [];
  35882. for (var i = 0; i < dimensions.length; i++) {
  35883. var dimName = dimensions[i];
  35884. var value = data.get(dimName, dataIndex);
  35885. if (!isEmptyValue(value, coordSys.getAxis(dimName).type)) {
  35886. points.push(coordSys.dataToPoint(value, dimName));
  35887. }
  35888. }
  35889. return points;
  35890. }
  35891. function addEl(data, dataGroup, dataIndex, dimensions, coordSys) {
  35892. var points = createLinePoints(data, dataIndex, dimensions, coordSys);
  35893. var line = new graphic.Polyline({
  35894. shape: {points: points},
  35895. silent: true,
  35896. z2: 10
  35897. });
  35898. dataGroup.add(line);
  35899. data.setItemGraphicEl(dataIndex, line);
  35900. }
  35901. function updateElCommon(data, smooth) {
  35902. var seriesStyleModel = data.hostModel.getModel('lineStyle.normal');
  35903. var lineStyle = seriesStyleModel.getLineStyle();
  35904. data.eachItemGraphicEl(function (line, dataIndex) {
  35905. if (data.hasItemOption) {
  35906. var itemModel = data.getItemModel(dataIndex);
  35907. var lineStyleModel = itemModel.getModel('lineStyle.normal', seriesStyleModel);
  35908. lineStyle = lineStyleModel.getLineStyle();
  35909. }
  35910. line.useStyle(zrUtil.extend(
  35911. lineStyle,
  35912. {
  35913. fill: null,
  35914. stroke: data.getItemVisual(dataIndex, 'color'),
  35915. opacity: data.getItemVisual(dataIndex, 'opacity')
  35916. }
  35917. ));
  35918. line.shape.smooth = smooth;
  35919. });
  35920. }
  35921. // function simpleDiff(oldData, newData, dimensions) {
  35922. // var oldLen;
  35923. // if (!oldData
  35924. // || !oldData.__plProgressive
  35925. // || (oldLen = oldData.count()) !== newData.count()
  35926. // ) {
  35927. // return true;
  35928. // }
  35929. // var dimLen = dimensions.length;
  35930. // for (var i = 0; i < oldLen; i++) {
  35931. // for (var j = 0; j < dimLen; j++) {
  35932. // if (oldData.get(dimensions[j], i) !== newData.get(dimensions[j], i)) {
  35933. // return true;
  35934. // }
  35935. // }
  35936. // }
  35937. // return false;
  35938. // }
  35939. // FIXME
  35940. // 公用方法?
  35941. function isEmptyValue(val, axisType) {
  35942. return axisType === 'category'
  35943. ? val == null
  35944. : (val == null || isNaN(val)); // axisType === 'value'
  35945. }
  35946. module.exports = ParallelView;
  35947. /***/ },
  35948. /* 237 */
  35949. /***/ function(module, exports) {
  35950. module.exports = function (ecModel) {
  35951. ecModel.eachSeriesByType('parallel', function (seriesModel) {
  35952. var itemStyleModel = seriesModel.getModel('itemStyle.normal');
  35953. var lineStyleModel = seriesModel.getModel('lineStyle.normal');
  35954. var globalColors = ecModel.get('color');
  35955. var color = lineStyleModel.get('color')
  35956. || itemStyleModel.get('color')
  35957. || globalColors[seriesModel.seriesIndex % globalColors.length];
  35958. var inactiveOpacity = seriesModel.get('inactiveOpacity');
  35959. var activeOpacity = seriesModel.get('activeOpacity');
  35960. var lineStyle = seriesModel.getModel('lineStyle.normal').getLineStyle();
  35961. var coordSys = seriesModel.coordinateSystem;
  35962. var data = seriesModel.getData();
  35963. var opacityMap = {
  35964. normal: lineStyle.opacity,
  35965. active: activeOpacity,
  35966. inactive: inactiveOpacity
  35967. };
  35968. coordSys.eachActiveState(data, function (activeState, dataIndex) {
  35969. data.setItemVisual(dataIndex, 'opacity', opacityMap[activeState]);
  35970. });
  35971. data.setVisual('color', color);
  35972. });
  35973. };
  35974. /***/ },
  35975. /* 238 */
  35976. /***/ function(module, exports, __webpack_require__) {
  35977. var echarts = __webpack_require__(1);
  35978. __webpack_require__(239);
  35979. __webpack_require__(240);
  35980. echarts.registerLayout(__webpack_require__(241));
  35981. echarts.registerVisual(__webpack_require__(243));
  35982. /***/ },
  35983. /* 239 */
  35984. /***/ function(module, exports, __webpack_require__) {
  35985. 'use strict';
  35986. var SeriesModel = __webpack_require__(28);
  35987. var createGraphFromNodeEdge = __webpack_require__(196);
  35988. var SankeySeries = SeriesModel.extend({
  35989. type: 'series.sankey',
  35990. layoutInfo: null,
  35991. getInitialData: function (option, ecModel) {
  35992. var links = option.edges || option.links;
  35993. var nodes = option.data || option.nodes;
  35994. if (nodes && links) {
  35995. var graph = createGraphFromNodeEdge(nodes, links, this, true);
  35996. return graph.data;
  35997. }
  35998. },
  35999. /**
  36000. * @return {module:echarts/data/Graph}
  36001. */
  36002. getGraph: function () {
  36003. return this.getData().graph;
  36004. },
  36005. /**
  36006. * return {module:echarts/data/List}
  36007. */
  36008. getEdgeData: function() {
  36009. return this.getGraph().edgeData;
  36010. },
  36011. /**
  36012. * @override
  36013. */
  36014. formatTooltip: function (dataIndex, multipleSeries, dataType) {
  36015. if (dataType === 'edge') {
  36016. var params = this.getDataParams(dataIndex, dataType);
  36017. var rawDataOpt = params.data;
  36018. var html = rawDataOpt.source + ' -- ' + rawDataOpt.target;
  36019. if (params.value) {
  36020. html += ' : ' + params.value;
  36021. }
  36022. return html;
  36023. }
  36024. else {
  36025. return SankeySeries.superCall(this, 'formatTooltip', dataIndex, multipleSeries);
  36026. }
  36027. // dataType === 'node' or empty do not show tooltip by default.
  36028. },
  36029. defaultOption: {
  36030. zlevel: 0,
  36031. z: 2,
  36032. coordinateSystem: 'view',
  36033. layout : null,
  36034. // the position of the whole view
  36035. left: '5%',
  36036. top: '5%',
  36037. right: '20%',
  36038. bottom: '5%',
  36039. // the dx of the node
  36040. nodeWidth: 20,
  36041. // the distance between two nodes
  36042. nodeGap: 8,
  36043. // the number of iterations to change the position of the node
  36044. layoutIterations: 32,
  36045. label: {
  36046. normal: {
  36047. show: true,
  36048. position: 'right',
  36049. textStyle: {
  36050. color: '#000',
  36051. fontSize: 12
  36052. }
  36053. },
  36054. emphasis: {
  36055. show: true
  36056. }
  36057. },
  36058. itemStyle: {
  36059. normal: {
  36060. borderWidth: 1,
  36061. borderColor: '#333'
  36062. }
  36063. },
  36064. lineStyle: {
  36065. normal: {
  36066. color: '#314656',
  36067. opacity: 0.2,
  36068. curveness: 0.5
  36069. },
  36070. emphasis: {
  36071. opacity: 0.6
  36072. }
  36073. },
  36074. animationEasing: 'linear',
  36075. animationDuration: 1000
  36076. }
  36077. });
  36078. module.exports = SankeySeries;
  36079. /***/ },
  36080. /* 240 */
  36081. /***/ function(module, exports, __webpack_require__) {
  36082. var graphic = __webpack_require__(43);
  36083. var zrUtil = __webpack_require__(4);
  36084. var SankeyShape = graphic.extendShape({
  36085. shape: {
  36086. x1: 0, y1: 0,
  36087. x2: 0, y2: 0,
  36088. cpx1: 0, cpy1: 0,
  36089. cpx2: 0, cpy2: 0,
  36090. extent: 0
  36091. },
  36092. buildPath: function (ctx, shape) {
  36093. var halfExtent = shape.extent / 2;
  36094. ctx.moveTo(shape.x1, shape.y1 - halfExtent);
  36095. ctx.bezierCurveTo(
  36096. shape.cpx1, shape.cpy1 - halfExtent,
  36097. shape.cpx2, shape.cpy2 - halfExtent,
  36098. shape.x2, shape.y2 - halfExtent
  36099. );
  36100. ctx.lineTo(shape.x2, shape.y2 + halfExtent);
  36101. ctx.bezierCurveTo(
  36102. shape.cpx2, shape.cpy2 + halfExtent,
  36103. shape.cpx1, shape.cpy1 + halfExtent,
  36104. shape.x1, shape.y1 + halfExtent
  36105. );
  36106. ctx.closePath();
  36107. }
  36108. });
  36109. module.exports = __webpack_require__(1).extendChartView({
  36110. type: 'sankey',
  36111. /**
  36112. * @private
  36113. * @type {module:echarts/chart/sankey/SankeySeries}
  36114. */
  36115. _model: null,
  36116. render: function(seriesModel, ecModel, api) {
  36117. var graph = seriesModel.getGraph();
  36118. var group = this.group;
  36119. var layoutInfo = seriesModel.layoutInfo;
  36120. var nodeData = seriesModel.getData();
  36121. var edgeData = seriesModel.getData('edge');
  36122. this._model = seriesModel;
  36123. group.removeAll();
  36124. group.position = [layoutInfo.x, layoutInfo.y];
  36125. // generate a rect for each node
  36126. graph.eachNode(function (node) {
  36127. var layout = node.getLayout();
  36128. var itemModel = node.getModel();
  36129. var labelModel = itemModel.getModel('label.normal');
  36130. var textStyleModel = labelModel.getModel('textStyle');
  36131. var labelHoverModel = itemModel.getModel('label.emphasis');
  36132. var textStyleHoverModel = labelHoverModel.getModel('textStyle');
  36133. var rect = new graphic.Rect({
  36134. shape: {
  36135. x: layout.x,
  36136. y: layout.y,
  36137. width: node.getLayout().dx,
  36138. height: node.getLayout().dy
  36139. },
  36140. style: {
  36141. // Get formatted label in label.normal option. Use node id if it is not specified
  36142. text: labelModel.get('show')
  36143. ? seriesModel.getFormattedLabel(node.dataIndex, 'normal') || node.id
  36144. // Use empty string to hide the label
  36145. : '',
  36146. textFont: textStyleModel.getFont(),
  36147. textFill: textStyleModel.getTextColor(),
  36148. textPosition: labelModel.get('position')
  36149. }
  36150. });
  36151. rect.setStyle(zrUtil.defaults(
  36152. {
  36153. fill: node.getVisual('color')
  36154. },
  36155. itemModel.getModel('itemStyle.normal').getItemStyle()
  36156. ));
  36157. graphic.setHoverStyle(rect, zrUtil.extend(
  36158. node.getModel('itemStyle.emphasis'),
  36159. {
  36160. text: labelHoverModel.get('show')
  36161. ? seriesModel.getFormattedLabel(node.dataIndex, 'emphasis') || node.id
  36162. : '',
  36163. textFont: textStyleHoverModel.getFont(),
  36164. textFill: textStyleHoverModel.getTextColor(),
  36165. textPosition: labelHoverModel.get('position')
  36166. }
  36167. ));
  36168. group.add(rect);
  36169. nodeData.setItemGraphicEl(node.dataIndex, rect);
  36170. rect.dataType = 'node';
  36171. });
  36172. // generate a bezire Curve for each edge
  36173. graph.eachEdge(function (edge) {
  36174. var curve = new SankeyShape();
  36175. curve.dataIndex = edge.dataIndex;
  36176. curve.seriesIndex = seriesModel.seriesIndex;
  36177. curve.dataType = 'edge';
  36178. var lineStyleModel = edge.getModel('lineStyle.normal');
  36179. var curvature = lineStyleModel.get('curveness');
  36180. var n1Layout = edge.node1.getLayout();
  36181. var n2Layout = edge.node2.getLayout();
  36182. var edgeLayout = edge.getLayout();
  36183. curve.shape.extent = Math.max(1, edgeLayout.dy);
  36184. var x1 = n1Layout.x + n1Layout.dx;
  36185. var y1 = n1Layout.y + edgeLayout.sy + edgeLayout.dy / 2;
  36186. var x2 = n2Layout.x;
  36187. var y2 = n2Layout.y + edgeLayout.ty + edgeLayout.dy / 2;
  36188. var cpx1 = x1 * (1 - curvature) + x2 * curvature;
  36189. var cpy1 = y1;
  36190. var cpx2 = x1 * curvature + x2 * (1 - curvature);
  36191. var cpy2 = y2;
  36192. curve.setShape({
  36193. x1: x1,
  36194. y1: y1,
  36195. x2: x2,
  36196. y2: y2,
  36197. cpx1: cpx1,
  36198. cpy1: cpy1,
  36199. cpx2: cpx2,
  36200. cpy2: cpy2
  36201. });
  36202. curve.setStyle(lineStyleModel.getItemStyle());
  36203. // Special color, use source node color or target node color
  36204. switch (curve.style.fill) {
  36205. case 'source':
  36206. curve.style.fill = edge.node1.getVisual('color');
  36207. break;
  36208. case 'target':
  36209. curve.style.fill = edge.node2.getVisual('color');
  36210. break;
  36211. default:
  36212. }
  36213. graphic.setHoverStyle(curve, edge.getModel('lineStyle.emphasis').getItemStyle());
  36214. group.add(curve);
  36215. edgeData.setItemGraphicEl(edge.dataIndex, curve);
  36216. });
  36217. if (!this._data && seriesModel.get('animation')) {
  36218. group.setClipPath(createGridClipShape(group.getBoundingRect(), seriesModel, function () {
  36219. group.removeClipPath();
  36220. }));
  36221. }
  36222. this._data = seriesModel.getData();
  36223. }
  36224. });
  36225. //add animation to the view
  36226. function createGridClipShape(rect, seriesModel, cb) {
  36227. var rectEl = new graphic.Rect({
  36228. shape: {
  36229. x: rect.x - 10,
  36230. y: rect.y - 10,
  36231. width: 0,
  36232. height: rect.height + 20
  36233. }
  36234. });
  36235. graphic.initProps(rectEl, {
  36236. shape: {
  36237. width: rect.width + 20,
  36238. height: rect.height + 20
  36239. }
  36240. }, seriesModel, cb);
  36241. return rectEl;
  36242. }
  36243. /***/ },
  36244. /* 241 */
  36245. /***/ function(module, exports, __webpack_require__) {
  36246. var layout = __webpack_require__(21);
  36247. var nest = __webpack_require__(242);
  36248. var zrUtil = __webpack_require__(4);
  36249. module.exports = function (ecModel, api, payload) {
  36250. ecModel.eachSeriesByType('sankey', function (seriesModel) {
  36251. var nodeWidth = seriesModel.get('nodeWidth');
  36252. var nodeGap = seriesModel.get('nodeGap');
  36253. var layoutInfo = getViewRect(seriesModel, api);
  36254. seriesModel.layoutInfo = layoutInfo;
  36255. var width = layoutInfo.width;
  36256. var height = layoutInfo.height;
  36257. var graph = seriesModel.getGraph();
  36258. var nodes = graph.nodes;
  36259. var edges = graph.edges;
  36260. computeNodeValues(nodes);
  36261. var filteredNodes = nodes.filter(function (node) {
  36262. return node.getLayout().value === 0;
  36263. });
  36264. var iterations = filteredNodes.length !== 0
  36265. ? 0 : seriesModel.get('layoutIterations');
  36266. layoutSankey(nodes, edges, nodeWidth, nodeGap, width, height, iterations);
  36267. });
  36268. };
  36269. /**
  36270. * get the layout position of the whole view.
  36271. */
  36272. function getViewRect(seriesModel, api) {
  36273. return layout.getLayoutRect(
  36274. seriesModel.getBoxLayoutParams(), {
  36275. width: api.getWidth(),
  36276. height: api.getHeight()
  36277. }
  36278. );
  36279. }
  36280. function layoutSankey(nodes, edges, nodeWidth, nodeGap, width, height, iterations) {
  36281. computeNodeBreadths(nodes, nodeWidth, width);
  36282. computeNodeDepths(nodes, edges, height, nodeGap, iterations);
  36283. computeEdgeDepths(nodes);
  36284. }
  36285. /**
  36286. * compute the value of each node by summing the associated edge's value.
  36287. * @param {module:echarts/data/Graph~Node} nodes
  36288. */
  36289. function computeNodeValues(nodes) {
  36290. zrUtil.each(nodes, function (node) {
  36291. var value1 = sum(node.outEdges, getEdgeValue);
  36292. var value2 = sum(node.inEdges, getEdgeValue);
  36293. var value = Math.max(value1, value2);
  36294. node.setLayout({value: value}, true);
  36295. });
  36296. }
  36297. /**
  36298. * compute the x-position for each node.
  36299. * @param {module:echarts/data/Graph~Node} nodes
  36300. * @param {number} nodeWidth
  36301. * @param {number} width
  36302. */
  36303. function computeNodeBreadths(nodes, nodeWidth, width) {
  36304. var remainNodes = nodes;
  36305. var nextNode = null;
  36306. var x = 0;
  36307. var kx = 0;
  36308. while (remainNodes.length) {
  36309. nextNode = [];
  36310. for (var i = 0, len = remainNodes.length; i < len; i++) {
  36311. var node = remainNodes[i];
  36312. node.setLayout({x: x}, true);
  36313. node.setLayout({dx: nodeWidth}, true);
  36314. for (var j = 0, lenj = node.outEdges.length; j < lenj; j++) {
  36315. nextNode.push(node.outEdges[j].node2);
  36316. }
  36317. }
  36318. remainNodes = nextNode;
  36319. ++x;
  36320. }
  36321. moveSinksRight(nodes, x);
  36322. kx = (width - nodeWidth) / (x - 1);
  36323. scaleNodeBreadths(nodes, kx);
  36324. }
  36325. /**
  36326. * all the node without outEgdes are assigned maximum breadth and
  36327. * be aligned in the last column.
  36328. * @param {module:echarts/data/Graph~Node} nodes
  36329. * @param {number} x
  36330. */
  36331. function moveSinksRight(nodes, x) {
  36332. zrUtil.each(nodes, function (node) {
  36333. if(!node.outEdges.length) {
  36334. node.setLayout({x: x-1}, true);
  36335. }
  36336. });
  36337. }
  36338. /**
  36339. * scale node x-position to the width.
  36340. * @param {module:echarts/data/Graph~Node} nodes
  36341. * @param {number} kx
  36342. */
  36343. function scaleNodeBreadths(nodes, kx) {
  36344. zrUtil.each(nodes, function(node) {
  36345. var nodeX = node.getLayout().x * kx;
  36346. node.setLayout({x: nodeX}, true);
  36347. });
  36348. }
  36349. /**
  36350. * using Gauss-Seidel iterations method to compute the node depth(y-position).
  36351. * @param {module:echarts/data/Graph~Node} nodes
  36352. * @param {module:echarts/data/Graph~Edge} edges
  36353. * @param {number} height
  36354. * @param {numbber} nodeGap
  36355. * @param {number} iterations
  36356. */
  36357. function computeNodeDepths(nodes, edges, height, nodeGap, iterations) {
  36358. var nodesByBreadth = nest()
  36359. .key(function (d) {
  36360. return d.getLayout().x;
  36361. })
  36362. .sortKeys(ascending)
  36363. .entries(nodes)
  36364. .map(function (d) {
  36365. return d.values;
  36366. });
  36367. initializeNodeDepth(nodes, nodesByBreadth, edges, height, nodeGap);
  36368. resolveCollisions(nodesByBreadth, nodeGap, height);
  36369. for (var alpha = 1; iterations > 0; iterations--) {
  36370. alpha *= 0.99;
  36371. relaxRightToLeft(nodesByBreadth, alpha);
  36372. resolveCollisions(nodesByBreadth, nodeGap, height);
  36373. relaxLeftToRight(nodesByBreadth, alpha);
  36374. resolveCollisions(nodesByBreadth, nodeGap, height);
  36375. }
  36376. }
  36377. /**
  36378. * compute the original y-position for each node.
  36379. * @param {module:echarts/data/Graph~Node} nodes
  36380. * @param {Array.<Array.<module:echarts/data/Graph~Node>>} nodesByBreadth
  36381. * @param {module:echarts/data/Graph~Edge} edges
  36382. * @param {number} height
  36383. * @param {number} nodeGap
  36384. */
  36385. function initializeNodeDepth(nodes, nodesByBreadth, edges, height, nodeGap) {
  36386. var kyArray = [];
  36387. zrUtil.each(nodesByBreadth, function (nodes) {
  36388. var n = nodes.length;
  36389. var sum = 0;
  36390. zrUtil.each(nodes, function (node) {
  36391. sum += node.getLayout().value;
  36392. });
  36393. var ky = (height - (n-1) * nodeGap) / sum;
  36394. kyArray.push(ky);
  36395. });
  36396. kyArray.sort(function (a, b) {
  36397. return a - b;
  36398. });
  36399. var ky0 = kyArray[0];
  36400. zrUtil.each(nodesByBreadth, function (nodes) {
  36401. zrUtil.each(nodes, function (node, i) {
  36402. node.setLayout({y: i}, true);
  36403. var nodeDy = node.getLayout().value * ky0;
  36404. node.setLayout({dy: nodeDy}, true);
  36405. });
  36406. });
  36407. zrUtil.each(edges, function (edge) {
  36408. var edgeDy = +edge.getValue() * ky0;
  36409. edge.setLayout({dy: edgeDy}, true);
  36410. });
  36411. }
  36412. /**
  36413. * resolve the collision of initialized depth.
  36414. * @param {Array.<Array.<module:echarts/data/Graph~Node>>} nodesByBreadth
  36415. * @param {number} nodeGap
  36416. * @param {number} height
  36417. */
  36418. function resolveCollisions(nodesByBreadth, nodeGap, height) {
  36419. zrUtil.each(nodesByBreadth, function (nodes) {
  36420. var node;
  36421. var dy;
  36422. var y0 = 0;
  36423. var n = nodes.length;
  36424. var i;
  36425. nodes.sort(ascendingDepth);
  36426. for (i = 0; i < n; i++) {
  36427. node = nodes[i];
  36428. dy = y0 - node.getLayout().y;
  36429. if(dy > 0) {
  36430. var nodeY = node.getLayout().y + dy;
  36431. node.setLayout({y: nodeY}, true);
  36432. }
  36433. y0 = node.getLayout().y + node.getLayout().dy + nodeGap;
  36434. }
  36435. // if the bottommost node goes outside the biunds, push it back up
  36436. dy = y0 - nodeGap - height;
  36437. if (dy > 0) {
  36438. var nodeY = node.getLayout().y -dy;
  36439. node.setLayout({y: nodeY}, true);
  36440. y0 = node.getLayout().y;
  36441. for (i = n - 2; i >= 0; --i) {
  36442. node = nodes[i];
  36443. dy = node.getLayout().y + node.getLayout().dy + nodeGap - y0;
  36444. if (dy > 0) {
  36445. nodeY = node.getLayout().y - dy;
  36446. node.setLayout({y: nodeY}, true);
  36447. }
  36448. y0 = node.getLayout().y;
  36449. }
  36450. }
  36451. });
  36452. }
  36453. /**
  36454. * change the y-position of the nodes, except most the right side nodes.
  36455. * @param {Array.<Array.<module:echarts/data/Graph~Node>>} nodesByBreadth
  36456. * @param {number} alpha
  36457. */
  36458. function relaxRightToLeft(nodesByBreadth, alpha) {
  36459. zrUtil.each(nodesByBreadth.slice().reverse(), function (nodes) {
  36460. zrUtil.each(nodes, function (node) {
  36461. if (node.outEdges.length) {
  36462. var y = sum(node.outEdges, weightedTarget) / sum(node.outEdges, getEdgeValue);
  36463. var nodeY = node.getLayout().y + (y - center(node)) * alpha;
  36464. node.setLayout({y: nodeY}, true);
  36465. }
  36466. });
  36467. });
  36468. }
  36469. function weightedTarget(edge) {
  36470. return center(edge.node2) * edge.getValue();
  36471. }
  36472. /**
  36473. * change the y-position of the nodes, except most the left side nodes.
  36474. * @param {Array.<Array.<module:echarts/data/Graph~Node>>} nodesByBreadth
  36475. * @param {number} alpha
  36476. */
  36477. function relaxLeftToRight(nodesByBreadth, alpha) {
  36478. zrUtil.each(nodesByBreadth, function (nodes) {
  36479. zrUtil.each(nodes, function (node) {
  36480. if (node.inEdges.length) {
  36481. var y = sum(node.inEdges, weightedSource) / sum(node.inEdges, getEdgeValue);
  36482. var nodeY = node.getLayout().y + (y - center(node)) * alpha;
  36483. node.setLayout({y: nodeY}, true);
  36484. }
  36485. });
  36486. });
  36487. }
  36488. function weightedSource(edge) {
  36489. return center(edge.node1) * edge.getValue();
  36490. }
  36491. /**
  36492. * compute the depth(y-position) of each edge.
  36493. * @param {module:echarts/data/Graph~Node} nodes
  36494. */
  36495. function computeEdgeDepths(nodes) {
  36496. zrUtil.each(nodes, function (node) {
  36497. node.outEdges.sort(ascendingTargetDepth);
  36498. node.inEdges.sort(ascendingSourceDepth);
  36499. });
  36500. zrUtil.each(nodes, function (node) {
  36501. var sy = 0;
  36502. var ty = 0;
  36503. zrUtil.each(node.outEdges, function (edge) {
  36504. edge.setLayout({sy: sy}, true);
  36505. sy += edge.getLayout().dy;
  36506. });
  36507. zrUtil.each(node.inEdges, function (edge) {
  36508. edge.setLayout({ty: ty}, true);
  36509. ty += edge.getLayout().dy;
  36510. });
  36511. });
  36512. }
  36513. function ascendingTargetDepth(a, b) {
  36514. return a.node2.getLayout().y - b.node2.getLayout().y;
  36515. }
  36516. function ascendingSourceDepth(a, b) {
  36517. return a.node1.getLayout().y - b.node1.getLayout().y;
  36518. }
  36519. function sum(array, f) {
  36520. var s = 0;
  36521. var n = array.length;
  36522. var a;
  36523. var i = -1;
  36524. if (arguments.length === 1) {
  36525. while (++i < n) {
  36526. a = +array[i];
  36527. if (!isNaN(a)) {
  36528. s += a;
  36529. }
  36530. }
  36531. }
  36532. else {
  36533. while (++i < n) {
  36534. a = +f.call(array, array[i], i);
  36535. if(!isNaN(a)) {
  36536. s += a;
  36537. }
  36538. }
  36539. }
  36540. return s;
  36541. }
  36542. function center(node) {
  36543. return node.getLayout().y + node.getLayout().dy / 2;
  36544. }
  36545. function ascendingDepth(a, b) {
  36546. return a.getLayout().y - b.getLayout().y;
  36547. }
  36548. function ascending(a, b) {
  36549. return a < b ? -1 : a > b ? 1 : a == b ? 0 : NaN;
  36550. }
  36551. function getEdgeValue(edge) {
  36552. return edge.getValue();
  36553. }
  36554. /***/ },
  36555. /* 242 */
  36556. /***/ function(module, exports, __webpack_require__) {
  36557. var zrUtil = __webpack_require__(4);
  36558. /**
  36559. * nest helper used to group by the array.
  36560. * can specified the keys and sort the keys.
  36561. */
  36562. function nest() {
  36563. var keysFunction = [];
  36564. var sortKeysFunction = [];
  36565. /**
  36566. * map an Array into the mapObject.
  36567. * @param {Array} array
  36568. * @param {number} depth
  36569. */
  36570. function map(array, depth) {
  36571. if (depth >= keysFunction.length) {
  36572. return array;
  36573. }
  36574. var i = -1;
  36575. var n = array.length;
  36576. var keyFunction = keysFunction[depth++];
  36577. var mapObject = {};
  36578. var valuesByKey = {};
  36579. while (++i < n) {
  36580. var keyValue = keyFunction(array[i]);
  36581. var values = valuesByKey[keyValue];
  36582. if (values) {
  36583. values.push(array[i]);
  36584. }
  36585. else {
  36586. valuesByKey[keyValue] = [array[i]];
  36587. }
  36588. }
  36589. zrUtil.each(valuesByKey, function (value, key) {
  36590. mapObject[key] = map(value, depth);
  36591. });
  36592. return mapObject;
  36593. }
  36594. /**
  36595. * transform the Map Object to multidimensional Array
  36596. * @param {Object} map
  36597. * @param {number} depth
  36598. */
  36599. function entriesMap(mapObject, depth) {
  36600. if (depth >= keysFunction.length) {
  36601. return mapObject;
  36602. }
  36603. var array = [];
  36604. var sortKeyFunction = sortKeysFunction[depth++];
  36605. zrUtil.each(mapObject, function (value, key) {
  36606. array.push({
  36607. key: key, values: entriesMap(value, depth)
  36608. });
  36609. });
  36610. if (sortKeyFunction) {
  36611. return array.sort(function (a, b) {
  36612. return sortKeyFunction(a.key, b.key);
  36613. });
  36614. }
  36615. else {
  36616. return array;
  36617. }
  36618. }
  36619. return {
  36620. /**
  36621. * specified the key to groupby the arrays.
  36622. * users can specified one more keys.
  36623. * @param {Function} d
  36624. */
  36625. key: function (d) {
  36626. keysFunction.push(d);
  36627. return this;
  36628. },
  36629. /**
  36630. * specified the comparator to sort the keys
  36631. * @param {Function} order
  36632. */
  36633. sortKeys: function (order) {
  36634. sortKeysFunction[keysFunction.length - 1] = order;
  36635. return this;
  36636. },
  36637. /**
  36638. * the array to be grouped by.
  36639. * @param {Array} array
  36640. */
  36641. entries: function (array) {
  36642. return entriesMap(map(array, 0), 0);
  36643. }
  36644. };
  36645. }
  36646. module.exports = nest;
  36647. /***/ },
  36648. /* 243 */
  36649. /***/ function(module, exports, __webpack_require__) {
  36650. var VisualMapping = __webpack_require__(192);
  36651. module.exports = function (ecModel, payload) {
  36652. ecModel.eachSeriesByType('sankey', function (seriesModel) {
  36653. var graph = seriesModel.getGraph();
  36654. var nodes = graph.nodes;
  36655. nodes.sort(function (a, b) {
  36656. return a.getLayout().value - b.getLayout().value;
  36657. });
  36658. var minValue = nodes[0].getLayout().value;
  36659. var maxValue = nodes[nodes.length - 1].getLayout().value;
  36660. nodes.forEach(function (node) {
  36661. var mapping = new VisualMapping({
  36662. type: 'color',
  36663. mappingMethod: 'linear',
  36664. dataExtent: [minValue, maxValue],
  36665. visual: seriesModel.get('color')
  36666. });
  36667. var mapValueToColor = mapping.mapValueToVisual(node.getLayout().value);
  36668. node.setVisual('color', mapValueToColor);
  36669. // If set itemStyle.normal.color
  36670. var itemModel = node.getModel();
  36671. var customColor = itemModel.get('itemStyle.normal.color');
  36672. if (customColor != null) {
  36673. node.setVisual('color', customColor);
  36674. }
  36675. });
  36676. }) ;
  36677. };
  36678. /***/ },
  36679. /* 244 */
  36680. /***/ function(module, exports, __webpack_require__) {
  36681. var echarts = __webpack_require__(1);
  36682. __webpack_require__(245);
  36683. __webpack_require__(248);
  36684. echarts.registerVisual(__webpack_require__(249));
  36685. echarts.registerLayout(__webpack_require__(250));
  36686. /***/ },
  36687. /* 245 */
  36688. /***/ function(module, exports, __webpack_require__) {
  36689. 'use strict';
  36690. var zrUtil = __webpack_require__(4);
  36691. var SeriesModel = __webpack_require__(28);
  36692. var whiskerBoxCommon = __webpack_require__(246);
  36693. var BoxplotSeries = SeriesModel.extend({
  36694. type: 'series.boxplot',
  36695. dependencies: ['xAxis', 'yAxis', 'grid'],
  36696. // TODO
  36697. // box width represents group size, so dimension should have 'size'.
  36698. /**
  36699. * @see <https://en.wikipedia.org/wiki/Box_plot>
  36700. * The meanings of 'min' and 'max' depend on user,
  36701. * and echarts do not need to know it.
  36702. * @readOnly
  36703. */
  36704. valueDimensions: ['min', 'Q1', 'median', 'Q3', 'max'],
  36705. /**
  36706. * @type {Array.<string>}
  36707. * @readOnly
  36708. */
  36709. dimensions: null,
  36710. /**
  36711. * @override
  36712. */
  36713. defaultOption: {
  36714. zlevel: 0, // 一级层叠
  36715. z: 2, // 二级层叠
  36716. coordinateSystem: 'cartesian2d',
  36717. legendHoverLink: true,
  36718. hoverAnimation: true,
  36719. xAxisIndex: 0,
  36720. yAxisIndex: 0,
  36721. layout: null, // 'horizontal' or 'vertical'
  36722. boxWidth: [7, 50], // [min, max] can be percent of band width.
  36723. itemStyle: {
  36724. normal: {
  36725. color: '#fff',
  36726. borderWidth: 1
  36727. },
  36728. emphasis: {
  36729. borderWidth: 2,
  36730. shadowBlur: 5,
  36731. shadowOffsetX: 2,
  36732. shadowOffsetY: 2,
  36733. shadowColor: 'rgba(0,0,0,0.4)'
  36734. }
  36735. },
  36736. animationEasing: 'elasticOut',
  36737. animationDuration: 800
  36738. }
  36739. });
  36740. zrUtil.mixin(BoxplotSeries, whiskerBoxCommon.seriesModelMixin, true);
  36741. module.exports = BoxplotSeries;
  36742. /***/ },
  36743. /* 246 */
  36744. /***/ function(module, exports, __webpack_require__) {
  36745. 'use strict';
  36746. var List = __webpack_require__(97);
  36747. var completeDimensions = __webpack_require__(102);
  36748. var WhiskerBoxDraw = __webpack_require__(247);
  36749. var zrUtil = __webpack_require__(4);
  36750. function getItemValue(item) {
  36751. return item.value == null ? item : item.value;
  36752. }
  36753. var seriesModelMixin = {
  36754. /**
  36755. * @private
  36756. * @type {string}
  36757. */
  36758. _baseAxisDim: null,
  36759. /**
  36760. * @override
  36761. */
  36762. getInitialData: function (option, ecModel) {
  36763. // When both types of xAxis and yAxis are 'value', layout is
  36764. // needed to be specified by user. Otherwise, layout can be
  36765. // judged by which axis is category.
  36766. var categories;
  36767. var xAxisModel = ecModel.getComponent('xAxis', this.get('xAxisIndex'));
  36768. var yAxisModel = ecModel.getComponent('yAxis', this.get('yAxisIndex'));
  36769. var xAxisType = xAxisModel.get('type');
  36770. var yAxisType = yAxisModel.get('type');
  36771. var addOrdinal;
  36772. // FIXME
  36773. // 考虑时间轴
  36774. if (xAxisType === 'category') {
  36775. option.layout = 'horizontal';
  36776. categories = xAxisModel.getCategories();
  36777. addOrdinal = true;
  36778. }
  36779. else if (yAxisType === 'category') {
  36780. option.layout = 'vertical';
  36781. categories = yAxisModel.getCategories();
  36782. addOrdinal = true;
  36783. }
  36784. else {
  36785. option.layout = option.layout || 'horizontal';
  36786. }
  36787. this._baseAxisDim = option.layout === 'horizontal' ? 'x' : 'y';
  36788. var data = option.data;
  36789. var dimensions = this.dimensions = ['base'].concat(this.valueDimensions);
  36790. completeDimensions(dimensions, data);
  36791. var list = new List(dimensions, this);
  36792. list.initData(data, categories ? categories.slice() : null, function (dataItem, dimName, idx, dimIdx) {
  36793. var value = getItemValue(dataItem);
  36794. return addOrdinal ? (dimName === 'base' ? idx : value[dimIdx - 1]) : value[dimIdx];
  36795. });
  36796. return list;
  36797. },
  36798. /**
  36799. * Used by Gird.
  36800. * @param {string} axisDim 'x' or 'y'
  36801. * @return {Array.<string>} dimensions on the axis.
  36802. */
  36803. coordDimToDataDim: function (axisDim) {
  36804. var dims = this.valueDimensions.slice();
  36805. var baseDim = ['base'];
  36806. var map = {
  36807. horizontal: {x: baseDim, y: dims},
  36808. vertical: {x: dims, y: baseDim}
  36809. };
  36810. return map[this.get('layout')][axisDim];
  36811. },
  36812. /**
  36813. * @override
  36814. * @param {string|number} dataDim
  36815. * @return {string} coord dimension
  36816. */
  36817. dataDimToCoordDim: function (dataDim) {
  36818. var dim;
  36819. zrUtil.each(['x', 'y'], function (coordDim, index) {
  36820. var dataDims = this.coordDimToDataDim(coordDim);
  36821. if (zrUtil.indexOf(dataDims, dataDim) >= 0) {
  36822. dim = coordDim;
  36823. }
  36824. }, this);
  36825. return dim;
  36826. },
  36827. /**
  36828. * If horizontal, base axis is x, otherwise y.
  36829. * @override
  36830. */
  36831. getBaseAxis: function () {
  36832. var dim = this._baseAxisDim;
  36833. return this.ecModel.getComponent(dim + 'Axis', this.get(dim + 'AxisIndex')).axis;
  36834. }
  36835. };
  36836. var viewMixin = {
  36837. init: function () {
  36838. /**
  36839. * Old data.
  36840. * @private
  36841. * @type {module:echarts/chart/helper/WhiskerBoxDraw}
  36842. */
  36843. var whiskerBoxDraw = this._whiskerBoxDraw = new WhiskerBoxDraw(
  36844. this.getStyleUpdater()
  36845. );
  36846. this.group.add(whiskerBoxDraw.group);
  36847. },
  36848. render: function (seriesModel, ecModel, api) {
  36849. this._whiskerBoxDraw.updateData(seriesModel.getData());
  36850. },
  36851. remove: function (ecModel) {
  36852. this._whiskerBoxDraw.remove();
  36853. }
  36854. };
  36855. module.exports = {
  36856. seriesModelMixin: seriesModelMixin,
  36857. viewMixin: viewMixin
  36858. };
  36859. /***/ },
  36860. /* 247 */
  36861. /***/ function(module, exports, __webpack_require__) {
  36862. /**
  36863. * @module echarts/chart/helper/Symbol
  36864. */
  36865. var zrUtil = __webpack_require__(4);
  36866. var graphic = __webpack_require__(43);
  36867. var Path = __webpack_require__(45);
  36868. var WhiskerPath = Path.extend({
  36869. type: 'whiskerInBox',
  36870. shape: {},
  36871. buildPath: function (ctx, shape) {
  36872. for (var i in shape) {
  36873. if (i.indexOf('ends') === 0) {
  36874. var pts = shape[i];
  36875. ctx.moveTo(pts[0][0], pts[0][1]);
  36876. ctx.lineTo(pts[1][0], pts[1][1]);
  36877. }
  36878. }
  36879. }
  36880. });
  36881. /**
  36882. * @constructor
  36883. * @alias {module:echarts/chart/helper/WhiskerBox}
  36884. * @param {module:echarts/data/List} data
  36885. * @param {number} idx
  36886. * @param {Function} styleUpdater
  36887. * @param {boolean} isInit
  36888. * @extends {module:zrender/graphic/Group}
  36889. */
  36890. function WhiskerBox(data, idx, styleUpdater, isInit) {
  36891. graphic.Group.call(this);
  36892. /**
  36893. * @type {number}
  36894. * @readOnly
  36895. */
  36896. this.bodyIndex;
  36897. /**
  36898. * @type {number}
  36899. * @readOnly
  36900. */
  36901. this.whiskerIndex;
  36902. /**
  36903. * @type {Function}
  36904. */
  36905. this.styleUpdater = styleUpdater;
  36906. this._createContent(data, idx, isInit);
  36907. this.updateData(data, idx, isInit);
  36908. /**
  36909. * Last series model.
  36910. * @type {module:echarts/model/Series}
  36911. */
  36912. this._seriesModel;
  36913. }
  36914. var whiskerBoxProto = WhiskerBox.prototype;
  36915. whiskerBoxProto._createContent = function (data, idx, isInit) {
  36916. var itemLayout = data.getItemLayout(idx);
  36917. var constDim = itemLayout.chartLayout === 'horizontal' ? 1 : 0;
  36918. var count = 0;
  36919. // Whisker element.
  36920. this.add(new graphic.Polygon({
  36921. shape: {
  36922. points: isInit
  36923. ? transInit(itemLayout.bodyEnds, constDim, itemLayout)
  36924. : itemLayout.bodyEnds
  36925. },
  36926. style: {strokeNoScale: true},
  36927. z2: 100
  36928. }));
  36929. this.bodyIndex = count++;
  36930. // Box element.
  36931. var whiskerEnds = zrUtil.map(itemLayout.whiskerEnds, function (ends) {
  36932. return isInit ? transInit(ends, constDim, itemLayout) : ends;
  36933. });
  36934. this.add(new WhiskerPath({
  36935. shape: makeWhiskerEndsShape(whiskerEnds),
  36936. style: {strokeNoScale: true},
  36937. z2: 100
  36938. }));
  36939. this.whiskerIndex = count++;
  36940. };
  36941. function transInit(points, dim, itemLayout) {
  36942. return zrUtil.map(points, function (point) {
  36943. point = point.slice();
  36944. point[dim] = itemLayout.initBaseline;
  36945. return point;
  36946. });
  36947. }
  36948. function makeWhiskerEndsShape(whiskerEnds) {
  36949. // zr animation only support 2-dim array.
  36950. var shape = {};
  36951. zrUtil.each(whiskerEnds, function (ends, i) {
  36952. shape['ends' + i] = ends;
  36953. });
  36954. return shape;
  36955. }
  36956. /**
  36957. * Update symbol properties
  36958. * @param {module:echarts/data/List} data
  36959. * @param {number} idx
  36960. */
  36961. whiskerBoxProto.updateData = function (data, idx, isInit) {
  36962. var seriesModel = this._seriesModel = data.hostModel;
  36963. var itemLayout = data.getItemLayout(idx);
  36964. var updateMethod = graphic[isInit ? 'initProps' : 'updateProps'];
  36965. // this.childAt(this.bodyIndex).stopAnimation(true);
  36966. // this.childAt(this.whiskerIndex).stopAnimation(true);
  36967. updateMethod(
  36968. this.childAt(this.bodyIndex),
  36969. {shape: {points: itemLayout.bodyEnds}},
  36970. seriesModel, idx
  36971. );
  36972. updateMethod(
  36973. this.childAt(this.whiskerIndex),
  36974. {shape: makeWhiskerEndsShape(itemLayout.whiskerEnds)},
  36975. seriesModel, idx
  36976. );
  36977. this.styleUpdater.call(null, this, data, idx);
  36978. };
  36979. zrUtil.inherits(WhiskerBox, graphic.Group);
  36980. /**
  36981. * @constructor
  36982. * @alias module:echarts/chart/helper/WhiskerBoxDraw
  36983. */
  36984. function WhiskerBoxDraw(styleUpdater) {
  36985. this.group = new graphic.Group();
  36986. this.styleUpdater = styleUpdater;
  36987. }
  36988. var whiskerBoxDrawProto = WhiskerBoxDraw.prototype;
  36989. /**
  36990. * Update symbols draw by new data
  36991. * @param {module:echarts/data/List} data
  36992. */
  36993. whiskerBoxDrawProto.updateData = function (data) {
  36994. var group = this.group;
  36995. var oldData = this._data;
  36996. var styleUpdater = this.styleUpdater;
  36997. data.diff(oldData)
  36998. .add(function (newIdx) {
  36999. if (data.hasValue(newIdx)) {
  37000. var symbolEl = new WhiskerBox(data, newIdx, styleUpdater, true);
  37001. data.setItemGraphicEl(newIdx, symbolEl);
  37002. group.add(symbolEl);
  37003. }
  37004. })
  37005. .update(function (newIdx, oldIdx) {
  37006. var symbolEl = oldData.getItemGraphicEl(oldIdx);
  37007. // Empty data
  37008. if (!data.hasValue(newIdx)) {
  37009. group.remove(symbolEl);
  37010. return;
  37011. }
  37012. if (!symbolEl) {
  37013. symbolEl = new WhiskerBox(data, newIdx, styleUpdater);
  37014. }
  37015. else {
  37016. symbolEl.updateData(data, newIdx);
  37017. }
  37018. // Add back
  37019. group.add(symbolEl);
  37020. data.setItemGraphicEl(newIdx, symbolEl);
  37021. })
  37022. .remove(function (oldIdx) {
  37023. var el = oldData.getItemGraphicEl(oldIdx);
  37024. el && group.remove(el);
  37025. })
  37026. .execute();
  37027. this._data = data;
  37028. };
  37029. /**
  37030. * Remove symbols.
  37031. * @param {module:echarts/data/List} data
  37032. */
  37033. whiskerBoxDrawProto.remove = function () {
  37034. var group = this.group;
  37035. var data = this._data;
  37036. this._data = null;
  37037. data && data.eachItemGraphicEl(function (el) {
  37038. el && group.remove(el);
  37039. });
  37040. };
  37041. module.exports = WhiskerBoxDraw;
  37042. /***/ },
  37043. /* 248 */
  37044. /***/ function(module, exports, __webpack_require__) {
  37045. 'use strict';
  37046. var zrUtil = __webpack_require__(4);
  37047. var ChartView = __webpack_require__(42);
  37048. var graphic = __webpack_require__(43);
  37049. var whiskerBoxCommon = __webpack_require__(246);
  37050. var BoxplotView = ChartView.extend({
  37051. type: 'boxplot',
  37052. getStyleUpdater: function () {
  37053. return updateStyle;
  37054. }
  37055. });
  37056. zrUtil.mixin(BoxplotView, whiskerBoxCommon.viewMixin, true);
  37057. // Update common properties
  37058. var normalStyleAccessPath = ['itemStyle', 'normal'];
  37059. var emphasisStyleAccessPath = ['itemStyle', 'emphasis'];
  37060. function updateStyle(itemGroup, data, idx) {
  37061. var itemModel = data.getItemModel(idx);
  37062. var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath);
  37063. var borderColor = data.getItemVisual(idx, 'color');
  37064. // Exclude borderColor.
  37065. var itemStyle = normalItemStyleModel.getItemStyle(['borderColor']);
  37066. var whiskerEl = itemGroup.childAt(itemGroup.whiskerIndex);
  37067. whiskerEl.style.set(itemStyle);
  37068. whiskerEl.style.stroke = borderColor;
  37069. whiskerEl.dirty();
  37070. var bodyEl = itemGroup.childAt(itemGroup.bodyIndex);
  37071. bodyEl.style.set(itemStyle);
  37072. bodyEl.style.stroke = borderColor;
  37073. bodyEl.dirty();
  37074. var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle();
  37075. graphic.setHoverStyle(itemGroup, hoverStyle);
  37076. }
  37077. module.exports = BoxplotView;
  37078. /***/ },
  37079. /* 249 */
  37080. /***/ function(module, exports) {
  37081. var borderColorQuery = ['itemStyle', 'normal', 'borderColor'];
  37082. module.exports = function (ecModel, api) {
  37083. var globalColors = ecModel.get('color');
  37084. ecModel.eachRawSeriesByType('boxplot', function (seriesModel) {
  37085. var defaulColor = globalColors[seriesModel.seriesIndex % globalColors.length];
  37086. var data = seriesModel.getData();
  37087. data.setVisual({
  37088. legendSymbol: 'roundRect',
  37089. // Use name 'color' but not 'borderColor' for legend usage and
  37090. // visual coding from other component like dataRange.
  37091. color: seriesModel.get(borderColorQuery) || defaulColor
  37092. });
  37093. // Only visible series has each data be visual encoded
  37094. if (!ecModel.isSeriesFiltered(seriesModel)) {
  37095. data.each(function (idx) {
  37096. var itemModel = data.getItemModel(idx);
  37097. data.setItemVisual(
  37098. idx,
  37099. {color: itemModel.get(borderColorQuery, true)}
  37100. );
  37101. });
  37102. }
  37103. });
  37104. };
  37105. /***/ },
  37106. /* 250 */
  37107. /***/ function(module, exports, __webpack_require__) {
  37108. var zrUtil = __webpack_require__(4);
  37109. var numberUtil = __webpack_require__(7);
  37110. var parsePercent = numberUtil.parsePercent;
  37111. var each = zrUtil.each;
  37112. module.exports = function (ecModel) {
  37113. var groupResult = groupSeriesByAxis(ecModel);
  37114. each(groupResult, function (groupItem) {
  37115. var seriesModels = groupItem.seriesModels;
  37116. if (!seriesModels.length) {
  37117. return;
  37118. }
  37119. calculateBase(groupItem);
  37120. each(seriesModels, function (seriesModel, idx) {
  37121. layoutSingleSeries(
  37122. seriesModel,
  37123. groupItem.boxOffsetList[idx],
  37124. groupItem.boxWidthList[idx]
  37125. );
  37126. });
  37127. });
  37128. };
  37129. /**
  37130. * Group series by axis.
  37131. */
  37132. function groupSeriesByAxis(ecModel) {
  37133. var result = [];
  37134. var axisList = [];
  37135. ecModel.eachSeriesByType('boxplot', function (seriesModel) {
  37136. var baseAxis = seriesModel.getBaseAxis();
  37137. var idx = zrUtil.indexOf(axisList, baseAxis);
  37138. if (idx < 0) {
  37139. idx = axisList.length;
  37140. axisList[idx] = baseAxis;
  37141. result[idx] = {axis: baseAxis, seriesModels: []};
  37142. }
  37143. result[idx].seriesModels.push(seriesModel);
  37144. });
  37145. return result;
  37146. }
  37147. /**
  37148. * Calculate offset and box width for each series.
  37149. */
  37150. function calculateBase(groupItem) {
  37151. var extent;
  37152. var baseAxis = groupItem.axis;
  37153. var seriesModels = groupItem.seriesModels;
  37154. var seriesCount = seriesModels.length;
  37155. var boxWidthList = groupItem.boxWidthList = [];
  37156. var boxOffsetList = groupItem.boxOffsetList = [];
  37157. var boundList = [];
  37158. var bandWidth;
  37159. if (baseAxis.type === 'category') {
  37160. bandWidth = baseAxis.getBandWidth();
  37161. }
  37162. else {
  37163. var maxDataCount = 0;
  37164. each(seriesModels, function (seriesModel) {
  37165. maxDataCount = Math.max(maxDataCount, seriesModel.getData().count());
  37166. });
  37167. extent = baseAxis.getExtent(),
  37168. Math.abs(extent[1] - extent[0]) / maxDataCount;
  37169. }
  37170. each(seriesModels, function (seriesModel) {
  37171. var boxWidthBound = seriesModel.get('boxWidth');
  37172. if (!zrUtil.isArray(boxWidthBound)) {
  37173. boxWidthBound = [boxWidthBound, boxWidthBound];
  37174. }
  37175. boundList.push([
  37176. parsePercent(boxWidthBound[0], bandWidth) || 0,
  37177. parsePercent(boxWidthBound[1], bandWidth) || 0
  37178. ]);
  37179. });
  37180. var availableWidth = bandWidth * 0.8 - 2;
  37181. var boxGap = availableWidth / seriesCount * 0.3;
  37182. var boxWidth = (availableWidth - boxGap * (seriesCount - 1)) / seriesCount;
  37183. var base = boxWidth / 2 - availableWidth / 2;
  37184. each(seriesModels, function (seriesModel, idx) {
  37185. boxOffsetList.push(base);
  37186. base += boxGap + boxWidth;
  37187. boxWidthList.push(
  37188. Math.min(Math.max(boxWidth, boundList[idx][0]), boundList[idx][1])
  37189. );
  37190. });
  37191. }
  37192. /**
  37193. * Calculate points location for each series.
  37194. */
  37195. function layoutSingleSeries(seriesModel, offset, boxWidth) {
  37196. var coordSys = seriesModel.coordinateSystem;
  37197. var data = seriesModel.getData();
  37198. var dimensions = seriesModel.dimensions;
  37199. var chartLayout = seriesModel.get('layout');
  37200. var halfWidth = boxWidth / 2;
  37201. data.each(dimensions, function () {
  37202. var args = arguments;
  37203. var dimLen = dimensions.length;
  37204. var axisDimVal = args[0];
  37205. var idx = args[dimLen];
  37206. var variableDim = chartLayout === 'horizontal' ? 0 : 1;
  37207. var constDim = 1 - variableDim;
  37208. var median = getPoint(args[3]);
  37209. var end1 = getPoint(args[1]);
  37210. var end5 = getPoint(args[5]);
  37211. var whiskerEnds = [
  37212. [end1, getPoint(args[2])],
  37213. [end5, getPoint(args[4])]
  37214. ];
  37215. layEndLine(end1);
  37216. layEndLine(end5);
  37217. layEndLine(median);
  37218. var bodyEnds = [];
  37219. addBodyEnd(whiskerEnds[0][1], 0);
  37220. addBodyEnd(whiskerEnds[1][1], 1);
  37221. data.setItemLayout(idx, {
  37222. chartLayout: chartLayout,
  37223. initBaseline: median[constDim],
  37224. median: median,
  37225. bodyEnds: bodyEnds,
  37226. whiskerEnds: whiskerEnds
  37227. });
  37228. function getPoint(val) {
  37229. var p = [];
  37230. p[variableDim] = axisDimVal;
  37231. p[constDim] = val;
  37232. var point;
  37233. if (isNaN(axisDimVal) || isNaN(val)) {
  37234. point = [NaN, NaN];
  37235. }
  37236. else {
  37237. point = coordSys.dataToPoint(p);
  37238. point[variableDim] += offset;
  37239. }
  37240. return point;
  37241. }
  37242. function addBodyEnd(point, start) {
  37243. var point1 = point.slice();
  37244. var point2 = point.slice();
  37245. point1[variableDim] += halfWidth;
  37246. point2[variableDim] -= halfWidth;
  37247. start
  37248. ? bodyEnds.push(point1, point2)
  37249. : bodyEnds.push(point2, point1);
  37250. }
  37251. function layEndLine(endCenter) {
  37252. var line = [endCenter.slice(), endCenter.slice()];
  37253. line[0][variableDim] -= halfWidth;
  37254. line[1][variableDim] += halfWidth;
  37255. whiskerEnds.push(line);
  37256. }
  37257. });
  37258. }
  37259. /***/ },
  37260. /* 251 */
  37261. /***/ function(module, exports, __webpack_require__) {
  37262. var echarts = __webpack_require__(1);
  37263. __webpack_require__(252);
  37264. __webpack_require__(253);
  37265. echarts.registerPreprocessor(
  37266. __webpack_require__(254)
  37267. );
  37268. echarts.registerVisual(__webpack_require__(255));
  37269. echarts.registerLayout(__webpack_require__(256));
  37270. /***/ },
  37271. /* 252 */
  37272. /***/ function(module, exports, __webpack_require__) {
  37273. 'use strict';
  37274. var zrUtil = __webpack_require__(4);
  37275. var SeriesModel = __webpack_require__(28);
  37276. var whiskerBoxCommon = __webpack_require__(246);
  37277. var formatUtil = __webpack_require__(6);
  37278. var encodeHTML = formatUtil.encodeHTML;
  37279. var addCommas = formatUtil.addCommas;
  37280. var CandlestickSeries = SeriesModel.extend({
  37281. type: 'series.candlestick',
  37282. dependencies: ['xAxis', 'yAxis', 'grid'],
  37283. /**
  37284. * @readOnly
  37285. */
  37286. valueDimensions: ['open', 'close', 'lowest', 'highest'],
  37287. /**
  37288. * @type {Array.<string>}
  37289. * @readOnly
  37290. */
  37291. dimensions: null,
  37292. /**
  37293. * @override
  37294. */
  37295. defaultOption: {
  37296. zlevel: 0, // 一级层叠
  37297. z: 2, // 二级层叠
  37298. coordinateSystem: 'cartesian2d',
  37299. legendHoverLink: true,
  37300. hoverAnimation: true,
  37301. xAxisIndex: 0,
  37302. yAxisIndex: 0,
  37303. layout: null, // 'horizontal' or 'vertical'
  37304. itemStyle: {
  37305. normal: {
  37306. color: '#c23531', // 阳线 positive
  37307. color0: '#314656', // 阴线 negative '#c23531', '#314656'
  37308. borderWidth: 1,
  37309. // FIXME
  37310. // ec2中使用的是lineStyle.color 和 lineStyle.color0
  37311. borderColor: '#c23531',
  37312. borderColor0: '#314656'
  37313. },
  37314. emphasis: {
  37315. borderWidth: 2
  37316. }
  37317. },
  37318. animationUpdate: false,
  37319. animationEasing: 'linear',
  37320. animationDuration: 300
  37321. },
  37322. /**
  37323. * Get dimension for shadow in dataZoom
  37324. * @return {string} dimension name
  37325. */
  37326. getShadowDim: function () {
  37327. return 'open';
  37328. },
  37329. /**
  37330. * @override
  37331. */
  37332. formatTooltip: function (dataIndex, mutipleSeries) {
  37333. // It rearly use mutiple candlestick series in one cartesian,
  37334. // so only consider one series in this default tooltip.
  37335. var valueHTMLArr = zrUtil.map(this.valueDimensions, function (dim) {
  37336. return dim + ': ' + addCommas(this._data.get(dim, dataIndex));
  37337. }, this);
  37338. return encodeHTML(this.name) + '<br />' + valueHTMLArr.join('<br />');
  37339. },
  37340. brushSelector: function (itemLayout, selectors) {
  37341. return selectors.rect(itemLayout.brushRect);
  37342. }
  37343. });
  37344. zrUtil.mixin(CandlestickSeries, whiskerBoxCommon.seriesModelMixin, true);
  37345. module.exports = CandlestickSeries;
  37346. /***/ },
  37347. /* 253 */
  37348. /***/ function(module, exports, __webpack_require__) {
  37349. 'use strict';
  37350. var zrUtil = __webpack_require__(4);
  37351. var ChartView = __webpack_require__(42);
  37352. var graphic = __webpack_require__(43);
  37353. var whiskerBoxCommon = __webpack_require__(246);
  37354. var CandlestickView = ChartView.extend({
  37355. type: 'candlestick',
  37356. getStyleUpdater: function () {
  37357. return updateStyle;
  37358. }
  37359. });
  37360. zrUtil.mixin(CandlestickView, whiskerBoxCommon.viewMixin, true);
  37361. // Update common properties
  37362. var normalStyleAccessPath = ['itemStyle', 'normal'];
  37363. var emphasisStyleAccessPath = ['itemStyle', 'emphasis'];
  37364. function updateStyle(itemGroup, data, idx) {
  37365. var itemModel = data.getItemModel(idx);
  37366. var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath);
  37367. var color = data.getItemVisual(idx, 'color');
  37368. var borderColor = data.getItemVisual(idx, 'borderColor') || color;
  37369. // Color must be excluded.
  37370. // Because symbol provide setColor individually to set fill and stroke
  37371. var itemStyle = normalItemStyleModel.getItemStyle(
  37372. ['color', 'color0', 'borderColor', 'borderColor0']
  37373. );
  37374. var whiskerEl = itemGroup.childAt(itemGroup.whiskerIndex);
  37375. whiskerEl.useStyle(itemStyle);
  37376. whiskerEl.style.stroke = borderColor;
  37377. var bodyEl = itemGroup.childAt(itemGroup.bodyIndex);
  37378. bodyEl.useStyle(itemStyle);
  37379. bodyEl.style.fill = color;
  37380. bodyEl.style.stroke = borderColor;
  37381. var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle();
  37382. graphic.setHoverStyle(itemGroup, hoverStyle);
  37383. }
  37384. module.exports = CandlestickView;
  37385. /***/ },
  37386. /* 254 */
  37387. /***/ function(module, exports, __webpack_require__) {
  37388. var zrUtil = __webpack_require__(4);
  37389. module.exports = function (option) {
  37390. if (!option || !zrUtil.isArray(option.series)) {
  37391. return;
  37392. }
  37393. // Translate 'k' to 'candlestick'.
  37394. zrUtil.each(option.series, function (seriesItem) {
  37395. if (zrUtil.isObject(seriesItem) && seriesItem.type === 'k') {
  37396. seriesItem.type = 'candlestick';
  37397. }
  37398. });
  37399. };
  37400. /***/ },
  37401. /* 255 */
  37402. /***/ function(module, exports) {
  37403. var positiveBorderColorQuery = ['itemStyle', 'normal', 'borderColor'];
  37404. var negativeBorderColorQuery = ['itemStyle', 'normal', 'borderColor0'];
  37405. var positiveColorQuery = ['itemStyle', 'normal', 'color'];
  37406. var negativeColorQuery = ['itemStyle', 'normal', 'color0'];
  37407. module.exports = function (ecModel, api) {
  37408. ecModel.eachRawSeriesByType('candlestick', function (seriesModel) {
  37409. var data = seriesModel.getData();
  37410. data.setVisual({
  37411. legendSymbol: 'roundRect'
  37412. });
  37413. // Only visible series has each data be visual encoded
  37414. if (!ecModel.isSeriesFiltered(seriesModel)) {
  37415. data.each(function (idx) {
  37416. var itemModel = data.getItemModel(idx);
  37417. var sign = data.getItemLayout(idx).sign;
  37418. data.setItemVisual(
  37419. idx,
  37420. {
  37421. color: itemModel.get(
  37422. sign > 0 ? positiveColorQuery : negativeColorQuery
  37423. ),
  37424. borderColor: itemModel.get(
  37425. sign > 0 ? positiveBorderColorQuery : negativeBorderColorQuery
  37426. )
  37427. }
  37428. );
  37429. });
  37430. }
  37431. });
  37432. };
  37433. /***/ },
  37434. /* 256 */
  37435. /***/ function(module, exports) {
  37436. var CANDLE_MIN_WIDTH = 2;
  37437. var CANDLE_MIN_NICE_WIDTH = 5;
  37438. var GPA_MIN = 4;
  37439. module.exports = function (ecModel) {
  37440. ecModel.eachSeriesByType('candlestick', function (seriesModel) {
  37441. var coordSys = seriesModel.coordinateSystem;
  37442. var data = seriesModel.getData();
  37443. var dimensions = seriesModel.dimensions;
  37444. var chartLayout = seriesModel.get('layout');
  37445. var candleWidth = calculateCandleWidth(seriesModel, data);
  37446. data.each(dimensions, function () {
  37447. var args = arguments;
  37448. var dimLen = dimensions.length;
  37449. var axisDimVal = args[0];
  37450. var idx = args[dimLen];
  37451. var variableDim = chartLayout === 'horizontal' ? 0 : 1;
  37452. var constDim = 1 - variableDim;
  37453. var openVal = args[1];
  37454. var closeVal = args[2];
  37455. var lowestVal = args[3];
  37456. var highestVal = args[4];
  37457. var ocLow = Math.min(openVal, closeVal);
  37458. var ocHigh = Math.max(openVal, closeVal);
  37459. var ocLowPoint = getPoint(ocLow);
  37460. var ocHighPoint = getPoint(ocHigh);
  37461. var lowestPoint = getPoint(lowestVal);
  37462. var highestPoint = getPoint(highestVal);
  37463. var whiskerEnds = [
  37464. [highestPoint, ocHighPoint],
  37465. [lowestPoint, ocLowPoint]
  37466. ];
  37467. var bodyEnds = [];
  37468. addBodyEnd(ocHighPoint, 0);
  37469. addBodyEnd(ocLowPoint, 1);
  37470. data.setItemLayout(idx, {
  37471. chartLayout: chartLayout,
  37472. sign: openVal > closeVal ? -1 : openVal < closeVal ? 1 : 0,
  37473. initBaseline: openVal > closeVal
  37474. ? ocHighPoint[constDim] : ocLowPoint[constDim], // open point.
  37475. bodyEnds: bodyEnds,
  37476. whiskerEnds: whiskerEnds,
  37477. brushRect: makeBrushRect()
  37478. });
  37479. function getPoint(val) {
  37480. var p = [];
  37481. p[variableDim] = axisDimVal;
  37482. p[constDim] = val;
  37483. return (isNaN(axisDimVal) || isNaN(val))
  37484. ? [NaN, NaN]
  37485. : coordSys.dataToPoint(p);
  37486. }
  37487. function addBodyEnd(point, start) {
  37488. var point1 = point.slice();
  37489. var point2 = point.slice();
  37490. point1[variableDim] += candleWidth / 2;
  37491. point2[variableDim] -= candleWidth / 2;
  37492. start
  37493. ? bodyEnds.push(point1, point2)
  37494. : bodyEnds.push(point2, point1);
  37495. }
  37496. function makeBrushRect() {
  37497. var pmin = getPoint(Math.min(openVal, closeVal, lowestVal, highestVal));
  37498. var pmax = getPoint(Math.max(openVal, closeVal, lowestVal, highestVal));
  37499. pmin[variableDim] -= candleWidth / 2;
  37500. pmax[variableDim] -= candleWidth / 2;
  37501. return {
  37502. x: pmin[0],
  37503. y: pmin[1],
  37504. width: constDim ? candleWidth : pmax[0] - pmin[0],
  37505. height: constDim ? pmax[1] - pmin[1] : candleWidth
  37506. };
  37507. }
  37508. }, true);
  37509. });
  37510. };
  37511. function calculateCandleWidth(seriesModel, data) {
  37512. var baseAxis = seriesModel.getBaseAxis();
  37513. var extent;
  37514. var bandWidth = baseAxis.type === 'category'
  37515. ? baseAxis.getBandWidth()
  37516. : (
  37517. extent = baseAxis.getExtent(),
  37518. Math.abs(extent[1] - extent[0]) / data.count()
  37519. );
  37520. // Half band width is perfect when space is enouph, otherwise
  37521. // try not to be smaller than CANDLE_MIN_NICE_WIDTH (and only
  37522. // gap is compressed), otherwise ensure not to be smaller than
  37523. // CANDLE_MIN_WIDTH in spite of overlap.
  37524. return bandWidth / 2 - 2 > CANDLE_MIN_NICE_WIDTH // "- 2" is minus border width
  37525. ? bandWidth / 2 - 2
  37526. : bandWidth - CANDLE_MIN_NICE_WIDTH > GPA_MIN
  37527. ? CANDLE_MIN_NICE_WIDTH
  37528. : Math.max(bandWidth - GPA_MIN, CANDLE_MIN_WIDTH);
  37529. }
  37530. /***/ },
  37531. /* 257 */
  37532. /***/ function(module, exports, __webpack_require__) {
  37533. var zrUtil = __webpack_require__(4);
  37534. var echarts = __webpack_require__(1);
  37535. __webpack_require__(258);
  37536. __webpack_require__(259);
  37537. echarts.registerVisual(zrUtil.curry(
  37538. __webpack_require__(109), 'effectScatter', 'circle', null
  37539. ));
  37540. echarts.registerLayout(zrUtil.curry(
  37541. __webpack_require__(110), 'effectScatter'
  37542. ));
  37543. /***/ },
  37544. /* 258 */
  37545. /***/ function(module, exports, __webpack_require__) {
  37546. 'use strict';
  37547. var createListFromArray = __webpack_require__(101);
  37548. var SeriesModel = __webpack_require__(28);
  37549. module.exports = SeriesModel.extend({
  37550. type: 'series.effectScatter',
  37551. dependencies: ['grid', 'polar'],
  37552. getInitialData: function (option, ecModel) {
  37553. var list = createListFromArray(option.data, this, ecModel);
  37554. return list;
  37555. },
  37556. brushSelector: 'point',
  37557. defaultOption: {
  37558. coordinateSystem: 'cartesian2d',
  37559. zlevel: 0,
  37560. z: 2,
  37561. legendHoverLink: true,
  37562. effectType: 'ripple',
  37563. // When to show the effect, option: 'render'|'emphasis'
  37564. showEffectOn: 'render',
  37565. // Ripple effect config
  37566. rippleEffect: {
  37567. period: 4,
  37568. // Scale of ripple
  37569. scale: 2.5,
  37570. // Brush type can be fill or stroke
  37571. brushType: 'fill'
  37572. },
  37573. // Cartesian coordinate system
  37574. xAxisIndex: 0,
  37575. yAxisIndex: 0,
  37576. // Polar coordinate system
  37577. polarIndex: 0,
  37578. // Geo coordinate system
  37579. geoIndex: 0,
  37580. // symbol: null, // 图形类型
  37581. symbolSize: 10 // 图形大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2
  37582. // symbolRotate: null, // 图形旋转控制
  37583. // large: false,
  37584. // Available when large is true
  37585. // largeThreshold: 2000,
  37586. // itemStyle: {
  37587. // normal: {
  37588. // opacity: 1
  37589. // }
  37590. // }
  37591. }
  37592. });
  37593. /***/ },
  37594. /* 259 */
  37595. /***/ function(module, exports, __webpack_require__) {
  37596. var SymbolDraw = __webpack_require__(104);
  37597. var EffectSymbol = __webpack_require__(260);
  37598. __webpack_require__(1).extendChartView({
  37599. type: 'effectScatter',
  37600. init: function () {
  37601. this._symbolDraw = new SymbolDraw(EffectSymbol);
  37602. },
  37603. render: function (seriesModel, ecModel, api) {
  37604. var data = seriesModel.getData();
  37605. var effectSymbolDraw = this._symbolDraw;
  37606. effectSymbolDraw.updateData(data);
  37607. this.group.add(effectSymbolDraw.group);
  37608. },
  37609. updateLayout: function () {
  37610. this._symbolDraw.updateLayout();
  37611. },
  37612. remove: function (ecModel, api) {
  37613. this._symbolDraw && this._symbolDraw.remove(api);
  37614. }
  37615. });
  37616. /***/ },
  37617. /* 260 */
  37618. /***/ function(module, exports, __webpack_require__) {
  37619. /**
  37620. * Symbol with ripple effect
  37621. * @module echarts/chart/helper/EffectSymbol
  37622. */
  37623. var zrUtil = __webpack_require__(4);
  37624. var symbolUtil = __webpack_require__(106);
  37625. var graphic = __webpack_require__(43);
  37626. var numberUtil = __webpack_require__(7);
  37627. var Symbol = __webpack_require__(105);
  37628. var Group = graphic.Group;
  37629. var EFFECT_RIPPLE_NUMBER = 3;
  37630. function normalizeSymbolSize(symbolSize) {
  37631. if (!zrUtil.isArray(symbolSize)) {
  37632. symbolSize = [+symbolSize, +symbolSize];
  37633. }
  37634. return symbolSize;
  37635. }
  37636. function updateRipplePath(rippleGroup, effectCfg) {
  37637. rippleGroup.eachChild(function (ripplePath) {
  37638. ripplePath.attr({
  37639. z: effectCfg.z,
  37640. zlevel: effectCfg.zlevel,
  37641. style: {
  37642. stroke: effectCfg.brushType === 'stroke' ? effectCfg.color : null,
  37643. fill: effectCfg.brushType === 'fill' ? effectCfg.color : null
  37644. }
  37645. });
  37646. });
  37647. }
  37648. /**
  37649. * @constructor
  37650. * @param {module:echarts/data/List} data
  37651. * @param {number} idx
  37652. * @extends {module:zrender/graphic/Group}
  37653. */
  37654. function EffectSymbol(data, idx) {
  37655. Group.call(this);
  37656. var symbol = new Symbol(data, idx);
  37657. var rippleGroup = new Group();
  37658. this.add(symbol);
  37659. this.add(rippleGroup);
  37660. rippleGroup.beforeUpdate = function () {
  37661. this.attr(symbol.getScale());
  37662. };
  37663. this.updateData(data, idx);
  37664. }
  37665. var effectSymbolProto = EffectSymbol.prototype;
  37666. effectSymbolProto.stopEffectAnimation = function () {
  37667. this.childAt(1).removeAll();
  37668. };
  37669. effectSymbolProto.startEffectAnimation = function (effectCfg) {
  37670. var symbolType = effectCfg.symbolType;
  37671. var color = effectCfg.color;
  37672. var rippleGroup = this.childAt(1);
  37673. for (var i = 0; i < EFFECT_RIPPLE_NUMBER; i++) {
  37674. var ripplePath = symbolUtil.createSymbol(
  37675. symbolType, -0.5, -0.5, 1, 1, color
  37676. );
  37677. ripplePath.attr({
  37678. style: {
  37679. strokeNoScale: true
  37680. },
  37681. z2: 99,
  37682. silent: true,
  37683. scale: [1, 1]
  37684. });
  37685. var delay = -i / EFFECT_RIPPLE_NUMBER * effectCfg.period + effectCfg.effectOffset;
  37686. // TODO Configurable effectCfg.period
  37687. ripplePath.animate('', true)
  37688. .when(effectCfg.period, {
  37689. scale: [effectCfg.rippleScale, effectCfg.rippleScale]
  37690. })
  37691. .delay(delay)
  37692. .start();
  37693. ripplePath.animateStyle(true)
  37694. .when(effectCfg.period, {
  37695. opacity: 0
  37696. })
  37697. .delay(delay)
  37698. .start();
  37699. rippleGroup.add(ripplePath);
  37700. }
  37701. updateRipplePath(rippleGroup, effectCfg);
  37702. };
  37703. /**
  37704. * Update effect symbol
  37705. */
  37706. effectSymbolProto.updateEffectAnimation = function (effectCfg) {
  37707. var oldEffectCfg = this._effectCfg;
  37708. var rippleGroup = this.childAt(1);
  37709. // Must reinitialize effect if following configuration changed
  37710. var DIFFICULT_PROPS = ['symbolType', 'period', 'rippleScale'];
  37711. for (var i = 0; i < DIFFICULT_PROPS; i++) {
  37712. var propName = DIFFICULT_PROPS[i];
  37713. if (oldEffectCfg[propName] !== effectCfg[propName]) {
  37714. this.stopEffectAnimation();
  37715. this.startEffectAnimation(effectCfg);
  37716. return;
  37717. }
  37718. }
  37719. updateRipplePath(rippleGroup, effectCfg);
  37720. };
  37721. /**
  37722. * Highlight symbol
  37723. */
  37724. effectSymbolProto.highlight = function () {
  37725. this.trigger('emphasis');
  37726. };
  37727. /**
  37728. * Downplay symbol
  37729. */
  37730. effectSymbolProto.downplay = function () {
  37731. this.trigger('normal');
  37732. };
  37733. /**
  37734. * Update symbol properties
  37735. * @param {module:echarts/data/List} data
  37736. * @param {number} idx
  37737. */
  37738. effectSymbolProto.updateData = function (data, idx) {
  37739. var seriesModel = data.hostModel;
  37740. this.childAt(0).updateData(data, idx);
  37741. var rippleGroup = this.childAt(1);
  37742. var itemModel = data.getItemModel(idx);
  37743. var symbolType = data.getItemVisual(idx, 'symbol');
  37744. var symbolSize = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'));
  37745. var color = data.getItemVisual(idx, 'color');
  37746. rippleGroup.attr('scale', symbolSize);
  37747. rippleGroup.traverse(function (ripplePath) {
  37748. ripplePath.attr({
  37749. fill: color
  37750. });
  37751. });
  37752. var symbolOffset = itemModel.getShallow('symbolOffset');
  37753. if (symbolOffset) {
  37754. var pos = rippleGroup.position;
  37755. pos[0] = numberUtil.parsePercent(symbolOffset[0], symbolSize[0]);
  37756. pos[1] = numberUtil.parsePercent(symbolOffset[1], symbolSize[1]);
  37757. }
  37758. rippleGroup.rotation = (itemModel.getShallow('symbolRotate') || 0) * Math.PI / 180 || 0;
  37759. var effectCfg = {};
  37760. effectCfg.showEffectOn = seriesModel.get('showEffectOn');
  37761. effectCfg.rippleScale = itemModel.get('rippleEffect.scale');
  37762. effectCfg.brushType = itemModel.get('rippleEffect.brushType');
  37763. effectCfg.period = itemModel.get('rippleEffect.period') * 1000;
  37764. effectCfg.effectOffset = idx / data.count();
  37765. effectCfg.z = itemModel.getShallow('z') || 0;
  37766. effectCfg.zlevel = itemModel.getShallow('zlevel') || 0;
  37767. effectCfg.symbolType = symbolType;
  37768. effectCfg.color = color;
  37769. this.off('mouseover').off('mouseout').off('emphasis').off('normal');
  37770. if (effectCfg.showEffectOn === 'render') {
  37771. this._effectCfg
  37772. ? this.updateEffectAnimation(effectCfg)
  37773. : this.startEffectAnimation(effectCfg);
  37774. this._effectCfg = effectCfg;
  37775. }
  37776. else {
  37777. // Not keep old effect config
  37778. this._effectCfg = null;
  37779. this.stopEffectAnimation();
  37780. var symbol = this.childAt(0);
  37781. var onEmphasis = function () {
  37782. symbol.trigger('emphasis');
  37783. if (effectCfg.showEffectOn !== 'render') {
  37784. this.startEffectAnimation(effectCfg);
  37785. }
  37786. };
  37787. var onNormal = function () {
  37788. symbol.trigger('normal');
  37789. if (effectCfg.showEffectOn !== 'render') {
  37790. this.stopEffectAnimation();
  37791. }
  37792. };
  37793. this.on('mouseover', onEmphasis, this)
  37794. .on('mouseout', onNormal, this)
  37795. .on('emphasis', onEmphasis, this)
  37796. .on('normal', onNormal, this);
  37797. }
  37798. this._effectCfg = effectCfg;
  37799. };
  37800. effectSymbolProto.fadeOut = function (cb) {
  37801. this.off('mouseover').off('mouseout').off('emphasis').off('normal');
  37802. cb && cb();
  37803. };
  37804. zrUtil.inherits(EffectSymbol, Group);
  37805. module.exports = EffectSymbol;
  37806. /***/ },
  37807. /* 261 */
  37808. /***/ function(module, exports, __webpack_require__) {
  37809. __webpack_require__(262);
  37810. __webpack_require__(263);
  37811. var echarts = __webpack_require__(1);
  37812. echarts.registerLayout(
  37813. __webpack_require__(268)
  37814. );
  37815. /***/ },
  37816. /* 262 */
  37817. /***/ function(module, exports, __webpack_require__) {
  37818. 'use strict';
  37819. var SeriesModel = __webpack_require__(28);
  37820. var List = __webpack_require__(97);
  37821. var zrUtil = __webpack_require__(4);
  37822. var CoordinateSystem = __webpack_require__(26);
  37823. // Convert [ [{coord: []}, {coord: []}] ]
  37824. // to [ { coords: [[]] } ]
  37825. function preprocessOption (seriesOpt) {
  37826. var data = seriesOpt.data;
  37827. if (data && data[0] && data[0][0] && data[0][0].coord) {
  37828. if (true) {
  37829. console.warn('Lines data configuration has been changed to'
  37830. + ' { coords:[[1,2],[2,3]] }');
  37831. }
  37832. seriesOpt.data = zrUtil.map(data, function (itemOpt) {
  37833. var coords = [
  37834. itemOpt[0].coord, itemOpt[1].coord
  37835. ];
  37836. var target = {
  37837. coords: coords
  37838. };
  37839. if (itemOpt[0].name) {
  37840. target.fromName = itemOpt[0].name;
  37841. }
  37842. if (itemOpt[1].name) {
  37843. target.toName = itemOpt[1].name;
  37844. }
  37845. return zrUtil.mergeAll([target, itemOpt[0], itemOpt[1]]);
  37846. });
  37847. }
  37848. }
  37849. var LinesSeries = SeriesModel.extend({
  37850. type: 'series.lines',
  37851. dependencies: ['grid', 'polar'],
  37852. visualColorAccessPath: 'lineStyle.normal.color',
  37853. init: function (option) {
  37854. // Not using preprocessor because mergeOption may not have series.type
  37855. preprocessOption(option);
  37856. LinesSeries.superApply(this, 'init', arguments);
  37857. },
  37858. mergeOption: function (option) {
  37859. preprocessOption(option);
  37860. LinesSeries.superApply(this, 'mergeOption', arguments);
  37861. },
  37862. getInitialData: function (option, ecModel) {
  37863. if (true) {
  37864. var CoordSys = CoordinateSystem.get(option.coordinateSystem);
  37865. if (!CoordSys) {
  37866. throw new Error('Unkown coordinate system ' + option.coordinateSystem);
  37867. }
  37868. }
  37869. var lineData = new List(['value'], this);
  37870. lineData.hasItemOption = false;
  37871. lineData.initData(option.data, [], function (dataItem, dimName, dataIndex, dimIndex) {
  37872. // dataItem is simply coords
  37873. if (dataItem instanceof Array) {
  37874. return NaN;
  37875. }
  37876. else {
  37877. lineData.hasItemOption = true;
  37878. var value = dataItem.value;
  37879. if (value) {
  37880. return value instanceof Array ? value[dimIndex] : value;
  37881. }
  37882. }
  37883. });
  37884. return lineData;
  37885. },
  37886. formatTooltip: function (dataIndex) {
  37887. var data = this.getData();
  37888. var itemModel = data.getItemModel(dataIndex);
  37889. var name = itemModel.get('name');
  37890. if (name) {
  37891. return name;
  37892. }
  37893. var fromName = itemModel.get('fromName');
  37894. var toName = itemModel.get('toName');
  37895. return fromName + ' > ' + toName;
  37896. },
  37897. defaultOption: {
  37898. coordinateSystem: 'geo',
  37899. zlevel: 0,
  37900. z: 2,
  37901. legendHoverLink: true,
  37902. hoverAnimation: true,
  37903. // Cartesian coordinate system
  37904. xAxisIndex: 0,
  37905. yAxisIndex: 0,
  37906. // Geo coordinate system
  37907. geoIndex: 0,
  37908. effect: {
  37909. show: false,
  37910. period: 4,
  37911. // Animation delay. support callback
  37912. // delay: 0,
  37913. // If move with constant speed px/sec
  37914. // period will be ignored if this property is > 0,
  37915. constantSpeed: 0,
  37916. symbol: 'circle',
  37917. symbolSize: 3,
  37918. loop: true,
  37919. // Length of trail, 0 - 1
  37920. trailLength: 0.2
  37921. // Same with lineStyle.normal.color
  37922. // color
  37923. },
  37924. large: false,
  37925. // Available when large is true
  37926. largeThreshold: 2000,
  37927. // If lines are polyline
  37928. // polyline not support curveness, label, animation
  37929. polyline: false,
  37930. label: {
  37931. normal: {
  37932. show: false,
  37933. position: 'end'
  37934. // distance: 5,
  37935. // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  37936. }
  37937. },
  37938. lineStyle: {
  37939. normal: {
  37940. opacity: 0.5
  37941. }
  37942. }
  37943. }
  37944. });
  37945. /***/ },
  37946. /* 263 */
  37947. /***/ function(module, exports, __webpack_require__) {
  37948. var LineDraw = __webpack_require__(199);
  37949. var EffectLine = __webpack_require__(264);
  37950. var Line = __webpack_require__(200);
  37951. var Polyline = __webpack_require__(265);
  37952. var EffectPolyline = __webpack_require__(266);
  37953. var LargeLineDraw = __webpack_require__(267);
  37954. __webpack_require__(1).extendChartView({
  37955. type: 'lines',
  37956. init: function () {},
  37957. render: function (seriesModel, ecModel, api) {
  37958. var data = seriesModel.getData();
  37959. var lineDraw = this._lineDraw;
  37960. var hasEffect = seriesModel.get('effect.show');
  37961. var isPolyline = seriesModel.get('polyline');
  37962. var isLarge = seriesModel.get('large') && data.count() >= seriesModel.get('largeThreshold');
  37963. if (true) {
  37964. if (hasEffect && isLarge) {
  37965. console.warn('Large lines not support effect');
  37966. }
  37967. }
  37968. if (hasEffect !== this._hasEffet || isPolyline !== this._isPolyline || isLarge !== this._isLarge) {
  37969. if (lineDraw) {
  37970. lineDraw.remove();
  37971. }
  37972. lineDraw = this._lineDraw = isLarge
  37973. ? new LargeLineDraw()
  37974. : new LineDraw(
  37975. isPolyline
  37976. ? (hasEffect ? EffectPolyline : Polyline)
  37977. : (hasEffect ? EffectLine : Line)
  37978. );
  37979. this._hasEffet = hasEffect;
  37980. this._isPolyline = isPolyline;
  37981. this._isLarge = isLarge;
  37982. }
  37983. var zlevel = seriesModel.get('zlevel');
  37984. var trailLength = seriesModel.get('effect.trailLength');
  37985. var zr = api.getZr();
  37986. // Avoid the drag cause ghost shadow
  37987. // FIXME Better way ?
  37988. zr.painter.getLayer(zlevel).clear(true);
  37989. // Config layer with motion blur
  37990. if (this._lastZlevel != null) {
  37991. zr.configLayer(this._lastZlevel, {
  37992. motionBlur: false
  37993. });
  37994. }
  37995. if (hasEffect && trailLength) {
  37996. if (true) {
  37997. var notInIndividual = false;
  37998. ecModel.eachSeries(function (otherSeriesModel) {
  37999. if (otherSeriesModel !== seriesModel && otherSeriesModel.get('zlevel') === zlevel) {
  38000. notInIndividual = true;
  38001. }
  38002. });
  38003. notInIndividual && console.warn('Lines with trail effect should have an individual zlevel');
  38004. }
  38005. zr.configLayer(zlevel, {
  38006. motionBlur: true,
  38007. lastFrameAlpha: Math.max(Math.min(trailLength / 10 + 0.9, 1), 0)
  38008. });
  38009. }
  38010. this.group.add(lineDraw.group);
  38011. lineDraw.updateData(data);
  38012. this._lastZlevel = zlevel;
  38013. },
  38014. updateLayout: function (seriesModel, ecModel, api) {
  38015. this._lineDraw.updateLayout(seriesModel);
  38016. // Not use motion when dragging or zooming
  38017. var zr = api.getZr();
  38018. zr.painter.getLayer(this._lastZlevel).clear(true);
  38019. },
  38020. remove: function (ecModel, api) {
  38021. this._lineDraw && this._lineDraw.remove(api, true);
  38022. }
  38023. });
  38024. /***/ },
  38025. /* 264 */
  38026. /***/ function(module, exports, __webpack_require__) {
  38027. /**
  38028. * Provide effect for line
  38029. * @module echarts/chart/helper/EffectLine
  38030. */
  38031. var graphic = __webpack_require__(43);
  38032. var Line = __webpack_require__(200);
  38033. var zrUtil = __webpack_require__(4);
  38034. var symbolUtil = __webpack_require__(106);
  38035. var vec2 = __webpack_require__(10);
  38036. var curveUtil = __webpack_require__(50);
  38037. /**
  38038. * @constructor
  38039. * @extends {module:zrender/graphic/Group}
  38040. * @alias {module:echarts/chart/helper/Line}
  38041. */
  38042. function EffectLine(lineData, idx, seriesScope) {
  38043. graphic.Group.call(this);
  38044. this.add(this.createLine(lineData, idx, seriesScope));
  38045. this._updateEffectSymbol(lineData, idx);
  38046. }
  38047. var effectLineProto = EffectLine.prototype;
  38048. effectLineProto.createLine = function (lineData, idx, seriesScope) {
  38049. return new Line(lineData, idx, seriesScope);
  38050. };
  38051. effectLineProto._updateEffectSymbol = function (lineData, idx) {
  38052. var itemModel = lineData.getItemModel(idx);
  38053. var effectModel = itemModel.getModel('effect');
  38054. var size = effectModel.get('symbolSize');
  38055. var symbolType = effectModel.get('symbol');
  38056. if (!zrUtil.isArray(size)) {
  38057. size = [size, size];
  38058. }
  38059. var color = effectModel.get('color') || lineData.getItemVisual(idx, 'color');
  38060. var symbol = this.childAt(1);
  38061. if (this._symbolType !== symbolType) {
  38062. // Remove previous
  38063. this.remove(symbol);
  38064. symbol = symbolUtil.createSymbol(
  38065. symbolType, -0.5, -0.5, 1, 1, color
  38066. );
  38067. symbol.z2 = 100;
  38068. symbol.culling = true;
  38069. this.add(symbol);
  38070. }
  38071. // Symbol may be removed if loop is false
  38072. if (!symbol) {
  38073. return;
  38074. }
  38075. // Shadow color is same with color in default
  38076. symbol.setStyle('shadowColor', color);
  38077. symbol.setStyle(effectModel.getItemStyle(['color']));
  38078. symbol.attr('scale', size);
  38079. symbol.setColor(color);
  38080. symbol.attr('scale', size);
  38081. this._symbolType = symbolType;
  38082. this._updateEffectAnimation(lineData, effectModel, idx);
  38083. };
  38084. effectLineProto._updateEffectAnimation = function (lineData, effectModel, idx) {
  38085. var symbol = this.childAt(1);
  38086. if (!symbol) {
  38087. return;
  38088. }
  38089. var self = this;
  38090. var points = lineData.getItemLayout(idx);
  38091. var period = effectModel.get('period') * 1000;
  38092. var loop = effectModel.get('loop');
  38093. var constantSpeed = effectModel.get('constantSpeed');
  38094. var delayExpr = effectModel.get('delay') || function (idx) {
  38095. return idx / lineData.count() * period / 3;
  38096. };
  38097. var isDelayFunc = typeof delayExpr === 'function';
  38098. // Ignore when updating
  38099. symbol.ignore = true;
  38100. this.updateAnimationPoints(symbol, points);
  38101. if (constantSpeed > 0) {
  38102. period = this.getLineLength(symbol) / constantSpeed * 1000;
  38103. }
  38104. if (period !== this._period || loop !== this._loop) {
  38105. symbol.stopAnimation();
  38106. var delay = delayExpr;
  38107. if (isDelayFunc) {
  38108. delay = delayExpr(idx);
  38109. }
  38110. if (symbol.__t > 0) {
  38111. delay = -period * symbol.__t;
  38112. }
  38113. symbol.__t = 0;
  38114. var animator = symbol.animate('', loop)
  38115. .when(period, {
  38116. __t: 1
  38117. })
  38118. .delay(delay)
  38119. .during(function () {
  38120. self.updateSymbolPosition(symbol);
  38121. });
  38122. if (!loop) {
  38123. animator.done(function () {
  38124. self.remove(symbol);
  38125. });
  38126. }
  38127. animator.start();
  38128. }
  38129. this._period = period;
  38130. this._loop = loop;
  38131. };
  38132. effectLineProto.getLineLength = function (symbol) {
  38133. // Not so accurate
  38134. return (vec2.dist(symbol.__p1, symbol.__cp1)
  38135. + vec2.dist(symbol.__cp1, symbol.__p2));
  38136. };
  38137. effectLineProto.updateAnimationPoints = function (symbol, points) {
  38138. symbol.__p1 = points[0];
  38139. symbol.__p2 = points[1];
  38140. symbol.__cp1 = points[2] || [
  38141. (points[0][0] + points[1][0]) / 2,
  38142. (points[0][1] + points[1][1]) / 2
  38143. ];
  38144. };
  38145. effectLineProto.updateData = function (lineData, idx, seriesScope) {
  38146. this.childAt(0).updateData(lineData, idx, seriesScope);
  38147. this._updateEffectSymbol(lineData, idx);
  38148. };
  38149. effectLineProto.updateSymbolPosition = function (symbol) {
  38150. var p1 = symbol.__p1;
  38151. var p2 = symbol.__p2;
  38152. var cp1 = symbol.__cp1;
  38153. var t = symbol.__t;
  38154. var pos = symbol.position;
  38155. var quadraticAt = curveUtil.quadraticAt;
  38156. var quadraticDerivativeAt = curveUtil.quadraticDerivativeAt;
  38157. pos[0] = quadraticAt(p1[0], cp1[0], p2[0], t);
  38158. pos[1] = quadraticAt(p1[1], cp1[1], p2[1], t);
  38159. // Tangent
  38160. var tx = quadraticDerivativeAt(p1[0], cp1[0], p2[0], t);
  38161. var ty = quadraticDerivativeAt(p1[1], cp1[1], p2[1], t);
  38162. symbol.rotation = -Math.atan2(ty, tx) - Math.PI / 2;
  38163. symbol.ignore = false;
  38164. };
  38165. effectLineProto.updateLayout = function (lineData, idx) {
  38166. this.childAt(0).updateLayout(lineData, idx);
  38167. var effectModel = lineData.getItemModel(idx).getModel('effect');
  38168. this._updateEffectAnimation(lineData, effectModel, idx);
  38169. };
  38170. zrUtil.inherits(EffectLine, graphic.Group);
  38171. module.exports = EffectLine;
  38172. /***/ },
  38173. /* 265 */
  38174. /***/ function(module, exports, __webpack_require__) {
  38175. /**
  38176. * @module echarts/chart/helper/Line
  38177. */
  38178. var graphic = __webpack_require__(43);
  38179. var zrUtil = __webpack_require__(4);
  38180. /**
  38181. * @constructor
  38182. * @extends {module:zrender/graphic/Group}
  38183. * @alias {module:echarts/chart/helper/Polyline}
  38184. */
  38185. function Polyline(lineData, idx, seriesScope) {
  38186. graphic.Group.call(this);
  38187. this._createPolyline(lineData, idx, seriesScope);
  38188. }
  38189. var polylineProto = Polyline.prototype;
  38190. polylineProto._createPolyline = function (lineData, idx, seriesScope) {
  38191. // var seriesModel = lineData.hostModel;
  38192. var points = lineData.getItemLayout(idx);
  38193. var line = new graphic.Polyline({
  38194. shape: {
  38195. points: points
  38196. }
  38197. });
  38198. this.add(line);
  38199. this._updateCommonStl(lineData, idx, seriesScope);
  38200. };
  38201. polylineProto.updateData = function (lineData, idx, seriesScope) {
  38202. var seriesModel = lineData.hostModel;
  38203. var line = this.childAt(0);
  38204. var target = {
  38205. shape: {
  38206. points: lineData.getItemLayout(idx)
  38207. }
  38208. };
  38209. graphic.updateProps(line, target, seriesModel, idx);
  38210. this._updateCommonStl(lineData, idx, seriesScope);
  38211. };
  38212. polylineProto._updateCommonStl = function (lineData, idx, seriesScope) {
  38213. var line = this.childAt(0);
  38214. var itemModel = lineData.getItemModel(idx);
  38215. var visualColor = lineData.getItemVisual(idx, 'color');
  38216. var lineStyle = seriesScope && seriesScope.lineStyle;
  38217. var hoverLineStyle = seriesScope && seriesScope.hoverLineStyle;
  38218. if (!seriesScope || lineData.hasItemOption) {
  38219. lineStyle = itemModel.getModel('lineStyle.normal').getLineStyle();
  38220. hoverLineStyle = itemModel.getModel('lineStyle.emphasis').getLineStyle();
  38221. }
  38222. line.useStyle(zrUtil.defaults(
  38223. {
  38224. strokeNoScale: true,
  38225. fill: 'none',
  38226. stroke: visualColor
  38227. },
  38228. lineStyle
  38229. ));
  38230. line.hoverStyle = hoverLineStyle;
  38231. graphic.setHoverStyle(this);
  38232. };
  38233. polylineProto.updateLayout = function (lineData, idx) {
  38234. var polyline = this.childAt(0);
  38235. polyline.setShape('points', lineData.getItemLayout(idx));
  38236. };
  38237. zrUtil.inherits(Polyline, graphic.Group);
  38238. module.exports = Polyline;
  38239. /***/ },
  38240. /* 266 */
  38241. /***/ function(module, exports, __webpack_require__) {
  38242. /**
  38243. * Provide effect for line
  38244. * @module echarts/chart/helper/EffectLine
  38245. */
  38246. var Polyline = __webpack_require__(265);
  38247. var zrUtil = __webpack_require__(4);
  38248. var EffectLine = __webpack_require__(264);
  38249. var vec2 = __webpack_require__(10);
  38250. /**
  38251. * @constructor
  38252. * @extends {module:echarts/chart/helper/EffectLine}
  38253. * @alias {module:echarts/chart/helper/Polyline}
  38254. */
  38255. function EffectPolyline(lineData, idx, seriesScope) {
  38256. EffectLine.call(this, lineData, idx, seriesScope);
  38257. this._lastFrame = 0;
  38258. this._lastFramePercent = 0;
  38259. }
  38260. var effectPolylineProto = EffectPolyline.prototype;
  38261. // Overwrite
  38262. effectPolylineProto.createLine = function (lineData, idx, seriesScope) {
  38263. return new Polyline(lineData, idx, seriesScope);
  38264. };
  38265. // Overwrite
  38266. effectPolylineProto.updateAnimationPoints = function (symbol, points) {
  38267. this._points = points;
  38268. var accLenArr = [0];
  38269. var len = 0;
  38270. for (var i = 1; i < points.length; i++) {
  38271. var p1 = points[i - 1];
  38272. var p2 = points[i];
  38273. len += vec2.dist(p1, p2);
  38274. accLenArr.push(len);
  38275. }
  38276. if (len === 0) {
  38277. return;
  38278. }
  38279. for (var i = 0; i < accLenArr.length; i++) {
  38280. accLenArr[i] /= len;
  38281. }
  38282. this._offsets = accLenArr;
  38283. this._length = len;
  38284. };
  38285. // Overwrite
  38286. effectPolylineProto.getLineLength = function (symbol) {
  38287. return this._length;
  38288. };
  38289. // Overwrite
  38290. effectPolylineProto.updateSymbolPosition = function (symbol) {
  38291. var t = symbol.__t;
  38292. var points = this._points;
  38293. var offsets = this._offsets;
  38294. var len = points.length;
  38295. if (!offsets) {
  38296. // Has length 0
  38297. return;
  38298. }
  38299. var lastFrame = this._lastFrame;
  38300. var frame;
  38301. if (t < this._lastFramePercent) {
  38302. // Start from the next frame
  38303. // PENDING start from lastFrame ?
  38304. var start = Math.min(lastFrame + 1, len - 1);
  38305. for (frame = start; frame >= 0; frame--) {
  38306. if (offsets[frame] <= t) {
  38307. break;
  38308. }
  38309. }
  38310. // PENDING really need to do this ?
  38311. frame = Math.min(frame, len - 2);
  38312. }
  38313. else {
  38314. for (var frame = lastFrame; frame < len; frame++) {
  38315. if (offsets[frame] > t) {
  38316. break;
  38317. }
  38318. }
  38319. frame = Math.min(frame - 1, len - 2);
  38320. }
  38321. vec2.lerp(
  38322. symbol.position, points[frame], points[frame + 1],
  38323. (t - offsets[frame]) / (offsets[frame + 1] - offsets[frame])
  38324. );
  38325. this._lastFrame = frame;
  38326. this._lastFramePercent = t;
  38327. symbol.ignore = false;
  38328. };
  38329. zrUtil.inherits(EffectPolyline, EffectLine);
  38330. module.exports = EffectPolyline;
  38331. /***/ },
  38332. /* 267 */
  38333. /***/ function(module, exports, __webpack_require__) {
  38334. // TODO Batch by color
  38335. var graphic = __webpack_require__(43);
  38336. var quadraticContain = __webpack_require__(55);
  38337. var lineContain = __webpack_require__(53);
  38338. var LargeLineShape = graphic.extendShape({
  38339. shape: {
  38340. polyline: false,
  38341. segs: []
  38342. },
  38343. buildPath: function (path, shape) {
  38344. var segs = shape.segs;
  38345. var isPolyline = shape.polyline;
  38346. for (var i = 0; i < segs.length; i++) {
  38347. var seg = segs[i];
  38348. if (isPolyline) {
  38349. path.moveTo(seg[0][0], seg[0][1]);
  38350. for (var j = 1; j < seg.length; j++) {
  38351. path.lineTo(seg[j][0], seg[j][1]);
  38352. }
  38353. }
  38354. else {
  38355. path.moveTo(seg[0][0], seg[0][1]);
  38356. if (seg.length > 2) {
  38357. path.quadraticCurveTo(seg[2][0], seg[2][1], seg[1][0], seg[1][1]);
  38358. }
  38359. else {
  38360. path.lineTo(seg[1][0], seg[1][1]);
  38361. }
  38362. }
  38363. }
  38364. },
  38365. findDataIndex: function (x, y) {
  38366. var shape = this.shape;
  38367. var segs = shape.segs;
  38368. var isPolyline = shape.polyline;
  38369. var lineWidth = Math.max(this.style.lineWidth, 1);
  38370. // Not consider transform
  38371. for (var i = 0; i < segs.length; i++) {
  38372. var seg = segs[i];
  38373. if (isPolyline) {
  38374. for (var j = 1; j < seg.length; j++) {
  38375. if (lineContain.containStroke(
  38376. seg[j - 1][0], seg[j - 1][1], seg[j][0], seg[j][1], lineWidth, x, y
  38377. )) {
  38378. return i;
  38379. }
  38380. }
  38381. }
  38382. else {
  38383. if (seg.length > 2) {
  38384. if (quadraticContain.containStroke(
  38385. seg[0][0], seg[0][1], seg[2][0], seg[2][1], seg[1][0], seg[1][1], lineWidth, x, y
  38386. )) {
  38387. return i;
  38388. }
  38389. }
  38390. else {
  38391. if (lineContain.containStroke(
  38392. seg[0][0], seg[0][1], seg[1][0], seg[1][1], lineWidth, x, y
  38393. )) {
  38394. return i;
  38395. }
  38396. }
  38397. }
  38398. }
  38399. return -1;
  38400. }
  38401. });
  38402. function LargeLineDraw() {
  38403. this.group = new graphic.Group();
  38404. this._lineEl = new LargeLineShape();
  38405. }
  38406. var largeLineProto = LargeLineDraw.prototype;
  38407. /**
  38408. * Update symbols draw by new data
  38409. * @param {module:echarts/data/List} data
  38410. */
  38411. largeLineProto.updateData = function (data) {
  38412. this.group.removeAll();
  38413. var lineEl = this._lineEl;
  38414. var seriesModel = data.hostModel;
  38415. lineEl.setShape({
  38416. segs: data.mapArray(data.getItemLayout),
  38417. polyline: seriesModel.get('polyline')
  38418. });
  38419. lineEl.useStyle(
  38420. seriesModel.getModel('lineStyle.normal').getLineStyle()
  38421. );
  38422. var visualColor = data.getVisual('color');
  38423. if (visualColor) {
  38424. lineEl.setStyle('stroke', visualColor);
  38425. }
  38426. lineEl.setStyle('fill');
  38427. // Enable tooltip
  38428. // PENDING May have performance issue when path is extremely large
  38429. lineEl.seriesIndex = seriesModel.seriesIndex;
  38430. lineEl.on('mousemove', function (e) {
  38431. lineEl.dataIndex = null;
  38432. var dataIndex = lineEl.findDataIndex(e.offsetX, e.offsetY);
  38433. if (dataIndex > 0) {
  38434. // Provide dataIndex for tooltip
  38435. lineEl.dataIndex = dataIndex;
  38436. }
  38437. });
  38438. // Add back
  38439. this.group.add(lineEl);
  38440. };
  38441. largeLineProto.updateLayout = function (seriesModel) {
  38442. var data = seriesModel.getData();
  38443. this._lineEl.setShape({
  38444. segs: data.mapArray(data.getItemLayout)
  38445. });
  38446. };
  38447. largeLineProto.remove = function () {
  38448. this.group.removeAll();
  38449. };
  38450. module.exports = LargeLineDraw;
  38451. /***/ },
  38452. /* 268 */
  38453. /***/ function(module, exports, __webpack_require__) {
  38454. module.exports = function (ecModel) {
  38455. ecModel.eachSeriesByType('lines', function (seriesModel) {
  38456. var coordSys = seriesModel.coordinateSystem;
  38457. var lineData = seriesModel.getData();
  38458. // FIXME Use data dimensions ?
  38459. lineData.each(function (idx) {
  38460. var itemModel = lineData.getItemModel(idx);
  38461. // TODO Support pure array
  38462. var coords = (itemModel.option instanceof Array) ?
  38463. itemModel.option : itemModel.get('coords');
  38464. if (true) {
  38465. if (!(coords instanceof Array && coords.length > 0 && coords[0] instanceof Array)) {
  38466. throw new Error('Invalid coords ' + JSON.stringify(coords) + '. Lines must have 2d coords array in data item.');
  38467. }
  38468. }
  38469. var pts = [];
  38470. if (seriesModel.get('polyline')) {
  38471. for (var i = 0; i < coords.length; i++) {
  38472. pts.push(coordSys.dataToPoint(coords[i]));
  38473. }
  38474. }
  38475. else {
  38476. pts[0] = coordSys.dataToPoint(coords[0]);
  38477. pts[1] = coordSys.dataToPoint(coords[1]);
  38478. var curveness = itemModel.get('lineStyle.normal.curveness');
  38479. if (curveness > 0) {
  38480. pts[2] = [
  38481. (pts[0][0] + pts[1][0]) / 2 - (pts[0][1] - pts[1][1]) * curveness,
  38482. (pts[0][1] + pts[1][1]) / 2 - (pts[1][0] - pts[0][0]) * curveness
  38483. ];
  38484. }
  38485. }
  38486. lineData.setItemLayout(idx, pts);
  38487. });
  38488. });
  38489. };
  38490. /***/ },
  38491. /* 269 */
  38492. /***/ function(module, exports, __webpack_require__) {
  38493. __webpack_require__(270);
  38494. __webpack_require__(271);
  38495. /***/ },
  38496. /* 270 */
  38497. /***/ function(module, exports, __webpack_require__) {
  38498. var SeriesModel = __webpack_require__(28);
  38499. var createListFromArray = __webpack_require__(101);
  38500. module.exports = SeriesModel.extend({
  38501. type: 'series.heatmap',
  38502. getInitialData: function (option, ecModel) {
  38503. return createListFromArray(option.data, this, ecModel);
  38504. },
  38505. defaultOption: {
  38506. // Cartesian2D or geo
  38507. coordinateSystem: 'cartesian2d',
  38508. zlevel: 0,
  38509. z: 2,
  38510. // Cartesian coordinate system
  38511. xAxisIndex: 0,
  38512. yAxisIndex: 0,
  38513. // Geo coordinate system
  38514. geoIndex: 0,
  38515. blurSize: 30,
  38516. pointSize: 20,
  38517. maxOpacity: 1,
  38518. minOpacity: 0
  38519. }
  38520. });
  38521. /***/ },
  38522. /* 271 */
  38523. /***/ function(module, exports, __webpack_require__) {
  38524. var graphic = __webpack_require__(43);
  38525. var HeatmapLayer = __webpack_require__(272);
  38526. var zrUtil = __webpack_require__(4);
  38527. function getIsInPiecewiseRange(dataExtent, pieceList, selected) {
  38528. var dataSpan = dataExtent[1] - dataExtent[0];
  38529. pieceList = zrUtil.map(pieceList, function (piece) {
  38530. return {
  38531. interval: [
  38532. (piece.interval[0] - dataExtent[0]) / dataSpan,
  38533. (piece.interval[1] - dataExtent[0]) / dataSpan
  38534. ]
  38535. };
  38536. });
  38537. var len = pieceList.length;
  38538. var lastIndex = 0;
  38539. return function (val) {
  38540. // Try to find in the location of the last found
  38541. for (var i = lastIndex; i < len; i++) {
  38542. var interval = pieceList[i].interval;
  38543. if (interval[0] <= val && val <= interval[1]) {
  38544. lastIndex = i;
  38545. break;
  38546. }
  38547. }
  38548. if (i === len) { // Not found, back interation
  38549. for (var i = lastIndex - 1; i >= 0; i--) {
  38550. var interval = pieceList[i].interval;
  38551. if (interval[0] <= val && val <= interval[1]) {
  38552. lastIndex = i;
  38553. break;
  38554. }
  38555. }
  38556. }
  38557. return i >= 0 && i < len && selected[i];
  38558. };
  38559. }
  38560. function getIsInContinuousRange(dataExtent, range) {
  38561. var dataSpan = dataExtent[1] - dataExtent[0];
  38562. range = [
  38563. (range[0] - dataExtent[0]) / dataSpan,
  38564. (range[1] - dataExtent[0]) / dataSpan
  38565. ];
  38566. return function (val) {
  38567. return val >= range[0] && val <= range[1];
  38568. };
  38569. }
  38570. function isGeoCoordSys(coordSys) {
  38571. var dimensions = coordSys.dimensions;
  38572. // Not use coorSys.type === 'geo' because coordSys maybe extended
  38573. return dimensions[0] === 'lng' && dimensions[1] === 'lat';
  38574. }
  38575. module.exports = __webpack_require__(1).extendChartView({
  38576. type: 'heatmap',
  38577. render: function (seriesModel, ecModel, api) {
  38578. var visualMapOfThisSeries;
  38579. ecModel.eachComponent('visualMap', function (visualMap) {
  38580. visualMap.eachTargetSeries(function (targetSeries) {
  38581. if (targetSeries === seriesModel) {
  38582. visualMapOfThisSeries = visualMap;
  38583. }
  38584. });
  38585. });
  38586. if (true) {
  38587. if (!visualMapOfThisSeries) {
  38588. throw new Error('Heatmap must use with visualMap');
  38589. }
  38590. }
  38591. this.group.removeAll();
  38592. var coordSys = seriesModel.coordinateSystem;
  38593. if (coordSys.type === 'cartesian2d') {
  38594. this._renderOnCartesian(coordSys, seriesModel, api);
  38595. }
  38596. else if (isGeoCoordSys(coordSys)) {
  38597. this._renderOnGeo(
  38598. coordSys, seriesModel, visualMapOfThisSeries, api
  38599. );
  38600. }
  38601. },
  38602. _renderOnCartesian: function (cartesian, seriesModel, api) {
  38603. var xAxis = cartesian.getAxis('x');
  38604. var yAxis = cartesian.getAxis('y');
  38605. var group = this.group;
  38606. if (true) {
  38607. if (!(xAxis.type === 'category' && yAxis.type === 'category')) {
  38608. throw new Error('Heatmap on cartesian must have two category axes');
  38609. }
  38610. if (!(xAxis.onBand && yAxis.onBand)) {
  38611. throw new Error('Heatmap on cartesian must have two axes with boundaryGap true');
  38612. }
  38613. }
  38614. var width = xAxis.getBandWidth();
  38615. var height = yAxis.getBandWidth();
  38616. var data = seriesModel.getData();
  38617. var itemStyleQuery = 'itemStyle.normal';
  38618. var hoverItemStyleQuery = 'itemStyle.emphasis';
  38619. var labelQuery = 'label.normal';
  38620. var hoverLabelQuery = 'label.emphasis';
  38621. var style = seriesModel.getModel(itemStyleQuery).getItemStyle(['color']);
  38622. var hoverStl = seriesModel.getModel(hoverItemStyleQuery).getItemStyle();
  38623. var labelModel = seriesModel.getModel('label.normal');
  38624. var hoverLabelModel = seriesModel.getModel('label.emphasis');
  38625. data.each(['x', 'y', 'z'], function (x, y, z, idx) {
  38626. var itemModel = data.getItemModel(idx);
  38627. var point = cartesian.dataToPoint([x, y]);
  38628. // Ignore empty data
  38629. if (isNaN(z)) {
  38630. return;
  38631. }
  38632. var rect = new graphic.Rect({
  38633. shape: {
  38634. x: point[0] - width / 2,
  38635. y: point[1] - height / 2,
  38636. width: width,
  38637. height: height
  38638. },
  38639. style: {
  38640. fill: data.getItemVisual(idx, 'color'),
  38641. opacity: data.getItemVisual(idx, 'opacity')
  38642. }
  38643. });
  38644. // Optimization for large datset
  38645. if (data.hasItemOption) {
  38646. style = itemModel.getModel(itemStyleQuery).getItemStyle(['color']);
  38647. hoverStl = itemModel.getModel(hoverItemStyleQuery).getItemStyle();
  38648. labelModel = itemModel.getModel(labelQuery);
  38649. hoverLabelModel = itemModel.getModel(hoverLabelQuery);
  38650. }
  38651. var rawValue = seriesModel.getRawValue(idx);
  38652. var defaultText = '-';
  38653. if (rawValue && rawValue[2] != null) {
  38654. defaultText = rawValue[2];
  38655. }
  38656. if (labelModel.getShallow('show')) {
  38657. graphic.setText(style, labelModel);
  38658. style.text = seriesModel.getFormattedLabel(idx, 'normal') || defaultText;
  38659. }
  38660. if (hoverLabelModel.getShallow('show')) {
  38661. graphic.setText(hoverStl, hoverLabelModel);
  38662. hoverStl.text = seriesModel.getFormattedLabel(idx, 'emphasis') || defaultText;
  38663. }
  38664. rect.setStyle(style);
  38665. graphic.setHoverStyle(rect, data.hasItemOption ? hoverStl : zrUtil.extend({}, hoverStl));
  38666. group.add(rect);
  38667. data.setItemGraphicEl(idx, rect);
  38668. });
  38669. },
  38670. _renderOnGeo: function (geo, seriesModel, visualMapModel, api) {
  38671. var inRangeVisuals = visualMapModel.targetVisuals.inRange;
  38672. var outOfRangeVisuals = visualMapModel.targetVisuals.outOfRange;
  38673. // if (!visualMapping) {
  38674. // throw new Error('Data range must have color visuals');
  38675. // }
  38676. var data = seriesModel.getData();
  38677. var hmLayer = this._hmLayer || (this._hmLayer || new HeatmapLayer());
  38678. hmLayer.blurSize = seriesModel.get('blurSize');
  38679. hmLayer.pointSize = seriesModel.get('pointSize');
  38680. hmLayer.minOpacity = seriesModel.get('minOpacity');
  38681. hmLayer.maxOpacity = seriesModel.get('maxOpacity');
  38682. var rect = geo.getViewRect().clone();
  38683. var roamTransform = geo.getRoamTransform().transform;
  38684. rect.applyTransform(roamTransform);
  38685. // Clamp on viewport
  38686. var x = Math.max(rect.x, 0);
  38687. var y = Math.max(rect.y, 0);
  38688. var x2 = Math.min(rect.width + rect.x, api.getWidth());
  38689. var y2 = Math.min(rect.height + rect.y, api.getHeight());
  38690. var width = x2 - x;
  38691. var height = y2 - y;
  38692. var points = data.mapArray(['lng', 'lat', 'value'], function (lng, lat, value) {
  38693. var pt = geo.dataToPoint([lng, lat]);
  38694. pt[0] -= x;
  38695. pt[1] -= y;
  38696. pt.push(value);
  38697. return pt;
  38698. });
  38699. var dataExtent = visualMapModel.getExtent();
  38700. var isInRange = visualMapModel.type === 'visualMap.continuous'
  38701. ? getIsInContinuousRange(dataExtent, visualMapModel.option.range)
  38702. : getIsInPiecewiseRange(
  38703. dataExtent, visualMapModel.getPieceList(), visualMapModel.option.selected
  38704. );
  38705. hmLayer.update(
  38706. points, width, height,
  38707. inRangeVisuals.color.getNormalizer(),
  38708. {
  38709. inRange: inRangeVisuals.color.getColorMapper(),
  38710. outOfRange: outOfRangeVisuals.color.getColorMapper()
  38711. },
  38712. isInRange
  38713. );
  38714. var img = new graphic.Image({
  38715. style: {
  38716. width: width,
  38717. height: height,
  38718. x: x,
  38719. y: y,
  38720. image: hmLayer.canvas
  38721. },
  38722. silent: true
  38723. });
  38724. this.group.add(img);
  38725. }
  38726. });
  38727. /***/ },
  38728. /* 272 */
  38729. /***/ function(module, exports, __webpack_require__) {
  38730. /**
  38731. * @file defines echarts Heatmap Chart
  38732. * @author Ovilia (me@zhangwenli.com)
  38733. * Inspired by https://github.com/mourner/simpleheat
  38734. *
  38735. * @module
  38736. */
  38737. var GRADIENT_LEVELS = 256;
  38738. var zrUtil = __webpack_require__(4);
  38739. /**
  38740. * Heatmap Chart
  38741. *
  38742. * @class
  38743. */
  38744. function Heatmap() {
  38745. var canvas = zrUtil.createCanvas();
  38746. this.canvas = canvas;
  38747. this.blurSize = 30;
  38748. this.pointSize = 20;
  38749. this.maxOpacity = 1;
  38750. this.minOpacity = 0;
  38751. this._gradientPixels = {};
  38752. }
  38753. Heatmap.prototype = {
  38754. /**
  38755. * Renders Heatmap and returns the rendered canvas
  38756. * @param {Array} data array of data, each has x, y, value
  38757. * @param {number} width canvas width
  38758. * @param {number} height canvas height
  38759. */
  38760. update: function(data, width, height, normalize, colorFunc, isInRange) {
  38761. var brush = this._getBrush();
  38762. var gradientInRange = this._getGradient(data, colorFunc, 'inRange');
  38763. var gradientOutOfRange = this._getGradient(data, colorFunc, 'outOfRange');
  38764. var r = this.pointSize + this.blurSize;
  38765. var canvas = this.canvas;
  38766. var ctx = canvas.getContext('2d');
  38767. var len = data.length;
  38768. canvas.width = width;
  38769. canvas.height = height;
  38770. for (var i = 0; i < len; ++i) {
  38771. var p = data[i];
  38772. var x = p[0];
  38773. var y = p[1];
  38774. var value = p[2];
  38775. // calculate alpha using value
  38776. var alpha = normalize(value);
  38777. // draw with the circle brush with alpha
  38778. ctx.globalAlpha = alpha;
  38779. ctx.drawImage(brush, x - r, y - r);
  38780. }
  38781. // colorize the canvas using alpha value and set with gradient
  38782. var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
  38783. var pixels = imageData.data;
  38784. var offset = 0;
  38785. var pixelLen = pixels.length;
  38786. var minOpacity = this.minOpacity;
  38787. var maxOpacity = this.maxOpacity;
  38788. var diffOpacity = maxOpacity - minOpacity;
  38789. while(offset < pixelLen) {
  38790. var alpha = pixels[offset + 3] / 256;
  38791. var gradientOffset = Math.floor(alpha * (GRADIENT_LEVELS - 1)) * 4;
  38792. // Simple optimize to ignore the empty data
  38793. if (alpha > 0) {
  38794. var gradient = isInRange(alpha) ? gradientInRange : gradientOutOfRange;
  38795. // Any alpha > 0 will be mapped to [minOpacity, maxOpacity]
  38796. alpha > 0 && (alpha = alpha * diffOpacity + minOpacity);
  38797. pixels[offset++] = gradient[gradientOffset];
  38798. pixels[offset++] = gradient[gradientOffset + 1];
  38799. pixels[offset++] = gradient[gradientOffset + 2];
  38800. pixels[offset++] = gradient[gradientOffset + 3] * alpha * 256;
  38801. }
  38802. else {
  38803. offset += 4;
  38804. }
  38805. }
  38806. ctx.putImageData(imageData, 0, 0);
  38807. return canvas;
  38808. },
  38809. /**
  38810. * get canvas of a black circle brush used for canvas to draw later
  38811. * @private
  38812. * @returns {Object} circle brush canvas
  38813. */
  38814. _getBrush: function() {
  38815. var brushCanvas = this._brushCanvas || (this._brushCanvas = zrUtil.createCanvas());
  38816. // set brush size
  38817. var r = this.pointSize + this.blurSize;
  38818. var d = r * 2;
  38819. brushCanvas.width = d;
  38820. brushCanvas.height = d;
  38821. var ctx = brushCanvas.getContext('2d');
  38822. ctx.clearRect(0, 0, d, d);
  38823. // in order to render shadow without the distinct circle,
  38824. // draw the distinct circle in an invisible place,
  38825. // and use shadowOffset to draw shadow in the center of the canvas
  38826. ctx.shadowOffsetX = d;
  38827. ctx.shadowBlur = this.blurSize;
  38828. // draw the shadow in black, and use alpha and shadow blur to generate
  38829. // color in color map
  38830. ctx.shadowColor = '#000';
  38831. // draw circle in the left to the canvas
  38832. ctx.beginPath();
  38833. ctx.arc(-r, r, this.pointSize, 0, Math.PI * 2, true);
  38834. ctx.closePath();
  38835. ctx.fill();
  38836. return brushCanvas;
  38837. },
  38838. /**
  38839. * get gradient color map
  38840. * @private
  38841. */
  38842. _getGradient: function (data, colorFunc, state) {
  38843. var gradientPixels = this._gradientPixels;
  38844. var pixelsSingleState = gradientPixels[state] || (gradientPixels[state] = new Uint8ClampedArray(256 * 4));
  38845. var color = [];
  38846. var off = 0;
  38847. for (var i = 0; i < 256; i++) {
  38848. colorFunc[state](i / 255, true, color);
  38849. pixelsSingleState[off++] = color[0];
  38850. pixelsSingleState[off++] = color[1];
  38851. pixelsSingleState[off++] = color[2];
  38852. pixelsSingleState[off++] = color[3];
  38853. }
  38854. return pixelsSingleState;
  38855. }
  38856. };
  38857. module.exports = Heatmap;
  38858. /***/ },
  38859. /* 273 */
  38860. /***/ function(module, exports, __webpack_require__) {
  38861. /**
  38862. * Legend component entry file8
  38863. */
  38864. __webpack_require__(274);
  38865. __webpack_require__(275);
  38866. __webpack_require__(276);
  38867. var echarts = __webpack_require__(1);
  38868. // Series Filter
  38869. echarts.registerProcessor(__webpack_require__(278));
  38870. /***/ },
  38871. /* 274 */
  38872. /***/ function(module, exports, __webpack_require__) {
  38873. 'use strict';
  38874. var zrUtil = __webpack_require__(4);
  38875. var Model = __webpack_require__(12);
  38876. var LegendModel = __webpack_require__(1).extendComponentModel({
  38877. type: 'legend',
  38878. dependencies: ['series'],
  38879. layoutMode: {
  38880. type: 'box',
  38881. ignoreSize: true
  38882. },
  38883. init: function (option, parentModel, ecModel) {
  38884. this.mergeDefaultAndTheme(option, ecModel);
  38885. option.selected = option.selected || {};
  38886. },
  38887. mergeOption: function (option) {
  38888. LegendModel.superCall(this, 'mergeOption', option);
  38889. },
  38890. optionUpdated: function () {
  38891. this._updateData(this.ecModel);
  38892. var legendData = this._data;
  38893. // If selectedMode is single, try to select one
  38894. if (legendData[0] && this.get('selectedMode') === 'single') {
  38895. var hasSelected = false;
  38896. // If has any selected in option.selected
  38897. for (var i = 0; i < legendData.length; i++) {
  38898. var name = legendData[i].get('name');
  38899. if (this.isSelected(name)) {
  38900. // Force to unselect others
  38901. this.select(name);
  38902. hasSelected = true;
  38903. break;
  38904. }
  38905. }
  38906. // Try select the first if selectedMode is single
  38907. !hasSelected && this.select(legendData[0].get('name'));
  38908. }
  38909. },
  38910. _updateData: function (ecModel) {
  38911. var legendData = zrUtil.map(this.get('data') || [], function (dataItem) {
  38912. // Can be string or number
  38913. if (typeof dataItem === 'string' || typeof dataItem === 'number') {
  38914. dataItem = {
  38915. name: dataItem
  38916. };
  38917. }
  38918. return new Model(dataItem, this, this.ecModel);
  38919. }, this);
  38920. this._data = legendData;
  38921. var availableNames = zrUtil.map(ecModel.getSeries(), function (series) {
  38922. return series.name;
  38923. });
  38924. ecModel.eachSeries(function (seriesModel) {
  38925. if (seriesModel.legendDataProvider) {
  38926. var data = seriesModel.legendDataProvider();
  38927. availableNames = availableNames.concat(data.mapArray(data.getName));
  38928. }
  38929. });
  38930. /**
  38931. * @type {Array.<string>}
  38932. * @private
  38933. */
  38934. this._availableNames = availableNames;
  38935. },
  38936. /**
  38937. * @return {Array.<module:echarts/model/Model>}
  38938. */
  38939. getData: function () {
  38940. return this._data;
  38941. },
  38942. /**
  38943. * @param {string} name
  38944. */
  38945. select: function (name) {
  38946. var selected = this.option.selected;
  38947. var selectedMode = this.get('selectedMode');
  38948. if (selectedMode === 'single') {
  38949. var data = this._data;
  38950. zrUtil.each(data, function (dataItem) {
  38951. selected[dataItem.get('name')] = false;
  38952. });
  38953. }
  38954. selected[name] = true;
  38955. },
  38956. /**
  38957. * @param {string} name
  38958. */
  38959. unSelect: function (name) {
  38960. if (this.get('selectedMode') !== 'single') {
  38961. this.option.selected[name] = false;
  38962. }
  38963. },
  38964. /**
  38965. * @param {string} name
  38966. */
  38967. toggleSelected: function (name) {
  38968. var selected = this.option.selected;
  38969. // Default is true
  38970. if (!(name in selected)) {
  38971. selected[name] = true;
  38972. }
  38973. this[selected[name] ? 'unSelect' : 'select'](name);
  38974. },
  38975. /**
  38976. * @param {string} name
  38977. */
  38978. isSelected: function (name) {
  38979. var selected = this.option.selected;
  38980. return !((name in selected) && !selected[name])
  38981. && zrUtil.indexOf(this._availableNames, name) >= 0;
  38982. },
  38983. defaultOption: {
  38984. // 一级层叠
  38985. zlevel: 0,
  38986. // 二级层叠
  38987. z: 4,
  38988. show: true,
  38989. // 布局方式,默认为水平布局,可选为:
  38990. // 'horizontal' | 'vertical'
  38991. orient: 'horizontal',
  38992. left: 'center',
  38993. // right: 'center',
  38994. top: 'top',
  38995. // bottom: 'top',
  38996. // 水平对齐
  38997. // 'auto' | 'left' | 'right'
  38998. // 默认为 'auto', 根据 x 的位置判断是左对齐还是右对齐
  38999. align: 'auto',
  39000. backgroundColor: 'rgba(0,0,0,0)',
  39001. // 图例边框颜色
  39002. borderColor: '#ccc',
  39003. // 图例边框线宽,单位px,默认为0(无边框)
  39004. borderWidth: 0,
  39005. // 图例内边距,单位px,默认各方向内边距为5,
  39006. // 接受数组分别设定上右下左边距,同css
  39007. padding: 5,
  39008. // 各个item之间的间隔,单位px,默认为10,
  39009. // 横向布局时为水平间隔,纵向布局时为纵向间隔
  39010. itemGap: 10,
  39011. // 图例图形宽度
  39012. itemWidth: 25,
  39013. // 图例图形高度
  39014. itemHeight: 14,
  39015. // 图例关闭时候的颜色
  39016. inactiveColor: '#ccc',
  39017. textStyle: {
  39018. // 图例文字颜色
  39019. color: '#333'
  39020. },
  39021. // formatter: '',
  39022. // 选择模式,默认开启图例开关
  39023. selectedMode: true,
  39024. // 配置默认选中状态,可配合LEGEND.SELECTED事件做动态数据载入
  39025. // selected: null,
  39026. // 图例内容(详见legend.data,数组中每一项代表一个item
  39027. // data: [],
  39028. // Tooltip 相关配置
  39029. tooltip: {
  39030. show: false
  39031. }
  39032. }
  39033. });
  39034. module.exports = LegendModel;
  39035. /***/ },
  39036. /* 275 */
  39037. /***/ function(module, exports, __webpack_require__) {
  39038. /**
  39039. * @file Legend action
  39040. */
  39041. var echarts = __webpack_require__(1);
  39042. var zrUtil = __webpack_require__(4);
  39043. function legendSelectActionHandler(methodName, payload, ecModel) {
  39044. var selectedMap = {};
  39045. var isToggleSelect = methodName === 'toggleSelected';
  39046. var isSelected;
  39047. // Update all legend components
  39048. ecModel.eachComponent('legend', function (legendModel) {
  39049. if (isToggleSelect && isSelected != null) {
  39050. // Force other legend has same selected status
  39051. // Or the first is toggled to true and other are toggled to false
  39052. // In the case one legend has some item unSelected in option. And if other legend
  39053. // doesn't has the item, they will assume it is selected.
  39054. legendModel[isSelected ? 'select' : 'unSelect'](payload.name);
  39055. }
  39056. else {
  39057. legendModel[methodName](payload.name);
  39058. isSelected = legendModel.isSelected(payload.name);
  39059. }
  39060. var legendData = legendModel.getData();
  39061. zrUtil.each(legendData, function (model) {
  39062. var name = model.get('name');
  39063. // Wrap element
  39064. if (name === '\n' || name === '') {
  39065. return;
  39066. }
  39067. var isItemSelected = legendModel.isSelected(name);
  39068. if (name in selectedMap) {
  39069. // Unselected if any legend is unselected
  39070. selectedMap[name] = selectedMap[name] && isItemSelected;
  39071. }
  39072. else {
  39073. selectedMap[name] = isItemSelected;
  39074. }
  39075. });
  39076. });
  39077. // Return the event explicitly
  39078. return {
  39079. name: payload.name,
  39080. selected: selectedMap
  39081. };
  39082. }
  39083. /**
  39084. * @event legendToggleSelect
  39085. * @type {Object}
  39086. * @property {string} type 'legendToggleSelect'
  39087. * @property {string} [from]
  39088. * @property {string} name Series name or data item name
  39089. */
  39090. echarts.registerAction(
  39091. 'legendToggleSelect', 'legendselectchanged',
  39092. zrUtil.curry(legendSelectActionHandler, 'toggleSelected')
  39093. );
  39094. /**
  39095. * @event legendSelect
  39096. * @type {Object}
  39097. * @property {string} type 'legendSelect'
  39098. * @property {string} name Series name or data item name
  39099. */
  39100. echarts.registerAction(
  39101. 'legendSelect', 'legendselected',
  39102. zrUtil.curry(legendSelectActionHandler, 'select')
  39103. );
  39104. /**
  39105. * @event legendUnSelect
  39106. * @type {Object}
  39107. * @property {string} type 'legendUnSelect'
  39108. * @property {string} name Series name or data item name
  39109. */
  39110. echarts.registerAction(
  39111. 'legendUnSelect', 'legendunselected',
  39112. zrUtil.curry(legendSelectActionHandler, 'unSelect')
  39113. );
  39114. /***/ },
  39115. /* 276 */
  39116. /***/ function(module, exports, __webpack_require__) {
  39117. var zrUtil = __webpack_require__(4);
  39118. var symbolCreator = __webpack_require__(106);
  39119. var graphic = __webpack_require__(43);
  39120. var listComponentHelper = __webpack_require__(277);
  39121. var curry = zrUtil.curry;
  39122. function dispatchSelectAction(name, api) {
  39123. api.dispatchAction({
  39124. type: 'legendToggleSelect',
  39125. name: name
  39126. });
  39127. }
  39128. function dispatchHighlightAction(seriesModel, dataName, api) {
  39129. // If element hover will move to a hoverLayer.
  39130. var el = api.getZr().storage.getDisplayList()[0];
  39131. if (!(el && el.useHoverLayer)) {
  39132. seriesModel.get('legendHoverLink') && api.dispatchAction({
  39133. type: 'highlight',
  39134. seriesName: seriesModel.name,
  39135. name: dataName
  39136. });
  39137. }
  39138. }
  39139. function dispatchDownplayAction(seriesModel, dataName, api) {
  39140. // If element hover will move to a hoverLayer.
  39141. var el = api.getZr().storage.getDisplayList()[0];
  39142. if (!(el && el.useHoverLayer)) {
  39143. seriesModel.get('legendHoverLink') && api.dispatchAction({
  39144. type: 'downplay',
  39145. seriesName: seriesModel.name,
  39146. name: dataName
  39147. });
  39148. }
  39149. }
  39150. module.exports = __webpack_require__(1).extendComponentView({
  39151. type: 'legend',
  39152. init: function () {
  39153. this._symbolTypeStore = {};
  39154. },
  39155. render: function (legendModel, ecModel, api) {
  39156. var group = this.group;
  39157. group.removeAll();
  39158. if (!legendModel.get('show')) {
  39159. return;
  39160. }
  39161. var selectMode = legendModel.get('selectedMode');
  39162. var itemAlign = legendModel.get('align');
  39163. if (itemAlign === 'auto') {
  39164. itemAlign = (legendModel.get('left') === 'right'
  39165. && legendModel.get('orient') === 'vertical')
  39166. ? 'right' : 'left';
  39167. }
  39168. var legendDrawedMap = {};
  39169. zrUtil.each(legendModel.getData(), function (itemModel) {
  39170. var name = itemModel.get('name');
  39171. // Use empty string or \n as a newline string
  39172. if (name === '' || name === '\n') {
  39173. group.add(new graphic.Group({
  39174. newline: true
  39175. }));
  39176. return;
  39177. }
  39178. var seriesModel = ecModel.getSeriesByName(name)[0];
  39179. if (legendDrawedMap[name]) {
  39180. // Have been drawed
  39181. return;
  39182. }
  39183. // Series legend
  39184. if (seriesModel) {
  39185. var data = seriesModel.getData();
  39186. var color = data.getVisual('color');
  39187. // If color is a callback function
  39188. if (typeof color === 'function') {
  39189. // Use the first data
  39190. color = color(seriesModel.getDataParams(0));
  39191. }
  39192. // Using rect symbol defaultly
  39193. var legendSymbolType = data.getVisual('legendSymbol') || 'roundRect';
  39194. var symbolType = data.getVisual('symbol');
  39195. var itemGroup = this._createItem(
  39196. name, itemModel, legendModel,
  39197. legendSymbolType, symbolType,
  39198. itemAlign, color,
  39199. selectMode
  39200. );
  39201. itemGroup.on('click', curry(dispatchSelectAction, name, api))
  39202. .on('mouseover', curry(dispatchHighlightAction, seriesModel, '', api))
  39203. .on('mouseout', curry(dispatchDownplayAction, seriesModel, '', api));
  39204. legendDrawedMap[name] = true;
  39205. }
  39206. else {
  39207. // Data legend of pie, funnel
  39208. ecModel.eachRawSeries(function (seriesModel) {
  39209. // In case multiple series has same data name
  39210. if (legendDrawedMap[name]) {
  39211. return;
  39212. }
  39213. if (seriesModel.legendDataProvider) {
  39214. var data = seriesModel.legendDataProvider();
  39215. var idx = data.indexOfName(name);
  39216. if (idx < 0) {
  39217. return;
  39218. }
  39219. var color = data.getItemVisual(idx, 'color');
  39220. var legendSymbolType = 'roundRect';
  39221. var itemGroup = this._createItem(
  39222. name, itemModel, legendModel,
  39223. legendSymbolType, null,
  39224. itemAlign, color,
  39225. selectMode
  39226. );
  39227. itemGroup.on('click', curry(dispatchSelectAction, name, api))
  39228. // FIXME Should not specify the series name
  39229. .on('mouseover', curry(dispatchHighlightAction, seriesModel, name, api))
  39230. .on('mouseout', curry(dispatchDownplayAction, seriesModel, name, api));
  39231. legendDrawedMap[name] = true;
  39232. }
  39233. }, this);
  39234. }
  39235. if (true) {
  39236. if (!legendDrawedMap[name]) {
  39237. console.warn(name + ' series not exists. Legend data should be same with series name or data name.');
  39238. }
  39239. }
  39240. }, this);
  39241. listComponentHelper.layout(group, legendModel, api);
  39242. // Render background after group is layout
  39243. // FIXME
  39244. listComponentHelper.addBackground(group, legendModel);
  39245. },
  39246. _createItem: function (
  39247. name, itemModel, legendModel,
  39248. legendSymbolType, symbolType,
  39249. itemAlign, color, selectMode
  39250. ) {
  39251. var itemWidth = legendModel.get('itemWidth');
  39252. var itemHeight = legendModel.get('itemHeight');
  39253. var inactiveColor = legendModel.get('inactiveColor');
  39254. var isSelected = legendModel.isSelected(name);
  39255. var itemGroup = new graphic.Group();
  39256. var textStyleModel = itemModel.getModel('textStyle');
  39257. var itemIcon = itemModel.get('icon');
  39258. var tooltipModel = itemModel.getModel('tooltip');
  39259. // Use user given icon first
  39260. legendSymbolType = itemIcon || legendSymbolType;
  39261. itemGroup.add(symbolCreator.createSymbol(
  39262. legendSymbolType, 0, 0, itemWidth, itemHeight, isSelected ? color : inactiveColor
  39263. ));
  39264. // Compose symbols
  39265. // PENDING
  39266. if (!itemIcon && symbolType
  39267. // At least show one symbol, can't be all none
  39268. && ((symbolType !== legendSymbolType) || symbolType == 'none')
  39269. ) {
  39270. var size = itemHeight * 0.8;
  39271. if (symbolType === 'none') {
  39272. symbolType = 'circle';
  39273. }
  39274. // Put symbol in the center
  39275. itemGroup.add(symbolCreator.createSymbol(
  39276. symbolType, (itemWidth - size) / 2, (itemHeight - size) / 2, size, size,
  39277. isSelected ? color : inactiveColor
  39278. ));
  39279. }
  39280. // Text
  39281. var textX = itemAlign === 'left' ? itemWidth + 5 : -5;
  39282. var textAlign = itemAlign;
  39283. var formatter = legendModel.get('formatter');
  39284. var content = name;
  39285. if (typeof formatter === 'string' && formatter) {
  39286. content = formatter.replace('{name}', name);
  39287. }
  39288. else if (typeof formatter === 'function') {
  39289. content = formatter(name);
  39290. }
  39291. var text = new graphic.Text({
  39292. style: {
  39293. text: content,
  39294. x: textX,
  39295. y: itemHeight / 2,
  39296. fill: isSelected ? textStyleModel.getTextColor() : inactiveColor,
  39297. textFont: textStyleModel.getFont(),
  39298. textAlign: textAlign,
  39299. textVerticalAlign: 'middle'
  39300. }
  39301. });
  39302. itemGroup.add(text);
  39303. // Add a invisible rect to increase the area of mouse hover
  39304. var hitRect = new graphic.Rect({
  39305. shape: itemGroup.getBoundingRect(),
  39306. invisible: true,
  39307. tooltip: tooltipModel.get('show') ? zrUtil.extend({
  39308. content: name,
  39309. // Defaul formatter
  39310. formatter: function () {
  39311. return name;
  39312. },
  39313. formatterParams: {
  39314. componentType: 'legend',
  39315. legendIndex: legendModel.componentIndex,
  39316. name: name,
  39317. $vars: ['name']
  39318. }
  39319. }, tooltipModel.option) : null
  39320. });
  39321. itemGroup.add(hitRect);
  39322. itemGroup.eachChild(function (child) {
  39323. child.silent = true;
  39324. });
  39325. hitRect.silent = !selectMode;
  39326. this.group.add(itemGroup);
  39327. graphic.setHoverStyle(itemGroup);
  39328. return itemGroup;
  39329. }
  39330. });
  39331. /***/ },
  39332. /* 277 */
  39333. /***/ function(module, exports, __webpack_require__) {
  39334. // List layout
  39335. var layout = __webpack_require__(21);
  39336. var formatUtil = __webpack_require__(6);
  39337. var graphic = __webpack_require__(43);
  39338. function positionGroup(group, model, api) {
  39339. layout.positionGroup(
  39340. group, model.getBoxLayoutParams(),
  39341. {
  39342. width: api.getWidth(),
  39343. height: api.getHeight()
  39344. },
  39345. model.get('padding')
  39346. );
  39347. }
  39348. module.exports = {
  39349. /**
  39350. * Layout list like component.
  39351. * It will box layout each items in group of component and then position the whole group in the viewport
  39352. * @param {module:zrender/group/Group} group
  39353. * @param {module:echarts/model/Component} componentModel
  39354. * @param {module:echarts/ExtensionAPI}
  39355. */
  39356. layout: function (group, componentModel, api) {
  39357. var rect = layout.getLayoutRect(componentModel.getBoxLayoutParams(), {
  39358. width: api.getWidth(),
  39359. height: api.getHeight()
  39360. }, componentModel.get('padding'));
  39361. layout.box(
  39362. componentModel.get('orient'),
  39363. group,
  39364. componentModel.get('itemGap'),
  39365. rect.width,
  39366. rect.height
  39367. );
  39368. positionGroup(group, componentModel, api);
  39369. },
  39370. addBackground: function (group, componentModel) {
  39371. var padding = formatUtil.normalizeCssArray(
  39372. componentModel.get('padding')
  39373. );
  39374. var boundingRect = group.getBoundingRect();
  39375. var style = componentModel.getItemStyle(['color', 'opacity']);
  39376. style.fill = componentModel.get('backgroundColor');
  39377. var rect = new graphic.Rect({
  39378. shape: {
  39379. x: boundingRect.x - padding[3],
  39380. y: boundingRect.y - padding[0],
  39381. width: boundingRect.width + padding[1] + padding[3],
  39382. height: boundingRect.height + padding[0] + padding[2]
  39383. },
  39384. style: style,
  39385. silent: true,
  39386. z2: -1
  39387. });
  39388. graphic.subPixelOptimizeRect(rect);
  39389. group.add(rect);
  39390. }
  39391. };
  39392. /***/ },
  39393. /* 278 */
  39394. /***/ function(module, exports) {
  39395. module.exports = function (ecModel) {
  39396. var legendModels = ecModel.findComponents({
  39397. mainType: 'legend'
  39398. });
  39399. if (legendModels && legendModels.length) {
  39400. ecModel.filterSeries(function (series) {
  39401. // If in any legend component the status is not selected.
  39402. // Because in legend series is assumed selected when it is not in the legend data.
  39403. for (var i = 0; i < legendModels.length; i++) {
  39404. if (!legendModels[i].isSelected(series.name)) {
  39405. return false;
  39406. }
  39407. }
  39408. return true;
  39409. });
  39410. }
  39411. };
  39412. /***/ },
  39413. /* 279 */
  39414. /***/ function(module, exports, __webpack_require__) {
  39415. // FIXME Better way to pack data in graphic element
  39416. __webpack_require__(280);
  39417. __webpack_require__(281);
  39418. // Show tip action
  39419. /**
  39420. * @action
  39421. * @property {string} type
  39422. * @property {number} seriesIndex
  39423. * @property {number} dataIndex
  39424. * @property {number} [x]
  39425. * @property {number} [y]
  39426. */
  39427. __webpack_require__(1).registerAction(
  39428. {
  39429. type: 'showTip',
  39430. event: 'showTip',
  39431. update: 'none'
  39432. },
  39433. // noop
  39434. function () {}
  39435. );
  39436. // Hide tip action
  39437. __webpack_require__(1).registerAction(
  39438. {
  39439. type: 'hideTip',
  39440. event: 'hideTip',
  39441. update: 'none'
  39442. },
  39443. // noop
  39444. function () {}
  39445. );
  39446. /***/ },
  39447. /* 280 */
  39448. /***/ function(module, exports, __webpack_require__) {
  39449. __webpack_require__(1).extendComponentModel({
  39450. type: 'tooltip',
  39451. defaultOption: {
  39452. zlevel: 0,
  39453. z: 8,
  39454. show: true,
  39455. // tooltip主体内容
  39456. showContent: true,
  39457. // 触发类型,默认数据触发,见下图,可选为:'item' ¦ 'axis'
  39458. trigger: 'item',
  39459. // 触发条件,支持 'click' | 'mousemove'
  39460. triggerOn: 'mousemove',
  39461. // 是否永远显示 content
  39462. alwaysShowContent: false,
  39463. // 位置 {Array} | {Function}
  39464. // position: null
  39465. // 内容格式器:{string}(Template) ¦ {Function}
  39466. // formatter: null
  39467. showDelay: 0,
  39468. // 隐藏延迟,单位ms
  39469. hideDelay: 100,
  39470. // 动画变换时间,单位s
  39471. transitionDuration: 0.4,
  39472. enterable: false,
  39473. // 提示背景颜色,默认为透明度为0.7的黑色
  39474. backgroundColor: 'rgba(50,50,50,0.7)',
  39475. // 提示边框颜色
  39476. borderColor: '#333',
  39477. // 提示边框圆角,单位px,默认为4
  39478. borderRadius: 4,
  39479. // 提示边框线宽,单位px,默认为0(无边框)
  39480. borderWidth: 0,
  39481. // 提示内边距,单位px,默认各方向内边距为5,
  39482. // 接受数组分别设定上右下左边距,同css
  39483. padding: 5,
  39484. // Extra css text
  39485. extraCssText: '',
  39486. // 坐标轴指示器,坐标轴触发有效
  39487. axisPointer: {
  39488. // 默认为直线
  39489. // 可选为:'line' | 'shadow' | 'cross'
  39490. type: 'line',
  39491. // type 为 line 的时候有效,指定 tooltip line 所在的轴,可选
  39492. // 可选 'x' | 'y' | 'angle' | 'radius' | 'auto'
  39493. // 默认 'auto',会选择类型为 cateogry 的轴,对于双数值轴,笛卡尔坐标系会默认选择 x 轴
  39494. // 极坐标系会默认选择 angle 轴
  39495. axis: 'auto',
  39496. animation: true,
  39497. animationDurationUpdate: 200,
  39498. animationEasingUpdate: 'exponentialOut',
  39499. // 直线指示器样式设置
  39500. lineStyle: {
  39501. color: '#555',
  39502. width: 1,
  39503. type: 'solid'
  39504. },
  39505. crossStyle: {
  39506. color: '#555',
  39507. width: 1,
  39508. type: 'dashed',
  39509. // TODO formatter
  39510. textStyle: {}
  39511. },
  39512. // 阴影指示器样式设置
  39513. shadowStyle: {
  39514. color: 'rgba(150,150,150,0.3)'
  39515. }
  39516. },
  39517. textStyle: {
  39518. color: '#fff',
  39519. fontSize: 14
  39520. }
  39521. }
  39522. });
  39523. /***/ },
  39524. /* 281 */
  39525. /***/ function(module, exports, __webpack_require__) {
  39526. var TooltipContent = __webpack_require__(282);
  39527. var graphic = __webpack_require__(43);
  39528. var zrUtil = __webpack_require__(4);
  39529. var formatUtil = __webpack_require__(6);
  39530. var numberUtil = __webpack_require__(7);
  39531. var parsePercent = numberUtil.parsePercent;
  39532. var env = __webpack_require__(2);
  39533. var Model = __webpack_require__(12);
  39534. function dataEqual(a, b) {
  39535. if (!a || !b) {
  39536. return false;
  39537. }
  39538. var round = numberUtil.round;
  39539. return round(a[0]) === round(b[0])
  39540. && round(a[1]) === round(b[1]);
  39541. }
  39542. /**
  39543. * @inner
  39544. */
  39545. function makeLineShape(x1, y1, x2, y2) {
  39546. return {
  39547. x1: x1,
  39548. y1: y1,
  39549. x2: x2,
  39550. y2: y2
  39551. };
  39552. }
  39553. /**
  39554. * @inner
  39555. */
  39556. function makeRectShape(x, y, width, height) {
  39557. return {
  39558. x: x,
  39559. y: y,
  39560. width: width,
  39561. height: height
  39562. };
  39563. }
  39564. /**
  39565. * @inner
  39566. */
  39567. function makeSectorShape(cx, cy, r0, r, startAngle, endAngle) {
  39568. return {
  39569. cx: cx,
  39570. cy: cy,
  39571. r0: r0,
  39572. r: r,
  39573. startAngle: startAngle,
  39574. endAngle: endAngle,
  39575. clockwise: true
  39576. };
  39577. }
  39578. function refixTooltipPosition(x, y, el, viewWidth, viewHeight) {
  39579. var width = el.clientWidth;
  39580. var height = el.clientHeight;
  39581. var gap = 20;
  39582. if (x + width + gap > viewWidth) {
  39583. x -= width + gap;
  39584. }
  39585. else {
  39586. x += gap;
  39587. }
  39588. if (y + height + gap > viewHeight) {
  39589. y -= height + gap;
  39590. }
  39591. else {
  39592. y += gap;
  39593. }
  39594. return [x, y];
  39595. }
  39596. function calcTooltipPosition(position, rect, dom) {
  39597. var domWidth = dom.clientWidth;
  39598. var domHeight = dom.clientHeight;
  39599. var gap = 5;
  39600. var x = 0;
  39601. var y = 0;
  39602. var rectWidth = rect.width;
  39603. var rectHeight = rect.height;
  39604. switch (position) {
  39605. case 'inside':
  39606. x = rect.x + rectWidth / 2 - domWidth / 2;
  39607. y = rect.y + rectHeight / 2 - domHeight / 2;
  39608. break;
  39609. case 'top':
  39610. x = rect.x + rectWidth / 2 - domWidth / 2;
  39611. y = rect.y - domHeight - gap;
  39612. break;
  39613. case 'bottom':
  39614. x = rect.x + rectWidth / 2 - domWidth / 2;
  39615. y = rect.y + rectHeight + gap;
  39616. break;
  39617. case 'left':
  39618. x = rect.x - domWidth - gap;
  39619. y = rect.y + rectHeight / 2 - domHeight / 2;
  39620. break;
  39621. case 'right':
  39622. x = rect.x + rectWidth + gap;
  39623. y = rect.y + rectHeight / 2 - domHeight / 2;
  39624. }
  39625. return [x, y];
  39626. }
  39627. /**
  39628. * @param {string|Function|Array.<number>} positionExpr
  39629. * @param {number} x Mouse x
  39630. * @param {number} y Mouse y
  39631. * @param {module:echarts/component/tooltip/TooltipContent} content
  39632. * @param {Object|<Array.<Object>} params
  39633. * @param {module:zrender/Element} el target element
  39634. * @param {module:echarts/ExtensionAPI} api
  39635. * @return {Array.<number>}
  39636. */
  39637. function updatePosition(positionExpr, x, y, content, params, el, api) {
  39638. var viewWidth = api.getWidth();
  39639. var viewHeight = api.getHeight();
  39640. var rect = el && el.getBoundingRect().clone();
  39641. el && rect.applyTransform(el.transform);
  39642. if (typeof positionExpr === 'function') {
  39643. // Callback of position can be an array or a string specify the position
  39644. positionExpr = positionExpr([x, y], params, content.el, rect);
  39645. }
  39646. if (zrUtil.isArray(positionExpr)) {
  39647. x = parsePercent(positionExpr[0], viewWidth);
  39648. y = parsePercent(positionExpr[1], viewHeight);
  39649. }
  39650. // Specify tooltip position by string 'top' 'bottom' 'left' 'right' around graphic element
  39651. else if (typeof positionExpr === 'string' && el) {
  39652. var pos = calcTooltipPosition(
  39653. positionExpr, rect, content.el
  39654. );
  39655. x = pos[0];
  39656. y = pos[1];
  39657. }
  39658. else {
  39659. var pos = refixTooltipPosition(
  39660. x, y, content.el, viewWidth, viewHeight
  39661. );
  39662. x = pos[0];
  39663. y = pos[1];
  39664. }
  39665. content.moveTo(x, y);
  39666. }
  39667. function ifSeriesSupportAxisTrigger(seriesModel) {
  39668. var coordSys = seriesModel.coordinateSystem;
  39669. var trigger = seriesModel.get('tooltip.trigger', true);
  39670. // Ignore series use item tooltip trigger and series coordinate system is not cartesian or
  39671. return !(!coordSys
  39672. || (coordSys.type !== 'cartesian2d' && coordSys.type !== 'polar' && coordSys.type !== 'singleAxis')
  39673. || trigger === 'item');
  39674. }
  39675. __webpack_require__(1).extendComponentView({
  39676. type: 'tooltip',
  39677. _axisPointers: {},
  39678. init: function (ecModel, api) {
  39679. if (env.node) {
  39680. return;
  39681. }
  39682. var tooltipContent = new TooltipContent(api.getDom(), api);
  39683. this._tooltipContent = tooltipContent;
  39684. api.on('showTip', this._manuallyShowTip, this);
  39685. api.on('hideTip', this._manuallyHideTip, this);
  39686. },
  39687. render: function (tooltipModel, ecModel, api) {
  39688. if (env.node) {
  39689. return;
  39690. }
  39691. // Reset
  39692. this.group.removeAll();
  39693. /**
  39694. * @type {Object}
  39695. * @private
  39696. */
  39697. this._axisPointers = {};
  39698. /**
  39699. * @private
  39700. * @type {module:echarts/component/tooltip/TooltipModel}
  39701. */
  39702. this._tooltipModel = tooltipModel;
  39703. /**
  39704. * @private
  39705. * @type {module:echarts/model/Global}
  39706. */
  39707. this._ecModel = ecModel;
  39708. /**
  39709. * @private
  39710. * @type {module:echarts/ExtensionAPI}
  39711. */
  39712. this._api = api;
  39713. /**
  39714. * @type {Object}
  39715. * @private
  39716. */
  39717. this._lastHover = {
  39718. // data
  39719. // payloadBatch
  39720. };
  39721. var tooltipContent = this._tooltipContent;
  39722. tooltipContent.update();
  39723. tooltipContent.enterable = tooltipModel.get('enterable');
  39724. this._alwaysShowContent = tooltipModel.get('alwaysShowContent');
  39725. /**
  39726. * @type {Object.<string, Array>}
  39727. */
  39728. this._seriesGroupByAxis = this._prepareAxisTriggerData(
  39729. tooltipModel, ecModel
  39730. );
  39731. var crossText = this._crossText;
  39732. if (crossText) {
  39733. this.group.add(crossText);
  39734. }
  39735. // Try to keep the tooltip show when refreshing
  39736. if (this._lastX != null && this._lastY != null) {
  39737. var self = this;
  39738. clearTimeout(this._refreshUpdateTimeout);
  39739. this._refreshUpdateTimeout = setTimeout(function () {
  39740. // Show tip next tick after other charts are rendered
  39741. // In case highlight action has wrong result
  39742. // FIXME
  39743. self._manuallyShowTip({
  39744. x: self._lastX,
  39745. y: self._lastY
  39746. });
  39747. });
  39748. }
  39749. var zr = this._api.getZr();
  39750. zr.off('click', this._tryShow);
  39751. zr.off('mousemove', this._mousemove);
  39752. zr.off('mouseout', this._hide);
  39753. zr.off('globalout', this._hide);
  39754. if (tooltipModel.get('triggerOn') === 'click') {
  39755. zr.on('click', this._tryShow, this);
  39756. }
  39757. else {
  39758. zr.on('mousemove', this._mousemove, this);
  39759. zr.on('mouseout', this._hide, this);
  39760. zr.on('globalout', this._hide, this);
  39761. }
  39762. },
  39763. _mousemove: function (e) {
  39764. var showDelay = this._tooltipModel.get('showDelay');
  39765. var self = this;
  39766. clearTimeout(this._showTimeout);
  39767. if (showDelay > 0) {
  39768. this._showTimeout = setTimeout(function () {
  39769. self._tryShow(e);
  39770. }, showDelay);
  39771. }
  39772. else {
  39773. this._tryShow(e);
  39774. }
  39775. },
  39776. /**
  39777. * Show tip manually by
  39778. * dispatchAction({
  39779. * type: 'showTip',
  39780. * x: 10,
  39781. * y: 10
  39782. * });
  39783. * Or
  39784. * dispatchAction({
  39785. * type: 'showTip',
  39786. * seriesIndex: 0,
  39787. * dataIndex: 1
  39788. * });
  39789. *
  39790. * TODO Batch
  39791. */
  39792. _manuallyShowTip: function (event) {
  39793. // From self
  39794. if (event.from === this.uid) {
  39795. return;
  39796. }
  39797. var ecModel = this._ecModel;
  39798. var seriesIndex = event.seriesIndex;
  39799. var dataIndex = event.dataIndex;
  39800. var seriesModel = ecModel.getSeriesByIndex(seriesIndex);
  39801. var api = this._api;
  39802. if (event.x == null || event.y == null) {
  39803. if (!seriesModel) {
  39804. // Find the first series can use axis trigger
  39805. ecModel.eachSeries(function (_series) {
  39806. if (ifSeriesSupportAxisTrigger(_series) && !seriesModel) {
  39807. seriesModel = _series;
  39808. }
  39809. });
  39810. }
  39811. if (seriesModel) {
  39812. var data = seriesModel.getData();
  39813. if (dataIndex == null) {
  39814. dataIndex = data.indexOfName(event.name);
  39815. }
  39816. var el = data.getItemGraphicEl(dataIndex);
  39817. var cx, cy;
  39818. // Try to get the point in coordinate system
  39819. var coordSys = seriesModel.coordinateSystem;
  39820. if (coordSys && coordSys.dataToPoint) {
  39821. var point = coordSys.dataToPoint(
  39822. data.getValues(
  39823. zrUtil.map(coordSys.dimensions, function (dim) {
  39824. return seriesModel.coordDimToDataDim(dim)[0];
  39825. }), dataIndex, true
  39826. )
  39827. );
  39828. cx = point && point[0];
  39829. cy = point && point[1];
  39830. }
  39831. else if (el) {
  39832. // Use graphic bounding rect
  39833. var rect = el.getBoundingRect().clone();
  39834. rect.applyTransform(el.transform);
  39835. cx = rect.x + rect.width / 2;
  39836. cy = rect.y + rect.height / 2;
  39837. }
  39838. if (cx != null && cy != null) {
  39839. this._tryShow({
  39840. offsetX: cx,
  39841. offsetY: cy,
  39842. target: el,
  39843. event: {}
  39844. });
  39845. }
  39846. }
  39847. }
  39848. else {
  39849. var el = api.getZr().handler.findHover(event.x, event.y);
  39850. this._tryShow({
  39851. offsetX: event.x,
  39852. offsetY: event.y,
  39853. target: el,
  39854. event: {}
  39855. });
  39856. }
  39857. },
  39858. _manuallyHideTip: function (e) {
  39859. if (e.from === this.uid) {
  39860. return;
  39861. }
  39862. this._hide();
  39863. },
  39864. _prepareAxisTriggerData: function (tooltipModel, ecModel) {
  39865. // Prepare data for axis trigger
  39866. var seriesGroupByAxis = {};
  39867. ecModel.eachSeries(function (seriesModel) {
  39868. if (ifSeriesSupportAxisTrigger(seriesModel)) {
  39869. var coordSys = seriesModel.coordinateSystem;
  39870. var baseAxis;
  39871. var key;
  39872. // Only cartesian2d, polar and single support axis trigger
  39873. if (coordSys.type === 'cartesian2d') {
  39874. // FIXME `axisPointer.axis` is not baseAxis
  39875. baseAxis = coordSys.getBaseAxis();
  39876. key = baseAxis.dim + baseAxis.index;
  39877. }
  39878. else if (coordSys.type === 'singleAxis') {
  39879. baseAxis = coordSys.getAxis();
  39880. key = baseAxis.dim + baseAxis.type;
  39881. }
  39882. else {
  39883. baseAxis = coordSys.getBaseAxis();
  39884. key = baseAxis.dim + coordSys.name;
  39885. }
  39886. seriesGroupByAxis[key] = seriesGroupByAxis[key] || {
  39887. coordSys: [],
  39888. series: []
  39889. };
  39890. seriesGroupByAxis[key].coordSys.push(coordSys);
  39891. seriesGroupByAxis[key].series.push(seriesModel);
  39892. }
  39893. }, this);
  39894. return seriesGroupByAxis;
  39895. },
  39896. /**
  39897. * mousemove handler
  39898. * @param {Object} e
  39899. * @private
  39900. */
  39901. _tryShow: function (e) {
  39902. var el = e.target;
  39903. var tooltipModel = this._tooltipModel;
  39904. var globalTrigger = tooltipModel.get('trigger');
  39905. var ecModel = this._ecModel;
  39906. var api = this._api;
  39907. if (!tooltipModel) {
  39908. return;
  39909. }
  39910. // Save mouse x, mouse y. So we can try to keep showing the tip if chart is refreshed
  39911. this._lastX = e.offsetX;
  39912. this._lastY = e.offsetY;
  39913. // Always show item tooltip if mouse is on the element with dataIndex
  39914. if (el && el.dataIndex != null) {
  39915. // Use dataModel in element if possible
  39916. // Used when mouseover on a element like markPoint or edge
  39917. // In which case, the data is not main data in series.
  39918. var dataModel = el.dataModel || ecModel.getSeriesByIndex(el.seriesIndex);
  39919. var dataIndex = el.dataIndex;
  39920. var itemModel = dataModel.getData().getItemModel(dataIndex);
  39921. // Series or single data may use item trigger when global is axis trigger
  39922. if ((itemModel.get('tooltip.trigger') || globalTrigger) === 'axis') {
  39923. this._showAxisTooltip(tooltipModel, ecModel, e);
  39924. }
  39925. else {
  39926. // Reset ticket
  39927. this._ticket = '';
  39928. // If either single data or series use item trigger
  39929. this._hideAxisPointer();
  39930. // Reset last hover and dispatch downplay action
  39931. this._resetLastHover();
  39932. this._showItemTooltipContent(dataModel, dataIndex, el.dataType, e);
  39933. }
  39934. api.dispatchAction({
  39935. type: 'showTip',
  39936. from: this.uid,
  39937. dataIndex: el.dataIndex,
  39938. seriesIndex: el.seriesIndex
  39939. });
  39940. }
  39941. // Tooltip provided directly. Like legend
  39942. else if (el && el.tooltip) {
  39943. var tooltipOpt = el.tooltip;
  39944. if (typeof tooltipOpt === 'string') {
  39945. var content = tooltipOpt;
  39946. tooltipOpt = {
  39947. content: content,
  39948. // Fixed formatter
  39949. formatter: content
  39950. };
  39951. }
  39952. var subTooltipModel = new Model(tooltipOpt, tooltipModel);
  39953. var defaultHtml = subTooltipModel.get('content');
  39954. var asyncTicket = Math.random();
  39955. this._showTooltipContent(
  39956. // TODO params
  39957. subTooltipModel, defaultHtml, subTooltipModel.get('formatterParams') || {},
  39958. asyncTicket, e.offsetX, e.offsetY, el, api
  39959. );
  39960. }
  39961. else {
  39962. if (globalTrigger === 'item') {
  39963. this._hide();
  39964. }
  39965. else {
  39966. // Try show axis tooltip
  39967. this._showAxisTooltip(tooltipModel, ecModel, e);
  39968. }
  39969. // Action of cross pointer
  39970. // other pointer types will trigger action in _dispatchAndShowSeriesTooltipContent method
  39971. if (tooltipModel.get('axisPointer.type') === 'cross') {
  39972. api.dispatchAction({
  39973. type: 'showTip',
  39974. from: this.uid,
  39975. x: e.offsetX,
  39976. y: e.offsetY
  39977. });
  39978. }
  39979. }
  39980. },
  39981. /**
  39982. * Show tooltip on axis
  39983. * @param {module:echarts/component/tooltip/TooltipModel} tooltipModel
  39984. * @param {module:echarts/model/Global} ecModel
  39985. * @param {Object} e
  39986. * @private
  39987. */
  39988. _showAxisTooltip: function (tooltipModel, ecModel, e) {
  39989. var axisPointerModel = tooltipModel.getModel('axisPointer');
  39990. var axisPointerType = axisPointerModel.get('type');
  39991. if (axisPointerType === 'cross') {
  39992. var el = e.target;
  39993. if (el && el.dataIndex != null) {
  39994. var seriesModel = ecModel.getSeriesByIndex(el.seriesIndex);
  39995. var dataIndex = el.dataIndex;
  39996. this._showItemTooltipContent(seriesModel, dataIndex, el.dataType, e);
  39997. }
  39998. }
  39999. this._showAxisPointer();
  40000. var allNotShow = true;
  40001. zrUtil.each(this._seriesGroupByAxis, function (seriesCoordSysSameAxis) {
  40002. // Try show the axis pointer
  40003. var allCoordSys = seriesCoordSysSameAxis.coordSys;
  40004. var coordSys = allCoordSys[0];
  40005. // If mouse position is not in the grid or polar
  40006. var point = [e.offsetX, e.offsetY];
  40007. if (!coordSys.containPoint(point)) {
  40008. // Hide axis pointer
  40009. this._hideAxisPointer(coordSys.name);
  40010. return;
  40011. }
  40012. allNotShow = false;
  40013. // Make sure point is discrete on cateogry axis
  40014. var dimensions = coordSys.dimensions;
  40015. var value = coordSys.pointToData(point, true);
  40016. point = coordSys.dataToPoint(value);
  40017. var baseAxis = coordSys.getBaseAxis();
  40018. var axisType = axisPointerModel.get('axis');
  40019. if (axisType === 'auto') {
  40020. axisType = baseAxis.dim;
  40021. }
  40022. var contentNotChange = false;
  40023. var lastHover = this._lastHover;
  40024. if (axisPointerType === 'cross') {
  40025. // If hover data not changed
  40026. // Possible when two axes are all category
  40027. if (dataEqual(lastHover.data, value)) {
  40028. contentNotChange = true;
  40029. }
  40030. lastHover.data = value;
  40031. }
  40032. else {
  40033. var valIndex = zrUtil.indexOf(dimensions, axisType);
  40034. // If hover data not changed on the axis dimension
  40035. if (lastHover.data === value[valIndex]) {
  40036. contentNotChange = true;
  40037. }
  40038. lastHover.data = value[valIndex];
  40039. }
  40040. if (coordSys.type === 'cartesian2d' && !contentNotChange) {
  40041. this._showCartesianPointer(
  40042. axisPointerModel, coordSys, axisType, point
  40043. );
  40044. }
  40045. else if (coordSys.type === 'polar' && !contentNotChange) {
  40046. this._showPolarPointer(
  40047. axisPointerModel, coordSys, axisType, point
  40048. );
  40049. }
  40050. else if (coordSys.type === 'singleAxis' && !contentNotChange) {
  40051. this._showSinglePointer(
  40052. axisPointerModel, coordSys, axisType, point
  40053. );
  40054. }
  40055. if (axisPointerType !== 'cross') {
  40056. this._dispatchAndShowSeriesTooltipContent(
  40057. coordSys, seriesCoordSysSameAxis.series, point, value, contentNotChange
  40058. );
  40059. }
  40060. }, this);
  40061. if (!this._tooltipModel.get('show')) {
  40062. this._hideAxisPointer();
  40063. }
  40064. if (allNotShow) {
  40065. this._hide();
  40066. }
  40067. },
  40068. /**
  40069. * Show tooltip on axis of cartesian coordinate
  40070. * @param {module:echarts/model/Model} axisPointerModel
  40071. * @param {module:echarts/coord/cartesian/Cartesian2D} cartesians
  40072. * @param {string} axisType
  40073. * @param {Array.<number>} point
  40074. * @private
  40075. */
  40076. _showCartesianPointer: function (axisPointerModel, cartesian, axisType, point) {
  40077. var self = this;
  40078. var axisPointerType = axisPointerModel.get('type');
  40079. var baseAxis = cartesian.getBaseAxis();
  40080. var moveAnimation = axisPointerType !== 'cross'
  40081. && baseAxis.type === 'category'
  40082. && baseAxis.getBandWidth() > 20;
  40083. if (axisPointerType === 'cross') {
  40084. moveGridLine('x', point, cartesian.getAxis('y').getGlobalExtent());
  40085. moveGridLine('y', point, cartesian.getAxis('x').getGlobalExtent());
  40086. this._updateCrossText(cartesian, point, axisPointerModel);
  40087. }
  40088. else {
  40089. var otherAxis = cartesian.getAxis(axisType === 'x' ? 'y' : 'x');
  40090. var otherExtent = otherAxis.getGlobalExtent();
  40091. if (cartesian.type === 'cartesian2d') {
  40092. (axisPointerType === 'line' ? moveGridLine : moveGridShadow)(
  40093. axisType, point, otherExtent
  40094. );
  40095. }
  40096. }
  40097. /**
  40098. * @inner
  40099. */
  40100. function moveGridLine(axisType, point, otherExtent) {
  40101. var targetShape = axisType === 'x'
  40102. ? makeLineShape(point[0], otherExtent[0], point[0], otherExtent[1])
  40103. : makeLineShape(otherExtent[0], point[1], otherExtent[1], point[1]);
  40104. var pointerEl = self._getPointerElement(
  40105. cartesian, axisPointerModel, axisType, targetShape
  40106. );
  40107. graphic.subPixelOptimizeLine({
  40108. shape: targetShape,
  40109. style: pointerEl.style
  40110. });
  40111. moveAnimation
  40112. ? graphic.updateProps(pointerEl, {
  40113. shape: targetShape
  40114. }, axisPointerModel)
  40115. : pointerEl.attr({
  40116. shape: targetShape
  40117. });
  40118. }
  40119. /**
  40120. * @inner
  40121. */
  40122. function moveGridShadow(axisType, point, otherExtent) {
  40123. var axis = cartesian.getAxis(axisType);
  40124. var bandWidth = axis.getBandWidth();
  40125. var span = otherExtent[1] - otherExtent[0];
  40126. var targetShape = axisType === 'x'
  40127. ? makeRectShape(point[0] - bandWidth / 2, otherExtent[0], bandWidth, span)
  40128. : makeRectShape(otherExtent[0], point[1] - bandWidth / 2, span, bandWidth);
  40129. var pointerEl = self._getPointerElement(
  40130. cartesian, axisPointerModel, axisType, targetShape
  40131. );
  40132. moveAnimation
  40133. ? graphic.updateProps(pointerEl, {
  40134. shape: targetShape
  40135. }, axisPointerModel)
  40136. : pointerEl.attr({
  40137. shape: targetShape
  40138. });
  40139. }
  40140. },
  40141. _showSinglePointer: function (axisPointerModel, single, axisType, point) {
  40142. var self = this;
  40143. var axisPointerType = axisPointerModel.get('type');
  40144. var moveAnimation = axisPointerType !== 'cross' && single.getBaseAxis().type === 'category';
  40145. var rect = single.getRect();
  40146. var otherExtent = [rect.y, rect.y + rect.height];
  40147. moveSingleLine(axisType, point, otherExtent);
  40148. /**
  40149. * @inner
  40150. */
  40151. function moveSingleLine(axisType, point, otherExtent) {
  40152. var axis = single.getAxis();
  40153. var orient = axis.orient;
  40154. var targetShape = orient === 'horizontal'
  40155. ? makeLineShape(point[0], otherExtent[0], point[0], otherExtent[1])
  40156. : makeLineShape(otherExtent[0], point[1], otherExtent[1], point[1]);
  40157. var pointerEl = self._getPointerElement(
  40158. single, axisPointerModel, axisType, targetShape
  40159. );
  40160. moveAnimation
  40161. ? graphic.updateProps(pointerEl, {
  40162. shape: targetShape
  40163. }, axisPointerModel)
  40164. : pointerEl.attr({
  40165. shape: targetShape
  40166. });
  40167. }
  40168. },
  40169. /**
  40170. * Show tooltip on axis of polar coordinate
  40171. * @param {module:echarts/model/Model} axisPointerModel
  40172. * @param {Array.<module:echarts/coord/polar/Polar>} polar
  40173. * @param {string} axisType
  40174. * @param {Array.<number>} point
  40175. */
  40176. _showPolarPointer: function (axisPointerModel, polar, axisType, point) {
  40177. var self = this;
  40178. var axisPointerType = axisPointerModel.get('type');
  40179. var angleAxis = polar.getAngleAxis();
  40180. var radiusAxis = polar.getRadiusAxis();
  40181. var moveAnimation = axisPointerType !== 'cross'
  40182. && polar.getBaseAxis().type === 'category';
  40183. if (axisPointerType === 'cross') {
  40184. movePolarLine('angle', point, radiusAxis.getExtent());
  40185. movePolarLine('radius', point, angleAxis.getExtent());
  40186. this._updateCrossText(polar, point, axisPointerModel);
  40187. }
  40188. else {
  40189. var otherAxis = polar.getAxis(axisType === 'radius' ? 'angle' : 'radius');
  40190. var otherExtent = otherAxis.getExtent();
  40191. (axisPointerType === 'line' ? movePolarLine : movePolarShadow)(
  40192. axisType, point, otherExtent
  40193. );
  40194. }
  40195. /**
  40196. * @inner
  40197. */
  40198. function movePolarLine(axisType, point, otherExtent) {
  40199. var mouseCoord = polar.pointToCoord(point);
  40200. var targetShape;
  40201. if (axisType === 'angle') {
  40202. var p1 = polar.coordToPoint([otherExtent[0], mouseCoord[1]]);
  40203. var p2 = polar.coordToPoint([otherExtent[1], mouseCoord[1]]);
  40204. targetShape = makeLineShape(p1[0], p1[1], p2[0], p2[1]);
  40205. }
  40206. else {
  40207. targetShape = {
  40208. cx: polar.cx,
  40209. cy: polar.cy,
  40210. r: mouseCoord[0]
  40211. };
  40212. }
  40213. var pointerEl = self._getPointerElement(
  40214. polar, axisPointerModel, axisType, targetShape
  40215. );
  40216. moveAnimation
  40217. ? graphic.updateProps(pointerEl, {
  40218. shape: targetShape
  40219. }, axisPointerModel)
  40220. : pointerEl.attr({
  40221. shape: targetShape
  40222. });
  40223. }
  40224. /**
  40225. * @inner
  40226. */
  40227. function movePolarShadow(axisType, point, otherExtent) {
  40228. var axis = polar.getAxis(axisType);
  40229. var bandWidth = axis.getBandWidth();
  40230. var mouseCoord = polar.pointToCoord(point);
  40231. var targetShape;
  40232. var radian = Math.PI / 180;
  40233. if (axisType === 'angle') {
  40234. targetShape = makeSectorShape(
  40235. polar.cx, polar.cy,
  40236. otherExtent[0], otherExtent[1],
  40237. // In ECharts y is negative if angle is positive
  40238. (-mouseCoord[1] - bandWidth / 2) * radian,
  40239. (-mouseCoord[1] + bandWidth / 2) * radian
  40240. );
  40241. }
  40242. else {
  40243. targetShape = makeSectorShape(
  40244. polar.cx, polar.cy,
  40245. mouseCoord[0] - bandWidth / 2,
  40246. mouseCoord[0] + bandWidth / 2,
  40247. 0, Math.PI * 2
  40248. );
  40249. }
  40250. var pointerEl = self._getPointerElement(
  40251. polar, axisPointerModel, axisType, targetShape
  40252. );
  40253. moveAnimation
  40254. ? graphic.updateProps(pointerEl, {
  40255. shape: targetShape
  40256. }, axisPointerModel)
  40257. : pointerEl.attr({
  40258. shape: targetShape
  40259. });
  40260. }
  40261. },
  40262. _updateCrossText: function (coordSys, point, axisPointerModel) {
  40263. var crossStyleModel = axisPointerModel.getModel('crossStyle');
  40264. var textStyleModel = crossStyleModel.getModel('textStyle');
  40265. var tooltipModel = this._tooltipModel;
  40266. var text = this._crossText;
  40267. if (!text) {
  40268. text = this._crossText = new graphic.Text({
  40269. style: {
  40270. textAlign: 'left',
  40271. textVerticalAlign: 'bottom'
  40272. }
  40273. });
  40274. this.group.add(text);
  40275. }
  40276. var value = coordSys.pointToData(point);
  40277. var dims = coordSys.dimensions;
  40278. value = zrUtil.map(value, function (val, idx) {
  40279. var axis = coordSys.getAxis(dims[idx]);
  40280. if (axis.type === 'category' || axis.type === 'time') {
  40281. val = axis.scale.getLabel(val);
  40282. }
  40283. else {
  40284. val = formatUtil.addCommas(
  40285. val.toFixed(axis.getPixelPrecision())
  40286. );
  40287. }
  40288. return val;
  40289. });
  40290. text.setStyle({
  40291. fill: textStyleModel.getTextColor() || crossStyleModel.get('color'),
  40292. textFont: textStyleModel.getFont(),
  40293. text: value.join(', '),
  40294. x: point[0] + 5,
  40295. y: point[1] - 5
  40296. });
  40297. text.z = tooltipModel.get('z');
  40298. text.zlevel = tooltipModel.get('zlevel');
  40299. },
  40300. _getPointerElement: function (coordSys, pointerModel, axisType, initShape) {
  40301. var tooltipModel = this._tooltipModel;
  40302. var z = tooltipModel.get('z');
  40303. var zlevel = tooltipModel.get('zlevel');
  40304. var axisPointers = this._axisPointers;
  40305. var coordSysName = coordSys.name;
  40306. axisPointers[coordSysName] = axisPointers[coordSysName] || {};
  40307. if (axisPointers[coordSysName][axisType]) {
  40308. return axisPointers[coordSysName][axisType];
  40309. }
  40310. // Create if not exists
  40311. var pointerType = pointerModel.get('type');
  40312. var styleModel = pointerModel.getModel(pointerType + 'Style');
  40313. var isShadow = pointerType === 'shadow';
  40314. var style = styleModel[isShadow ? 'getAreaStyle' : 'getLineStyle']();
  40315. var elementType = coordSys.type === 'polar'
  40316. ? (isShadow ? 'Sector' : (axisType === 'radius' ? 'Circle' : 'Line'))
  40317. : (isShadow ? 'Rect' : 'Line');
  40318. isShadow ? (style.stroke = null) : (style.fill = null);
  40319. var el = axisPointers[coordSysName][axisType] = new graphic[elementType]({
  40320. style: style,
  40321. z: z,
  40322. zlevel: zlevel,
  40323. silent: true,
  40324. shape: initShape
  40325. });
  40326. this.group.add(el);
  40327. return el;
  40328. },
  40329. /**
  40330. * Dispatch actions and show tooltip on series
  40331. * @param {Array.<module:echarts/model/Series>} seriesList
  40332. * @param {Array.<number>} point
  40333. * @param {Array.<number>} value
  40334. * @param {boolean} contentNotChange
  40335. * @param {Object} e
  40336. */
  40337. _dispatchAndShowSeriesTooltipContent: function (
  40338. coordSys, seriesList, point, value, contentNotChange
  40339. ) {
  40340. var rootTooltipModel = this._tooltipModel;
  40341. var baseAxis = coordSys.getBaseAxis();
  40342. var baseDimIndex = baseAxis.dim === 'x' || baseAxis.dim === 'radius' ? 0 : 1;
  40343. var payloadBatch = zrUtil.map(seriesList, function (series) {
  40344. return {
  40345. seriesIndex: series.seriesIndex,
  40346. dataIndex: series.getAxisTooltipDataIndex
  40347. ? series.getAxisTooltipDataIndex(series.coordDimToDataDim(baseAxis.dim), value, baseAxis)
  40348. : series.getData().indexOfNearest(
  40349. series.coordDimToDataDim(baseAxis.dim)[0],
  40350. value[baseDimIndex],
  40351. // Add a threshold to avoid find the wrong dataIndex when data length is not same
  40352. false, baseAxis.type === 'category' ? 0.5 : null
  40353. )
  40354. };
  40355. });
  40356. var lastHover = this._lastHover;
  40357. var api = this._api;
  40358. // Dispatch downplay action
  40359. if (lastHover.payloadBatch && !contentNotChange) {
  40360. api.dispatchAction({
  40361. type: 'downplay',
  40362. batch: lastHover.payloadBatch
  40363. });
  40364. }
  40365. // Dispatch highlight action
  40366. if (!contentNotChange) {
  40367. api.dispatchAction({
  40368. type: 'highlight',
  40369. batch: payloadBatch
  40370. });
  40371. lastHover.payloadBatch = payloadBatch;
  40372. }
  40373. // Dispatch showTip action
  40374. api.dispatchAction({
  40375. type: 'showTip',
  40376. dataIndex: payloadBatch[0].dataIndex,
  40377. seriesIndex: payloadBatch[0].seriesIndex,
  40378. from: this.uid
  40379. });
  40380. if (baseAxis && rootTooltipModel.get('showContent') && rootTooltipModel.get('show')) {
  40381. var paramsList = zrUtil.map(seriesList, function (series, index) {
  40382. return series.getDataParams(payloadBatch[index].dataIndex);
  40383. });
  40384. if (!contentNotChange) {
  40385. // Update html content
  40386. var firstDataIndex = payloadBatch[0].dataIndex;
  40387. // Default tooltip content
  40388. // FIXME
  40389. // (1) shold be the first data which has name?
  40390. // (2) themeRiver, firstDataIndex is array, and first line is unnecessary.
  40391. var firstLine = baseAxis.type === 'time'
  40392. ? baseAxis.scale.getLabel(value[baseDimIndex])
  40393. : seriesList[0].getData().getName(firstDataIndex);
  40394. var defaultHtml = (firstLine ? firstLine + '<br />' : '')
  40395. + zrUtil.map(seriesList, function (series, index) {
  40396. return series.formatTooltip(payloadBatch[index].dataIndex, true);
  40397. }).join('<br />');
  40398. var asyncTicket = 'axis_' + coordSys.name + '_' + firstDataIndex;
  40399. this._showTooltipContent(
  40400. rootTooltipModel, defaultHtml, paramsList, asyncTicket,
  40401. point[0], point[1], null, api
  40402. );
  40403. }
  40404. else {
  40405. updatePosition(
  40406. rootTooltipModel.get('position'), point[0], point[1],
  40407. this._tooltipContent, paramsList, null, api
  40408. );
  40409. }
  40410. }
  40411. },
  40412. /**
  40413. * Show tooltip on item
  40414. * @param {module:echarts/model/Series} seriesModel
  40415. * @param {number} dataIndex
  40416. * @param {string} dataType
  40417. * @param {Object} e
  40418. */
  40419. _showItemTooltipContent: function (seriesModel, dataIndex, dataType, e) {
  40420. // FIXME Graph data
  40421. var api = this._api;
  40422. var data = seriesModel.getData(dataType);
  40423. var itemModel = data.getItemModel(dataIndex);
  40424. var tooltipOpt = itemModel.get('tooltip', true);
  40425. if (typeof tooltipOpt === 'string') {
  40426. // In each data item tooltip can be simply write:
  40427. // {
  40428. // value: 10,
  40429. // tooltip: 'Something you need to know'
  40430. // }
  40431. var tooltipContent = tooltipOpt;
  40432. tooltipOpt = {
  40433. formatter: tooltipContent
  40434. };
  40435. }
  40436. var rootTooltipModel = this._tooltipModel;
  40437. var seriesTooltipModel = seriesModel.getModel(
  40438. 'tooltip', rootTooltipModel
  40439. );
  40440. var tooltipModel = new Model(tooltipOpt, seriesTooltipModel, seriesTooltipModel.ecModel);
  40441. var params = seriesModel.getDataParams(dataIndex, dataType);
  40442. var defaultHtml = seriesModel.formatTooltip(dataIndex, false, dataType);
  40443. var asyncTicket = 'item_' + seriesModel.name + '_' + dataIndex;
  40444. this._showTooltipContent(
  40445. tooltipModel, defaultHtml, params, asyncTicket,
  40446. e.offsetX, e.offsetY, e.target, api
  40447. );
  40448. },
  40449. _showTooltipContent: function (
  40450. tooltipModel, defaultHtml, params, asyncTicket, x, y, target, api
  40451. ) {
  40452. // Reset ticket
  40453. this._ticket = '';
  40454. if (tooltipModel.get('showContent') && tooltipModel.get('show')) {
  40455. var tooltipContent = this._tooltipContent;
  40456. var formatter = tooltipModel.get('formatter');
  40457. var positionExpr = tooltipModel.get('position');
  40458. var html = defaultHtml;
  40459. if (formatter) {
  40460. if (typeof formatter === 'string') {
  40461. html = formatUtil.formatTpl(formatter, params);
  40462. }
  40463. else if (typeof formatter === 'function') {
  40464. var self = this;
  40465. var ticket = asyncTicket;
  40466. var callback = function (cbTicket, html) {
  40467. if (cbTicket === self._ticket) {
  40468. tooltipContent.setContent(html);
  40469. updatePosition(
  40470. positionExpr, x, y,
  40471. tooltipContent, params, target, api
  40472. );
  40473. }
  40474. };
  40475. self._ticket = ticket;
  40476. html = formatter(params, ticket, callback);
  40477. }
  40478. }
  40479. tooltipContent.show(tooltipModel);
  40480. tooltipContent.setContent(html);
  40481. updatePosition(
  40482. positionExpr, x, y,
  40483. tooltipContent, params, target, api
  40484. );
  40485. }
  40486. },
  40487. /**
  40488. * Show axis pointer
  40489. * @param {string} [coordSysName]
  40490. */
  40491. _showAxisPointer: function (coordSysName) {
  40492. if (coordSysName) {
  40493. var axisPointers = this._axisPointers[coordSysName];
  40494. axisPointers && zrUtil.each(axisPointers, function (el) {
  40495. el.show();
  40496. });
  40497. }
  40498. else {
  40499. this.group.eachChild(function (child) {
  40500. child.show();
  40501. });
  40502. this.group.show();
  40503. }
  40504. },
  40505. _resetLastHover: function () {
  40506. var lastHover = this._lastHover;
  40507. if (lastHover.payloadBatch) {
  40508. this._api.dispatchAction({
  40509. type: 'downplay',
  40510. batch: lastHover.payloadBatch
  40511. });
  40512. }
  40513. // Reset lastHover
  40514. this._lastHover = {};
  40515. },
  40516. /**
  40517. * Hide axis pointer
  40518. * @param {string} [coordSysName]
  40519. */
  40520. _hideAxisPointer: function (coordSysName) {
  40521. if (coordSysName) {
  40522. var axisPointers = this._axisPointers[coordSysName];
  40523. axisPointers && zrUtil.each(axisPointers, function (el) {
  40524. el.hide();
  40525. });
  40526. }
  40527. else {
  40528. if (this.group.children().length) {
  40529. this.group.hide();
  40530. }
  40531. }
  40532. },
  40533. _hide: function () {
  40534. clearTimeout(this._showTimeout);
  40535. this._hideAxisPointer();
  40536. this._resetLastHover();
  40537. if (!this._alwaysShowContent) {
  40538. this._tooltipContent.hideLater(this._tooltipModel.get('hideDelay'));
  40539. }
  40540. this._api.dispatchAction({
  40541. type: 'hideTip',
  40542. from: this.uid
  40543. });
  40544. this._lastX = this._lastY = null;
  40545. },
  40546. dispose: function (ecModel, api) {
  40547. if (env.node) {
  40548. return;
  40549. }
  40550. var zr = api.getZr();
  40551. this._tooltipContent.hide();
  40552. zr.off('click', this._tryShow);
  40553. zr.off('mousemove', this._mousemove);
  40554. zr.off('mouseout', this._hide);
  40555. zr.off('globalout', this._hide);
  40556. api.off('showTip', this._manuallyShowTip);
  40557. api.off('hideTip', this._manuallyHideTip);
  40558. }
  40559. });
  40560. /***/ },
  40561. /* 282 */
  40562. /***/ function(module, exports, __webpack_require__) {
  40563. /**
  40564. * @module echarts/component/tooltip/TooltipContent
  40565. */
  40566. var zrUtil = __webpack_require__(4);
  40567. var zrColor = __webpack_require__(39);
  40568. var eventUtil = __webpack_require__(87);
  40569. var formatUtil = __webpack_require__(6);
  40570. var each = zrUtil.each;
  40571. var toCamelCase = formatUtil.toCamelCase;
  40572. var env = __webpack_require__(2);
  40573. var vendors = ['', '-webkit-', '-moz-', '-o-'];
  40574. var gCssText = 'position:absolute;display:block;border-style:solid;white-space:nowrap;z-index:9999999;';
  40575. /**
  40576. * @param {number} duration
  40577. * @return {string}
  40578. * @inner
  40579. */
  40580. function assembleTransition(duration) {
  40581. var transitionCurve = 'cubic-bezier(0.23, 1, 0.32, 1)';
  40582. var transitionText = 'left ' + duration + 's ' + transitionCurve + ','
  40583. + 'top ' + duration + 's ' + transitionCurve;
  40584. return zrUtil.map(vendors, function (vendorPrefix) {
  40585. return vendorPrefix + 'transition:' + transitionText;
  40586. }).join(';');
  40587. }
  40588. /**
  40589. * @param {Object} textStyle
  40590. * @return {string}
  40591. * @inner
  40592. */
  40593. function assembleFont(textStyleModel) {
  40594. var cssText = [];
  40595. var fontSize = textStyleModel.get('fontSize');
  40596. var color = textStyleModel.getTextColor();
  40597. color && cssText.push('color:' + color);
  40598. cssText.push('font:' + textStyleModel.getFont());
  40599. fontSize &&
  40600. cssText.push('line-height:' + Math.round(fontSize * 3 / 2) + 'px');
  40601. each(['decoration', 'align'], function (name) {
  40602. var val = textStyleModel.get(name);
  40603. val && cssText.push('text-' + name + ':' + val);
  40604. });
  40605. return cssText.join(';');
  40606. }
  40607. /**
  40608. * @param {Object} tooltipModel
  40609. * @return {string}
  40610. * @inner
  40611. */
  40612. function assembleCssText(tooltipModel) {
  40613. tooltipModel = tooltipModel;
  40614. var cssText = [];
  40615. var transitionDuration = tooltipModel.get('transitionDuration');
  40616. var backgroundColor = tooltipModel.get('backgroundColor');
  40617. var textStyleModel = tooltipModel.getModel('textStyle');
  40618. var padding = tooltipModel.get('padding');
  40619. // Animation transition
  40620. transitionDuration &&
  40621. cssText.push(assembleTransition(transitionDuration));
  40622. if (backgroundColor) {
  40623. if (env.canvasSupported) {
  40624. cssText.push('background-Color:' + backgroundColor);
  40625. }
  40626. else {
  40627. // for ie
  40628. cssText.push(
  40629. 'background-Color:#' + zrColor.toHex(backgroundColor)
  40630. );
  40631. cssText.push('filter:alpha(opacity=70)');
  40632. }
  40633. }
  40634. // Border style
  40635. each(['width', 'color', 'radius'], function (name) {
  40636. var borderName = 'border-' + name;
  40637. var camelCase = toCamelCase(borderName);
  40638. var val = tooltipModel.get(camelCase);
  40639. val != null &&
  40640. cssText.push(borderName + ':' + val + (name === 'color' ? '' : 'px'));
  40641. });
  40642. // Text style
  40643. cssText.push(assembleFont(textStyleModel));
  40644. // Padding
  40645. if (padding != null) {
  40646. cssText.push('padding:' + formatUtil.normalizeCssArray(padding).join('px ') + 'px');
  40647. }
  40648. return cssText.join(';') + ';';
  40649. }
  40650. /**
  40651. * @alias module:echarts/component/tooltip/TooltipContent
  40652. * @constructor
  40653. */
  40654. function TooltipContent(container, api) {
  40655. var el = document.createElement('div');
  40656. var zr = api.getZr();
  40657. this.el = el;
  40658. this._x = api.getWidth() / 2;
  40659. this._y = api.getHeight() / 2;
  40660. container.appendChild(el);
  40661. this._container = container;
  40662. this._show = false;
  40663. /**
  40664. * @private
  40665. */
  40666. this._hideTimeout;
  40667. var self = this;
  40668. el.onmouseenter = function () {
  40669. // clear the timeout in hideLater and keep showing tooltip
  40670. if (self.enterable) {
  40671. clearTimeout(self._hideTimeout);
  40672. self._show = true;
  40673. }
  40674. self._inContent = true;
  40675. };
  40676. el.onmousemove = function (e) {
  40677. if (!self.enterable) {
  40678. // Try trigger zrender event to avoid mouse
  40679. // in and out shape too frequently
  40680. var handler = zr.handler;
  40681. eventUtil.normalizeEvent(container, e);
  40682. handler.dispatch('mousemove', e);
  40683. }
  40684. };
  40685. el.onmouseleave = function () {
  40686. if (self.enterable) {
  40687. if (self._show) {
  40688. self.hideLater(self._hideDelay);
  40689. }
  40690. }
  40691. self._inContent = false;
  40692. };
  40693. compromiseMobile(el, container);
  40694. }
  40695. function compromiseMobile(tooltipContentEl, container) {
  40696. // Prevent default behavior on mobile. For example,
  40697. // default pinch gesture will cause browser zoom.
  40698. // We do not preventing event on tooltip contnet el,
  40699. // because user may need customization in tooltip el.
  40700. eventUtil.addEventListener(container, 'touchstart', preventDefault);
  40701. eventUtil.addEventListener(container, 'touchmove', preventDefault);
  40702. eventUtil.addEventListener(container, 'touchend', preventDefault);
  40703. function preventDefault(e) {
  40704. if (contains(e.target)) {
  40705. e.preventDefault();
  40706. }
  40707. }
  40708. function contains(targetEl) {
  40709. while (targetEl && targetEl !== container) {
  40710. if (targetEl === tooltipContentEl) {
  40711. return true;
  40712. }
  40713. targetEl = targetEl.parentNode;
  40714. }
  40715. }
  40716. }
  40717. TooltipContent.prototype = {
  40718. constructor: TooltipContent,
  40719. enterable: true,
  40720. /**
  40721. * Update when tooltip is rendered
  40722. */
  40723. update: function () {
  40724. var container = this._container;
  40725. var stl = container.currentStyle
  40726. || document.defaultView.getComputedStyle(container);
  40727. var domStyle = container.style;
  40728. if (domStyle.position !== 'absolute' && stl.position !== 'absolute') {
  40729. domStyle.position = 'relative';
  40730. }
  40731. // Hide the tooltip
  40732. // PENDING
  40733. // this.hide();
  40734. },
  40735. show: function (tooltipModel) {
  40736. clearTimeout(this._hideTimeout);
  40737. var el = this.el;
  40738. el.style.cssText = gCssText + assembleCssText(tooltipModel)
  40739. // http://stackoverflow.com/questions/21125587/css3-transition-not-working-in-chrome-anymore
  40740. + ';left:' + this._x + 'px;top:' + this._y + 'px;'
  40741. + (tooltipModel.get('extraCssText') || '');
  40742. el.style.display = el.innerHTML ? 'block' : 'none';
  40743. this._show = true;
  40744. },
  40745. setContent: function (content) {
  40746. var el = this.el;
  40747. el.innerHTML = content;
  40748. el.style.display = content ? 'block' : 'none';
  40749. },
  40750. moveTo: function (x, y) {
  40751. var style = this.el.style;
  40752. style.left = x + 'px';
  40753. style.top = y + 'px';
  40754. this._x = x;
  40755. this._y = y;
  40756. },
  40757. hide: function () {
  40758. this.el.style.display = 'none';
  40759. this._show = false;
  40760. },
  40761. // showLater: function ()
  40762. hideLater: function (time) {
  40763. if (this._show && !(this._inContent && this.enterable)) {
  40764. if (time) {
  40765. this._hideDelay = time;
  40766. // Set show false to avoid invoke hideLater mutiple times
  40767. this._show = false;
  40768. this._hideTimeout = setTimeout(zrUtil.bind(this.hide, this), time);
  40769. }
  40770. else {
  40771. this.hide();
  40772. }
  40773. }
  40774. },
  40775. isShow: function () {
  40776. return this._show;
  40777. }
  40778. };
  40779. module.exports = TooltipContent;
  40780. /***/ },
  40781. /* 283 */
  40782. /***/ function(module, exports, __webpack_require__) {
  40783. 'use strict';
  40784. __webpack_require__(284);
  40785. __webpack_require__(290);
  40786. __webpack_require__(292);
  40787. // Polar view
  40788. __webpack_require__(1).extendComponentView({
  40789. type: 'polar'
  40790. });
  40791. /***/ },
  40792. /* 284 */
  40793. /***/ function(module, exports, __webpack_require__) {
  40794. // TODO Axis scale
  40795. var Polar = __webpack_require__(285);
  40796. var numberUtil = __webpack_require__(7);
  40797. var axisHelper = __webpack_require__(114);
  40798. var niceScaleExtent = axisHelper.niceScaleExtent;
  40799. // 依赖 PolarModel 做预处理
  40800. __webpack_require__(288);
  40801. /**
  40802. * Resize method bound to the polar
  40803. * @param {module:echarts/coord/polar/PolarModel} polarModel
  40804. * @param {module:echarts/ExtensionAPI} api
  40805. */
  40806. function resizePolar(polarModel, api) {
  40807. var center = polarModel.get('center');
  40808. var radius = polarModel.get('radius');
  40809. var width = api.getWidth();
  40810. var height = api.getHeight();
  40811. var parsePercent = numberUtil.parsePercent;
  40812. this.cx = parsePercent(center[0], width);
  40813. this.cy = parsePercent(center[1], height);
  40814. var radiusAxis = this.getRadiusAxis();
  40815. var size = Math.min(width, height) / 2;
  40816. // var idx = radiusAxis.inverse ? 1 : 0;
  40817. radiusAxis.setExtent(0, parsePercent(radius, size));
  40818. }
  40819. /**
  40820. * Update polar
  40821. */
  40822. function updatePolarScale(ecModel, api) {
  40823. var polar = this;
  40824. var angleAxis = polar.getAngleAxis();
  40825. var radiusAxis = polar.getRadiusAxis();
  40826. // Reset scale
  40827. angleAxis.scale.setExtent(Infinity, -Infinity);
  40828. radiusAxis.scale.setExtent(Infinity, -Infinity);
  40829. ecModel.eachSeries(function (seriesModel) {
  40830. if (seriesModel.coordinateSystem === polar) {
  40831. var data = seriesModel.getData();
  40832. radiusAxis.scale.unionExtent(
  40833. data.getDataExtent('radius', radiusAxis.type !== 'category')
  40834. );
  40835. angleAxis.scale.unionExtent(
  40836. data.getDataExtent('angle', angleAxis.type !== 'category')
  40837. );
  40838. }
  40839. });
  40840. niceScaleExtent(angleAxis, angleAxis.model);
  40841. niceScaleExtent(radiusAxis, radiusAxis.model);
  40842. // Fix extent of category angle axis
  40843. if (angleAxis.type === 'category' && !angleAxis.onBand) {
  40844. var extent = angleAxis.getExtent();
  40845. var diff = 360 / angleAxis.scale.count();
  40846. angleAxis.inverse ? (extent[1] += diff) : (extent[1] -= diff);
  40847. angleAxis.setExtent(extent[0], extent[1]);
  40848. }
  40849. }
  40850. /**
  40851. * Set common axis properties
  40852. * @param {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
  40853. * @param {module:echarts/coord/polar/AxisModel}
  40854. * @inner
  40855. */
  40856. function setAxis(axis, axisModel) {
  40857. axis.type = axisModel.get('type');
  40858. axis.scale = axisHelper.createScaleByModel(axisModel);
  40859. axis.onBand = axisModel.get('boundaryGap') && axis.type === 'category';
  40860. // FIXME Radius axis not support inverse axis
  40861. if (axisModel.mainType === 'angleAxis') {
  40862. var startAngle = axisModel.get('startAngle');
  40863. axis.inverse = axisModel.get('inverse') ^ axisModel.get('clockwise');
  40864. axis.setExtent(startAngle, startAngle + (axis.inverse ? -360 : 360));
  40865. }
  40866. // Inject axis instance
  40867. axisModel.axis = axis;
  40868. axis.model = axisModel;
  40869. }
  40870. var polarCreator = {
  40871. dimensions: Polar.prototype.dimensions,
  40872. create: function (ecModel, api) {
  40873. var polarList = [];
  40874. ecModel.eachComponent('polar', function (polarModel, idx) {
  40875. var polar = new Polar(idx);
  40876. // Inject resize and update method
  40877. polar.resize = resizePolar;
  40878. polar.update = updatePolarScale;
  40879. var radiusAxis = polar.getRadiusAxis();
  40880. var angleAxis = polar.getAngleAxis();
  40881. var radiusAxisModel = polarModel.findAxisModel('radiusAxis');
  40882. var angleAxisModel = polarModel.findAxisModel('angleAxis');
  40883. setAxis(radiusAxis, radiusAxisModel);
  40884. setAxis(angleAxis, angleAxisModel);
  40885. polar.resize(polarModel, api);
  40886. polarList.push(polar);
  40887. polarModel.coordinateSystem = polar;
  40888. });
  40889. // Inject coordinateSystem to series
  40890. ecModel.eachSeries(function (seriesModel) {
  40891. if (seriesModel.get('coordinateSystem') === 'polar') {
  40892. seriesModel.coordinateSystem = polarList[seriesModel.get('polarIndex')];
  40893. }
  40894. });
  40895. return polarList;
  40896. }
  40897. };
  40898. __webpack_require__(26).register('polar', polarCreator);
  40899. /***/ },
  40900. /* 285 */
  40901. /***/ function(module, exports, __webpack_require__) {
  40902. 'use strict';
  40903. /**
  40904. * @module echarts/coord/polar/Polar
  40905. */
  40906. var RadiusAxis = __webpack_require__(286);
  40907. var AngleAxis = __webpack_require__(287);
  40908. /**
  40909. * @alias {module:echarts/coord/polar/Polar}
  40910. * @constructor
  40911. * @param {string} name
  40912. */
  40913. var Polar = function (name) {
  40914. /**
  40915. * @type {string}
  40916. */
  40917. this.name = name || '';
  40918. /**
  40919. * x of polar center
  40920. * @type {number}
  40921. */
  40922. this.cx = 0;
  40923. /**
  40924. * y of polar center
  40925. * @type {number}
  40926. */
  40927. this.cy = 0;
  40928. /**
  40929. * @type {module:echarts/coord/polar/RadiusAxis}
  40930. * @private
  40931. */
  40932. this._radiusAxis = new RadiusAxis();
  40933. /**
  40934. * @type {module:echarts/coord/polar/AngleAxis}
  40935. * @private
  40936. */
  40937. this._angleAxis = new AngleAxis();
  40938. };
  40939. Polar.prototype = {
  40940. constructor: Polar,
  40941. type: 'polar',
  40942. /**
  40943. * @param {Array.<string>}
  40944. * @readOnly
  40945. */
  40946. dimensions: ['radius', 'angle'],
  40947. /**
  40948. * If contain coord
  40949. * @param {Array.<number>} point
  40950. * @return {boolean}
  40951. */
  40952. containPoint: function (point) {
  40953. var coord = this.pointToCoord(point);
  40954. return this._radiusAxis.contain(coord[0])
  40955. && this._angleAxis.contain(coord[1]);
  40956. },
  40957. /**
  40958. * If contain data
  40959. * @param {Array.<number>} data
  40960. * @return {boolean}
  40961. */
  40962. containData: function (data) {
  40963. return this._radiusAxis.containData(data[0])
  40964. && this._angleAxis.containData(data[1]);
  40965. },
  40966. /**
  40967. * @param {string} axisType
  40968. * @return {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
  40969. */
  40970. getAxis: function (axisType) {
  40971. return this['_' + axisType + 'Axis'];
  40972. },
  40973. /**
  40974. * Get axes by type of scale
  40975. * @param {string} scaleType
  40976. * @return {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
  40977. */
  40978. getAxesByScale: function (scaleType) {
  40979. var axes = [];
  40980. var angleAxis = this._angleAxis;
  40981. var radiusAxis = this._radiusAxis;
  40982. angleAxis.scale.type === scaleType && axes.push(angleAxis);
  40983. radiusAxis.scale.type === scaleType && axes.push(radiusAxis);
  40984. return axes;
  40985. },
  40986. /**
  40987. * @return {module:echarts/coord/polar/AngleAxis}
  40988. */
  40989. getAngleAxis: function () {
  40990. return this._angleAxis;
  40991. },
  40992. /**
  40993. * @return {module:echarts/coord/polar/RadiusAxis}
  40994. */
  40995. getRadiusAxis: function () {
  40996. return this._radiusAxis;
  40997. },
  40998. /**
  40999. * @param {module:echarts/coord/polar/Axis}
  41000. * @return {module:echarts/coord/polar/Axis}
  41001. */
  41002. getOtherAxis: function (axis) {
  41003. var angleAxis = this._angleAxis;
  41004. return axis === angleAxis ? this._radiusAxis : angleAxis;
  41005. },
  41006. /**
  41007. * Base axis will be used on stacking.
  41008. *
  41009. * @return {module:echarts/coord/polar/Axis}
  41010. */
  41011. getBaseAxis: function () {
  41012. return this.getAxesByScale('ordinal')[0]
  41013. || this.getAxesByScale('time')[0]
  41014. || this.getAngleAxis();
  41015. },
  41016. /**
  41017. * Convert series data to a list of (x, y) points
  41018. * @param {module:echarts/data/List} data
  41019. * @return {Array}
  41020. * Return list of coordinates. For example:
  41021. * `[[10, 10], [20, 20], [30, 30]]`
  41022. */
  41023. dataToPoints: function (data) {
  41024. return data.mapArray(this.dimensions, function (radius, angle) {
  41025. return this.dataToPoint([radius, angle]);
  41026. }, this);
  41027. },
  41028. /**
  41029. * Convert a single data item to (x, y) point.
  41030. * Parameter data is an array which the first element is radius and the second is angle
  41031. * @param {Array.<number>} data
  41032. * @param {boolean} [clamp=false]
  41033. * @return {Array.<number>}
  41034. */
  41035. dataToPoint: function (data, clamp) {
  41036. return this.coordToPoint([
  41037. this._radiusAxis.dataToRadius(data[0], clamp),
  41038. this._angleAxis.dataToAngle(data[1], clamp)
  41039. ]);
  41040. },
  41041. /**
  41042. * Convert a (x, y) point to data
  41043. * @param {Array.<number>} point
  41044. * @param {boolean} [clamp=false]
  41045. * @return {Array.<number>}
  41046. */
  41047. pointToData: function (point, clamp) {
  41048. var coord = this.pointToCoord(point);
  41049. return [
  41050. this._radiusAxis.radiusToData(coord[0], clamp),
  41051. this._angleAxis.angleToData(coord[1], clamp)
  41052. ];
  41053. },
  41054. /**
  41055. * Convert a (x, y) point to (radius, angle) coord
  41056. * @param {Array.<number>} point
  41057. * @return {Array.<number>}
  41058. */
  41059. pointToCoord: function (point) {
  41060. var dx = point[0] - this.cx;
  41061. var dy = point[1] - this.cy;
  41062. var angleAxis = this.getAngleAxis();
  41063. var extent = angleAxis.getExtent();
  41064. var minAngle = Math.min(extent[0], extent[1]);
  41065. var maxAngle = Math.max(extent[0], extent[1]);
  41066. // Fix fixed extent in polarCreator
  41067. // FIXME
  41068. angleAxis.inverse
  41069. ? (minAngle = maxAngle - 360)
  41070. : (maxAngle = minAngle + 360);
  41071. var radius = Math.sqrt(dx * dx + dy * dy);
  41072. dx /= radius;
  41073. dy /= radius;
  41074. var radian = Math.atan2(-dy, dx) / Math.PI * 180;
  41075. // move to angleExtent
  41076. var dir = radian < minAngle ? 1 : -1;
  41077. while (radian < minAngle || radian > maxAngle) {
  41078. radian += dir * 360;
  41079. }
  41080. return [radius, radian];
  41081. },
  41082. /**
  41083. * Convert a (radius, angle) coord to (x, y) point
  41084. * @param {Array.<number>} coord
  41085. * @return {Array.<number>}
  41086. */
  41087. coordToPoint: function (coord) {
  41088. var radius = coord[0];
  41089. var radian = coord[1] / 180 * Math.PI;
  41090. var x = Math.cos(radian) * radius + this.cx;
  41091. // Inverse the y
  41092. var y = -Math.sin(radian) * radius + this.cy;
  41093. return [x, y];
  41094. }
  41095. };
  41096. module.exports = Polar;
  41097. /***/ },
  41098. /* 286 */
  41099. /***/ function(module, exports, __webpack_require__) {
  41100. 'use strict';
  41101. var zrUtil = __webpack_require__(4);
  41102. var Axis = __webpack_require__(123);
  41103. function RadiusAxis(scale, radiusExtent) {
  41104. Axis.call(this, 'radius', scale, radiusExtent);
  41105. /**
  41106. * Axis type
  41107. * - 'category'
  41108. * - 'value'
  41109. * - 'time'
  41110. * - 'log'
  41111. * @type {string}
  41112. */
  41113. this.type = 'category';
  41114. }
  41115. RadiusAxis.prototype = {
  41116. constructor: RadiusAxis,
  41117. dataToRadius: Axis.prototype.dataToCoord,
  41118. radiusToData: Axis.prototype.coordToData
  41119. };
  41120. zrUtil.inherits(RadiusAxis, Axis);
  41121. module.exports = RadiusAxis;
  41122. /***/ },
  41123. /* 287 */
  41124. /***/ function(module, exports, __webpack_require__) {
  41125. 'use strict';
  41126. var zrUtil = __webpack_require__(4);
  41127. var Axis = __webpack_require__(123);
  41128. function AngleAxis(scale, angleExtent) {
  41129. angleExtent = angleExtent || [0, 360];
  41130. Axis.call(this, 'angle', scale, angleExtent);
  41131. /**
  41132. * Axis type
  41133. * - 'category'
  41134. * - 'value'
  41135. * - 'time'
  41136. * - 'log'
  41137. * @type {string}
  41138. */
  41139. this.type = 'category';
  41140. }
  41141. AngleAxis.prototype = {
  41142. constructor: AngleAxis,
  41143. dataToAngle: Axis.prototype.dataToCoord,
  41144. angleToData: Axis.prototype.coordToData
  41145. };
  41146. zrUtil.inherits(AngleAxis, Axis);
  41147. module.exports = AngleAxis;
  41148. /***/ },
  41149. /* 288 */
  41150. /***/ function(module, exports, __webpack_require__) {
  41151. 'use strict';
  41152. __webpack_require__(289);
  41153. __webpack_require__(1).extendComponentModel({
  41154. type: 'polar',
  41155. dependencies: ['polarAxis', 'angleAxis'],
  41156. /**
  41157. * @type {module:echarts/coord/polar/Polar}
  41158. */
  41159. coordinateSystem: null,
  41160. /**
  41161. * @param {string} axisType
  41162. * @return {module:echarts/coord/polar/AxisModel}
  41163. */
  41164. findAxisModel: function (axisType) {
  41165. var angleAxisModel;
  41166. var ecModel = this.ecModel;
  41167. ecModel.eachComponent(axisType, function (axisModel) {
  41168. if (ecModel.getComponent(
  41169. 'polar', axisModel.getShallow('polarIndex')
  41170. ) === this) {
  41171. angleAxisModel = axisModel;
  41172. }
  41173. }, this);
  41174. return angleAxisModel;
  41175. },
  41176. defaultOption: {
  41177. zlevel: 0,
  41178. z: 0,
  41179. center: ['50%', '50%'],
  41180. radius: '80%'
  41181. }
  41182. });
  41183. /***/ },
  41184. /* 289 */
  41185. /***/ function(module, exports, __webpack_require__) {
  41186. 'use strict';
  41187. var zrUtil = __webpack_require__(4);
  41188. var ComponentModel = __webpack_require__(19);
  41189. var axisModelCreator = __webpack_require__(127);
  41190. var PolarAxisModel = ComponentModel.extend({
  41191. type: 'polarAxis',
  41192. /**
  41193. * @type {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
  41194. */
  41195. axis: null
  41196. });
  41197. zrUtil.merge(PolarAxisModel.prototype, __webpack_require__(129));
  41198. var polarAxisDefaultExtendedOption = {
  41199. angle: {
  41200. polarIndex: 0,
  41201. startAngle: 90,
  41202. clockwise: true,
  41203. splitNumber: 12,
  41204. axisLabel: {
  41205. rotate: false
  41206. }
  41207. },
  41208. radius: {
  41209. polarIndex: 0,
  41210. splitNumber: 5
  41211. }
  41212. };
  41213. function getAxisType(axisDim, option) {
  41214. // Default axis with data is category axis
  41215. return option.type || (option.data ? 'category' : 'value');
  41216. }
  41217. axisModelCreator('angle', PolarAxisModel, getAxisType, polarAxisDefaultExtendedOption.angle);
  41218. axisModelCreator('radius', PolarAxisModel, getAxisType, polarAxisDefaultExtendedOption.radius);
  41219. /***/ },
  41220. /* 290 */
  41221. /***/ function(module, exports, __webpack_require__) {
  41222. 'use strict';
  41223. __webpack_require__(284);
  41224. __webpack_require__(291);
  41225. /***/ },
  41226. /* 291 */
  41227. /***/ function(module, exports, __webpack_require__) {
  41228. 'use strict';
  41229. var zrUtil = __webpack_require__(4);
  41230. var graphic = __webpack_require__(43);
  41231. var Model = __webpack_require__(12);
  41232. var elementList = ['axisLine', 'axisLabel', 'axisTick', 'splitLine', 'splitArea'];
  41233. function getAxisLineShape(polar, r0, r, angle) {
  41234. var start = polar.coordToPoint([r0, angle]);
  41235. var end = polar.coordToPoint([r, angle]);
  41236. return {
  41237. x1: start[0],
  41238. y1: start[1],
  41239. x2: end[0],
  41240. y2: end[1]
  41241. };
  41242. }
  41243. __webpack_require__(1).extendComponentView({
  41244. type: 'angleAxis',
  41245. render: function (angleAxisModel, ecModel) {
  41246. this.group.removeAll();
  41247. if (!angleAxisModel.get('show')) {
  41248. return;
  41249. }
  41250. var polarModel = ecModel.getComponent('polar', angleAxisModel.get('polarIndex'));
  41251. var angleAxis = angleAxisModel.axis;
  41252. var polar = polarModel.coordinateSystem;
  41253. var radiusExtent = polar.getRadiusAxis().getExtent();
  41254. var ticksAngles = angleAxis.getTicksCoords();
  41255. if (angleAxis.type !== 'category') {
  41256. // Remove the last tick which will overlap the first tick
  41257. ticksAngles.pop();
  41258. }
  41259. zrUtil.each(elementList, function (name) {
  41260. if (angleAxisModel.get(name +'.show')) {
  41261. this['_' + name](angleAxisModel, polar, ticksAngles, radiusExtent);
  41262. }
  41263. }, this);
  41264. },
  41265. /**
  41266. * @private
  41267. */
  41268. _axisLine: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
  41269. var lineStyleModel = angleAxisModel.getModel('axisLine.lineStyle');
  41270. var circle = new graphic.Circle({
  41271. shape: {
  41272. cx: polar.cx,
  41273. cy: polar.cy,
  41274. r: radiusExtent[1]
  41275. },
  41276. style: lineStyleModel.getLineStyle(),
  41277. z2: 1,
  41278. silent: true
  41279. });
  41280. circle.style.fill = null;
  41281. this.group.add(circle);
  41282. },
  41283. /**
  41284. * @private
  41285. */
  41286. _axisTick: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
  41287. var tickModel = angleAxisModel.getModel('axisTick');
  41288. var tickLen = (tickModel.get('inside') ? -1 : 1) * tickModel.get('length');
  41289. var lines = zrUtil.map(ticksAngles, function (tickAngle) {
  41290. return new graphic.Line({
  41291. shape: getAxisLineShape(polar, radiusExtent[1], radiusExtent[1] + tickLen, tickAngle)
  41292. });
  41293. });
  41294. this.group.add(graphic.mergePath(
  41295. lines, {
  41296. style: zrUtil.defaults(
  41297. tickModel.getModel('lineStyle').getLineStyle(),
  41298. {
  41299. stroke: angleAxisModel.get('axisLine.lineStyle.color')
  41300. }
  41301. )
  41302. }
  41303. ));
  41304. },
  41305. /**
  41306. * @private
  41307. */
  41308. _axisLabel: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
  41309. var axis = angleAxisModel.axis;
  41310. var categoryData = angleAxisModel.get('data');
  41311. var labelModel = angleAxisModel.getModel('axisLabel');
  41312. var axisTextStyleModel = labelModel.getModel('textStyle');
  41313. var labels = angleAxisModel.getFormattedLabels();
  41314. var labelMargin = labelModel.get('margin');
  41315. var labelsAngles = axis.getLabelsCoords();
  41316. // Use length of ticksAngles because it may remove the last tick to avoid overlapping
  41317. for (var i = 0; i < ticksAngles.length; i++) {
  41318. var r = radiusExtent[1];
  41319. var p = polar.coordToPoint([r + labelMargin, labelsAngles[i]]);
  41320. var cx = polar.cx;
  41321. var cy = polar.cy;
  41322. var labelTextAlign = Math.abs(p[0] - cx) / r < 0.3
  41323. ? 'center' : (p[0] > cx ? 'left' : 'right');
  41324. var labelTextBaseline = Math.abs(p[1] - cy) / r < 0.3
  41325. ? 'middle' : (p[1] > cy ? 'top' : 'bottom');
  41326. var textStyleModel = axisTextStyleModel;
  41327. if (categoryData && categoryData[i] && categoryData[i].textStyle) {
  41328. textStyleModel = new Model(
  41329. categoryData[i].textStyle, axisTextStyleModel
  41330. );
  41331. }
  41332. this.group.add(new graphic.Text({
  41333. style: {
  41334. x: p[0],
  41335. y: p[1],
  41336. fill: textStyleModel.getTextColor() || angleAxisModel.get('axisLine.lineStyle.color'),
  41337. text: labels[i],
  41338. textAlign: labelTextAlign,
  41339. textVerticalAlign: labelTextBaseline,
  41340. textFont: textStyleModel.getFont()
  41341. },
  41342. silent: true
  41343. }));
  41344. }
  41345. },
  41346. /**
  41347. * @private
  41348. */
  41349. _splitLine: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
  41350. var splitLineModel = angleAxisModel.getModel('splitLine');
  41351. var lineStyleModel = splitLineModel.getModel('lineStyle');
  41352. var lineColors = lineStyleModel.get('color');
  41353. var lineCount = 0;
  41354. lineColors = lineColors instanceof Array ? lineColors : [lineColors];
  41355. var splitLines = [];
  41356. for (var i = 0; i < ticksAngles.length; i++) {
  41357. var colorIndex = (lineCount++) % lineColors.length;
  41358. splitLines[colorIndex] = splitLines[colorIndex] || [];
  41359. splitLines[colorIndex].push(new graphic.Line({
  41360. shape: getAxisLineShape(polar, radiusExtent[0], radiusExtent[1], ticksAngles[i])
  41361. }));
  41362. }
  41363. // Simple optimization
  41364. // Batching the lines if color are the same
  41365. for (var i = 0; i < splitLines.length; i++) {
  41366. this.group.add(graphic.mergePath(splitLines[i], {
  41367. style: zrUtil.defaults({
  41368. stroke: lineColors[i % lineColors.length]
  41369. }, lineStyleModel.getLineStyle()),
  41370. silent: true,
  41371. z: angleAxisModel.get('z')
  41372. }));
  41373. }
  41374. },
  41375. /**
  41376. * @private
  41377. */
  41378. _splitArea: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
  41379. var splitAreaModel = angleAxisModel.getModel('splitArea');
  41380. var areaStyleModel = splitAreaModel.getModel('areaStyle');
  41381. var areaColors = areaStyleModel.get('color');
  41382. var lineCount = 0;
  41383. areaColors = areaColors instanceof Array ? areaColors : [areaColors];
  41384. var splitAreas = [];
  41385. var RADIAN = Math.PI / 180;
  41386. var prevAngle = -ticksAngles[0] * RADIAN;
  41387. var r0 = Math.min(radiusExtent[0], radiusExtent[1]);
  41388. var r1 = Math.max(radiusExtent[0], radiusExtent[1]);
  41389. var clockwise = angleAxisModel.get('clockwise');
  41390. for (var i = 1; i < ticksAngles.length; i++) {
  41391. var colorIndex = (lineCount++) % areaColors.length;
  41392. splitAreas[colorIndex] = splitAreas[colorIndex] || [];
  41393. splitAreas[colorIndex].push(new graphic.Sector({
  41394. shape: {
  41395. cx: polar.cx,
  41396. cy: polar.cy,
  41397. r0: r0,
  41398. r: r1,
  41399. startAngle: prevAngle,
  41400. endAngle: -ticksAngles[i] * RADIAN,
  41401. clockwise: clockwise
  41402. },
  41403. silent: true
  41404. }));
  41405. prevAngle = -ticksAngles[i] * RADIAN;
  41406. }
  41407. // Simple optimization
  41408. // Batching the lines if color are the same
  41409. for (var i = 0; i < splitAreas.length; i++) {
  41410. this.group.add(graphic.mergePath(splitAreas[i], {
  41411. style: zrUtil.defaults({
  41412. fill: areaColors[i % areaColors.length]
  41413. }, areaStyleModel.getAreaStyle()),
  41414. silent: true
  41415. }));
  41416. }
  41417. }
  41418. });
  41419. /***/ },
  41420. /* 292 */
  41421. /***/ function(module, exports, __webpack_require__) {
  41422. __webpack_require__(284);
  41423. __webpack_require__(293);
  41424. /***/ },
  41425. /* 293 */
  41426. /***/ function(module, exports, __webpack_require__) {
  41427. 'use strict';
  41428. var zrUtil = __webpack_require__(4);
  41429. var graphic = __webpack_require__(43);
  41430. var AxisBuilder = __webpack_require__(132);
  41431. var axisBuilderAttrs = [
  41432. 'axisLine', 'axisLabel', 'axisTick', 'axisName'
  41433. ];
  41434. var selfBuilderAttrs = [
  41435. 'splitLine', 'splitArea'
  41436. ];
  41437. __webpack_require__(1).extendComponentView({
  41438. type: 'radiusAxis',
  41439. render: function (radiusAxisModel, ecModel) {
  41440. this.group.removeAll();
  41441. if (!radiusAxisModel.get('show')) {
  41442. return;
  41443. }
  41444. var polarModel = ecModel.getComponent('polar', radiusAxisModel.get('polarIndex'));
  41445. var angleAxis = polarModel.coordinateSystem.getAngleAxis();
  41446. var radiusAxis = radiusAxisModel.axis;
  41447. var polar = polarModel.coordinateSystem;
  41448. var ticksCoords = radiusAxis.getTicksCoords();
  41449. var axisAngle = angleAxis.getExtent()[0];
  41450. var radiusExtent = radiusAxis.getExtent();
  41451. var layout = layoutAxis(polar, radiusAxisModel, axisAngle);
  41452. var axisBuilder = new AxisBuilder(radiusAxisModel, layout);
  41453. zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder);
  41454. this.group.add(axisBuilder.getGroup());
  41455. zrUtil.each(selfBuilderAttrs, function (name) {
  41456. if (radiusAxisModel.get(name +'.show')) {
  41457. this['_' + name](radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords);
  41458. }
  41459. }, this);
  41460. },
  41461. /**
  41462. * @private
  41463. */
  41464. _splitLine: function (radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords) {
  41465. var splitLineModel = radiusAxisModel.getModel('splitLine');
  41466. var lineStyleModel = splitLineModel.getModel('lineStyle');
  41467. var lineColors = lineStyleModel.get('color');
  41468. var lineCount = 0;
  41469. lineColors = lineColors instanceof Array ? lineColors : [lineColors];
  41470. var splitLines = [];
  41471. for (var i = 0; i < ticksCoords.length; i++) {
  41472. var colorIndex = (lineCount++) % lineColors.length;
  41473. splitLines[colorIndex] = splitLines[colorIndex] || [];
  41474. splitLines[colorIndex].push(new graphic.Circle({
  41475. shape: {
  41476. cx: polar.cx,
  41477. cy: polar.cy,
  41478. r: ticksCoords[i]
  41479. },
  41480. silent: true
  41481. }));
  41482. }
  41483. // Simple optimization
  41484. // Batching the lines if color are the same
  41485. for (var i = 0; i < splitLines.length; i++) {
  41486. this.group.add(graphic.mergePath(splitLines[i], {
  41487. style: zrUtil.defaults({
  41488. stroke: lineColors[i % lineColors.length],
  41489. fill: null
  41490. }, lineStyleModel.getLineStyle()),
  41491. silent: true
  41492. }));
  41493. }
  41494. },
  41495. /**
  41496. * @private
  41497. */
  41498. _splitArea: function (radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords) {
  41499. var splitAreaModel = radiusAxisModel.getModel('splitArea');
  41500. var areaStyleModel = splitAreaModel.getModel('areaStyle');
  41501. var areaColors = areaStyleModel.get('color');
  41502. var lineCount = 0;
  41503. areaColors = areaColors instanceof Array ? areaColors : [areaColors];
  41504. var splitAreas = [];
  41505. var prevRadius = ticksCoords[0];
  41506. for (var i = 1; i < ticksCoords.length; i++) {
  41507. var colorIndex = (lineCount++) % areaColors.length;
  41508. splitAreas[colorIndex] = splitAreas[colorIndex] || [];
  41509. splitAreas[colorIndex].push(new graphic.Sector({
  41510. shape: {
  41511. cx: polar.cx,
  41512. cy: polar.cy,
  41513. r0: prevRadius,
  41514. r: ticksCoords[i],
  41515. startAngle: 0,
  41516. endAngle: Math.PI * 2
  41517. },
  41518. silent: true
  41519. }));
  41520. prevRadius = ticksCoords[i];
  41521. }
  41522. // Simple optimization
  41523. // Batching the lines if color are the same
  41524. for (var i = 0; i < splitAreas.length; i++) {
  41525. this.group.add(graphic.mergePath(splitAreas[i], {
  41526. style: zrUtil.defaults({
  41527. fill: areaColors[i % areaColors.length]
  41528. }, areaStyleModel.getAreaStyle()),
  41529. silent: true
  41530. }));
  41531. }
  41532. }
  41533. });
  41534. /**
  41535. * @inner
  41536. */
  41537. function layoutAxis(polar, radiusAxisModel, axisAngle) {
  41538. return {
  41539. position: [polar.cx, polar.cy],
  41540. rotation: axisAngle / 180 * Math.PI,
  41541. labelDirection: -1,
  41542. tickDirection: -1,
  41543. nameDirection: 1,
  41544. labelRotation: radiusAxisModel.getModel('axisLabel').get('rotate'),
  41545. // Over splitLine and splitArea
  41546. z2: 1
  41547. };
  41548. }
  41549. /***/ },
  41550. /* 294 */
  41551. /***/ function(module, exports, __webpack_require__) {
  41552. __webpack_require__(295);
  41553. __webpack_require__(163);
  41554. __webpack_require__(296);
  41555. __webpack_require__(176);
  41556. var echarts = __webpack_require__(1);
  41557. var zrUtil = __webpack_require__(4);
  41558. function makeAction(method, actionInfo) {
  41559. actionInfo.update = 'updateView';
  41560. echarts.registerAction(actionInfo, function (payload, ecModel) {
  41561. var selected = {};
  41562. ecModel.eachComponent(
  41563. { mainType: 'geo', query: payload},
  41564. function (geoModel) {
  41565. geoModel[method](payload.name);
  41566. var geo = geoModel.coordinateSystem;
  41567. zrUtil.each(geo.regions, function (region) {
  41568. selected[region.name] = geoModel.isSelected(region.name) || false;
  41569. });
  41570. }
  41571. );
  41572. return {
  41573. selected: selected,
  41574. name: payload.name
  41575. }
  41576. });
  41577. }
  41578. makeAction('toggleSelected', {
  41579. type: 'geoToggleSelect',
  41580. event: 'geoselectchanged'
  41581. });
  41582. makeAction('select', {
  41583. type: 'geoSelect',
  41584. event: 'geoselected'
  41585. });
  41586. makeAction('unSelect', {
  41587. type: 'geoUnSelect',
  41588. event: 'geounselected'
  41589. });
  41590. /***/ },
  41591. /* 295 */
  41592. /***/ function(module, exports, __webpack_require__) {
  41593. 'use strict';
  41594. var modelUtil = __webpack_require__(5);
  41595. var ComponentModel = __webpack_require__(19);
  41596. var Model = __webpack_require__(12);
  41597. var zrUtil = __webpack_require__(4);
  41598. var selectableMixin = __webpack_require__(140);
  41599. var geoCreator = __webpack_require__(163);
  41600. var GeoModel = ComponentModel.extend({
  41601. type: 'geo',
  41602. /**
  41603. * @type {module:echarts/coord/geo/Geo}
  41604. */
  41605. coordinateSystem: null,
  41606. layoutMode: 'box',
  41607. init: function (option) {
  41608. ComponentModel.prototype.init.apply(this, arguments);
  41609. // Default label emphasis `position` and `show`
  41610. modelUtil.defaultEmphasis(
  41611. option.label, ['position', 'show', 'textStyle', 'distance', 'formatter']
  41612. );
  41613. },
  41614. optionUpdated: function () {
  41615. var option = this.option;
  41616. var self = this;
  41617. option.regions = geoCreator.getFilledRegions(option.regions, option.map);
  41618. this._optionModelMap = zrUtil.reduce(option.regions || [], function (obj, regionOpt) {
  41619. if (regionOpt.name) {
  41620. obj[regionOpt.name] = new Model(regionOpt, self);
  41621. }
  41622. return obj;
  41623. }, {});
  41624. this.updateSelectedMap(option.regions);
  41625. },
  41626. defaultOption: {
  41627. zlevel: 0,
  41628. z: 0,
  41629. show: true,
  41630. left: 'center',
  41631. top: 'center',
  41632. // width:,
  41633. // height:,
  41634. // right
  41635. // bottom
  41636. // Aspect is width / height. Inited to be geoJson bbox aspect
  41637. // This parameter is used for scale this aspect
  41638. aspectScale: 0.75,
  41639. ///// Layout with center and size
  41640. // If you wan't to put map in a fixed size box with right aspect ratio
  41641. // This two properties may more conveninet
  41642. // layoutCenter: [50%, 50%]
  41643. // layoutSize: 100
  41644. silent: false,
  41645. // Map type
  41646. map: '',
  41647. // Default on center of map
  41648. center: null,
  41649. zoom: 1,
  41650. scaleLimit: null,
  41651. // selectedMode: false
  41652. label: {
  41653. normal: {
  41654. show: false,
  41655. textStyle: {
  41656. color: '#000'
  41657. }
  41658. },
  41659. emphasis: {
  41660. show: true,
  41661. textStyle: {
  41662. color: 'rgb(100,0,0)'
  41663. }
  41664. }
  41665. },
  41666. itemStyle: {
  41667. normal: {
  41668. // color: 各异,
  41669. borderWidth: 0.5,
  41670. borderColor: '#444',
  41671. color: '#eee'
  41672. },
  41673. emphasis: { // 也是选中样式
  41674. color: 'rgba(255,215,0,0.8)'
  41675. }
  41676. },
  41677. regions: []
  41678. },
  41679. /**
  41680. * Get model of region
  41681. * @param {string} name
  41682. * @return {module:echarts/model/Model}
  41683. */
  41684. getRegionModel: function (name) {
  41685. return this._optionModelMap[name];
  41686. },
  41687. /**
  41688. * Format label
  41689. * @param {string} name Region name
  41690. * @param {string} [status='normal'] 'normal' or 'emphasis'
  41691. * @return {string}
  41692. */
  41693. getFormattedLabel: function (name, status) {
  41694. var formatter = this.get('label.' + status + '.formatter');
  41695. var params = {
  41696. name: name
  41697. };
  41698. if (typeof formatter === 'function') {
  41699. params.status = status;
  41700. return formatter(params);
  41701. }
  41702. else if (typeof formatter === 'string') {
  41703. return formatter.replace('{a}', params.seriesName);
  41704. }
  41705. },
  41706. setZoom: function (zoom) {
  41707. this.option.zoom = zoom;
  41708. },
  41709. setCenter: function (center) {
  41710. this.option.center = center;
  41711. }
  41712. });
  41713. zrUtil.mixin(GeoModel, selectableMixin);
  41714. module.exports = GeoModel;
  41715. /***/ },
  41716. /* 296 */
  41717. /***/ function(module, exports, __webpack_require__) {
  41718. 'use strict';
  41719. var MapDraw = __webpack_require__(173);
  41720. module.exports = __webpack_require__(1).extendComponentView({
  41721. type: 'geo',
  41722. init: function (ecModel, api) {
  41723. var mapDraw = new MapDraw(api, true);
  41724. this._mapDraw = mapDraw;
  41725. this.group.add(mapDraw.group);
  41726. },
  41727. render: function (geoModel, ecModel, api, payload) {
  41728. // Not render if it is an toggleSelect action from self
  41729. if (payload && payload.type === 'geoToggleSelect'
  41730. && payload.from === this.uid
  41731. ) {
  41732. return;
  41733. }
  41734. var mapDraw = this._mapDraw;
  41735. if (geoModel.get('show')) {
  41736. mapDraw.draw(geoModel, ecModel, api, this, payload);
  41737. }
  41738. else {
  41739. this._mapDraw.group.removeAll();
  41740. }
  41741. this.group.silent = geoModel.get('silent');
  41742. }
  41743. });
  41744. /***/ },
  41745. /* 297 */
  41746. /***/ function(module, exports, __webpack_require__) {
  41747. __webpack_require__(298);
  41748. __webpack_require__(301);
  41749. __webpack_require__(302);
  41750. var echarts = __webpack_require__(1);
  41751. echarts.extendComponentView({
  41752. type: 'single'
  41753. });
  41754. /***/ },
  41755. /* 298 */
  41756. /***/ function(module, exports, __webpack_require__) {
  41757. /**
  41758. * Single coordinate system creator.
  41759. */
  41760. var Single = __webpack_require__(299);
  41761. /**
  41762. * Create single coordinate system and inject it into seriesModel.
  41763. *
  41764. * @param {module:echarts/model/Global} ecModel
  41765. * @param {module:echarts/ExtensionAPI} api
  41766. * @return {Array.<module:echarts/coord/single/Single>}
  41767. */
  41768. function create(ecModel, api) {
  41769. var singles = [];
  41770. ecModel.eachComponent('singleAxis', function(axisModel, idx) {
  41771. var single = new Single(axisModel, ecModel, api);
  41772. single.name = 'single_' + idx;
  41773. single.resize(axisModel, api);
  41774. axisModel.coordinateSystem = single;
  41775. singles.push(single);
  41776. });
  41777. ecModel.eachSeries(function (seriesModel) {
  41778. if (seriesModel.get('coordinateSystem') === 'singleAxis') {
  41779. var singleAxisIndex = seriesModel.get('singleAxisIndex') || 0;
  41780. var axisModel = ecModel.getComponent('singleAxis', singleAxisIndex);
  41781. seriesModel.coordinateSystem = axisModel.coordinateSystem;
  41782. }
  41783. });
  41784. return singles;
  41785. }
  41786. __webpack_require__(26).register('single', {
  41787. create: create,
  41788. dimensions: Single.prototype.dimensions
  41789. });
  41790. /***/ },
  41791. /* 299 */
  41792. /***/ function(module, exports, __webpack_require__) {
  41793. /**
  41794. * Single coordinates system.
  41795. */
  41796. var SingleAxis = __webpack_require__(300);
  41797. var axisHelper = __webpack_require__(114);
  41798. var layout = __webpack_require__(21);
  41799. /**
  41800. * Create a single coordinates system.
  41801. *
  41802. * @param {module:echarts/coord/single/AxisModel} axisModel
  41803. * @param {module:echarts/model/Global} ecModel
  41804. * @param {module:echarts/ExtensionAPI} api
  41805. */
  41806. function Single(axisModel, ecModel, api) {
  41807. /**
  41808. * @type {string}
  41809. * @readOnly
  41810. */
  41811. this.dimension = 'x';
  41812. /**
  41813. * Add it just for draw tooltip.
  41814. *
  41815. * @type {Array.<string>}
  41816. * @readOnly
  41817. */
  41818. this.dimensions = ['x'];
  41819. /**
  41820. * @private
  41821. * @type {module:echarts/coord/single/SingleAxis}.
  41822. */
  41823. this._axis = null;
  41824. /**
  41825. * @private
  41826. * @type {module:zrender/core/BoundingRect}
  41827. */
  41828. this._rect;
  41829. this._init(axisModel, ecModel, api);
  41830. /**
  41831. * @type {module:echarts/coord/single/AxisModel}
  41832. */
  41833. this._model = axisModel;
  41834. }
  41835. Single.prototype = {
  41836. type: 'singleAxis',
  41837. constructor: Single,
  41838. /**
  41839. * Initialize single coordinate system.
  41840. *
  41841. * @param {module:echarts/coord/single/AxisModel} axisModel
  41842. * @param {module:echarts/model/Global} ecModel
  41843. * @param {module:echarts/ExtensionAPI} api
  41844. * @private
  41845. */
  41846. _init: function (axisModel, ecModel, api) {
  41847. var dim = this.dimension;
  41848. var axis = new SingleAxis(
  41849. dim,
  41850. axisHelper.createScaleByModel(axisModel),
  41851. [0, 0],
  41852. axisModel.get('type'),
  41853. axisModel.get('position')
  41854. );
  41855. var isCategory = axis.type === 'category';
  41856. axis.onBand = isCategory && axisModel.get('boundaryGap');
  41857. axis.inverse = axisModel.get('inverse');
  41858. axis.orient = axisModel.get('orient');
  41859. axisModel.axis = axis;
  41860. axis.model = axisModel;
  41861. this._axis = axis;
  41862. },
  41863. /**
  41864. * Update axis scale after data processed
  41865. * @param {module:echarts/model/Global} ecModel
  41866. * @param {module:echarts/ExtensionAPI} api
  41867. */
  41868. update: function (ecModel, api) {
  41869. this._updateAxisFromSeries(ecModel);
  41870. },
  41871. /**
  41872. * Update the axis extent from series.
  41873. *
  41874. * @param {module:echarts/model/Global} ecModel
  41875. * @private
  41876. */
  41877. _updateAxisFromSeries: function (ecModel) {
  41878. ecModel.eachSeries(function (seriesModel) {
  41879. var data = seriesModel.getData();
  41880. var dim = this.dimension;
  41881. this._axis.scale.unionExtent(
  41882. data.getDataExtent(seriesModel.coordDimToDataDim(dim))
  41883. );
  41884. axisHelper.niceScaleExtent(this._axis, this._axis.model);
  41885. }, this);
  41886. },
  41887. /**
  41888. * Resize the single coordinate system.
  41889. *
  41890. * @param {module:echarts/coord/single/AxisModel} axisModel
  41891. * @param {module:echarts/ExtensionAPI} api
  41892. */
  41893. resize: function (axisModel, api) {
  41894. this._rect = layout.getLayoutRect(
  41895. {
  41896. left: axisModel.get('left'),
  41897. top: axisModel.get('top'),
  41898. right: axisModel.get('right'),
  41899. bottom: axisModel.get('bottom'),
  41900. width: axisModel.get('width'),
  41901. height: axisModel.get('height')
  41902. },
  41903. {
  41904. width: api.getWidth(),
  41905. height: api.getHeight()
  41906. }
  41907. );
  41908. this._adjustAxis();
  41909. },
  41910. /**
  41911. * @return {module:zrender/core/BoundingRect}
  41912. */
  41913. getRect: function () {
  41914. return this._rect;
  41915. },
  41916. /**
  41917. * @private
  41918. */
  41919. _adjustAxis: function () {
  41920. var rect = this._rect;
  41921. var axis = this._axis;
  41922. var isHorizontal = axis.isHorizontal();
  41923. var extent = isHorizontal ? [0, rect.width] : [0, rect.height];
  41924. var idx = axis.reverse ? 1 : 0;
  41925. axis.setExtent(extent[idx], extent[1 - idx]);
  41926. this._updateAxisTransform(axis, isHorizontal ? rect.x : rect.y);
  41927. },
  41928. /**
  41929. * @param {module:echarts/coord/single/SingleAxis} axis
  41930. * @param {number} coordBase
  41931. */
  41932. _updateAxisTransform: function (axis, coordBase) {
  41933. var axisExtent = axis.getExtent();
  41934. var extentSum = axisExtent[0] + axisExtent[1];
  41935. var isHorizontal = axis.isHorizontal();
  41936. axis.toGlobalCoord = isHorizontal ?
  41937. function (coord) {
  41938. return coord + coordBase;
  41939. } :
  41940. function (coord) {
  41941. return extentSum - coord + coordBase;
  41942. };
  41943. axis.toLocalCoord = isHorizontal ?
  41944. function (coord) {
  41945. return coord - coordBase;
  41946. } :
  41947. function (coord) {
  41948. return extentSum - coord + coordBase;
  41949. };
  41950. },
  41951. /**
  41952. * Get axis.
  41953. *
  41954. * @return {module:echarts/coord/single/SingleAxis}
  41955. */
  41956. getAxis: function () {
  41957. return this._axis;
  41958. },
  41959. /**
  41960. * Get axis, add it just for draw tooltip.
  41961. *
  41962. * @return {[type]} [description]
  41963. */
  41964. getBaseAxis: function () {
  41965. return this._axis;
  41966. },
  41967. /**
  41968. * If contain point.
  41969. *
  41970. * @param {Array.<number>} point
  41971. * @return {boolean}
  41972. */
  41973. containPoint: function (point) {
  41974. var rect = this.getRect();
  41975. var axis = this.getAxis();
  41976. var orient = axis.orient;
  41977. if (orient === 'horizontal') {
  41978. return axis.contain(axis.toLocalCoord(point[0]))
  41979. && (point[1] >= rect.y && point[1] <= (rect.y + rect.height));
  41980. }
  41981. else {
  41982. return axis.contain(axis.toLocalCoord(point[1]))
  41983. && (point[0] >= rect.y && point[0] <= (rect.y + rect.height));
  41984. }
  41985. },
  41986. /**
  41987. * @param {Array.<number>} point
  41988. * @return {Array.<number>}
  41989. */
  41990. pointToData: function (point) {
  41991. var axis = this.getAxis();
  41992. return [axis.coordToData(axis.toLocalCoord(
  41993. point[axis.orient === 'horizontal' ? 0 : 1]
  41994. ))];
  41995. },
  41996. /**
  41997. * Convert the series data to concrete point.
  41998. *
  41999. * @param {number|Array.<number>} val
  42000. * @return {Array.<number>}
  42001. */
  42002. dataToPoint: function (val) {
  42003. var axis = this.getAxis();
  42004. var rect = this.getRect();
  42005. var pt = [];
  42006. var idx = axis.orient === 'horizontal' ? 0 : 1;
  42007. pt[idx] = axis.toGlobalCoord(axis.dataToCoord(+val));
  42008. pt[1 - idx] = idx === 0 ? (rect.y + rect.height / 2) : (rect.x + rect.width / 2);
  42009. return pt;
  42010. }
  42011. };
  42012. module.exports = Single;
  42013. /***/ },
  42014. /* 300 */
  42015. /***/ function(module, exports, __webpack_require__) {
  42016. var zrUtil = __webpack_require__(4);
  42017. var Axis = __webpack_require__(123);
  42018. var axisHelper = __webpack_require__(114);
  42019. /**
  42020. * @constructor module:echarts/coord/single/SingleAxis
  42021. * @extends {module:echarts/coord/Axis}
  42022. * @param {string} dim
  42023. * @param {*} scale
  42024. * @param {Array.<number>} coordExtent
  42025. * @param {string} axisType
  42026. * @param {string} position
  42027. */
  42028. var SingleAxis = function (dim, scale, coordExtent, axisType, position) {
  42029. Axis.call(this, dim, scale, coordExtent);
  42030. /**
  42031. * Axis type
  42032. * - 'category'
  42033. * - 'value'
  42034. * - 'time'
  42035. * - 'log'
  42036. * @type {string}
  42037. */
  42038. this.type = axisType || 'value';
  42039. /**
  42040. * Axis position
  42041. * - 'top'
  42042. * - 'bottom'
  42043. * - 'left'
  42044. * - 'right'
  42045. * @type {string}
  42046. */
  42047. this.position = position || 'bottom';
  42048. /**
  42049. * Axis orient
  42050. * - 'horizontal'
  42051. * - 'vertical'
  42052. * @type {[type]}
  42053. */
  42054. this.orient = null;
  42055. /**
  42056. * @type {number}
  42057. */
  42058. this._labelInterval = null;
  42059. };
  42060. SingleAxis.prototype = {
  42061. constructor: SingleAxis,
  42062. /**
  42063. * Axis model
  42064. * @type {module:echarts/coord/single/AxisModel}
  42065. */
  42066. model: null,
  42067. /**
  42068. * Judge the orient of the axis.
  42069. * @return {boolean}
  42070. */
  42071. isHorizontal: function () {
  42072. var position = this.position;
  42073. return position === 'top' || position === 'bottom';
  42074. },
  42075. /**
  42076. * Get interval of the axis label.
  42077. * @return {number}
  42078. */
  42079. getLabelInterval: function () {
  42080. var labelInterval = this._labelInterval;
  42081. if (!labelInterval) {
  42082. var axisModel = this.model;
  42083. var labelModel = axisModel.getModel('axisLabel');
  42084. var interval = labelModel.get('interval');
  42085. if (!(this.type === 'category' && interval === 'auto')) {
  42086. labelInterval = this._labelInterval = interval === 'auto' ? 0 : interval;
  42087. return labelInterval;
  42088. }
  42089. labelInterval = this._labelInterval =
  42090. axisHelper.getAxisLabelInterval(
  42091. zrUtil.map(this.scale.getTicks(), this.dataToCoord, this),
  42092. axisModel.getFormattedLabels(),
  42093. labelModel.getModel('textStyle').getFont(),
  42094. this.isHorizontal()
  42095. );
  42096. }
  42097. return labelInterval;
  42098. },
  42099. /**
  42100. * Convert the local coord(processed by dataToCoord())
  42101. * to global coord(concrete pixel coord).
  42102. * designated by module:echarts/coord/single/Single.
  42103. * @type {Function}
  42104. */
  42105. toGlobalCoord: null,
  42106. /**
  42107. * Convert the global coord to local coord.
  42108. * designated by module:echarts/coord/single/Single.
  42109. * @type {Function}
  42110. */
  42111. toLocalCoord: null
  42112. };
  42113. zrUtil.inherits(SingleAxis, Axis);
  42114. module.exports = SingleAxis;
  42115. /***/ },
  42116. /* 301 */
  42117. /***/ function(module, exports, __webpack_require__) {
  42118. var AxisBuilder = __webpack_require__(132);
  42119. var zrUtil = __webpack_require__(4);
  42120. var graphic = __webpack_require__(43);
  42121. var getInterval = AxisBuilder.getInterval;
  42122. var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick;
  42123. var axisBuilderAttrs = [
  42124. 'axisLine', 'axisLabel', 'axisTick', 'axisName'
  42125. ];
  42126. var selfBuilderAttr = 'splitLine';
  42127. var AxisView = __webpack_require__(1).extendComponentView({
  42128. type: 'singleAxis',
  42129. render: function (axisModel, ecModel) {
  42130. var group = this.group;
  42131. group.removeAll();
  42132. var layout = axisLayout(axisModel);
  42133. var axisBuilder = new AxisBuilder(axisModel, layout);
  42134. zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder);
  42135. group.add(axisBuilder.getGroup());
  42136. if (axisModel.get(selfBuilderAttr + '.show')) {
  42137. this['_' + selfBuilderAttr](axisModel, layout.labelInterval);
  42138. }
  42139. },
  42140. _splitLine: function(axisModel, labelInterval) {
  42141. var axis = axisModel.axis;
  42142. var splitLineModel = axisModel.getModel('splitLine');
  42143. var lineStyleModel = splitLineModel.getModel('lineStyle');
  42144. var lineWidth = lineStyleModel.get('width');
  42145. var lineColors = lineStyleModel.get('color');
  42146. var lineInterval = getInterval(splitLineModel, labelInterval);
  42147. lineColors = lineColors instanceof Array ? lineColors : [lineColors];
  42148. var gridRect = axisModel.coordinateSystem.getRect();
  42149. var isHorizontal = axis.isHorizontal();
  42150. var splitLines = [];
  42151. var lineCount = 0;
  42152. var ticksCoords = axis.getTicksCoords();
  42153. var p1 = [];
  42154. var p2 = [];
  42155. for (var i = 0; i < ticksCoords.length; ++i) {
  42156. if (ifIgnoreOnTick(axis, i, lineInterval)) {
  42157. continue;
  42158. }
  42159. var tickCoord = axis.toGlobalCoord(ticksCoords[i]);
  42160. if (isHorizontal) {
  42161. p1[0] = tickCoord;
  42162. p1[1] = gridRect.y;
  42163. p2[0] = tickCoord;
  42164. p2[1] = gridRect.y + gridRect.height;
  42165. }
  42166. else {
  42167. p1[0] = gridRect.x;
  42168. p1[1] = tickCoord;
  42169. p2[0] = gridRect.x + gridRect.width;
  42170. p2[1] = tickCoord;
  42171. }
  42172. var colorIndex = (lineCount++) % lineColors.length;
  42173. splitLines[colorIndex] = splitLines[colorIndex] || [];
  42174. splitLines[colorIndex].push(new graphic.Line(
  42175. graphic.subPixelOptimizeLine({
  42176. shape: {
  42177. x1: p1[0],
  42178. y1: p1[1],
  42179. x2: p2[0],
  42180. y2: p2[1]
  42181. },
  42182. style: {
  42183. lineWidth: lineWidth
  42184. },
  42185. silent: true
  42186. })));
  42187. }
  42188. for (var i = 0; i < splitLines.length; ++i) {
  42189. this.group.add(graphic.mergePath(splitLines[i], {
  42190. style: {
  42191. stroke: lineColors[i % lineColors.length],
  42192. lineDash: lineStyleModel.getLineDash(),
  42193. lineWidth: lineWidth
  42194. },
  42195. silent: true
  42196. }));
  42197. }
  42198. }
  42199. });
  42200. function axisLayout(axisModel) {
  42201. var single = axisModel.coordinateSystem;
  42202. var axis = axisModel.axis;
  42203. var layout = {};
  42204. var axisPosition = axis.position;
  42205. var orient = axis.orient;
  42206. var rect = single.getRect();
  42207. var rectBound = [rect.x, rect.x + rect.width, rect.y, rect.y + rect.height];
  42208. var positionMap = {
  42209. horizontal: {top: rectBound[2], bottom: rectBound[3]},
  42210. vertical: {left: rectBound[0], right: rectBound[1]}
  42211. };
  42212. layout.position = [
  42213. orient === 'vertical'
  42214. ? positionMap.vertical[axisPosition]
  42215. : rectBound[0],
  42216. orient === 'horizontal'
  42217. ? positionMap.horizontal[axisPosition]
  42218. : rectBound[3]
  42219. ];
  42220. var r = {horizontal: 0, vertical: 1};
  42221. layout.rotation = Math.PI / 2 * r[orient];
  42222. var directionMap = {top: -1, bottom: 1, right: 1, left: -1};
  42223. layout.labelDirection = layout.tickDirection
  42224. = layout.nameDirection
  42225. = directionMap[axisPosition];
  42226. if (axisModel.getModel('axisTick').get('inside')) {
  42227. layout.tickDirection = -layout.tickDirection;
  42228. }
  42229. if (axisModel.getModel('axisLabel').get('inside')) {
  42230. layout.labelDirection = -layout.labelDirection;
  42231. }
  42232. var labelRotation = axisModel.getModel('axisLabel').get('rotate');
  42233. layout.labelRotation = axisPosition === 'top' ? -labelRotation : labelRotation;
  42234. layout.labelInterval = axis.getLabelInterval();
  42235. layout.z2 = 1;
  42236. return layout;
  42237. }
  42238. module.exports = AxisView;
  42239. /***/ },
  42240. /* 302 */
  42241. /***/ function(module, exports, __webpack_require__) {
  42242. var ComponentModel = __webpack_require__(19);
  42243. var axisModelCreator = __webpack_require__(127);
  42244. var zrUtil = __webpack_require__(4);
  42245. var AxisModel = ComponentModel.extend({
  42246. type: 'singleAxis',
  42247. layoutMode: 'box',
  42248. /**
  42249. * @type {module:echarts/coord/single/SingleAxis}
  42250. */
  42251. axis: null,
  42252. /**
  42253. * @type {module:echarts/coord/single/Single}
  42254. */
  42255. coordinateSystem: null
  42256. });
  42257. var defaultOption = {
  42258. left: '5%',
  42259. top: '5%',
  42260. right: '5%',
  42261. bottom: '5%',
  42262. type: 'value',
  42263. position: 'bottom',
  42264. orient: 'horizontal',
  42265. axisLine: {
  42266. show: true,
  42267. lineStyle: {
  42268. width: 2,
  42269. type: 'solid'
  42270. }
  42271. },
  42272. axisTick: {
  42273. show: true,
  42274. length: 6,
  42275. lineStyle: {
  42276. width: 2
  42277. }
  42278. },
  42279. axisLabel: {
  42280. show: true,
  42281. interval: 'auto'
  42282. },
  42283. splitLine: {
  42284. show: true,
  42285. lineStyle: {
  42286. type: 'dashed',
  42287. opacity: 0.2
  42288. }
  42289. }
  42290. };
  42291. function getAxisType(axisName, option) {
  42292. return option.type || (option.data ? 'category' : 'value');
  42293. }
  42294. zrUtil.merge(AxisModel.prototype, __webpack_require__(129));
  42295. axisModelCreator('single', AxisModel, getAxisType, defaultOption);
  42296. module.exports = AxisModel;
  42297. /***/ },
  42298. /* 303 */
  42299. /***/ function(module, exports, __webpack_require__) {
  42300. /**
  42301. * Brush component entry
  42302. */
  42303. __webpack_require__(1).registerPreprocessor(
  42304. __webpack_require__(304)
  42305. );
  42306. __webpack_require__(305);
  42307. __webpack_require__(310);
  42308. __webpack_require__(311);
  42309. __webpack_require__(312);
  42310. __webpack_require__(313);
  42311. /***/ },
  42312. /* 304 */
  42313. /***/ function(module, exports, __webpack_require__) {
  42314. /**
  42315. * @file brush preprocessor
  42316. */
  42317. var zrUtil = __webpack_require__(4);
  42318. var DEFAULT_TOOLBOX_BTNS = ['rect', 'polygon', 'keep', 'clear'];
  42319. module.exports = function (option, isNew) {
  42320. var brushComponents = option && option.brush;
  42321. if (!zrUtil.isArray(brushComponents)) {
  42322. brushComponents = brushComponents ? [brushComponents] : [];
  42323. }
  42324. if (!brushComponents.length) {
  42325. return;
  42326. }
  42327. var brushComponentSpecifiedBtns = [];
  42328. zrUtil.each(brushComponents, function (brushOpt) {
  42329. var tbs = brushOpt.hasOwnProperty('toolbox')
  42330. ? brushOpt.toolbox : [];
  42331. if (tbs instanceof Array) {
  42332. brushComponentSpecifiedBtns = brushComponentSpecifiedBtns.concat(tbs);
  42333. }
  42334. });
  42335. var toolbox = option && option.toolbox;
  42336. if (zrUtil.isArray(toolbox)) {
  42337. toolbox = toolbox[0];
  42338. }
  42339. if (!toolbox) {
  42340. toolbox = {feature: {}};
  42341. option.toolbox = [toolbox];
  42342. }
  42343. var toolboxFeature = (toolbox.feature || (toolbox.feature = {}));
  42344. var toolboxBrush = toolboxFeature.brush || (toolboxFeature.brush = {});
  42345. var brushTypes = toolboxBrush.type || (toolboxBrush.type = []);
  42346. brushTypes.push.apply(brushTypes, brushComponentSpecifiedBtns);
  42347. removeDuplicate(brushTypes);
  42348. if (isNew && !brushTypes.length) {
  42349. brushTypes.push.apply(brushTypes, DEFAULT_TOOLBOX_BTNS);
  42350. }
  42351. };
  42352. function removeDuplicate(arr) {
  42353. var map = {};
  42354. zrUtil.each(arr, function (val) {
  42355. map[val] = 1;
  42356. });
  42357. arr.length = 0;
  42358. zrUtil.each(map, function (flag, val) {
  42359. arr.push(val);
  42360. });
  42361. }
  42362. /***/ },
  42363. /* 305 */
  42364. /***/ function(module, exports, __webpack_require__) {
  42365. /**
  42366. * @file Brush visual coding.
  42367. */
  42368. var echarts = __webpack_require__(1);
  42369. var visualSolution = __webpack_require__(306);
  42370. var zrUtil = __webpack_require__(4);
  42371. var BoundingRect = __webpack_require__(9);
  42372. var selector = __webpack_require__(307);
  42373. var throttle = __webpack_require__(308);
  42374. var brushHelper = __webpack_require__(309);
  42375. var STATE_LIST = ['inBrush', 'outOfBrush'];
  42376. var DISPATCH_METHOD = '__ecBrushSelect';
  42377. var DISPATCH_FLAG = '__ecInBrushSelectEvent';
  42378. var PRIORITY_BRUSH = echarts.PRIORITY.VISUAL.BRUSH;
  42379. /**
  42380. * Layout for visual, the priority higher than other layout, and before brush visual.
  42381. */
  42382. echarts.registerLayout(PRIORITY_BRUSH, function (ecModel, api, payload) {
  42383. ecModel.eachComponent({mainType: 'brush'}, function (brushModel) {
  42384. payload && payload.type === 'takeGlobalCursor' && brushModel.setBrushOption(
  42385. payload.key === 'brush' ? payload.brushOption : {brushType: false}
  42386. );
  42387. brushModel.coordInfoList = brushHelper.makeCoordInfoList(brushModel.option, ecModel);
  42388. brushHelper.parseInputRanges(brushModel, ecModel);
  42389. });
  42390. });
  42391. /**
  42392. * Register the visual encoding if this modules required.
  42393. */
  42394. echarts.registerVisual(PRIORITY_BRUSH, function (ecModel, api, payload) {
  42395. var brushSelected = [];
  42396. var throttleType;
  42397. var throttleDelay;
  42398. ecModel.eachComponent({mainType: 'brush'}, function (brushModel, brushIndex) {
  42399. var thisBrushSelected = {
  42400. brushId: brushModel.id,
  42401. brushIndex: brushIndex,
  42402. brushName: brushModel.name,
  42403. areas: zrUtil.clone(brushModel.areas),
  42404. selected: []
  42405. };
  42406. // Every brush component exists in event params, convenient
  42407. // for user to find by index.
  42408. brushSelected.push(thisBrushSelected);
  42409. var brushOption = brushModel.option;
  42410. var brushLink = brushOption.brushLink;
  42411. var linkedSeriesMap = [];
  42412. var selectedDataIndexForLink = [];
  42413. var rangeInfoBySeries = [];
  42414. var hasBrushExists = 0;
  42415. if (!brushIndex) { // Only the first throttle setting works.
  42416. throttleType = brushOption.throttleType;
  42417. throttleDelay = brushOption.throttleDelay;
  42418. }
  42419. // Add boundingRect and selectors to range.
  42420. var areas = zrUtil.map(brushModel.areas, function (area) {
  42421. return bindSelector(
  42422. zrUtil.defaults(
  42423. {boundingRect: boundingRectBuilders[area.brushType](area)},
  42424. area
  42425. )
  42426. );
  42427. });
  42428. var visualMappings = visualSolution.createVisualMappings(
  42429. brushModel.option, STATE_LIST, function (mappingOption) {
  42430. mappingOption.mappingMethod = 'fixed';
  42431. }
  42432. );
  42433. zrUtil.isArray(brushLink) && zrUtil.each(brushLink, function (seriesIndex) {
  42434. linkedSeriesMap[seriesIndex] = 1;
  42435. });
  42436. function linkOthers(seriesIndex) {
  42437. return brushLink === 'all' || linkedSeriesMap[seriesIndex];
  42438. }
  42439. // If no supported brush or no brush on the series,
  42440. // all visuals should be in original state.
  42441. function brushed(rangeInfoList) {
  42442. return !!rangeInfoList.length;
  42443. }
  42444. /**
  42445. * Logic for each series: (If the logic has to be modified one day, do it carefully!)
  42446. *
  42447. * ( brushed ┬ && ┬hasBrushExist ┬ && linkOthers ) => StepA: ┬record, ┬ StepB: ┬visualByRecord.
  42448. * !brushed┘ ├hasBrushExist ┤ └nothing,┘ ├visualByRecord.
  42449. * └!hasBrushExist┘ └nothing.
  42450. * ( !brushed && ┬hasBrushExist ┬ && linkOthers ) => StepA: nothing, StepB: ┬visualByRecord.
  42451. * └!hasBrushExist┘ └nothing.
  42452. * ( brushed ┬ && !linkOthers ) => StepA: nothing, StepB: ┬visualByCheck.
  42453. * !brushed┘ └nothing.
  42454. * ( !brushed && !linkOthers ) => StepA: nothing, StepB: nothing.
  42455. */
  42456. // Step A
  42457. ecModel.eachSeries(function (seriesModel, seriesIndex) {
  42458. var rangeInfoList = rangeInfoBySeries[seriesIndex] = [];
  42459. seriesModel.subType === 'parallel'
  42460. ? stepAParallel(seriesModel, seriesIndex, rangeInfoList)
  42461. : stepAOthers(seriesModel, seriesIndex, rangeInfoList);
  42462. });
  42463. function stepAParallel(seriesModel, seriesIndex) {
  42464. var coordSys = seriesModel.coordinateSystem;
  42465. hasBrushExists |= coordSys.hasAxisbrushed();
  42466. linkOthers(seriesIndex) && coordSys.eachActiveState(
  42467. seriesModel.getData(),
  42468. function (activeState, dataIndex) {
  42469. activeState === 'active' && (selectedDataIndexForLink[dataIndex] = 1);
  42470. }
  42471. );
  42472. }
  42473. function stepAOthers(seriesModel, seriesIndex, rangeInfoList) {
  42474. var selectorsByBrushType = getSelectorsByBrushType(seriesModel);
  42475. if (!selectorsByBrushType || brushModelNotControll(brushModel, seriesIndex)) {
  42476. return;
  42477. }
  42478. zrUtil.each(areas, function (area) {
  42479. selectorsByBrushType[area.brushType]
  42480. && brushHelper.controlSeries(area, brushModel, seriesModel)
  42481. && rangeInfoList.push(area);
  42482. hasBrushExists |= brushed(rangeInfoList);
  42483. });
  42484. if (linkOthers(seriesIndex) && brushed(rangeInfoList)) {
  42485. var data = seriesModel.getData();
  42486. data.each(function (dataIndex) {
  42487. if (checkInRange(selectorsByBrushType, rangeInfoList, data, dataIndex)) {
  42488. selectedDataIndexForLink[dataIndex] = 1;
  42489. }
  42490. });
  42491. }
  42492. }
  42493. // Step B
  42494. ecModel.eachSeries(function (seriesModel, seriesIndex) {
  42495. var seriesBrushSelected = {
  42496. seriesId: seriesModel.id,
  42497. seriesIndex: seriesIndex,
  42498. seriesName: seriesModel.name,
  42499. dataIndex: []
  42500. };
  42501. // Every series exists in event params, convenient
  42502. // for user to find series by seriesIndex.
  42503. thisBrushSelected.selected.push(seriesBrushSelected);
  42504. var selectorsByBrushType = getSelectorsByBrushType(seriesModel);
  42505. var rangeInfoList = rangeInfoBySeries[seriesIndex];
  42506. var data = seriesModel.getData();
  42507. var getValueState = linkOthers(seriesIndex)
  42508. ? function (dataIndex) {
  42509. return selectedDataIndexForLink[dataIndex]
  42510. ? (seriesBrushSelected.dataIndex.push(data.getRawIndex(dataIndex)), 'inBrush')
  42511. : 'outOfBrush';
  42512. }
  42513. : function (dataIndex) {
  42514. return checkInRange(selectorsByBrushType, rangeInfoList, data, dataIndex)
  42515. ? (seriesBrushSelected.dataIndex.push(data.getRawIndex(dataIndex)), 'inBrush')
  42516. : 'outOfBrush';
  42517. };
  42518. // If no supported brush or no brush, all visuals are in original state.
  42519. (linkOthers(seriesIndex) ? hasBrushExists : brushed(rangeInfoList))
  42520. && visualSolution.applyVisual(
  42521. STATE_LIST, visualMappings, data, getValueState
  42522. );
  42523. });
  42524. });
  42525. dispatchAction(api, throttleType, throttleDelay, brushSelected, payload);
  42526. });
  42527. function dispatchAction(api, throttleType, throttleDelay, brushSelected, payload) {
  42528. // This event will not be triggered when `setOpion`, otherwise dead lock may
  42529. // triggered when do `setOption` in event listener, which we do not find
  42530. // satisfactory way to solve yet. Some considered resolutions:
  42531. // (a) Diff with prevoius selected data ant only trigger event when changed.
  42532. // But store previous data and diff precisely (i.e., not only by dataIndex, but
  42533. // also detect value changes in selected data) might bring complexity or fragility.
  42534. // (b) Use spectial param like `silent` to suppress event triggering.
  42535. // But such kind of volatile param may be weird in `setOption`.
  42536. if (!payload) {
  42537. return;
  42538. }
  42539. var zr = api.getZr();
  42540. if (zr[DISPATCH_FLAG]) {
  42541. return;
  42542. }
  42543. if (!zr[DISPATCH_METHOD]) {
  42544. zr[DISPATCH_METHOD] = doDispatch;
  42545. }
  42546. var fn = throttle.createOrUpdate(zr, DISPATCH_METHOD, throttleDelay, throttleType);
  42547. fn(api, brushSelected);
  42548. }
  42549. function doDispatch(api, brushSelected) {
  42550. if (!api.isDisposed()) {
  42551. var zr = api.getZr();
  42552. zr[DISPATCH_FLAG] = true;
  42553. api.dispatchAction({
  42554. type: 'brushSelect',
  42555. batch: brushSelected
  42556. });
  42557. zr[DISPATCH_FLAG] = false;
  42558. }
  42559. }
  42560. function checkInRange(selectorsByBrushType, rangeInfoList, data, dataIndex) {
  42561. var itemLayout = data.getItemLayout(dataIndex);
  42562. for (var i = 0, len = rangeInfoList.length; i < len; i++) {
  42563. var area = rangeInfoList[i];
  42564. if (selectorsByBrushType[area.brushType](
  42565. itemLayout, area.selectors, area
  42566. )) {
  42567. return true;
  42568. }
  42569. }
  42570. }
  42571. function getSelectorsByBrushType(seriesModel) {
  42572. var brushSelector = seriesModel.brushSelector;
  42573. if (zrUtil.isString(brushSelector)) {
  42574. var sels = [];
  42575. zrUtil.each(selector, function (selectorsByElementType, brushType) {
  42576. sels[brushType] = selectorsByElementType[brushSelector];
  42577. });
  42578. return sels;
  42579. }
  42580. else if (zrUtil.isFunction(brushSelector)) {
  42581. var bSelector = {};
  42582. zrUtil.each(selector, function (sel, brushType) {
  42583. bSelector[brushType] = brushSelector;
  42584. });
  42585. return bSelector;
  42586. }
  42587. return brushSelector;
  42588. }
  42589. function brushModelNotControll(brushModel, seriesIndex) {
  42590. var seriesIndices = brushModel.option.seriesIndex;
  42591. return seriesIndices != null
  42592. && seriesIndices !== 'all'
  42593. && (
  42594. zrUtil.isArray(seriesIndices)
  42595. ? zrUtil.indexOf(seriesIndices, seriesIndex) < 0
  42596. : seriesIndex !== seriesIndices
  42597. );
  42598. }
  42599. function bindSelector(area) {
  42600. var selectors = area.selectors = {};
  42601. zrUtil.each(selector[area.brushType], function (selFn, elType) {
  42602. // Do not use function binding or curry for performance.
  42603. selectors[elType] = function (itemLayout) {
  42604. return selFn(itemLayout, selectors, area);
  42605. };
  42606. });
  42607. return area;
  42608. }
  42609. var boundingRectBuilders = {
  42610. lineX: zrUtil.noop,
  42611. lineY: zrUtil.noop,
  42612. rect: function (area) {
  42613. return getBoundingRectFromMinMax(area.range);
  42614. },
  42615. polygon: function (area) {
  42616. var minMax;
  42617. var range = area.range;
  42618. for (var i = 0, len = range.length; i < len; i++) {
  42619. minMax = minMax || [[Infinity, -Infinity], [Infinity, -Infinity]];
  42620. var rg = range[i];
  42621. rg[0] < minMax[0][0] && (minMax[0][0] = rg[0]);
  42622. rg[0] > minMax[0][1] && (minMax[0][1] = rg[0]);
  42623. rg[1] < minMax[1][0] && (minMax[1][0] = rg[1]);
  42624. rg[1] > minMax[1][1] && (minMax[1][1] = rg[1]);
  42625. }
  42626. return minMax && getBoundingRectFromMinMax(minMax);
  42627. }
  42628. };
  42629. function getBoundingRectFromMinMax(minMax) {
  42630. return new BoundingRect(
  42631. minMax[0][0],
  42632. minMax[1][0],
  42633. minMax[0][1] - minMax[0][0],
  42634. minMax[1][1] - minMax[1][0]
  42635. );
  42636. }
  42637. /***/ },
  42638. /* 306 */
  42639. /***/ function(module, exports, __webpack_require__) {
  42640. /**
  42641. * @file Visual solution, for consistent option specification.
  42642. */
  42643. var zrUtil = __webpack_require__(4);
  42644. var VisualMapping = __webpack_require__(192);
  42645. var each = zrUtil.each;
  42646. function hasKeys(obj) {
  42647. if (obj) {
  42648. for (var name in obj){
  42649. if (obj.hasOwnProperty(name)) {
  42650. return true;
  42651. }
  42652. }
  42653. }
  42654. }
  42655. var visualSolution = {
  42656. /**
  42657. * @param {Object} option
  42658. * @param {Array.<string>} stateList
  42659. * @param {Function} [supplementVisualOption]
  42660. * @return {Object} visualMappings <state, <visualType, module:echarts/visual/VisualMapping>>
  42661. */
  42662. createVisualMappings: function (option, stateList, supplementVisualOption) {
  42663. var visualMappings = {};
  42664. each(stateList, function (state) {
  42665. var mappings = visualMappings[state] = createMappings();
  42666. each(option[state], function (visualData, visualType) {
  42667. if (!VisualMapping.isValidType(visualType)) {
  42668. return;
  42669. }
  42670. var mappingOption = {
  42671. type: visualType,
  42672. visual: visualData
  42673. };
  42674. supplementVisualOption && supplementVisualOption(mappingOption, state);
  42675. mappings[visualType] = new VisualMapping(mappingOption);
  42676. // Prepare a alpha for opacity, for some case that opacity
  42677. // is not supported, such as rendering using gradient color.
  42678. if (visualType === 'opacity') {
  42679. mappingOption = zrUtil.clone(mappingOption);
  42680. mappingOption.type = 'colorAlpha';
  42681. mappings.__hidden.__alphaForOpacity = new VisualMapping(mappingOption);
  42682. }
  42683. });
  42684. });
  42685. return visualMappings;
  42686. function createMappings() {
  42687. var Creater = function () {};
  42688. // Make sure hidden fields will not be visited by
  42689. // object iteration (with hasOwnProperty checking).
  42690. Creater.prototype.__hidden = Creater.prototype;
  42691. var obj = new Creater();
  42692. return obj;
  42693. }
  42694. },
  42695. /**
  42696. * @param {Object} thisOption
  42697. * @param {Object} newOption
  42698. * @param {Array.<string>} keys
  42699. */
  42700. replaceVisualOption: function (thisOption, newOption, keys) {
  42701. // Visual attributes merge is not supported, otherwise it
  42702. // brings overcomplicated merge logic. See #2853. So if
  42703. // newOption has anyone of these keys, all of these keys
  42704. // will be reset. Otherwise, all keys remain.
  42705. var has;
  42706. zrUtil.each(keys, function (key) {
  42707. if (newOption.hasOwnProperty(key) && hasKeys(newOption[key])) {
  42708. has = true;
  42709. }
  42710. });
  42711. has && zrUtil.each(keys, function (key) {
  42712. if (newOption.hasOwnProperty(key) && hasKeys(newOption[key])) {
  42713. thisOption[key] = zrUtil.clone(newOption[key]);
  42714. }
  42715. else {
  42716. delete thisOption[key];
  42717. }
  42718. });
  42719. },
  42720. /**
  42721. * @param {Array.<string>} stateList
  42722. * @param {Object} visualMappings <state, Object.<visualType, module:echarts/visual/VisualMapping>>
  42723. * @param {module:echarts/data/List} list
  42724. * @param {Function} getValueState param: valueOrIndex, return: state.
  42725. * @param {object} [scope] Scope for getValueState
  42726. * @param {string} [dimension] Concrete dimension, if used.
  42727. */
  42728. applyVisual: function (stateList, visualMappings, data, getValueState, scope, dimension) {
  42729. var visualTypesMap = {};
  42730. zrUtil.each(stateList, function (state) {
  42731. var visualTypes = VisualMapping.prepareVisualTypes(visualMappings[state]);
  42732. visualTypesMap[state] = visualTypes;
  42733. });
  42734. var dataIndex;
  42735. function getVisual(key) {
  42736. return data.getItemVisual(dataIndex, key);
  42737. }
  42738. function setVisual(key, value) {
  42739. data.setItemVisual(dataIndex, key, value);
  42740. }
  42741. if (dimension == null) {
  42742. data.each(eachItem, true);
  42743. }
  42744. else {
  42745. data.each([dimension], eachItem, true);
  42746. }
  42747. function eachItem(valueOrIndex, index) {
  42748. dataIndex = dimension == null ? valueOrIndex : index;
  42749. var valueState = getValueState.call(scope, valueOrIndex);
  42750. var mappings = visualMappings[valueState];
  42751. var visualTypes = visualTypesMap[valueState];
  42752. for (var i = 0, len = visualTypes.length; i < len; i++) {
  42753. var type = visualTypes[i];
  42754. mappings[type] && mappings[type].applyVisual(
  42755. valueOrIndex, getVisual, setVisual
  42756. );
  42757. }
  42758. }
  42759. }
  42760. };
  42761. module.exports = visualSolution;
  42762. /***/ },
  42763. /* 307 */
  42764. /***/ function(module, exports, __webpack_require__) {
  42765. var polygonContain = __webpack_require__(167).contain;
  42766. var BoundingRect = __webpack_require__(9);
  42767. // Key of the first level is brushType: `line`, `rect`, `polygon`.
  42768. // Key of the second level is chart element type: `point`, `rect`.
  42769. // See moudule:echarts/component/helper/BrushController
  42770. // function param:
  42771. // {Object} itemLayout fetch from data.getItemLayout(dataIndex)
  42772. // {Object} selectors {point: selector, rect: selector, ...}
  42773. // {Object} area {range: [[], [], ..], boudingRect}
  42774. // function return:
  42775. // {boolean} Whether in the given brush.
  42776. var selector = {
  42777. lineX: getLineSelectors(0),
  42778. lineY: getLineSelectors(1),
  42779. rect: {
  42780. point: function (itemLayout, selectors, area) {
  42781. return area.boundingRect.contain(itemLayout[0], itemLayout[1]);
  42782. },
  42783. rect: function (itemLayout, selectors, area) {
  42784. return area.boundingRect.intersect(makeBoundingRect(itemLayout));
  42785. }
  42786. },
  42787. polygon: {
  42788. point: function (itemLayout, selectors, area) {
  42789. return area.boundingRect.contain(itemLayout[0], itemLayout[1])
  42790. && polygonContain(area.range, itemLayout[0], itemLayout[1]);
  42791. },
  42792. rect: function (itemLayout, selectors, area) {
  42793. // FIXME
  42794. // 随意写的,没有考察过效率。
  42795. var points = area.range;
  42796. if (points.length <= 1) {
  42797. return false;
  42798. }
  42799. var x = itemLayout.x;
  42800. var y = itemLayout.y;
  42801. var width = itemLayout.width;
  42802. var height = itemLayout.height;
  42803. var p = points[0];
  42804. if (polygonContain(points, x, y)
  42805. || polygonContain(points, x + width, y)
  42806. || polygonContain(points, x, y + height)
  42807. || polygonContain(points, x + width, y + height)
  42808. || makeBoundingRect(itemLayout).contain(p[0], p[1])
  42809. || lineIntersectPolygon(x, y, x + width, y, points)
  42810. || lineIntersectPolygon(x, y, x, y + height, points)
  42811. || lineIntersectPolygon(x + width, y, x + width, y + height, points)
  42812. || lineIntersectPolygon(x, y + height, x + width, y + height, points)
  42813. ) {
  42814. return true;
  42815. }
  42816. }
  42817. }
  42818. };
  42819. function getLineSelectors(xyIndex) {
  42820. var xy = ['x', 'y'];
  42821. var wh = ['width', 'height'];
  42822. return {
  42823. point: function (itemLayout, selectors, area) {
  42824. var range = area.range;
  42825. var p = itemLayout[xyIndex];
  42826. return inLineRange(p, range);
  42827. },
  42828. rect: function (itemLayout, selectors, area) {
  42829. var range = area.range;
  42830. return inLineRange(itemLayout[xy[xyIndex]], range)
  42831. || inLineRange(itemLayout[xy[xyIndex]] + itemLayout[wh[xyIndex]], range);
  42832. }
  42833. };
  42834. }
  42835. function inLineRange(p, range) {
  42836. return range[0] <= p && p <= range[1];
  42837. }
  42838. // FIXME
  42839. // 随意写的,没考察过效率。
  42840. function lineIntersectPolygon(lx, ly, l2x, l2y, points) {
  42841. for (var i = 0, p2 = points[points.length - 1]; i < points.length; i++) {
  42842. var p = points[i];
  42843. if (lineIntersect(lx, ly, l2x, l2y, p[0], p[1], p2[0], p2[1])) {
  42844. return true;
  42845. }
  42846. p2 = p;
  42847. }
  42848. }
  42849. // Code from <http://blog.csdn.net/rickliuxiao/article/details/6259322> with some fix.
  42850. // See <https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection>
  42851. function lineIntersect(a1x, a1y, a2x, a2y, b1x, b1y, b2x, b2y) {
  42852. var delta = determinant(a2x - a1x, b1x - b2x, a2y - a1y, b1y - b2y);
  42853. if (nearZero(delta)) { // parallel
  42854. return false;
  42855. }
  42856. var namenda = determinant(b1x - a1x, b1x - b2x, b1y - a1y, b1y - b2y) / delta;
  42857. if (namenda < 0 || namenda > 1) {
  42858. return false;
  42859. }
  42860. var miu = determinant(a2x - a1x, b1x - a1x, a2y - a1y, b1y - a1y) / delta;
  42861. if (miu < 0 || miu > 1) {
  42862. return false;
  42863. }
  42864. return true;
  42865. }
  42866. function nearZero(val) {
  42867. return val <= (1e-6) && val >= -(1e-6);
  42868. }
  42869. function determinant(v1, v2, v3, v4) {
  42870. return v1 * v4 - v2 * v3;
  42871. }
  42872. function makeBoundingRect(itemLayout) {
  42873. var x = itemLayout.x;
  42874. var y = itemLayout.y;
  42875. var width = itemLayout.width;
  42876. var height = itemLayout.height;
  42877. // width and height might be negative.
  42878. if (width < 0) {
  42879. x = x + width;
  42880. width = -width;
  42881. }
  42882. if (height < 0) {
  42883. y = y + height;
  42884. height = -height;
  42885. }
  42886. return new BoundingRect(x, y, width, height);
  42887. }
  42888. module.exports = selector;
  42889. /***/ },
  42890. /* 308 */
  42891. /***/ function(module, exports) {
  42892. var lib = {};
  42893. var ORIGIN_METHOD = '\0__throttleOriginMethod';
  42894. var RATE = '\0__throttleRate';
  42895. var THROTTLE_TYPE = '\0__throttleType';
  42896. /**
  42897. * @public
  42898. * @param {(Function)} fn
  42899. * @param {number} [delay=0] Unit: ms.
  42900. * @param {boolean} [debounce=false]
  42901. * true: If call interval less than `delay`, only the last call works.
  42902. * false: If call interval less than `delay, call works on fixed rate.
  42903. * @return {(Function)} throttled fn.
  42904. */
  42905. lib.throttle = function (fn, delay, debounce) {
  42906. var currCall;
  42907. var lastCall = 0;
  42908. var lastExec = 0;
  42909. var timer = null;
  42910. var diff;
  42911. var scope;
  42912. var args;
  42913. delay = delay || 0;
  42914. function exec() {
  42915. lastExec = (new Date()).getTime();
  42916. timer = null;
  42917. fn.apply(scope, args || []);
  42918. }
  42919. var cb = function () {
  42920. currCall = (new Date()).getTime();
  42921. scope = this;
  42922. args = arguments;
  42923. diff = currCall - (debounce ? lastCall : lastExec) - delay;
  42924. clearTimeout(timer);
  42925. if (debounce) {
  42926. timer = setTimeout(exec, delay);
  42927. }
  42928. else {
  42929. if (diff >= 0) {
  42930. exec();
  42931. }
  42932. else {
  42933. timer = setTimeout(exec, -diff);
  42934. }
  42935. }
  42936. lastCall = currCall;
  42937. };
  42938. /**
  42939. * Clear throttle.
  42940. * @public
  42941. */
  42942. cb.clear = function () {
  42943. if (timer) {
  42944. clearTimeout(timer);
  42945. timer = null;
  42946. }
  42947. };
  42948. return cb;
  42949. };
  42950. /**
  42951. * Create throttle method or update throttle rate.
  42952. *
  42953. * @example
  42954. * ComponentView.prototype.render = function () {
  42955. * ...
  42956. * throttle.createOrUpdate(
  42957. * this,
  42958. * '_dispatchAction',
  42959. * this.model.get('throttle'),
  42960. * 'fixRate'
  42961. * );
  42962. * };
  42963. * ComponentView.prototype.remove = function () {
  42964. * throttle.clear(this, '_dispatchAction');
  42965. * };
  42966. * ComponentView.prototype.dispose = function () {
  42967. * throttle.clear(this, '_dispatchAction');
  42968. * };
  42969. *
  42970. * @public
  42971. * @param {Object} obj
  42972. * @param {string} fnAttr
  42973. * @param {number} [rate]
  42974. * @param {string} [throttleType='fixRate'] 'fixRate' or 'debounce'
  42975. * @return {Function} throttled function.
  42976. */
  42977. lib.createOrUpdate = function (obj, fnAttr, rate, throttleType) {
  42978. var fn = obj[fnAttr];
  42979. if (!fn) {
  42980. return;
  42981. }
  42982. var originFn = fn[ORIGIN_METHOD] || fn;
  42983. var lastThrottleType = fn[THROTTLE_TYPE];
  42984. var lastRate = fn[RATE];
  42985. if (lastRate !== rate || lastThrottleType !== throttleType) {
  42986. if (rate == null || !throttleType) {
  42987. return (obj[fnAttr] = originFn);
  42988. }
  42989. fn = obj[fnAttr] = lib.throttle(
  42990. originFn, rate, throttleType === 'debounce'
  42991. );
  42992. fn[ORIGIN_METHOD] = originFn;
  42993. fn[THROTTLE_TYPE] = throttleType;
  42994. fn[RATE] = rate;
  42995. }
  42996. return fn;
  42997. };
  42998. /**
  42999. * Clear throttle. Example see throttle.createOrUpdate.
  43000. *
  43001. * @public
  43002. * @param {Object} obj
  43003. * @param {string} fnAttr
  43004. */
  43005. lib.clear = function (obj, fnAttr) {
  43006. var fn = obj[fnAttr];
  43007. if (fn && fn[ORIGIN_METHOD]) {
  43008. obj[fnAttr] = fn[ORIGIN_METHOD];
  43009. }
  43010. };
  43011. module.exports = lib;
  43012. /***/ },
  43013. /* 309 */
  43014. /***/ function(module, exports, __webpack_require__) {
  43015. var zrUtil = __webpack_require__(4);
  43016. var graphic = __webpack_require__(43);
  43017. var each = zrUtil.each;
  43018. var helper = {};
  43019. var COMPONENT_NAMES = ['geo', 'xAxis', 'yAxis'];
  43020. var PANEL_ID_SPLIT = '--';
  43021. var COORD_CONVERTS = ['dataToPoint', 'pointToData'];
  43022. helper.parseOutputRanges = function (areas, coordInfoList, ecModel, rangesCoordInfo) {
  43023. each(areas, function (area, index) {
  43024. var panelId = area.panelId;
  43025. if (panelId) {
  43026. panelId = panelId.split(PANEL_ID_SPLIT);
  43027. area[panelId[0] + 'Index'] = +panelId[1];
  43028. var coordInfo = findCoordInfo(area, coordInfoList);
  43029. area.coordRange = coordConvert[area.brushType](
  43030. 1, coordInfo, area.range
  43031. );
  43032. rangesCoordInfo && (rangesCoordInfo[index] = coordInfo);
  43033. }
  43034. });
  43035. };
  43036. helper.parseInputRanges = function (brushModel, ecModel) {
  43037. each(brushModel.areas, function (area) {
  43038. var coordInfo = findCoordInfo(area, brushModel.coordInfoList);
  43039. if (true) {
  43040. zrUtil.assert(
  43041. !coordInfo || coordInfo === true || area.coordRange,
  43042. 'coordRange must be specified when coord index specified.'
  43043. );
  43044. zrUtil.assert(
  43045. !coordInfo || coordInfo !== true || area.range,
  43046. 'range must be specified.'
  43047. );
  43048. }
  43049. area.range = area.range || [];
  43050. // convert coordRange to global range and set panelId.
  43051. if (coordInfo && coordInfo !== true) {
  43052. area.range = coordConvert[area.brushType](
  43053. 0, coordInfo, area.coordRange
  43054. );
  43055. area.panelId = coordInfo.panelId;
  43056. }
  43057. });
  43058. };
  43059. helper.makePanelOpts = function (coordInfoList) {
  43060. var panelOpts = [];
  43061. each(coordInfoList, function (coordInfo) {
  43062. var coordSys = coordInfo.coordSys;
  43063. var rect;
  43064. if (coordInfo.geoIndex >= 0) {
  43065. rect = coordSys.getBoundingRect().clone();
  43066. // geo roam and zoom transform
  43067. rect.applyTransform(graphic.getTransform(coordSys));
  43068. }
  43069. else { // xAxis or yAxis
  43070. // grid is not Transformable.
  43071. rect = coordSys.grid.getRect().clone();
  43072. }
  43073. panelOpts.push({panelId: coordInfo.panelId, rect: rect});
  43074. });
  43075. return panelOpts;
  43076. };
  43077. /**
  43078. * @param {Object} option {xAxisIndex, yAxisIndex, geoIndex}
  43079. * @param {module:echarts/model/Global} ecModel
  43080. * @return {Array.<Obejct>} coordInfoList
  43081. */
  43082. helper.makeCoordInfoList = function (option, ecModel) {
  43083. var coordInfoList = [];
  43084. each(COMPONENT_NAMES, function (componentName) {
  43085. var componentIndices = option[componentName + 'Index'];
  43086. if (componentIndices == null || componentIndices === 'none') {
  43087. return;
  43088. }
  43089. if (componentIndices !== 'all' && !zrUtil.isArray(componentIndices)) {
  43090. componentIndices = [componentIndices];
  43091. }
  43092. ecModel.eachComponent({mainType: componentName}, function (componentModel, index) {
  43093. if (componentIndices !== 'all' && zrUtil.indexOf(componentIndices, index) < 0) {
  43094. return;
  43095. }
  43096. var grid;
  43097. var coordSys;
  43098. (componentName === 'xAxis' || componentName === 'yAxis')
  43099. ? (grid = componentModel.axis.grid)
  43100. : (coordSys = componentModel.coordinateSystem); // geo
  43101. var coordInfo;
  43102. // Check duplicate and find cartesian when tranval to yAxis.
  43103. for (var i = 0, len = coordInfoList.length; i < len; i++) {
  43104. var cInfo = coordInfoList[i];
  43105. if (true) {
  43106. zrUtil.assert(
  43107. cInfo[componentName + 'Index'] != index,
  43108. 'Coord should not be defined duplicately: ' + componentName + index
  43109. );
  43110. }
  43111. // CoordSys is always required for `rect brush` or `polygon brush`.
  43112. // If both xAxisIndex and yAxisIndex specified, fetch cartesian by them.
  43113. if (componentName === 'yAxis' && !cInfo.yAxis && cInfo.xAxis) {
  43114. var aCoordSys = grid.getCartesian(cInfo.xAxisIndex, index);
  43115. if (aCoordSys) { // The yAxis and xAxis are in the same cartesian.
  43116. coordSys = aCoordSys;
  43117. coordInfo = cInfo;
  43118. break;
  43119. }
  43120. }
  43121. }
  43122. !coordInfo && coordInfoList.push(coordInfo = {});
  43123. coordInfo[componentName] = componentModel;
  43124. coordInfo[componentName + 'Index'] = index;
  43125. // If both xAxisIndex and yAxisIndex specified, panelId only use yAxisIndex,
  43126. // which is enough to index panel.
  43127. coordInfo.panelId = componentName + PANEL_ID_SPLIT + index;
  43128. coordInfo.coordSys = coordSys
  43129. // If only xAxisIndex or only yAxisIndex specified, find its first cartesian.
  43130. || grid.getCartesian(coordInfo.xAxisIndex, coordInfo.yAxisIndex);
  43131. coordInfo.coordSys
  43132. ? (coordInfoList[componentName + 'Has'] = true)
  43133. : coordInfoList.pop(); // If a coordInfo exists originally, existance of coordSys is ensured.
  43134. });
  43135. });
  43136. return coordInfoList;
  43137. };
  43138. helper.controlSeries = function (area, brushModel, seriesModel) {
  43139. // Check whether area is bound in coord, and series do not belong to that coord.
  43140. // If do not do this check, some brush (like lineX) will controll all axes.
  43141. var coordInfo = findCoordInfo(area, brushModel.coordInfoList);
  43142. return coordInfo === true || (coordInfo && coordInfo.coordSys === seriesModel.coordinateSystem);
  43143. };
  43144. function formatMinMax(minMax) {
  43145. minMax[0] > minMax[1] && minMax.reverse();
  43146. return minMax;
  43147. }
  43148. /**
  43149. * If return Object, a coord found.
  43150. * If reutrn true, global found.
  43151. * Otherwise nothing found.
  43152. *
  43153. * @param {Object} area {<componentName>Index}
  43154. * @param {Array} coordInfoList
  43155. * @return {Obejct|boolean}
  43156. */
  43157. function findCoordInfo(area, coordInfoList) {
  43158. var isGlobal = true;
  43159. for (var j = 0; j < COMPONENT_NAMES.length; j++) {
  43160. var indexAttr = COMPONENT_NAMES[j] + 'Index';
  43161. if (area[indexAttr] >= 0) {
  43162. isGlobal = false;
  43163. for (var i = 0; i < coordInfoList.length; i++) {
  43164. if (coordInfoList[i][indexAttr] === area[indexAttr]) {
  43165. return coordInfoList[i];
  43166. }
  43167. }
  43168. }
  43169. }
  43170. return isGlobal;
  43171. }
  43172. function axisConvert(axisName, to, coordInfo, coordRange) {
  43173. var axis = coordInfo.coordSys.getAxis(axisName);
  43174. if (true) {
  43175. zrUtil.assert(axis, 'line brush is only available in cartesian (grid).');
  43176. }
  43177. return formatMinMax(zrUtil.map([0, 1], function (i) {
  43178. return to
  43179. ? axis.coordToData(axis.toLocalCoord(coordRange[i]))
  43180. : axis.toGlobalCoord(axis.dataToCoord(coordRange[i]));
  43181. }));
  43182. }
  43183. var coordConvert = {
  43184. lineX: zrUtil.curry(axisConvert, 'x'),
  43185. lineY: zrUtil.curry(axisConvert, 'y'),
  43186. rect: function (to, coordInfo, coordRange) {
  43187. var coordSys = coordInfo.coordSys;
  43188. var xminymin = coordSys[COORD_CONVERTS[to]]([coordRange[0][0], coordRange[1][0]]);
  43189. var xmaxymax = coordSys[COORD_CONVERTS[to]]([coordRange[0][1], coordRange[1][1]]);
  43190. return [
  43191. formatMinMax([xminymin[0], xmaxymax[0]]),
  43192. formatMinMax([xminymin[1], xmaxymax[1]])
  43193. ];
  43194. },
  43195. polygon: function (to, coordInfo, coordRange) {
  43196. var coordSys = coordInfo.coordSys;
  43197. return zrUtil.map(coordRange, coordSys[COORD_CONVERTS[to]], coordSys);
  43198. }
  43199. };
  43200. module.exports = helper;
  43201. /***/ },
  43202. /* 310 */
  43203. /***/ function(module, exports, __webpack_require__) {
  43204. /**
  43205. * @file Brush model
  43206. */
  43207. var echarts = __webpack_require__(1);
  43208. var zrUtil = __webpack_require__(4);
  43209. var visualSolution = __webpack_require__(306);
  43210. var Model = __webpack_require__(12);
  43211. var DEFAULT_OUT_OF_BRUSH_COLOR = ['#ddd'];
  43212. var BrushModel = echarts.extendComponentModel({
  43213. type: 'brush',
  43214. dependencies: ['geo', 'grid', 'xAxis', 'yAxis', 'parallel', 'series'],
  43215. /**
  43216. * @protected
  43217. */
  43218. defaultOption: {
  43219. // inBrush: null,
  43220. // outOfBrush: null,
  43221. toolbox: null, // Default value see preprocessor.
  43222. brushLink: null, // Series indices array, broadcast using dataIndex.
  43223. // or 'all', which means all series. 'none' or null means no series.
  43224. seriesIndex: 'all', // seriesIndex array, specify series controlled by this brush component.
  43225. geoIndex: null, //
  43226. xAxisIndex: null,
  43227. yAxisIndex: null,
  43228. brushType: 'rect', // Default brushType, see BrushController.
  43229. brushMode: 'single', // Default brushMode, 'single' or 'multiple'
  43230. transformable: true, // Default transformable.
  43231. brushStyle: { // Default brushStyle
  43232. borderWidth: 1,
  43233. color: 'rgba(120,140,180,0.3)',
  43234. borderColor: 'rgba(120,140,180,0.8)',
  43235. width: null // do not use bursh width in line brush, but fetch from grid.
  43236. },
  43237. throttleType: 'fixRate',// Throttle in brushSelected event. 'fixRate' or 'debounce'.
  43238. // If null, no throttle. Valid only in the first brush component
  43239. throttleDelay: 0, // Unit: ms, 0 means every event will be triggered.
  43240. // FIXME
  43241. // 试验效果
  43242. removeOnClick: true
  43243. },
  43244. /**
  43245. * @readOnly
  43246. * @type {Array.<Object>}
  43247. */
  43248. areas: [],
  43249. /**
  43250. * Current activated brush type.
  43251. * If null, brush is inactived.
  43252. * see module:echarts/component/helper/BrushController
  43253. * @readOnly
  43254. * @type {string}
  43255. */
  43256. brushType: null,
  43257. /**
  43258. * Current brush opt.
  43259. * see module:echarts/component/helper/BrushController
  43260. * @readOnly
  43261. * @type {Object}
  43262. */
  43263. brushOption: {},
  43264. /**
  43265. * @readOnly
  43266. * @type {Array.<Object>}
  43267. */
  43268. coordInfoList: [],
  43269. optionUpdated: function (newOption, isInit) {
  43270. var thisOption = this.option;
  43271. !isInit && visualSolution.replaceVisualOption(
  43272. thisOption, newOption, ['inBrush', 'outOfBrush']
  43273. );
  43274. thisOption.inBrush = thisOption.inBrush || {};
  43275. // Always give default visual, consider setOption at the second time.
  43276. thisOption.outOfBrush = thisOption.outOfBrush || {color: DEFAULT_OUT_OF_BRUSH_COLOR};
  43277. },
  43278. /**
  43279. * If ranges is null/undefined, range state remain.
  43280. *
  43281. * @param {Array.<Object>} [ranges]
  43282. */
  43283. setAreas: function (areas) {
  43284. if (true) {
  43285. zrUtil.assert(zrUtil.isArray(areas));
  43286. zrUtil.each(areas, function (area) {
  43287. zrUtil.assert(area.brushType, 'Illegal areas');
  43288. });
  43289. }
  43290. // If ranges is null/undefined, range state remain.
  43291. // This helps user to dispatchAction({type: 'brush'}) with no areas
  43292. // set but just want to get the current brush select info from a `brush` event.
  43293. if (!areas) {
  43294. return;
  43295. }
  43296. this.areas = zrUtil.map(areas, function (area) {
  43297. return this._mergeBrushOption(area);
  43298. }, this);
  43299. },
  43300. /**
  43301. * see module:echarts/component/helper/BrushController
  43302. * @param {Object} brushOption
  43303. */
  43304. setBrushOption: function (brushOption) {
  43305. this.brushOption = this._mergeBrushOption(brushOption);
  43306. this.brushType = this.brushOption.brushType;
  43307. },
  43308. /**
  43309. * @private
  43310. */
  43311. _mergeBrushOption: function (brushOption) {
  43312. var option = this.option;
  43313. return zrUtil.merge(
  43314. {
  43315. brushType: option.brushType,
  43316. brushMode: option.brushMode,
  43317. transformable: option.transformable,
  43318. brushStyle: new Model(option.brushStyle).getItemStyle(),
  43319. removeOnClick: option.removeOnClick
  43320. },
  43321. brushOption,
  43322. true
  43323. );
  43324. }
  43325. });
  43326. module.exports = BrushModel;
  43327. /***/ },
  43328. /* 311 */
  43329. /***/ function(module, exports, __webpack_require__) {
  43330. var zrUtil = __webpack_require__(4);
  43331. var BrushController = __webpack_require__(233);
  43332. var echarts = __webpack_require__(1);
  43333. var brushHelper = __webpack_require__(309);
  43334. module.exports = echarts.extendComponentView({
  43335. type: 'brush',
  43336. init: function (ecModel, api) {
  43337. /**
  43338. * @readOnly
  43339. * @type {module:echarts/model/Global}
  43340. */
  43341. this.ecModel = ecModel;
  43342. /**
  43343. * @readOnly
  43344. * @type {module:echarts/ExtensionAPI}
  43345. */
  43346. this.api = api;
  43347. /**
  43348. * @readOnly
  43349. * @type {module:echarts/component/brush/BrushModel}
  43350. */
  43351. this.model;
  43352. /**
  43353. * @private
  43354. * @type {module:echarts/component/helper/BrushController}
  43355. */
  43356. (this._brushController = new BrushController(api.getZr()))
  43357. .on('brush', zrUtil.bind(this._onBrush, this))
  43358. .mount();
  43359. },
  43360. /**
  43361. * @override
  43362. */
  43363. render: function (brushModel) {
  43364. this.model = brushModel;
  43365. return updateController.apply(this, arguments);
  43366. },
  43367. /**
  43368. * @override
  43369. */
  43370. updateView: updateController,
  43371. /**
  43372. * @override
  43373. */
  43374. updateLayout: updateController,
  43375. /**
  43376. * @override
  43377. */
  43378. updateVisual: updateController,
  43379. /**
  43380. * @override
  43381. */
  43382. dispose: function () {
  43383. this._brushController.dispose();
  43384. },
  43385. /**
  43386. * @private
  43387. */
  43388. _onBrush: function (areas, opt) {
  43389. var modelId = this.model.id;
  43390. brushHelper.parseOutputRanges(areas, this.model.coordInfoList, this.ecModel);
  43391. // Action is not dispatched on drag end, because the drag end
  43392. // emits the same params with the last drag move event, and
  43393. // may have some delay when using touch pad, which makes
  43394. // animation not smooth (when using debounce).
  43395. (!opt.isEnd || opt.removeOnClick) && this.api.dispatchAction({
  43396. type: 'brush',
  43397. brushId: modelId,
  43398. areas: zrUtil.clone(areas),
  43399. $from: modelId
  43400. });
  43401. }
  43402. });
  43403. function updateController(brushModel, ecModel, api, payload) {
  43404. // Do not update controller when drawing.
  43405. (!payload || payload.$from !== brushModel.id) && this._brushController
  43406. .setPanels(brushHelper.makePanelOpts(brushModel.coordInfoList))
  43407. .enableBrush(brushModel.brushOption)
  43408. .updateCovers(brushModel.areas.slice());
  43409. }
  43410. /***/ },
  43411. /* 312 */
  43412. /***/ function(module, exports, __webpack_require__) {
  43413. /**
  43414. * @file Brush action
  43415. */
  43416. var echarts = __webpack_require__(1);
  43417. /**
  43418. * payload: {
  43419. * brushIndex: number, or,
  43420. * brushId: string, or,
  43421. * brushName: string,
  43422. * globalRanges: Array
  43423. * }
  43424. */
  43425. echarts.registerAction(
  43426. {type: 'brush', event: 'brush', update: 'updateView'},
  43427. function (payload, ecModel) {
  43428. ecModel.eachComponent({mainType: 'brush', query: payload}, function (brushModel) {
  43429. brushModel.setAreas(payload.areas);
  43430. });
  43431. }
  43432. );
  43433. /**
  43434. * payload: {
  43435. * brushComponents: [
  43436. * {
  43437. * brushId,
  43438. * brushIndex,
  43439. * brushName,
  43440. * series: [
  43441. * {
  43442. * seriesId,
  43443. * seriesIndex,
  43444. * seriesName,
  43445. * rawIndices: [21, 34, ...]
  43446. * },
  43447. * ...
  43448. * ]
  43449. * },
  43450. * ...
  43451. * ]
  43452. * }
  43453. */
  43454. echarts.registerAction(
  43455. {type: 'brushSelect', event: 'brushSelected', update: 'none'},
  43456. function () {}
  43457. );
  43458. /***/ },
  43459. /* 313 */
  43460. /***/ function(module, exports, __webpack_require__) {
  43461. 'use strict';
  43462. var featureManager = __webpack_require__(314);
  43463. var zrUtil = __webpack_require__(4);
  43464. function Brush(model, ecModel, api) {
  43465. this.model = model;
  43466. this.ecModel = ecModel;
  43467. this.api = api;
  43468. /**
  43469. * @private
  43470. * @type {string}
  43471. */
  43472. this._brushType;
  43473. /**
  43474. * @private
  43475. * @type {string}
  43476. */
  43477. this._brushMode;
  43478. }
  43479. Brush.defaultOption = {
  43480. show: true,
  43481. type: ['rect', 'polygon', 'lineX', 'lineY', 'keep', 'clear'],
  43482. icon: {
  43483. 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
  43484. 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
  43485. 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
  43486. 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
  43487. 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
  43488. 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
  43489. },
  43490. title: {
  43491. rect: '矩形选择',
  43492. polygon: '圈选',
  43493. lineX: '横向选择',
  43494. lineY: '纵向选择',
  43495. keep: '保持选择',
  43496. clear: '清除选择'
  43497. }
  43498. };
  43499. var proto = Brush.prototype;
  43500. proto.render =
  43501. proto.updateView =
  43502. proto.updateLayout = function (featureModel, ecModel, api) {
  43503. var brushType;
  43504. var brushMode;
  43505. var isBrushed;
  43506. ecModel.eachComponent({mainType: 'brush'}, function (brushModel) {
  43507. brushType = brushModel.brushType;
  43508. brushMode = brushModel.brushOption.brushMode || 'single';
  43509. isBrushed |= brushModel.areas.length;
  43510. });
  43511. this._brushType = brushType;
  43512. this._brushMode = brushMode;
  43513. zrUtil.each(featureModel.get('type', true), function (type) {
  43514. featureModel.setIconStatus(
  43515. type,
  43516. (
  43517. type === 'keep'
  43518. ? brushMode === 'multiple'
  43519. : type === 'clear'
  43520. ? isBrushed
  43521. : type === brushType
  43522. ) ? 'emphasis' : 'normal'
  43523. );
  43524. });
  43525. };
  43526. proto.getIcons = function () {
  43527. var model = this.model;
  43528. var availableIcons = model.get('icon', true);
  43529. var icons = {};
  43530. zrUtil.each(model.get('type', true), function (type) {
  43531. if (availableIcons[type]) {
  43532. icons[type] = availableIcons[type];
  43533. }
  43534. });
  43535. return icons;
  43536. };
  43537. proto.onclick = function (ecModel, api, type) {
  43538. var api = this.api;
  43539. var brushType = this._brushType;
  43540. var brushMode = this._brushMode;
  43541. if (type === 'clear') {
  43542. api.dispatchAction({
  43543. type: 'brush',
  43544. // Clear all areas of all brush components.
  43545. areas: []
  43546. });
  43547. }
  43548. else {
  43549. api.dispatchAction({
  43550. type: 'takeGlobalCursor',
  43551. key: 'brush',
  43552. brushOption: {
  43553. brushType: type === 'keep'
  43554. ? brushType
  43555. : (brushType === type ? false : type),
  43556. brushMode: type === 'keep'
  43557. ? (brushMode === 'multiple' ? 'single' : 'multiple')
  43558. : brushMode
  43559. }
  43560. });
  43561. }
  43562. };
  43563. featureManager.register('brush', Brush);
  43564. module.exports = Brush;
  43565. /***/ },
  43566. /* 314 */
  43567. /***/ function(module, exports) {
  43568. 'use strict';
  43569. var features = {};
  43570. module.exports = {
  43571. register: function (name, ctor) {
  43572. features[name] = ctor;
  43573. },
  43574. get: function (name) {
  43575. return features[name];
  43576. }
  43577. };
  43578. /***/ },
  43579. /* 315 */
  43580. /***/ function(module, exports, __webpack_require__) {
  43581. 'use strict';
  43582. var echarts = __webpack_require__(1);
  43583. var graphic = __webpack_require__(43);
  43584. var layout = __webpack_require__(21);
  43585. // Model
  43586. echarts.extendComponentModel({
  43587. type: 'title',
  43588. layoutMode: {type: 'box', ignoreSize: true},
  43589. defaultOption: {
  43590. // 一级层叠
  43591. zlevel: 0,
  43592. // 二级层叠
  43593. z: 6,
  43594. show: true,
  43595. text: '',
  43596. // 超链接跳转
  43597. // link: null,
  43598. // 仅支持self | blank
  43599. target: 'blank',
  43600. subtext: '',
  43601. // 超链接跳转
  43602. // sublink: null,
  43603. // 仅支持self | blank
  43604. subtarget: 'blank',
  43605. // 'center' ¦ 'left' ¦ 'right'
  43606. // ¦ {number}(x坐标,单位px)
  43607. left: 0,
  43608. // 'top' ¦ 'bottom' ¦ 'center'
  43609. // ¦ {number}(y坐标,单位px)
  43610. top: 0,
  43611. // 水平对齐
  43612. // 'auto' | 'left' | 'right' | 'center'
  43613. // 默认根据 left 的位置判断是左对齐还是右对齐
  43614. // textAlign: null
  43615. //
  43616. // 垂直对齐
  43617. // 'auto' | 'top' | 'bottom' | 'middle'
  43618. // 默认根据 top 位置判断是上对齐还是下对齐
  43619. // textBaseline: null
  43620. backgroundColor: 'rgba(0,0,0,0)',
  43621. // 标题边框颜色
  43622. borderColor: '#ccc',
  43623. // 标题边框线宽,单位px,默认为0(无边框)
  43624. borderWidth: 0,
  43625. // 标题内边距,单位px,默认各方向内边距为5,
  43626. // 接受数组分别设定上右下左边距,同css
  43627. padding: 5,
  43628. // 主副标题纵向间隔,单位px,默认为10,
  43629. itemGap: 10,
  43630. textStyle: {
  43631. fontSize: 18,
  43632. fontWeight: 'bolder',
  43633. color: '#333'
  43634. },
  43635. subtextStyle: {
  43636. color: '#aaa'
  43637. }
  43638. }
  43639. });
  43640. // View
  43641. echarts.extendComponentView({
  43642. type: 'title',
  43643. render: function (titleModel, ecModel, api) {
  43644. this.group.removeAll();
  43645. if (!titleModel.get('show')) {
  43646. return;
  43647. }
  43648. var group = this.group;
  43649. var textStyleModel = titleModel.getModel('textStyle');
  43650. var subtextStyleModel = titleModel.getModel('subtextStyle');
  43651. var textAlign = titleModel.get('textAlign');
  43652. var textBaseline = titleModel.get('textBaseline');
  43653. var textEl = new graphic.Text({
  43654. style: {
  43655. text: titleModel.get('text'),
  43656. textFont: textStyleModel.getFont(),
  43657. fill: textStyleModel.getTextColor()
  43658. },
  43659. z2: 10
  43660. });
  43661. var textRect = textEl.getBoundingRect();
  43662. var subText = titleModel.get('subtext');
  43663. var subTextEl = new graphic.Text({
  43664. style: {
  43665. text: subText,
  43666. textFont: subtextStyleModel.getFont(),
  43667. fill: subtextStyleModel.getTextColor(),
  43668. y: textRect.height + titleModel.get('itemGap'),
  43669. textBaseline: 'top'
  43670. },
  43671. z2: 10
  43672. });
  43673. var link = titleModel.get('link');
  43674. var sublink = titleModel.get('sublink');
  43675. textEl.silent = !link;
  43676. subTextEl.silent = !sublink;
  43677. if (link) {
  43678. textEl.on('click', function () {
  43679. window.open(link, '_' + titleModel.get('target'));
  43680. });
  43681. }
  43682. if (sublink) {
  43683. subTextEl.on('click', function () {
  43684. window.open(sublink, '_' + titleModel.get('subtarget'));
  43685. });
  43686. }
  43687. group.add(textEl);
  43688. subText && group.add(subTextEl);
  43689. // If no subText, but add subTextEl, there will be an empty line.
  43690. var groupRect = group.getBoundingRect();
  43691. var layoutOption = titleModel.getBoxLayoutParams();
  43692. layoutOption.width = groupRect.width;
  43693. layoutOption.height = groupRect.height;
  43694. var layoutRect = layout.getLayoutRect(
  43695. layoutOption, {
  43696. width: api.getWidth(),
  43697. height: api.getHeight()
  43698. }, titleModel.get('padding')
  43699. );
  43700. // Adjust text align based on position
  43701. if (!textAlign) {
  43702. // Align left if title is on the left. center and right is same
  43703. textAlign = titleModel.get('left') || titleModel.get('right');
  43704. if (textAlign === 'middle') {
  43705. textAlign = 'center';
  43706. }
  43707. // Adjust layout by text align
  43708. if (textAlign === 'right') {
  43709. layoutRect.x += layoutRect.width;
  43710. }
  43711. else if (textAlign === 'center') {
  43712. layoutRect.x += layoutRect.width / 2;
  43713. }
  43714. }
  43715. if (!textBaseline) {
  43716. textBaseline = titleModel.get('top') || titleModel.get('bottom');
  43717. if (textBaseline === 'center') {
  43718. textBaseline = 'middle';
  43719. }
  43720. if (textBaseline === 'bottom') {
  43721. layoutRect.y += layoutRect.height;
  43722. }
  43723. else if (textBaseline === 'middle') {
  43724. layoutRect.y += layoutRect.height / 2;
  43725. }
  43726. textBaseline = textBaseline || 'top';
  43727. }
  43728. group.attr('position', [layoutRect.x, layoutRect.y]);
  43729. var alignStyle = {
  43730. textAlign: textAlign,
  43731. textVerticalAlign: textBaseline
  43732. };
  43733. textEl.setStyle(alignStyle);
  43734. subTextEl.setStyle(alignStyle);
  43735. // Render background
  43736. // Get groupRect again because textAlign has been changed
  43737. groupRect = group.getBoundingRect();
  43738. var padding = layoutRect.margin;
  43739. var style = titleModel.getItemStyle(['color', 'opacity']);
  43740. style.fill = titleModel.get('backgroundColor');
  43741. var rect = new graphic.Rect({
  43742. shape: {
  43743. x: groupRect.x - padding[3],
  43744. y: groupRect.y - padding[0],
  43745. width: groupRect.width + padding[1] + padding[3],
  43746. height: groupRect.height + padding[0] + padding[2]
  43747. },
  43748. style: style,
  43749. silent: true
  43750. });
  43751. graphic.subPixelOptimizeRect(rect);
  43752. group.add(rect);
  43753. }
  43754. });
  43755. /***/ },
  43756. /* 316 */
  43757. /***/ function(module, exports, __webpack_require__) {
  43758. /**
  43759. * DataZoom component entry
  43760. */
  43761. __webpack_require__(317);
  43762. __webpack_require__(318);
  43763. __webpack_require__(320);
  43764. __webpack_require__(321);
  43765. __webpack_require__(322);
  43766. __webpack_require__(324);
  43767. __webpack_require__(325);
  43768. __webpack_require__(327);
  43769. __webpack_require__(328);
  43770. /***/ },
  43771. /* 317 */
  43772. /***/ function(module, exports, __webpack_require__) {
  43773. __webpack_require__(19).registerSubTypeDefaulter('dataZoom', function (option) {
  43774. // Default 'slider' when no type specified.
  43775. return 'slider';
  43776. });
  43777. /***/ },
  43778. /* 318 */
  43779. /***/ function(module, exports, __webpack_require__) {
  43780. /**
  43781. * @file Data zoom model
  43782. */
  43783. var zrUtil = __webpack_require__(4);
  43784. var env = __webpack_require__(2);
  43785. var echarts = __webpack_require__(1);
  43786. var modelUtil = __webpack_require__(5);
  43787. var AxisProxy = __webpack_require__(319);
  43788. var each = zrUtil.each;
  43789. var eachAxisDim = modelUtil.eachAxisDim;
  43790. var DataZoomModel = echarts.extendComponentModel({
  43791. type: 'dataZoom',
  43792. dependencies: [
  43793. 'xAxis', 'yAxis', 'zAxis', 'radiusAxis', 'angleAxis', 'series'
  43794. ],
  43795. /**
  43796. * @protected
  43797. */
  43798. defaultOption: {
  43799. zlevel: 0,
  43800. z: 4, // Higher than normal component (z: 2).
  43801. orient: null, // Default auto by axisIndex. Possible value: 'horizontal', 'vertical'.
  43802. xAxisIndex: null, // Default the first horizontal category axis.
  43803. yAxisIndex: null, // Default the first vertical category axis.
  43804. angleAxisIndex: null,
  43805. radiusAxisIndex: null,
  43806. filterMode: 'filter', // Possible values: 'filter' or 'empty'.
  43807. // 'filter': data items which are out of window will be removed.
  43808. // This option is applicable when filtering outliers.
  43809. // 'empty': data items which are out of window will be set to empty.
  43810. // This option is applicable when user should not neglect
  43811. // that there are some data items out of window.
  43812. // Taking line chart as an example, line will be broken in
  43813. // the filtered points when filterModel is set to 'empty', but
  43814. // be connected when set to 'filter'.
  43815. throttle: null, // Dispatch action by the fixed rate, avoid frequency.
  43816. // default 100. Do not throttle when use null/undefined.
  43817. // If animation === true and animationDurationUpdate > 0,
  43818. // default value is 100, otherwise 20.
  43819. start: 0, // Start percent. 0 ~ 100
  43820. end: 100, // End percent. 0 ~ 100
  43821. startValue: null, // Start value. If startValue specified, start is ignored.
  43822. endValue: null // End value. If endValue specified, end is ignored.
  43823. },
  43824. /**
  43825. * @override
  43826. */
  43827. init: function (option, parentModel, ecModel) {
  43828. /**
  43829. * key like x_0, y_1
  43830. * @private
  43831. * @type {Object}
  43832. */
  43833. this._dataIntervalByAxis = {};
  43834. /**
  43835. * @private
  43836. */
  43837. this._dataInfo = {};
  43838. /**
  43839. * key like x_0, y_1
  43840. * @private
  43841. */
  43842. this._axisProxies = {};
  43843. /**
  43844. * @readOnly
  43845. */
  43846. this.textStyleModel;
  43847. /**
  43848. * @private
  43849. */
  43850. this._autoThrottle = true;
  43851. var rawOption = retrieveRaw(option);
  43852. this.mergeDefaultAndTheme(option, ecModel);
  43853. this.doInit(rawOption);
  43854. },
  43855. /**
  43856. * @override
  43857. */
  43858. mergeOption: function (newOption) {
  43859. var rawOption = retrieveRaw(newOption);
  43860. //FIX #2591
  43861. zrUtil.merge(this.option, newOption, true);
  43862. this.doInit(rawOption);
  43863. },
  43864. /**
  43865. * @protected
  43866. */
  43867. doInit: function (rawOption) {
  43868. var thisOption = this.option;
  43869. // Disable realtime view update if canvas is not supported.
  43870. if (!env.canvasSupported) {
  43871. thisOption.realtime = false;
  43872. }
  43873. this._setDefaultThrottle(rawOption);
  43874. processRangeProp('start', 'startValue', rawOption, thisOption);
  43875. processRangeProp('end', 'endValue', rawOption, thisOption);
  43876. this.textStyleModel = this.getModel('textStyle');
  43877. this._resetTarget();
  43878. this._giveAxisProxies();
  43879. },
  43880. /**
  43881. * @private
  43882. */
  43883. _giveAxisProxies: function () {
  43884. var axisProxies = this._axisProxies;
  43885. this.eachTargetAxis(function (dimNames, axisIndex, dataZoomModel, ecModel) {
  43886. var axisModel = this.dependentModels[dimNames.axis][axisIndex];
  43887. // If exists, share axisProxy with other dataZoomModels.
  43888. var axisProxy = axisModel.__dzAxisProxy || (
  43889. // Use the first dataZoomModel as the main model of axisProxy.
  43890. axisModel.__dzAxisProxy = new AxisProxy(
  43891. dimNames.name, axisIndex, this, ecModel
  43892. )
  43893. );
  43894. // FIXME
  43895. // dispose __dzAxisProxy
  43896. axisProxies[dimNames.name + '_' + axisIndex] = axisProxy;
  43897. }, this);
  43898. },
  43899. /**
  43900. * @private
  43901. */
  43902. _resetTarget: function () {
  43903. var thisOption = this.option;
  43904. var autoMode = this._judgeAutoMode();
  43905. eachAxisDim(function (dimNames) {
  43906. var axisIndexName = dimNames.axisIndex;
  43907. thisOption[axisIndexName] = modelUtil.normalizeToArray(
  43908. thisOption[axisIndexName]
  43909. );
  43910. }, this);
  43911. if (autoMode === 'axisIndex') {
  43912. this._autoSetAxisIndex();
  43913. }
  43914. else if (autoMode === 'orient') {
  43915. this._autoSetOrient();
  43916. }
  43917. },
  43918. /**
  43919. * @private
  43920. */
  43921. _judgeAutoMode: function () {
  43922. // Auto set only works for setOption at the first time.
  43923. // The following is user's reponsibility. So using merged
  43924. // option is OK.
  43925. var thisOption = this.option;
  43926. var hasIndexSpecified = false;
  43927. eachAxisDim(function (dimNames) {
  43928. // When user set axisIndex as a empty array, we think that user specify axisIndex
  43929. // but do not want use auto mode. Because empty array may be encountered when
  43930. // some error occured.
  43931. if (thisOption[dimNames.axisIndex] != null) {
  43932. hasIndexSpecified = true;
  43933. }
  43934. }, this);
  43935. var orient = thisOption.orient;
  43936. if (orient == null && hasIndexSpecified) {
  43937. return 'orient';
  43938. }
  43939. else if (!hasIndexSpecified) {
  43940. if (orient == null) {
  43941. thisOption.orient = 'horizontal';
  43942. }
  43943. return 'axisIndex';
  43944. }
  43945. },
  43946. /**
  43947. * @private
  43948. */
  43949. _autoSetAxisIndex: function () {
  43950. var autoAxisIndex = true;
  43951. var orient = this.get('orient', true);
  43952. var thisOption = this.option;
  43953. if (autoAxisIndex) {
  43954. // Find axis that parallel to dataZoom as default.
  43955. var dimNames = orient === 'vertical'
  43956. ? {dim: 'y', axisIndex: 'yAxisIndex', axis: 'yAxis'}
  43957. : {dim: 'x', axisIndex: 'xAxisIndex', axis: 'xAxis'};
  43958. if (this.dependentModels[dimNames.axis].length) {
  43959. thisOption[dimNames.axisIndex] = [0];
  43960. autoAxisIndex = false;
  43961. }
  43962. }
  43963. if (autoAxisIndex) {
  43964. // Find the first category axis as default. (consider polar)
  43965. eachAxisDim(function (dimNames) {
  43966. if (!autoAxisIndex) {
  43967. return;
  43968. }
  43969. var axisIndices = [];
  43970. var axisModels = this.dependentModels[dimNames.axis];
  43971. if (axisModels.length && !axisIndices.length) {
  43972. for (var i = 0, len = axisModels.length; i < len; i++) {
  43973. if (axisModels[i].get('type') === 'category') {
  43974. axisIndices.push(i);
  43975. }
  43976. }
  43977. }
  43978. thisOption[dimNames.axisIndex] = axisIndices;
  43979. if (axisIndices.length) {
  43980. autoAxisIndex = false;
  43981. }
  43982. }, this);
  43983. }
  43984. if (autoAxisIndex) {
  43985. // FIXME
  43986. // 这里是兼容ec2的写法(没指定xAxisIndex和yAxisIndex时把scatter和双数值轴折柱纳入dataZoom控制),
  43987. // 但是实际是否需要Grid.js#getScaleByOption来判断(考虑time,log等axis type)?
  43988. // If both dataZoom.xAxisIndex and dataZoom.yAxisIndex is not specified,
  43989. // dataZoom component auto adopts series that reference to
  43990. // both xAxis and yAxis which type is 'value'.
  43991. this.ecModel.eachSeries(function (seriesModel) {
  43992. if (this._isSeriesHasAllAxesTypeOf(seriesModel, 'value')) {
  43993. eachAxisDim(function (dimNames) {
  43994. var axisIndices = thisOption[dimNames.axisIndex];
  43995. var axisIndex = seriesModel.get(dimNames.axisIndex);
  43996. if (zrUtil.indexOf(axisIndices, axisIndex) < 0) {
  43997. axisIndices.push(axisIndex);
  43998. }
  43999. });
  44000. }
  44001. }, this);
  44002. }
  44003. },
  44004. /**
  44005. * @private
  44006. */
  44007. _autoSetOrient: function () {
  44008. var dim;
  44009. // Find the first axis
  44010. this.eachTargetAxis(function (dimNames) {
  44011. !dim && (dim = dimNames.name);
  44012. }, this);
  44013. this.option.orient = dim === 'y' ? 'vertical' : 'horizontal';
  44014. },
  44015. /**
  44016. * @private
  44017. */
  44018. _isSeriesHasAllAxesTypeOf: function (seriesModel, axisType) {
  44019. // FIXME
  44020. // 需要series的xAxisIndex和yAxisIndex都首先自动设置上。
  44021. // 例如series.type === scatter时。
  44022. var is = true;
  44023. eachAxisDim(function (dimNames) {
  44024. var seriesAxisIndex = seriesModel.get(dimNames.axisIndex);
  44025. var axisModel = this.dependentModels[dimNames.axis][seriesAxisIndex];
  44026. if (!axisModel || axisModel.get('type') !== axisType) {
  44027. is = false;
  44028. }
  44029. }, this);
  44030. return is;
  44031. },
  44032. /**
  44033. * @private
  44034. */
  44035. _setDefaultThrottle: function (rawOption) {
  44036. // When first time user set throttle, auto throttle ends.
  44037. if (rawOption.hasOwnProperty('throttle')) {
  44038. this._autoThrottle = false;
  44039. }
  44040. if (this._autoThrottle) {
  44041. var globalOption = this.ecModel.option;
  44042. this.option.throttle =
  44043. (globalOption.animation && globalOption.animationDurationUpdate > 0)
  44044. ? 100 : 20;
  44045. }
  44046. },
  44047. /**
  44048. * @public
  44049. */
  44050. getFirstTargetAxisModel: function () {
  44051. var firstAxisModel;
  44052. eachAxisDim(function (dimNames) {
  44053. if (firstAxisModel == null) {
  44054. var indices = this.get(dimNames.axisIndex);
  44055. if (indices.length) {
  44056. firstAxisModel = this.dependentModels[dimNames.axis][indices[0]];
  44057. }
  44058. }
  44059. }, this);
  44060. return firstAxisModel;
  44061. },
  44062. /**
  44063. * @public
  44064. * @param {Function} callback param: axisModel, dimNames, axisIndex, dataZoomModel, ecModel
  44065. */
  44066. eachTargetAxis: function (callback, context) {
  44067. var ecModel = this.ecModel;
  44068. eachAxisDim(function (dimNames) {
  44069. each(
  44070. this.get(dimNames.axisIndex),
  44071. function (axisIndex) {
  44072. callback.call(context, dimNames, axisIndex, this, ecModel);
  44073. },
  44074. this
  44075. );
  44076. }, this);
  44077. },
  44078. getAxisProxy: function (dimName, axisIndex) {
  44079. return this._axisProxies[dimName + '_' + axisIndex];
  44080. },
  44081. /**
  44082. * If not specified, set to undefined.
  44083. *
  44084. * @public
  44085. * @param {Object} opt
  44086. * @param {number} [opt.start]
  44087. * @param {number} [opt.end]
  44088. * @param {number} [opt.startValue]
  44089. * @param {number} [opt.endValue]
  44090. */
  44091. setRawRange: function (opt) {
  44092. each(['start', 'end', 'startValue', 'endValue'], function (name) {
  44093. // If any of those prop is null/undefined, we should alos set
  44094. // them, because only one pair between start/end and
  44095. // startValue/endValue can work.
  44096. this.option[name] = opt[name];
  44097. }, this);
  44098. },
  44099. /**
  44100. * @public
  44101. * @return {Array.<number>} [startPercent, endPercent]
  44102. */
  44103. getPercentRange: function () {
  44104. var axisProxy = this.findRepresentativeAxisProxy();
  44105. if (axisProxy) {
  44106. return axisProxy.getDataPercentWindow();
  44107. }
  44108. },
  44109. /**
  44110. * @public
  44111. * For example, chart.getModel().getComponent('dataZoom').getValueRange('y', 0);
  44112. *
  44113. * @param {string} [axisDimName]
  44114. * @param {number} [axisIndex]
  44115. * @return {Array.<number>} [startValue, endValue]
  44116. */
  44117. getValueRange: function (axisDimName, axisIndex) {
  44118. if (axisDimName == null && axisIndex == null) {
  44119. var axisProxy = this.findRepresentativeAxisProxy();
  44120. if (axisProxy) {
  44121. return axisProxy.getDataValueWindow();
  44122. }
  44123. }
  44124. else {
  44125. return this.getAxisProxy(axisDimName, axisIndex).getDataValueWindow();
  44126. }
  44127. },
  44128. /**
  44129. * @public
  44130. * @return {module:echarts/component/dataZoom/AxisProxy}
  44131. */
  44132. findRepresentativeAxisProxy: function () {
  44133. // Find the first hosted axisProxy
  44134. var axisProxies = this._axisProxies;
  44135. for (var key in axisProxies) {
  44136. if (axisProxies.hasOwnProperty(key) && axisProxies[key].hostedBy(this)) {
  44137. return axisProxies[key];
  44138. }
  44139. }
  44140. // If no hosted axis find not hosted axisProxy.
  44141. // Consider this case: dataZoomModel1 and dataZoomModel2 control the same axis,
  44142. // and the option.start or option.end settings are different. The percentRange
  44143. // should follow axisProxy.
  44144. // (We encounter this problem in toolbox data zoom.)
  44145. for (var key in axisProxies) {
  44146. if (axisProxies.hasOwnProperty(key) && !axisProxies[key].hostedBy(this)) {
  44147. return axisProxies[key];
  44148. }
  44149. }
  44150. }
  44151. });
  44152. function retrieveRaw(option) {
  44153. var ret = {};
  44154. each(
  44155. ['start', 'end', 'startValue', 'endValue', 'throttle'],
  44156. function (name) {
  44157. option.hasOwnProperty(name) && (ret[name] = option[name]);
  44158. }
  44159. );
  44160. return ret;
  44161. }
  44162. function processRangeProp(percentProp, valueProp, rawOption, thisOption) {
  44163. // start/end has higher priority over startValue/endValue,
  44164. // but we should make chart.setOption({endValue: 1000}) effective,
  44165. // rather than chart.setOption({endValue: 1000, end: null}).
  44166. if (rawOption[valueProp] != null && rawOption[percentProp] == null) {
  44167. thisOption[percentProp] = null;
  44168. }
  44169. // Otherwise do nothing and use the merge result.
  44170. }
  44171. module.exports = DataZoomModel;
  44172. /***/ },
  44173. /* 319 */
  44174. /***/ function(module, exports, __webpack_require__) {
  44175. /**
  44176. * @file Axis operator
  44177. */
  44178. var zrUtil = __webpack_require__(4);
  44179. var numberUtil = __webpack_require__(7);
  44180. var each = zrUtil.each;
  44181. var asc = numberUtil.asc;
  44182. /**
  44183. * Operate single axis.
  44184. * One axis can only operated by one axis operator.
  44185. * Different dataZoomModels may be defined to operate the same axis.
  44186. * (i.e. 'inside' data zoom and 'slider' data zoom components)
  44187. * So dataZoomModels share one axisProxy in that case.
  44188. *
  44189. * @class
  44190. */
  44191. var AxisProxy = function (dimName, axisIndex, dataZoomModel, ecModel) {
  44192. /**
  44193. * @private
  44194. * @type {string}
  44195. */
  44196. this._dimName = dimName;
  44197. /**
  44198. * @private
  44199. */
  44200. this._axisIndex = axisIndex;
  44201. /**
  44202. * @private
  44203. * @type {Array.<number>}
  44204. */
  44205. this._valueWindow;
  44206. /**
  44207. * @private
  44208. * @type {Array.<number>}
  44209. */
  44210. this._percentWindow;
  44211. /**
  44212. * @private
  44213. * @type {Array.<number>}
  44214. */
  44215. this._dataExtent;
  44216. /**
  44217. * @readOnly
  44218. * @type {module: echarts/model/Global}
  44219. */
  44220. this.ecModel = ecModel;
  44221. /**
  44222. * @private
  44223. * @type {module: echarts/component/dataZoom/DataZoomModel}
  44224. */
  44225. this._dataZoomModel = dataZoomModel;
  44226. };
  44227. AxisProxy.prototype = {
  44228. constructor: AxisProxy,
  44229. /**
  44230. * Whether the axisProxy is hosted by dataZoomModel.
  44231. *
  44232. * @public
  44233. * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel
  44234. * @return {boolean}
  44235. */
  44236. hostedBy: function (dataZoomModel) {
  44237. return this._dataZoomModel === dataZoomModel;
  44238. },
  44239. /**
  44240. * @return {Array.<number>}
  44241. */
  44242. getDataExtent: function () {
  44243. return this._dataExtent.slice();
  44244. },
  44245. /**
  44246. * @return {Array.<number>}
  44247. */
  44248. getDataValueWindow: function () {
  44249. return this._valueWindow.slice();
  44250. },
  44251. /**
  44252. * @return {Array.<number>}
  44253. */
  44254. getDataPercentWindow: function () {
  44255. return this._percentWindow.slice();
  44256. },
  44257. /**
  44258. * @public
  44259. * @param {number} axisIndex
  44260. * @return {Array} seriesModels
  44261. */
  44262. getTargetSeriesModels: function () {
  44263. var seriesModels = [];
  44264. this.ecModel.eachSeries(function (seriesModel) {
  44265. // Legacy problem: some one wrote xAxisIndex as [0] following the wrong way in example.
  44266. if (this._axisIndex === +seriesModel.get(this._dimName + 'AxisIndex')) {
  44267. seriesModels.push(seriesModel);
  44268. }
  44269. }, this);
  44270. return seriesModels;
  44271. },
  44272. getAxisModel: function () {
  44273. return this.ecModel.getComponent(this._dimName + 'Axis', this._axisIndex);
  44274. },
  44275. getOtherAxisModel: function () {
  44276. var axisDim = this._dimName;
  44277. var ecModel = this.ecModel;
  44278. var axisModel = this.getAxisModel();
  44279. var isCartesian = axisDim === 'x' || axisDim === 'y';
  44280. var otherAxisDim;
  44281. var coordSysIndexName;
  44282. if (isCartesian) {
  44283. coordSysIndexName = 'gridIndex';
  44284. otherAxisDim = axisDim === 'x' ? 'y' : 'x';
  44285. }
  44286. else {
  44287. coordSysIndexName = 'polarIndex';
  44288. otherAxisDim = axisDim === 'angle' ? 'radius' : 'angle';
  44289. }
  44290. var foundOtherAxisModel;
  44291. ecModel.eachComponent(otherAxisDim + 'Axis', function (otherAxisModel) {
  44292. if ((otherAxisModel.get(coordSysIndexName) || 0)
  44293. === (axisModel.get(coordSysIndexName) || 0)
  44294. ) {
  44295. foundOtherAxisModel = otherAxisModel;
  44296. }
  44297. });
  44298. return foundOtherAxisModel;
  44299. },
  44300. /**
  44301. * Notice: reset should not be called before series.restoreData() called,
  44302. * so it is recommanded to be called in "process stage" but not "model init
  44303. * stage".
  44304. *
  44305. * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel
  44306. */
  44307. reset: function (dataZoomModel) {
  44308. if (dataZoomModel !== this._dataZoomModel) {
  44309. return;
  44310. }
  44311. // Culculate data window and data extent, and record them.
  44312. var dataExtent = this._dataExtent = calculateDataExtent(
  44313. this._dimName, this.getTargetSeriesModels()
  44314. );
  44315. var dataWindow = calculateDataWindow(
  44316. dataZoomModel.option, dataExtent, this
  44317. );
  44318. this._valueWindow = dataWindow.valueWindow;
  44319. this._percentWindow = dataWindow.percentWindow;
  44320. // Update axis setting then.
  44321. setAxisModel(this);
  44322. },
  44323. /**
  44324. * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel
  44325. */
  44326. restore: function (dataZoomModel) {
  44327. if (dataZoomModel !== this._dataZoomModel) {
  44328. return;
  44329. }
  44330. this._valueWindow = this._percentWindow = null;
  44331. setAxisModel(this, true);
  44332. },
  44333. /**
  44334. * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel
  44335. */
  44336. filterData: function (dataZoomModel) {
  44337. if (dataZoomModel !== this._dataZoomModel) {
  44338. return;
  44339. }
  44340. var axisDim = this._dimName;
  44341. var seriesModels = this.getTargetSeriesModels();
  44342. var filterMode = dataZoomModel.get('filterMode');
  44343. var valueWindow = this._valueWindow;
  44344. // FIXME
  44345. // Toolbox may has dataZoom injected. And if there are stacked bar chart
  44346. // with NaN data, NaN will be filtered and stack will be wrong.
  44347. // So we need to force the mode to be set empty.
  44348. // In fect, it is not a big deal that do not support filterMode-'filter'
  44349. // when using toolbox#dataZoom, utill tooltip#dataZoom support "single axis
  44350. // selection" some day, which might need "adapt to data extent on the
  44351. // otherAxis", which is disabled by filterMode-'empty'.
  44352. var otherAxisModel = this.getOtherAxisModel();
  44353. if (dataZoomModel.get('$fromToolbox')
  44354. && otherAxisModel
  44355. && otherAxisModel.get('type') === 'category'
  44356. ) {
  44357. filterMode = 'empty';
  44358. }
  44359. // Process series data
  44360. each(seriesModels, function (seriesModel) {
  44361. var seriesData = seriesModel.getData();
  44362. seriesData && each(seriesModel.coordDimToDataDim(axisDim), function (dim) {
  44363. if (filterMode === 'empty') {
  44364. seriesModel.setData(
  44365. seriesData.map(dim, function (value) {
  44366. return !isInWindow(value) ? NaN : value;
  44367. })
  44368. );
  44369. }
  44370. else {
  44371. seriesData.filterSelf(dim, isInWindow);
  44372. }
  44373. });
  44374. });
  44375. function isInWindow(value) {
  44376. return value >= valueWindow[0] && value <= valueWindow[1];
  44377. }
  44378. }
  44379. };
  44380. function calculateDataExtent(axisDim, seriesModels) {
  44381. var dataExtent = [Infinity, -Infinity];
  44382. each(seriesModels, function (seriesModel) {
  44383. var seriesData = seriesModel.getData();
  44384. if (seriesData) {
  44385. each(seriesModel.coordDimToDataDim(axisDim), function (dim) {
  44386. var seriesExtent = seriesData.getDataExtent(dim);
  44387. seriesExtent[0] < dataExtent[0] && (dataExtent[0] = seriesExtent[0]);
  44388. seriesExtent[1] > dataExtent[1] && (dataExtent[1] = seriesExtent[1]);
  44389. });
  44390. }
  44391. }, this);
  44392. return dataExtent;
  44393. }
  44394. function calculateDataWindow(opt, dataExtent, axisProxy) {
  44395. var axisModel = axisProxy.getAxisModel();
  44396. var scale = axisModel.axis.scale;
  44397. var percentExtent = [0, 100];
  44398. var percentWindow = [
  44399. opt.start,
  44400. opt.end
  44401. ];
  44402. var valueWindow = [];
  44403. // In percent range is used and axis min/max/scale is set,
  44404. // window should be based on min/max/0, but should not be
  44405. // based on the extent of filtered data.
  44406. dataExtent = dataExtent.slice();
  44407. fixExtendByAxis(dataExtent, axisModel, scale);
  44408. each(['startValue', 'endValue'], function (prop) {
  44409. valueWindow.push(
  44410. opt[prop] != null
  44411. ? scale.parse(opt[prop])
  44412. : null
  44413. );
  44414. });
  44415. // Normalize bound.
  44416. each([0, 1], function (idx) {
  44417. var boundValue = valueWindow[idx];
  44418. var boundPercent = percentWindow[idx];
  44419. // start/end has higher priority over startValue/endValue,
  44420. // because start/end can be consistent among different type
  44421. // of axis but startValue/endValue not.
  44422. if (boundPercent != null || boundValue == null) {
  44423. if (boundPercent == null) {
  44424. boundPercent = percentExtent[idx];
  44425. }
  44426. // Use scale.parse to math round for category or time axis.
  44427. boundValue = scale.parse(numberUtil.linearMap(
  44428. boundPercent, percentExtent, dataExtent, true
  44429. ));
  44430. }
  44431. else { // boundPercent == null && boundValue != null
  44432. boundPercent = numberUtil.linearMap(
  44433. boundValue, dataExtent, percentExtent, true
  44434. );
  44435. }
  44436. // valueWindow[idx] = round(boundValue);
  44437. // percentWindow[idx] = round(boundPercent);
  44438. valueWindow[idx] = boundValue;
  44439. percentWindow[idx] = boundPercent;
  44440. });
  44441. return {
  44442. valueWindow: asc(valueWindow),
  44443. percentWindow: asc(percentWindow)
  44444. };
  44445. }
  44446. function fixExtendByAxis(dataExtent, axisModel, scale) {
  44447. each(['min', 'max'], function (minMax, index) {
  44448. var axisMax = axisModel.get(minMax, true);
  44449. // Consider 'dataMin', 'dataMax'
  44450. if (axisMax != null && (axisMax + '').toLowerCase() !== 'data' + minMax) {
  44451. dataExtent[index] = scale.parse(axisMax);
  44452. }
  44453. });
  44454. if (!axisModel.get('scale', true)) {
  44455. dataExtent[0] > 0 && (dataExtent[0] = 0);
  44456. dataExtent[1] < 0 && (dataExtent[1] = 0);
  44457. }
  44458. return dataExtent;
  44459. }
  44460. function setAxisModel(axisProxy, isRestore) {
  44461. var axisModel = axisProxy.getAxisModel();
  44462. var percentWindow = axisProxy._percentWindow;
  44463. var valueWindow = axisProxy._valueWindow;
  44464. if (!percentWindow) {
  44465. return;
  44466. }
  44467. var isFull = isRestore || (percentWindow[0] === 0 && percentWindow[1] === 100);
  44468. // [0, 500]: arbitrary value, guess axis extent.
  44469. var precision = !isRestore && numberUtil.getPixelPrecision(valueWindow, [0, 500]);
  44470. // toFixed() digits argument must be between 0 and 20
  44471. var invalidPrecision = !isRestore && !(precision < 20 && precision >= 0);
  44472. var useOrigin = isRestore || isFull || invalidPrecision;
  44473. axisModel.setRange && axisModel.setRange(
  44474. useOrigin ? null : +valueWindow[0].toFixed(precision),
  44475. useOrigin ? null : +valueWindow[1].toFixed(precision)
  44476. );
  44477. }
  44478. module.exports = AxisProxy;
  44479. /***/ },
  44480. /* 320 */
  44481. /***/ function(module, exports, __webpack_require__) {
  44482. var ComponentView = __webpack_require__(29);
  44483. module.exports = ComponentView.extend({
  44484. type: 'dataZoom',
  44485. render: function (dataZoomModel, ecModel, api, payload) {
  44486. this.dataZoomModel = dataZoomModel;
  44487. this.ecModel = ecModel;
  44488. this.api = api;
  44489. },
  44490. /**
  44491. * Find the first target coordinate system.
  44492. *
  44493. * @protected
  44494. * @return {Object} {
  44495. * cartesians: [
  44496. * {model: coord0, axisModels: [axis1, axis3], coordIndex: 1},
  44497. * {model: coord1, axisModels: [axis0, axis2], coordIndex: 0},
  44498. * ...
  44499. * ], // cartesians must not be null/undefined.
  44500. * polars: [
  44501. * {model: coord0, axisModels: [axis4], coordIndex: 0},
  44502. * ...
  44503. * ], // polars must not be null/undefined.
  44504. * axisModels: [axis0, axis1, axis2, axis3, axis4]
  44505. * // axisModels must not be null/undefined.
  44506. * }
  44507. */
  44508. getTargetInfo: function () {
  44509. var dataZoomModel = this.dataZoomModel;
  44510. var ecModel = this.ecModel;
  44511. var cartesians = [];
  44512. var polars = [];
  44513. var axisModels = [];
  44514. dataZoomModel.eachTargetAxis(function (dimNames, axisIndex) {
  44515. var axisModel = ecModel.getComponent(dimNames.axis, axisIndex);
  44516. if (axisModel) {
  44517. axisModels.push(axisModel);
  44518. var gridIndex = axisModel.get('gridIndex');
  44519. var polarIndex = axisModel.get('polarIndex');
  44520. if (gridIndex != null) {
  44521. var coordModel = ecModel.getComponent('grid', gridIndex);
  44522. save(coordModel, axisModel, cartesians, gridIndex);
  44523. }
  44524. else if (polarIndex != null) {
  44525. var coordModel = ecModel.getComponent('polar', polarIndex);
  44526. save(coordModel, axisModel, polars, polarIndex);
  44527. }
  44528. }
  44529. }, this);
  44530. function save(coordModel, axisModel, store, coordIndex) {
  44531. var item;
  44532. for (var i = 0; i < store.length; i++) {
  44533. if (store[i].model === coordModel) {
  44534. item = store[i];
  44535. break;
  44536. }
  44537. }
  44538. if (!item) {
  44539. store.push(item = {
  44540. model: coordModel, axisModels: [], coordIndex: coordIndex
  44541. });
  44542. }
  44543. item.axisModels.push(axisModel);
  44544. }
  44545. return {
  44546. cartesians: cartesians,
  44547. polars: polars,
  44548. axisModels: axisModels
  44549. };
  44550. }
  44551. });
  44552. /***/ },
  44553. /* 321 */
  44554. /***/ function(module, exports, __webpack_require__) {
  44555. /**
  44556. * @file Data zoom model
  44557. */
  44558. var DataZoomModel = __webpack_require__(318);
  44559. var SliderZoomModel = DataZoomModel.extend({
  44560. type: 'dataZoom.slider',
  44561. layoutMode: 'box',
  44562. /**
  44563. * @protected
  44564. */
  44565. defaultOption: {
  44566. show: true,
  44567. // ph => placeholder. Using placehoder here because
  44568. // deault value can only be drived in view stage.
  44569. right: 'ph', // Default align to grid rect.
  44570. top: 'ph', // Default align to grid rect.
  44571. width: 'ph', // Default align to grid rect.
  44572. height: 'ph', // Default align to grid rect.
  44573. left: null, // Default align to grid rect.
  44574. bottom: null, // Default align to grid rect.
  44575. backgroundColor: 'rgba(47,69,84,0)', // Background of slider zoom component.
  44576. // dataBackgroundColor: '#ddd', // Background coor of data shadow and border of box,
  44577. // highest priority, remain for compatibility of
  44578. // previous version, but not recommended any more.
  44579. dataBackground: {
  44580. lineStyle: {
  44581. color: '#2f4554',
  44582. width: 0.5,
  44583. opacity: 0.3
  44584. },
  44585. areaStyle: {
  44586. color: 'rgba(47,69,84,0.3)',
  44587. opacity: 0.3
  44588. }
  44589. },
  44590. borderColor: '#ddd', // border color of the box. For compatibility,
  44591. // if dataBackgroundColor is set, borderColor
  44592. // is ignored.
  44593. fillerColor: 'rgba(167,183,204,0.4)', // Color of selected area.
  44594. // handleColor: 'rgba(89,170,216,0.95)', // Color of handle.
  44595. // 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',
  44596. 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',
  44597. // Percent of the slider height
  44598. handleSize: '100%',
  44599. handleStyle: {
  44600. color: '#a7b7cc'
  44601. },
  44602. labelPrecision: null,
  44603. labelFormatter: null,
  44604. showDetail: true,
  44605. showDataShadow: 'auto', // Default auto decision.
  44606. realtime: true,
  44607. zoomLock: false, // Whether disable zoom.
  44608. textStyle: {
  44609. color: '#333'
  44610. }
  44611. }
  44612. });
  44613. module.exports = SliderZoomModel;
  44614. /***/ },
  44615. /* 322 */
  44616. /***/ function(module, exports, __webpack_require__) {
  44617. var zrUtil = __webpack_require__(4);
  44618. var graphic = __webpack_require__(43);
  44619. var throttle = __webpack_require__(308);
  44620. var DataZoomView = __webpack_require__(320);
  44621. var Rect = graphic.Rect;
  44622. var numberUtil = __webpack_require__(7);
  44623. var linearMap = numberUtil.linearMap;
  44624. var layout = __webpack_require__(21);
  44625. var sliderMove = __webpack_require__(323);
  44626. var asc = numberUtil.asc;
  44627. var bind = zrUtil.bind;
  44628. // var mathMax = Math.max;
  44629. var each = zrUtil.each;
  44630. // Constants
  44631. var DEFAULT_LOCATION_EDGE_GAP = 7;
  44632. var DEFAULT_FRAME_BORDER_WIDTH = 1;
  44633. var DEFAULT_FILLER_SIZE = 30;
  44634. var HORIZONTAL = 'horizontal';
  44635. var VERTICAL = 'vertical';
  44636. var LABEL_GAP = 5;
  44637. var SHOW_DATA_SHADOW_SERIES_TYPE = ['line', 'bar', 'candlestick', 'scatter'];
  44638. var SliderZoomView = DataZoomView.extend({
  44639. type: 'dataZoom.slider',
  44640. init: function (ecModel, api) {
  44641. /**
  44642. * @private
  44643. * @type {Object}
  44644. */
  44645. this._displayables = {};
  44646. /**
  44647. * @private
  44648. * @type {string}
  44649. */
  44650. this._orient;
  44651. /**
  44652. * [0, 100]
  44653. * @private
  44654. */
  44655. this._range;
  44656. /**
  44657. * [coord of the first handle, coord of the second handle]
  44658. * @private
  44659. */
  44660. this._handleEnds;
  44661. /**
  44662. * [length, thick]
  44663. * @private
  44664. * @type {Array.<number>}
  44665. */
  44666. this._size;
  44667. /**
  44668. * @private
  44669. * @type {number}
  44670. */
  44671. this._handleWidth;
  44672. /**
  44673. * @private
  44674. * @type {number}
  44675. */
  44676. this._handleHeight;
  44677. /**
  44678. * @private
  44679. */
  44680. this._location;
  44681. /**
  44682. * @private
  44683. */
  44684. this._dragging;
  44685. /**
  44686. * @private
  44687. */
  44688. this._dataShadowInfo;
  44689. this.api = api;
  44690. },
  44691. /**
  44692. * @override
  44693. */
  44694. render: function (dataZoomModel, ecModel, api, payload) {
  44695. SliderZoomView.superApply(this, 'render', arguments);
  44696. throttle.createOrUpdate(
  44697. this,
  44698. '_dispatchZoomAction',
  44699. this.dataZoomModel.get('throttle'),
  44700. 'fixRate'
  44701. );
  44702. this._orient = dataZoomModel.get('orient');
  44703. if (this.dataZoomModel.get('show') === false) {
  44704. this.group.removeAll();
  44705. return;
  44706. }
  44707. // Notice: this._resetInterval() should not be executed when payload.type
  44708. // is 'dataZoom', origin this._range should be maintained, otherwise 'pan'
  44709. // or 'zoom' info will be missed because of 'throttle' of this.dispatchAction,
  44710. if (!payload || payload.type !== 'dataZoom' || payload.from !== this.uid) {
  44711. this._buildView();
  44712. }
  44713. this._updateView();
  44714. },
  44715. /**
  44716. * @override
  44717. */
  44718. remove: function () {
  44719. SliderZoomView.superApply(this, 'remove', arguments);
  44720. throttle.clear(this, '_dispatchZoomAction');
  44721. },
  44722. /**
  44723. * @override
  44724. */
  44725. dispose: function () {
  44726. SliderZoomView.superApply(this, 'dispose', arguments);
  44727. throttle.clear(this, '_dispatchZoomAction');
  44728. },
  44729. _buildView: function () {
  44730. var thisGroup = this.group;
  44731. thisGroup.removeAll();
  44732. this._resetLocation();
  44733. this._resetInterval();
  44734. var barGroup = this._displayables.barGroup = new graphic.Group();
  44735. this._renderBackground();
  44736. this._renderHandle();
  44737. this._renderDataShadow();
  44738. thisGroup.add(barGroup);
  44739. this._positionGroup();
  44740. },
  44741. /**
  44742. * @private
  44743. */
  44744. _resetLocation: function () {
  44745. var dataZoomModel = this.dataZoomModel;
  44746. var api = this.api;
  44747. // If some of x/y/width/height are not specified,
  44748. // auto-adapt according to target grid.
  44749. var coordRect = this._findCoordRect();
  44750. var ecSize = {width: api.getWidth(), height: api.getHeight()};
  44751. // Default align by coordinate system rect.
  44752. var positionInfo = this._orient === HORIZONTAL
  44753. ? {
  44754. // Why using 'right', because right should be used in vertical,
  44755. // and it is better to be consistent for dealing with position param merge.
  44756. right: ecSize.width - coordRect.x - coordRect.width,
  44757. top: (ecSize.height - DEFAULT_FILLER_SIZE - DEFAULT_LOCATION_EDGE_GAP),
  44758. width: coordRect.width,
  44759. height: DEFAULT_FILLER_SIZE
  44760. }
  44761. : { // vertical
  44762. right: DEFAULT_LOCATION_EDGE_GAP,
  44763. top: coordRect.y,
  44764. width: DEFAULT_FILLER_SIZE,
  44765. height: coordRect.height
  44766. };
  44767. // Do not write back to option and replace value 'ph', because
  44768. // the 'ph' value should be recalculated when resize.
  44769. var layoutParams = layout.getLayoutParams(dataZoomModel.option);
  44770. // Replace the placeholder value.
  44771. zrUtil.each(['right', 'top', 'width', 'height'], function (name) {
  44772. if (layoutParams[name] === 'ph') {
  44773. layoutParams[name] = positionInfo[name];
  44774. }
  44775. });
  44776. var layoutRect = layout.getLayoutRect(
  44777. layoutParams,
  44778. ecSize,
  44779. dataZoomModel.padding
  44780. );
  44781. this._location = {x: layoutRect.x, y: layoutRect.y};
  44782. this._size = [layoutRect.width, layoutRect.height];
  44783. this._orient === VERTICAL && this._size.reverse();
  44784. },
  44785. /**
  44786. * @private
  44787. */
  44788. _positionGroup: function () {
  44789. var thisGroup = this.group;
  44790. var location = this._location;
  44791. var orient = this._orient;
  44792. // Just use the first axis to determine mapping.
  44793. var targetAxisModel = this.dataZoomModel.getFirstTargetAxisModel();
  44794. var inverse = targetAxisModel && targetAxisModel.get('inverse');
  44795. var barGroup = this._displayables.barGroup;
  44796. var otherAxisInverse = (this._dataShadowInfo || {}).otherAxisInverse;
  44797. // Transform barGroup.
  44798. barGroup.attr(
  44799. (orient === HORIZONTAL && !inverse)
  44800. ? {scale: otherAxisInverse ? [1, 1] : [1, -1]}
  44801. : (orient === HORIZONTAL && inverse)
  44802. ? {scale: otherAxisInverse ? [-1, 1] : [-1, -1]}
  44803. : (orient === VERTICAL && !inverse)
  44804. ? {scale: otherAxisInverse ? [1, -1] : [1, 1], rotation: Math.PI / 2}
  44805. // Dont use Math.PI, considering shadow direction.
  44806. : {scale: otherAxisInverse ? [-1, -1] : [-1, 1], rotation: Math.PI / 2}
  44807. );
  44808. // Position barGroup
  44809. var rect = thisGroup.getBoundingRect([barGroup]);
  44810. thisGroup.attr('position', [location.x - rect.x, location.y - rect.y]);
  44811. },
  44812. /**
  44813. * @private
  44814. */
  44815. _getViewExtent: function () {
  44816. return [0, this._size[0]];
  44817. },
  44818. _renderBackground : function () {
  44819. var dataZoomModel = this.dataZoomModel;
  44820. var size = this._size;
  44821. this._displayables.barGroup.add(new Rect({
  44822. silent: true,
  44823. shape: {
  44824. x: 0, y: 0, width: size[0], height: size[1]
  44825. },
  44826. style: {
  44827. fill: dataZoomModel.get('backgroundColor')
  44828. },
  44829. z2: -40
  44830. }));
  44831. },
  44832. _renderDataShadow: function () {
  44833. var info = this._dataShadowInfo = this._prepareDataShadowInfo();
  44834. if (!info) {
  44835. return;
  44836. }
  44837. var size = this._size;
  44838. var seriesModel = info.series;
  44839. var data = seriesModel.getRawData();
  44840. var otherDim = seriesModel.getShadowDim
  44841. ? seriesModel.getShadowDim() // @see candlestick
  44842. : info.otherDim;
  44843. var otherDataExtent = data.getDataExtent(otherDim);
  44844. // Nice extent.
  44845. var otherOffset = (otherDataExtent[1] - otherDataExtent[0]) * 0.3;
  44846. otherDataExtent = [
  44847. otherDataExtent[0] - otherOffset,
  44848. otherDataExtent[1] + otherOffset
  44849. ];
  44850. var otherShadowExtent = [0, size[1]];
  44851. var thisShadowExtent = [0, size[0]];
  44852. var areaPoints = [[size[0], 0], [0, 0]];
  44853. var linePoints = [];
  44854. var step = thisShadowExtent[1] / (data.count() - 1);
  44855. var thisCoord = 0;
  44856. // Optimize for large data shadow
  44857. var stride = Math.round(data.count() / size[0]);
  44858. data.each([otherDim], function (value, index) {
  44859. if (stride > 0 && (index % stride)) {
  44860. thisCoord += step;
  44861. return;
  44862. }
  44863. // FIXME
  44864. // 应该使用统计的空判断?还是在list里进行空判断?
  44865. var otherCoord = (value == null || isNaN(value) || value === '')
  44866. ? null
  44867. : linearMap(value, otherDataExtent, otherShadowExtent, true);
  44868. if (otherCoord != null) {
  44869. areaPoints.push([thisCoord, otherCoord]);
  44870. linePoints.push([thisCoord, otherCoord]);
  44871. }
  44872. thisCoord += step;
  44873. });
  44874. var dataZoomModel = this.dataZoomModel;
  44875. // var dataBackgroundModel = dataZoomModel.getModel('dataBackground');
  44876. this._displayables.barGroup.add(new graphic.Polygon({
  44877. shape: {points: areaPoints},
  44878. style: zrUtil.defaults(
  44879. {fill: dataZoomModel.get('dataBackgroundColor')},
  44880. dataZoomModel.getModel('dataBackground.areaStyle').getAreaStyle()
  44881. ),
  44882. silent: true,
  44883. z2: -20
  44884. }));
  44885. this._displayables.barGroup.add(new graphic.Polyline({
  44886. shape: {points: linePoints},
  44887. style: dataZoomModel.getModel('dataBackground.lineStyle').getLineStyle(),
  44888. silent: true,
  44889. z2: -19
  44890. }));
  44891. },
  44892. _prepareDataShadowInfo: function () {
  44893. var dataZoomModel = this.dataZoomModel;
  44894. var showDataShadow = dataZoomModel.get('showDataShadow');
  44895. if (showDataShadow === false) {
  44896. return;
  44897. }
  44898. // Find a representative series.
  44899. var result;
  44900. var ecModel = this.ecModel;
  44901. dataZoomModel.eachTargetAxis(function (dimNames, axisIndex) {
  44902. var seriesModels = dataZoomModel
  44903. .getAxisProxy(dimNames.name, axisIndex)
  44904. .getTargetSeriesModels();
  44905. zrUtil.each(seriesModels, function (seriesModel) {
  44906. if (result) {
  44907. return;
  44908. }
  44909. if (showDataShadow !== true && zrUtil.indexOf(
  44910. SHOW_DATA_SHADOW_SERIES_TYPE, seriesModel.get('type')
  44911. ) < 0
  44912. ) {
  44913. return;
  44914. }
  44915. var otherDim = getOtherDim(dimNames.name);
  44916. var thisAxis = ecModel.getComponent(dimNames.axis, axisIndex).axis;
  44917. result = {
  44918. thisAxis: thisAxis,
  44919. series: seriesModel,
  44920. thisDim: dimNames.name,
  44921. otherDim: otherDim,
  44922. otherAxisInverse: seriesModel
  44923. .coordinateSystem.getOtherAxis(thisAxis).inverse
  44924. };
  44925. }, this);
  44926. }, this);
  44927. return result;
  44928. },
  44929. _renderHandle: function () {
  44930. var displaybles = this._displayables;
  44931. var handles = displaybles.handles = [];
  44932. var handleLabels = displaybles.handleLabels = [];
  44933. var barGroup = this._displayables.barGroup;
  44934. var size = this._size;
  44935. var dataZoomModel = this.dataZoomModel;
  44936. barGroup.add(displaybles.filler = new Rect({
  44937. draggable: true,
  44938. cursor: 'move',
  44939. drift: bind(this._onDragMove, this, 'all'),
  44940. ondragstart: bind(this._showDataInfo, this, true),
  44941. ondragend: bind(this._onDragEnd, this),
  44942. onmouseover: bind(this._showDataInfo, this, true),
  44943. onmouseout: bind(this._showDataInfo, this, false),
  44944. style: {
  44945. fill: dataZoomModel.get('fillerColor'),
  44946. textPosition : 'inside'
  44947. }
  44948. }));
  44949. // Frame border.
  44950. barGroup.add(new Rect(graphic.subPixelOptimizeRect({
  44951. silent: true,
  44952. shape: {
  44953. x: 0,
  44954. y: 0,
  44955. width: size[0],
  44956. height: size[1]
  44957. },
  44958. style: {
  44959. stroke: dataZoomModel.get('dataBackgroundColor')
  44960. || dataZoomModel.get('borderColor'),
  44961. lineWidth: DEFAULT_FRAME_BORDER_WIDTH,
  44962. fill: 'rgba(0,0,0,0)'
  44963. }
  44964. })));
  44965. var iconStr = dataZoomModel.get('handleIcon');
  44966. each([0, 1], function (handleIndex) {
  44967. var path = graphic.makePath(iconStr, {
  44968. style: {
  44969. strokeNoScale: true
  44970. },
  44971. rectHover: true,
  44972. cursor: this._orient === 'vertical' ? 'ns-resize' : 'ew-resize',
  44973. draggable: true,
  44974. drift: bind(this._onDragMove, this, handleIndex),
  44975. ondragend: bind(this._onDragEnd, this),
  44976. onmouseover: bind(this._showDataInfo, this, true),
  44977. onmouseout: bind(this._showDataInfo, this, false)
  44978. }, {
  44979. x: -0.5,
  44980. y: 0,
  44981. width: 1,
  44982. height: 1
  44983. }, 'center');
  44984. var bRect = path.getBoundingRect();
  44985. this._handleHeight = numberUtil.parsePercent(dataZoomModel.get('handleSize'), this._size[1]);
  44986. this._handleWidth = bRect.width / bRect.height * this._handleHeight;
  44987. path.setStyle(dataZoomModel.getModel('handleStyle').getItemStyle());
  44988. var handleColor = dataZoomModel.get('handleColor');
  44989. // Compatitable with previous version
  44990. if (handleColor != null) {
  44991. path.style.fill = handleColor;
  44992. }
  44993. barGroup.add(handles[handleIndex] = path);
  44994. var textStyleModel = dataZoomModel.textStyleModel;
  44995. this.group.add(
  44996. handleLabels[handleIndex] = new graphic.Text({
  44997. silent: true,
  44998. invisible: true,
  44999. style: {
  45000. x: 0, y: 0, text: '',
  45001. textVerticalAlign: 'middle',
  45002. textAlign: 'center',
  45003. fill: textStyleModel.getTextColor(),
  45004. textFont: textStyleModel.getFont()
  45005. },
  45006. z2: 10
  45007. }));
  45008. }, this);
  45009. },
  45010. /**
  45011. * @private
  45012. */
  45013. _resetInterval: function () {
  45014. var range = this._range = this.dataZoomModel.getPercentRange();
  45015. var viewExtent = this._getViewExtent();
  45016. this._handleEnds = [
  45017. linearMap(range[0], [0, 100], viewExtent, true),
  45018. linearMap(range[1], [0, 100], viewExtent, true)
  45019. ];
  45020. },
  45021. /**
  45022. * @private
  45023. * @param {(number|string)} handleIndex 0 or 1 or 'all'
  45024. * @param {number} dx
  45025. * @param {number} dy
  45026. */
  45027. _updateInterval: function (handleIndex, delta) {
  45028. var handleEnds = this._handleEnds;
  45029. var viewExtend = this._getViewExtent();
  45030. sliderMove(
  45031. delta,
  45032. handleEnds,
  45033. viewExtend,
  45034. (handleIndex === 'all' || this.dataZoomModel.get('zoomLock'))
  45035. ? 'rigid' : 'cross',
  45036. handleIndex
  45037. );
  45038. this._range = asc([
  45039. linearMap(handleEnds[0], viewExtend, [0, 100], true),
  45040. linearMap(handleEnds[1], viewExtend, [0, 100], true)
  45041. ]);
  45042. },
  45043. /**
  45044. * @private
  45045. */
  45046. _updateView: function () {
  45047. var displaybles = this._displayables;
  45048. var handleEnds = this._handleEnds;
  45049. var handleInterval = asc(handleEnds.slice());
  45050. var size = this._size;
  45051. each([0, 1], function (handleIndex) {
  45052. // Handles
  45053. var handle = displaybles.handles[handleIndex];
  45054. var handleHeight = this._handleHeight;
  45055. handle.attr({
  45056. scale: [handleHeight, handleHeight],
  45057. position: [handleEnds[handleIndex], size[1] / 2 - handleHeight / 2]
  45058. });
  45059. }, this);
  45060. // Filler
  45061. displaybles.filler.setShape({
  45062. x: handleInterval[0],
  45063. y: 0,
  45064. width: handleInterval[1] - handleInterval[0],
  45065. height: size[1]
  45066. });
  45067. this._updateDataInfo();
  45068. },
  45069. /**
  45070. * @private
  45071. */
  45072. _updateDataInfo: function () {
  45073. var dataZoomModel = this.dataZoomModel;
  45074. var displaybles = this._displayables;
  45075. var handleLabels = displaybles.handleLabels;
  45076. var orient = this._orient;
  45077. var labelTexts = ['', ''];
  45078. // FIXME
  45079. // date型,支持formatter,autoformatter(ec2 date.getAutoFormatter)
  45080. if (dataZoomModel.get('showDetail')) {
  45081. var dataInterval;
  45082. var axis;
  45083. dataZoomModel.eachTargetAxis(function (dimNames, axisIndex) {
  45084. // Using dataInterval of the first axis.
  45085. if (!dataInterval) {
  45086. dataInterval = dataZoomModel
  45087. .getAxisProxy(dimNames.name, axisIndex)
  45088. .getDataValueWindow();
  45089. axis = this.ecModel.getComponent(dimNames.axis, axisIndex).axis;
  45090. }
  45091. }, this);
  45092. if (dataInterval) {
  45093. labelTexts = [
  45094. this._formatLabel(dataInterval[0], axis),
  45095. this._formatLabel(dataInterval[1], axis)
  45096. ];
  45097. }
  45098. }
  45099. var orderedHandleEnds = asc(this._handleEnds.slice());
  45100. setLabel.call(this, 0);
  45101. setLabel.call(this, 1);
  45102. function setLabel(handleIndex) {
  45103. // Label
  45104. // Text should not transform by barGroup.
  45105. // Ignore handlers transform
  45106. var barTransform = graphic.getTransform(
  45107. displaybles.handles[handleIndex].parent, this.group
  45108. );
  45109. var direction = graphic.transformDirection(
  45110. handleIndex === 0 ? 'right' : 'left', barTransform
  45111. );
  45112. var offset = this._handleWidth / 2 + LABEL_GAP;
  45113. var textPoint = graphic.applyTransform(
  45114. [
  45115. orderedHandleEnds[handleIndex] + (handleIndex === 0 ? -offset : offset),
  45116. this._size[1] / 2
  45117. ],
  45118. barTransform
  45119. );
  45120. handleLabels[handleIndex].setStyle({
  45121. x: textPoint[0],
  45122. y: textPoint[1],
  45123. textVerticalAlign: orient === HORIZONTAL ? 'middle' : direction,
  45124. textAlign: orient === HORIZONTAL ? direction : 'center',
  45125. text: labelTexts[handleIndex]
  45126. });
  45127. }
  45128. },
  45129. /**
  45130. * @private
  45131. */
  45132. _formatLabel: function (value, axis) {
  45133. var dataZoomModel = this.dataZoomModel;
  45134. var labelFormatter = dataZoomModel.get('labelFormatter');
  45135. if (zrUtil.isFunction(labelFormatter)) {
  45136. return labelFormatter(value);
  45137. }
  45138. var labelPrecision = dataZoomModel.get('labelPrecision');
  45139. if (labelPrecision == null || labelPrecision === 'auto') {
  45140. labelPrecision = axis.getPixelPrecision();
  45141. }
  45142. value = (value == null && isNaN(value))
  45143. ? ''
  45144. // FIXME Glue code
  45145. : (axis.type === 'category' || axis.type === 'time')
  45146. ? axis.scale.getLabel(Math.round(value))
  45147. // param of toFixed should less then 20.
  45148. : value.toFixed(Math.min(labelPrecision, 20));
  45149. if (zrUtil.isString(labelFormatter)) {
  45150. value = labelFormatter.replace('{value}', value);
  45151. }
  45152. return value;
  45153. },
  45154. /**
  45155. * @private
  45156. * @param {boolean} showOrHide true: show, false: hide
  45157. */
  45158. _showDataInfo: function (showOrHide) {
  45159. // Always show when drgging.
  45160. showOrHide = this._dragging || showOrHide;
  45161. var handleLabels = this._displayables.handleLabels;
  45162. handleLabels[0].attr('invisible', !showOrHide);
  45163. handleLabels[1].attr('invisible', !showOrHide);
  45164. },
  45165. _onDragMove: function (handleIndex, dx, dy) {
  45166. this._dragging = true;
  45167. // Transform dx, dy to bar coordination.
  45168. var vertex = this._applyBarTransform([dx, dy], true);
  45169. this._updateInterval(handleIndex, vertex[0]);
  45170. this._updateView();
  45171. if (this.dataZoomModel.get('realtime')) {
  45172. this._dispatchZoomAction();
  45173. }
  45174. },
  45175. _onDragEnd: function () {
  45176. this._dragging = false;
  45177. this._showDataInfo(false);
  45178. this._dispatchZoomAction();
  45179. },
  45180. /**
  45181. * This action will be throttled.
  45182. * @private
  45183. */
  45184. _dispatchZoomAction: function () {
  45185. var range = this._range;
  45186. this.api.dispatchAction({
  45187. type: 'dataZoom',
  45188. from: this.uid,
  45189. dataZoomId: this.dataZoomModel.id,
  45190. start: range[0],
  45191. end: range[1]
  45192. });
  45193. },
  45194. /**
  45195. * @private
  45196. */
  45197. _applyBarTransform: function (vertex, inverse) {
  45198. var barTransform = this._displayables.barGroup.getLocalTransform();
  45199. return graphic.applyTransform(vertex, barTransform, inverse);
  45200. },
  45201. /**
  45202. * @private
  45203. */
  45204. _findCoordRect: function () {
  45205. // Find the grid coresponding to the first axis referred by dataZoom.
  45206. var targetInfo = this.getTargetInfo();
  45207. // FIXME
  45208. // 判断是catesian还是polar
  45209. var rect;
  45210. if (targetInfo.cartesians.length) {
  45211. rect = targetInfo.cartesians[0].model.coordinateSystem.getRect();
  45212. }
  45213. else { // Polar
  45214. // FIXME
  45215. // 暂时随便写的
  45216. var width = this.api.getWidth();
  45217. var height = this.api.getHeight();
  45218. rect = {
  45219. x: width * 0.2,
  45220. y: height * 0.2,
  45221. width: width * 0.6,
  45222. height: height * 0.6
  45223. };
  45224. }
  45225. return rect;
  45226. }
  45227. });
  45228. function getOtherDim(thisDim) {
  45229. // FIXME
  45230. // 这个逻辑和getOtherAxis里一致,但是写在这里是否不好
  45231. return thisDim === 'x' ? 'y' : 'x';
  45232. }
  45233. module.exports = SliderZoomView;
  45234. /***/ },
  45235. /* 323 */
  45236. /***/ function(module, exports) {
  45237. /**
  45238. * Calculate slider move result.
  45239. *
  45240. * @param {number} delta Move length.
  45241. * @param {Array.<number>} handleEnds handleEnds[0] and be bigger then handleEnds[1].
  45242. * handleEnds will be modified in this method.
  45243. * @param {Array.<number>} extent handleEnds is restricted by extent.
  45244. * extent[0] should less or equals than extent[1].
  45245. * @param {string} mode 'rigid': Math.abs(handleEnds[0] - handleEnds[1]) remain unchanged,
  45246. * 'cross' handleEnds[0] can be bigger then handleEnds[1],
  45247. * 'push' handleEnds[0] can not be bigger then handleEnds[1],
  45248. * when they touch, one push other.
  45249. * @param {number} handleIndex If mode is 'rigid', handleIndex is not required.
  45250. * @param {Array.<number>} The input handleEnds.
  45251. */
  45252. module.exports = function (delta, handleEnds, extent, mode, handleIndex) {
  45253. if (!delta) {
  45254. return handleEnds;
  45255. }
  45256. if (mode === 'rigid') {
  45257. delta = getRealDelta(delta, handleEnds, extent);
  45258. handleEnds[0] += delta;
  45259. handleEnds[1] += delta;
  45260. }
  45261. else {
  45262. delta = getRealDelta(delta, handleEnds[handleIndex], extent);
  45263. handleEnds[handleIndex] += delta;
  45264. if (mode === 'push' && handleEnds[0] > handleEnds[1]) {
  45265. handleEnds[1 - handleIndex] = handleEnds[handleIndex];
  45266. }
  45267. }
  45268. return handleEnds;
  45269. function getRealDelta(delta, handleEnds, extent) {
  45270. var handleMinMax = !handleEnds.length
  45271. ? [handleEnds, handleEnds]
  45272. : handleEnds.slice();
  45273. handleEnds[0] > handleEnds[1] && handleMinMax.reverse();
  45274. if (delta < 0 && handleMinMax[0] + delta < extent[0]) {
  45275. delta = extent[0] - handleMinMax[0];
  45276. }
  45277. if (delta > 0 && handleMinMax[1] + delta > extent[1]) {
  45278. delta = extent[1] - handleMinMax[1];
  45279. }
  45280. return delta;
  45281. }
  45282. };
  45283. /***/ },
  45284. /* 324 */
  45285. /***/ function(module, exports, __webpack_require__) {
  45286. /**
  45287. * @file Data zoom model
  45288. */
  45289. module.exports = __webpack_require__(318).extend({
  45290. type: 'dataZoom.inside',
  45291. /**
  45292. * @protected
  45293. */
  45294. defaultOption: {
  45295. zoomLock: false // Whether disable zoom but only pan.
  45296. }
  45297. });
  45298. /***/ },
  45299. /* 325 */
  45300. /***/ function(module, exports, __webpack_require__) {
  45301. var DataZoomView = __webpack_require__(320);
  45302. var zrUtil = __webpack_require__(4);
  45303. var sliderMove = __webpack_require__(323);
  45304. var roams = __webpack_require__(326);
  45305. var bind = zrUtil.bind;
  45306. var InsideZoomView = DataZoomView.extend({
  45307. type: 'dataZoom.inside',
  45308. /**
  45309. * @override
  45310. */
  45311. init: function (ecModel, api) {
  45312. /**
  45313. * 'throttle' is used in this.dispatchAction, so we save range
  45314. * to avoid missing some 'pan' info.
  45315. * @private
  45316. * @type {Array.<number>}
  45317. */
  45318. this._range;
  45319. },
  45320. /**
  45321. * @override
  45322. */
  45323. render: function (dataZoomModel, ecModel, api, payload) {
  45324. InsideZoomView.superApply(this, 'render', arguments);
  45325. // Notice: origin this._range should be maintained, and should not be re-fetched
  45326. // from dataZoomModel when payload.type is 'dataZoom', otherwise 'pan' or 'zoom'
  45327. // info will be missed because of 'throttle' of this.dispatchAction.
  45328. if (roams.shouldRecordRange(payload, dataZoomModel.id)) {
  45329. this._range = dataZoomModel.getPercentRange();
  45330. }
  45331. // Reset controllers.
  45332. var coordInfoList = this.getTargetInfo().cartesians;
  45333. var allCoordIds = zrUtil.map(coordInfoList, function (coordInfo) {
  45334. return roams.generateCoordId(coordInfo.model);
  45335. });
  45336. zrUtil.each(coordInfoList, function (coordInfo) {
  45337. var coordModel = coordInfo.model;
  45338. roams.register(
  45339. api,
  45340. {
  45341. coordId: roams.generateCoordId(coordModel),
  45342. allCoordIds: allCoordIds,
  45343. coordinateSystem: coordModel.coordinateSystem,
  45344. dataZoomId: dataZoomModel.id,
  45345. throttleRate: dataZoomModel.get('throttle', true),
  45346. panGetRange: bind(this._onPan, this, coordInfo),
  45347. zoomGetRange: bind(this._onZoom, this, coordInfo)
  45348. }
  45349. );
  45350. }, this);
  45351. // TODO
  45352. // polar支持
  45353. },
  45354. /**
  45355. * @override
  45356. */
  45357. dispose: function () {
  45358. roams.unregister(this.api, this.dataZoomModel.id);
  45359. InsideZoomView.superApply(this, 'dispose', arguments);
  45360. this._range = null;
  45361. },
  45362. /**
  45363. * @private
  45364. */
  45365. _onPan: function (coordInfo, controller, dx, dy) {
  45366. return (
  45367. this._range = panCartesian(
  45368. [dx, dy], this._range, controller, coordInfo
  45369. )
  45370. );
  45371. },
  45372. /**
  45373. * @private
  45374. */
  45375. _onZoom: function (coordInfo, controller, scale, mouseX, mouseY) {
  45376. var dataZoomModel = this.dataZoomModel;
  45377. if (dataZoomModel.option.zoomLock) {
  45378. return this._range;
  45379. }
  45380. return (
  45381. this._range = scaleCartesian(
  45382. 1 / scale, [mouseX, mouseY], this._range,
  45383. controller, coordInfo, dataZoomModel
  45384. )
  45385. );
  45386. }
  45387. });
  45388. function panCartesian(pixelDeltas, range, controller, coordInfo) {
  45389. range = range.slice();
  45390. // Calculate transform by the first axis.
  45391. var axisModel = coordInfo.axisModels[0];
  45392. if (!axisModel) {
  45393. return;
  45394. }
  45395. var directionInfo = getDirectionInfo(pixelDeltas, axisModel, controller);
  45396. var percentDelta = directionInfo.signal
  45397. * (range[1] - range[0])
  45398. * directionInfo.pixel / directionInfo.pixelLength;
  45399. sliderMove(
  45400. percentDelta,
  45401. range,
  45402. [0, 100],
  45403. 'rigid'
  45404. );
  45405. return range;
  45406. }
  45407. function scaleCartesian(scale, mousePoint, range, controller, coordInfo, dataZoomModel) {
  45408. range = range.slice();
  45409. // Calculate transform by the first axis.
  45410. var axisModel = coordInfo.axisModels[0];
  45411. if (!axisModel) {
  45412. return;
  45413. }
  45414. var directionInfo = getDirectionInfo(mousePoint, axisModel, controller);
  45415. var mouse = directionInfo.pixel - directionInfo.pixelStart;
  45416. var percentPoint = mouse / directionInfo.pixelLength * (range[1] - range[0]) + range[0];
  45417. scale = Math.max(scale, 0);
  45418. range[0] = (range[0] - percentPoint) * scale + percentPoint;
  45419. range[1] = (range[1] - percentPoint) * scale + percentPoint;
  45420. return fixRange(range);
  45421. }
  45422. function getDirectionInfo(xy, axisModel, controller) {
  45423. var axis = axisModel.axis;
  45424. var rect = controller.rectProvider();
  45425. var ret = {};
  45426. if (axis.dim === 'x') {
  45427. ret.pixel = xy[0];
  45428. ret.pixelLength = rect.width;
  45429. ret.pixelStart = rect.x;
  45430. ret.signal = axis.inverse ? 1 : -1;
  45431. }
  45432. else { // axis.dim === 'y'
  45433. ret.pixel = xy[1];
  45434. ret.pixelLength = rect.height;
  45435. ret.pixelStart = rect.y;
  45436. ret.signal = axis.inverse ? -1 : 1;
  45437. }
  45438. return ret;
  45439. }
  45440. function fixRange(range) {
  45441. // Clamp, using !(<= or >=) to handle NaN.
  45442. // jshint ignore:start
  45443. var bound = [0, 100];
  45444. !(range[0] <= bound[1]) && (range[0] = bound[1]);
  45445. !(range[1] <= bound[1]) && (range[1] = bound[1]);
  45446. !(range[0] >= bound[0]) && (range[0] = bound[0]);
  45447. !(range[1] >= bound[0]) && (range[1] = bound[0]);
  45448. // jshint ignore:end
  45449. return range;
  45450. }
  45451. module.exports = InsideZoomView;
  45452. /***/ },
  45453. /* 326 */
  45454. /***/ function(module, exports, __webpack_require__) {
  45455. /**
  45456. * @file Roam controller manager.
  45457. */
  45458. // Only create one roam controller for each coordinate system.
  45459. // one roam controller might be refered by two inside data zoom
  45460. // components (for example, one for x and one for y). When user
  45461. // pan or zoom, only dispatch one action for those data zoom
  45462. // components.
  45463. var zrUtil = __webpack_require__(4);
  45464. var RoamController = __webpack_require__(174);
  45465. var throttle = __webpack_require__(308);
  45466. var curry = zrUtil.curry;
  45467. var ATTR = '\0_ec_dataZoom_roams';
  45468. var roams = {
  45469. /**
  45470. * @public
  45471. * @param {module:echarts/ExtensionAPI} api
  45472. * @param {Object} dataZoomInfo
  45473. * @param {string} dataZoomInfo.coordId
  45474. * @param {Object} dataZoomInfo.coordinateSystem
  45475. * @param {Array.<string>} dataZoomInfo.allCoordIds
  45476. * @param {string} dataZoomInfo.dataZoomId
  45477. * @param {number} dataZoomInfo.throttleRate
  45478. * @param {Function} dataZoomInfo.panGetRange
  45479. * @param {Function} dataZoomInfo.zoomGetRange
  45480. */
  45481. register: function (api, dataZoomInfo) {
  45482. var store = giveStore(api);
  45483. var theDataZoomId = dataZoomInfo.dataZoomId;
  45484. var theCoordId = dataZoomInfo.coordId;
  45485. // Do clean when a dataZoom changes its target coordnate system.
  45486. zrUtil.each(store, function (record, coordId) {
  45487. var dataZoomInfos = record.dataZoomInfos;
  45488. if (dataZoomInfos[theDataZoomId]
  45489. && zrUtil.indexOf(dataZoomInfo.allCoordIds, theCoordId) < 0
  45490. ) {
  45491. delete dataZoomInfos[theDataZoomId];
  45492. record.count--;
  45493. }
  45494. });
  45495. cleanStore(store);
  45496. var record = store[theCoordId];
  45497. // Create if needed.
  45498. if (!record) {
  45499. record = store[theCoordId] = {
  45500. coordId: theCoordId,
  45501. dataZoomInfos: {},
  45502. count: 0
  45503. };
  45504. record.controller = createController(api, dataZoomInfo, record);
  45505. record.dispatchAction = zrUtil.curry(dispatchAction, api);
  45506. }
  45507. // Consider resize, area should be always updated.
  45508. var rect = dataZoomInfo.coordinateSystem.getRect().clone();
  45509. record.controller.rectProvider = function () {
  45510. return rect;
  45511. };
  45512. // Update throttle.
  45513. throttle.createOrUpdate(
  45514. record,
  45515. 'dispatchAction',
  45516. dataZoomInfo.throttleRate,
  45517. 'fixRate'
  45518. );
  45519. // Update reference of dataZoom.
  45520. !(record.dataZoomInfos[theDataZoomId]) && record.count++;
  45521. record.dataZoomInfos[theDataZoomId] = dataZoomInfo;
  45522. },
  45523. /**
  45524. * @public
  45525. * @param {module:echarts/ExtensionAPI} api
  45526. * @param {string} dataZoomId
  45527. */
  45528. unregister: function (api, dataZoomId) {
  45529. var store = giveStore(api);
  45530. zrUtil.each(store, function (record) {
  45531. var dataZoomInfos = record.dataZoomInfos;
  45532. if (dataZoomInfos[dataZoomId]) {
  45533. delete dataZoomInfos[dataZoomId];
  45534. record.count--;
  45535. }
  45536. });
  45537. cleanStore(store);
  45538. },
  45539. /**
  45540. * @public
  45541. */
  45542. shouldRecordRange: function (payload, dataZoomId) {
  45543. if (payload && payload.type === 'dataZoom' && payload.batch) {
  45544. for (var i = 0, len = payload.batch.length; i < len; i++) {
  45545. if (payload.batch[i].dataZoomId === dataZoomId) {
  45546. return false;
  45547. }
  45548. }
  45549. }
  45550. return true;
  45551. },
  45552. /**
  45553. * @public
  45554. */
  45555. generateCoordId: function (coordModel) {
  45556. return coordModel.type + '\0_' + coordModel.id;
  45557. }
  45558. };
  45559. /**
  45560. * Key: coordId, value: {dataZoomInfos: [], count, controller}
  45561. * @type {Array.<Object>}
  45562. */
  45563. function giveStore(api) {
  45564. // Mount store on zrender instance, so that we do not
  45565. // need to worry about dispose.
  45566. var zr = api.getZr();
  45567. return zr[ATTR] || (zr[ATTR] = {});
  45568. }
  45569. function createController(api, dataZoomInfo, newRecord) {
  45570. var controller = new RoamController(api.getZr());
  45571. controller.enable();
  45572. controller.on('pan', curry(onPan, newRecord));
  45573. controller.on('zoom', curry(onZoom, newRecord));
  45574. return controller;
  45575. }
  45576. function cleanStore(store) {
  45577. zrUtil.each(store, function (record, coordId) {
  45578. if (!record.count) {
  45579. record.controller.off('pan').off('zoom');
  45580. delete store[coordId];
  45581. }
  45582. });
  45583. }
  45584. function onPan(record, dx, dy) {
  45585. wrapAndDispatch(record, function (info) {
  45586. return info.panGetRange(record.controller, dx, dy);
  45587. });
  45588. }
  45589. function onZoom(record, scale, mouseX, mouseY) {
  45590. wrapAndDispatch(record, function (info) {
  45591. return info.zoomGetRange(record.controller, scale, mouseX, mouseY);
  45592. });
  45593. }
  45594. function wrapAndDispatch(record, getRange) {
  45595. var batch = [];
  45596. zrUtil.each(record.dataZoomInfos, function (info) {
  45597. var range = getRange(info);
  45598. range && batch.push({
  45599. dataZoomId: info.dataZoomId,
  45600. start: range[0],
  45601. end: range[1]
  45602. });
  45603. });
  45604. record.dispatchAction(batch);
  45605. }
  45606. /**
  45607. * This action will be throttled.
  45608. */
  45609. function dispatchAction(api, batch) {
  45610. api.dispatchAction({
  45611. type: 'dataZoom',
  45612. batch: batch
  45613. });
  45614. }
  45615. module.exports = roams;
  45616. /***/ },
  45617. /* 327 */
  45618. /***/ function(module, exports, __webpack_require__) {
  45619. /**
  45620. * @file Data zoom processor
  45621. */
  45622. var echarts = __webpack_require__(1);
  45623. echarts.registerProcessor(function (ecModel, api) {
  45624. ecModel.eachComponent('dataZoom', function (dataZoomModel) {
  45625. // We calculate window and reset axis here but not in model
  45626. // init stage and not after action dispatch handler, because
  45627. // reset should be called after seriesData.restoreData.
  45628. dataZoomModel.eachTargetAxis(resetSingleAxis);
  45629. // Caution: data zoom filtering is order sensitive when using
  45630. // percent range and no min/max/scale set on axis.
  45631. // For example, we have dataZoom definition:
  45632. // [
  45633. // {xAxisIndex: 0, start: 30, end: 70},
  45634. // {yAxisIndex: 0, start: 20, end: 80}
  45635. // ]
  45636. // In this case, [20, 80] of y-dataZoom should be based on data
  45637. // that have filtered by x-dataZoom using range of [30, 70],
  45638. // but should not be based on full raw data. Thus sliding
  45639. // x-dataZoom will change both ranges of xAxis and yAxis,
  45640. // while sliding y-dataZoom will only change the range of yAxis.
  45641. // So we should filter x-axis after reset x-axis immediately,
  45642. // and then reset y-axis and filter y-axis.
  45643. dataZoomModel.eachTargetAxis(filterSingleAxis);
  45644. });
  45645. ecModel.eachComponent('dataZoom', function (dataZoomModel) {
  45646. // Fullfill all of the range props so that user
  45647. // is able to get them from chart.getOption().
  45648. var axisProxy = dataZoomModel.findRepresentativeAxisProxy();
  45649. var percentRange = axisProxy.getDataPercentWindow();
  45650. var valueRange = axisProxy.getDataValueWindow();
  45651. dataZoomModel.setRawRange({
  45652. start: percentRange[0],
  45653. end: percentRange[1],
  45654. startValue: valueRange[0],
  45655. endValue: valueRange[1]
  45656. });
  45657. });
  45658. });
  45659. function resetSingleAxis(dimNames, axisIndex, dataZoomModel) {
  45660. dataZoomModel.getAxisProxy(dimNames.name, axisIndex).reset(dataZoomModel);
  45661. }
  45662. function filterSingleAxis(dimNames, axisIndex, dataZoomModel) {
  45663. dataZoomModel.getAxisProxy(dimNames.name, axisIndex).filterData(dataZoomModel);
  45664. }
  45665. /***/ },
  45666. /* 328 */
  45667. /***/ function(module, exports, __webpack_require__) {
  45668. /**
  45669. * @file Data zoom action
  45670. */
  45671. var zrUtil = __webpack_require__(4);
  45672. var modelUtil = __webpack_require__(5);
  45673. var echarts = __webpack_require__(1);
  45674. echarts.registerAction('dataZoom', function (payload, ecModel) {
  45675. var linkedNodesFinder = modelUtil.createLinkedNodesFinder(
  45676. zrUtil.bind(ecModel.eachComponent, ecModel, 'dataZoom'),
  45677. modelUtil.eachAxisDim,
  45678. function (model, dimNames) {
  45679. return model.get(dimNames.axisIndex);
  45680. }
  45681. );
  45682. var effectedModels = [];
  45683. ecModel.eachComponent(
  45684. {mainType: 'dataZoom', query: payload},
  45685. function (model, index) {
  45686. effectedModels.push.apply(
  45687. effectedModels, linkedNodesFinder(model).nodes
  45688. );
  45689. }
  45690. );
  45691. zrUtil.each(effectedModels, function (dataZoomModel, index) {
  45692. dataZoomModel.setRawRange({
  45693. start: payload.start,
  45694. end: payload.end,
  45695. startValue: payload.startValue,
  45696. endValue: payload.endValue
  45697. });
  45698. });
  45699. });
  45700. /***/ },
  45701. /* 329 */
  45702. /***/ function(module, exports, __webpack_require__) {
  45703. /**
  45704. * visualMap component entry
  45705. */
  45706. __webpack_require__(330);
  45707. __webpack_require__(341);
  45708. /***/ },
  45709. /* 330 */
  45710. /***/ function(module, exports, __webpack_require__) {
  45711. /**
  45712. * DataZoom component entry
  45713. */
  45714. __webpack_require__(1).registerPreprocessor(
  45715. __webpack_require__(331)
  45716. );
  45717. __webpack_require__(332);
  45718. __webpack_require__(333);
  45719. __webpack_require__(334);
  45720. __webpack_require__(337);
  45721. __webpack_require__(340);
  45722. /***/ },
  45723. /* 331 */
  45724. /***/ function(module, exports, __webpack_require__) {
  45725. /**
  45726. * @file VisualMap preprocessor
  45727. */
  45728. var zrUtil = __webpack_require__(4);
  45729. var each = zrUtil.each;
  45730. module.exports = function (option) {
  45731. var visualMap = option && option.visualMap;
  45732. if (!zrUtil.isArray(visualMap)) {
  45733. visualMap = visualMap ? [visualMap] : [];
  45734. }
  45735. each(visualMap, function (opt) {
  45736. if (!opt) {
  45737. return;
  45738. }
  45739. // rename splitList to pieces
  45740. if (has(opt, 'splitList') && !has(opt, 'pieces')) {
  45741. opt.pieces = opt.splitList;
  45742. delete opt.splitList;
  45743. }
  45744. var pieces = opt.pieces;
  45745. if (pieces && zrUtil.isArray(pieces)) {
  45746. each(pieces, function (piece) {
  45747. if (zrUtil.isObject(piece)) {
  45748. if (has(piece, 'start') && !has(piece, 'min')) {
  45749. piece.min = piece.start;
  45750. }
  45751. if (has(piece, 'end') && !has(piece, 'max')) {
  45752. piece.max = piece.end;
  45753. }
  45754. }
  45755. });
  45756. }
  45757. });
  45758. };
  45759. function has(obj, name) {
  45760. return obj && obj.hasOwnProperty && obj.hasOwnProperty(name);
  45761. }
  45762. /***/ },
  45763. /* 332 */
  45764. /***/ function(module, exports, __webpack_require__) {
  45765. __webpack_require__(19).registerSubTypeDefaulter('visualMap', function (option) {
  45766. // Compatible with ec2, when splitNumber === 0, continuous visualMap will be used.
  45767. return (
  45768. !option.categories
  45769. && (
  45770. !(
  45771. option.pieces
  45772. ? option.pieces.length > 0
  45773. : option.splitNumber > 0
  45774. )
  45775. || option.calculable
  45776. )
  45777. )
  45778. ? 'continuous' : 'piecewise';
  45779. });
  45780. /***/ },
  45781. /* 333 */
  45782. /***/ function(module, exports, __webpack_require__) {
  45783. /**
  45784. * @file Data range visual coding.
  45785. */
  45786. var echarts = __webpack_require__(1);
  45787. var visualSolution = __webpack_require__(306);
  45788. var VisualMapping = __webpack_require__(192);
  45789. echarts.registerVisual(echarts.PRIORITY.VISUAL.COMPONENT, function (ecModel) {
  45790. ecModel.eachComponent('visualMap', function (visualMapModel) {
  45791. processSingleVisualMap(visualMapModel, ecModel);
  45792. });
  45793. prepareVisualMeta(ecModel);
  45794. });
  45795. function processSingleVisualMap(visualMapModel, ecModel) {
  45796. visualMapModel.eachTargetSeries(function (seriesModel) {
  45797. var data = seriesModel.getData();
  45798. visualSolution.applyVisual(
  45799. visualMapModel.stateList,
  45800. visualMapModel.targetVisuals,
  45801. data,
  45802. visualMapModel.getValueState,
  45803. visualMapModel,
  45804. visualMapModel.getDataDimension(data)
  45805. );
  45806. });
  45807. }
  45808. // Only support color.
  45809. function prepareVisualMeta(ecModel) {
  45810. ecModel.eachSeries(function (seriesModel) {
  45811. var data = seriesModel.getData();
  45812. var visualMetaList = [];
  45813. ecModel.eachComponent('visualMap', function (visualMapModel) {
  45814. if (visualMapModel.isTargetSeries(seriesModel)) {
  45815. var visualMeta = {};
  45816. visualMetaList.push(visualMeta);
  45817. visualMeta.stops = visualMapModel.getStops(seriesModel, getColorVisual);
  45818. visualMeta.dimension = visualMapModel.getDataDimension(data);
  45819. }
  45820. });
  45821. // console.log(JSON.stringify(visualMetaList.map(a => a.stops)));
  45822. seriesModel.getData().setVisual('visualMeta', visualMetaList);
  45823. });
  45824. }
  45825. // FIXME
  45826. // performance and export for heatmap?
  45827. function getColorVisual(visualMapModel, value, valueState) {
  45828. var mappings = visualMapModel.targetVisuals[valueState];
  45829. var visualTypes = VisualMapping.prepareVisualTypes(mappings);
  45830. var resultVisual = {};
  45831. for (var i = 0, len = visualTypes.length; i < len; i++) {
  45832. var type = visualTypes[i];
  45833. var mapping = mappings[
  45834. type === 'colorAlpha' ? '__alphaForOpacity' : type
  45835. ];
  45836. mapping && mapping.applyVisual(value, getVisual, setVisual);
  45837. }
  45838. return resultVisual.color;
  45839. function getVisual(key) {
  45840. return resultVisual[key];
  45841. }
  45842. function setVisual(key, value) {
  45843. resultVisual[key] = value;
  45844. }
  45845. }
  45846. /***/ },
  45847. /* 334 */
  45848. /***/ function(module, exports, __webpack_require__) {
  45849. /**
  45850. * @file Data zoom model
  45851. */
  45852. var VisualMapModel = __webpack_require__(335);
  45853. var zrUtil = __webpack_require__(4);
  45854. var numberUtil = __webpack_require__(7);
  45855. // Constant
  45856. var DEFAULT_BAR_BOUND = [20, 140];
  45857. var ContinuousModel = VisualMapModel.extend({
  45858. type: 'visualMap.continuous',
  45859. /**
  45860. * @protected
  45861. */
  45862. defaultOption: {
  45863. align: 'auto', // 'auto', 'left', 'right', 'top', 'bottom'
  45864. calculable: false, // This prop effect default component type determine,
  45865. // See echarts/component/visualMap/typeDefaulter.
  45866. range: null, // selected range. In default case `range` is [min, max]
  45867. // and can auto change along with modification of min max,
  45868. // util use specifid a range.
  45869. realtime: true, // Whether realtime update.
  45870. itemHeight: null, // The length of the range control edge.
  45871. itemWidth: null, // The length of the other side.
  45872. hoverLink: true, // Enable hover highlight.
  45873. hoverLinkDataSize: null,// The size of hovered data.
  45874. hoverLinkOnHandle: true // Whether trigger hoverLink when hover handle.
  45875. },
  45876. /**
  45877. * @override
  45878. */
  45879. optionUpdated: function (newOption, isInit) {
  45880. ContinuousModel.superApply(this, 'optionUpdated', arguments);
  45881. this.resetTargetSeries();
  45882. this.resetExtent();
  45883. this.resetVisual(function (mappingOption) {
  45884. mappingOption.mappingMethod = 'linear';
  45885. mappingOption.dataExtent = this.getExtent();
  45886. });
  45887. this._resetRange();
  45888. },
  45889. /**
  45890. * @protected
  45891. * @override
  45892. */
  45893. resetItemSize: function () {
  45894. ContinuousModel.superApply(this, 'resetItemSize', arguments);
  45895. var itemSize = this.itemSize;
  45896. this._orient === 'horizontal' && itemSize.reverse();
  45897. (itemSize[0] == null || isNaN(itemSize[0])) && (itemSize[0] = DEFAULT_BAR_BOUND[0]);
  45898. (itemSize[1] == null || isNaN(itemSize[1])) && (itemSize[1] = DEFAULT_BAR_BOUND[1]);
  45899. },
  45900. /**
  45901. * @private
  45902. */
  45903. _resetRange: function () {
  45904. var dataExtent = this.getExtent();
  45905. var range = this.option.range;
  45906. if (!range || range.auto) {
  45907. // `range` should always be array (so we dont use other
  45908. // value like 'auto') for user-friend. (consider getOption).
  45909. dataExtent.auto = 1;
  45910. this.option.range = dataExtent;
  45911. }
  45912. else if (zrUtil.isArray(range)) {
  45913. if (range[0] > range[1]) {
  45914. range.reverse();
  45915. }
  45916. range[0] = Math.max(range[0], dataExtent[0]);
  45917. range[1] = Math.min(range[1], dataExtent[1]);
  45918. }
  45919. },
  45920. /**
  45921. * @protected
  45922. * @override
  45923. */
  45924. completeVisualOption: function () {
  45925. VisualMapModel.prototype.completeVisualOption.apply(this, arguments);
  45926. zrUtil.each(this.stateList, function (state) {
  45927. var symbolSize = this.option.controller[state].symbolSize;
  45928. if (symbolSize && symbolSize[0] !== symbolSize[1]) {
  45929. symbolSize[0] = 0; // For good looking.
  45930. }
  45931. }, this);
  45932. },
  45933. /**
  45934. * @override
  45935. */
  45936. setSelected: function (selected) {
  45937. this.option.range = selected.slice();
  45938. this._resetRange();
  45939. },
  45940. /**
  45941. * @public
  45942. */
  45943. getSelected: function () {
  45944. var dataExtent = this.getExtent();
  45945. var dataInterval = numberUtil.asc(
  45946. (this.get('range') || []).slice()
  45947. );
  45948. // Clamp
  45949. dataInterval[0] > dataExtent[1] && (dataInterval[0] = dataExtent[1]);
  45950. dataInterval[1] > dataExtent[1] && (dataInterval[1] = dataExtent[1]);
  45951. dataInterval[0] < dataExtent[0] && (dataInterval[0] = dataExtent[0]);
  45952. dataInterval[1] < dataExtent[0] && (dataInterval[1] = dataExtent[0]);
  45953. return dataInterval;
  45954. },
  45955. /**
  45956. * @override
  45957. */
  45958. getValueState: function (value) {
  45959. var range = this.option.range;
  45960. var dataExtent = this.getExtent();
  45961. // When range[0] === dataExtent[0], any value larger than dataExtent[0] maps to 'inRange'.
  45962. // range[1] is processed likewise.
  45963. return (
  45964. (range[0] <= dataExtent[0] || range[0] <= value)
  45965. && (range[1] >= dataExtent[1] || value <= range[1])
  45966. ) ? 'inRange' : 'outOfRange';
  45967. },
  45968. /**
  45969. * @params {Array.<number>} range target value: range[0] <= value && value <= range[1]
  45970. * @return {Array.<Object>} [{seriesId, dataIndices: <Array.<number>>}, ...]
  45971. */
  45972. findTargetDataIndices: function (range) {
  45973. var result = [];
  45974. this.eachTargetSeries(function (seriesModel) {
  45975. var dataIndices = [];
  45976. var data = seriesModel.getData();
  45977. data.each(this.getDataDimension(data), function (value, dataIndex) {
  45978. range[0] <= value && value <= range[1] && dataIndices.push(dataIndex);
  45979. }, true, this);
  45980. result.push({seriesId: seriesModel.id, dataIndex: dataIndices});
  45981. }, this);
  45982. return result;
  45983. },
  45984. getStops: function (seriesModel, getColorVisual) {
  45985. var result = [];
  45986. insertStopList(this, 'outOfRange', this.getExtent(), result);
  45987. insertStopList(this, 'inRange', this.option.range.slice(), result);
  45988. zrUtil.each(result, function (item) {
  45989. item.color = getColorVisual(this, item.value, item.valueState);
  45990. }, this);
  45991. return result;
  45992. }
  45993. });
  45994. function getColorStopValues(visualMapModel, valueState, dataExtent) {
  45995. var mapping = visualMapModel.targetVisuals[valueState].color;
  45996. if (!mapping) {
  45997. return dataExtent.slice();
  45998. }
  45999. var count = mapping.option.visual.length;
  46000. if (count <= 1 || dataExtent[0] === dataExtent[1]) {
  46001. return dataExtent.slice();
  46002. }
  46003. // We only use linear mappping for color, so we can do inverse mapping:
  46004. var step = (dataExtent[1] - dataExtent[0]) / (count - 1);
  46005. var value = dataExtent[0];
  46006. var stopValues = [];
  46007. for (var i = 0; i < count && value < dataExtent[1]; i++) {
  46008. stopValues.push(value);
  46009. value += step;
  46010. }
  46011. stopValues.push(dataExtent[1]);
  46012. return stopValues;
  46013. }
  46014. function insertStopList(visualMapModel, valueState, dataExtent, result) {
  46015. var stops = getColorStopValues(visualMapModel, valueState, dataExtent);
  46016. zrUtil.each(stops, function (val) {
  46017. var stop = {value: val, valueState: valueState};
  46018. var inRange = 0;
  46019. for (var i = 0; i < result.length; i++) {
  46020. // Format to: outOfRange -- inRange -- outOfRange.
  46021. inRange |= result[i].valueState === 'inRange';
  46022. if (val < result[i].value) {
  46023. result.splice(i, 0, stop);
  46024. return;
  46025. }
  46026. inRange && (result[i].valueState = 'inRange');
  46027. }
  46028. result.push(stop);
  46029. });
  46030. }
  46031. module.exports = ContinuousModel;
  46032. /***/ },
  46033. /* 335 */
  46034. /***/ function(module, exports, __webpack_require__) {
  46035. /**
  46036. * @file Controller visual map model
  46037. */
  46038. var echarts = __webpack_require__(1);
  46039. var zrUtil = __webpack_require__(4);
  46040. var env = __webpack_require__(2);
  46041. var visualDefault = __webpack_require__(336);
  46042. var VisualMapping = __webpack_require__(192);
  46043. var visualSolution = __webpack_require__(306);
  46044. var mapVisual = VisualMapping.mapVisual;
  46045. var modelUtil = __webpack_require__(5);
  46046. var eachVisual = VisualMapping.eachVisual;
  46047. var numberUtil = __webpack_require__(7);
  46048. var isArray = zrUtil.isArray;
  46049. var each = zrUtil.each;
  46050. var asc = numberUtil.asc;
  46051. var linearMap = numberUtil.linearMap;
  46052. var noop = zrUtil.noop;
  46053. var DEFAULT_COLOR = ['#f6efa6', '#d88273', '#bf444c'];
  46054. var VisualMapModel = echarts.extendComponentModel({
  46055. type: 'visualMap',
  46056. dependencies: ['series'],
  46057. /**
  46058. * @readOnly
  46059. * @type {Array.<string>}
  46060. */
  46061. stateList: ['inRange', 'outOfRange'],
  46062. /**
  46063. * @readOnly
  46064. * @type {Array.<string>}
  46065. */
  46066. replacableOptionKeys: [
  46067. 'inRange', 'outOfRange', 'target', 'controller', 'color'
  46068. ],
  46069. /**
  46070. * [lowerBound, upperBound]
  46071. *
  46072. * @readOnly
  46073. * @type {Array.<number>}
  46074. */
  46075. dataBound: [-Infinity, Infinity],
  46076. /**
  46077. * @readOnly
  46078. * @type {string|Object}
  46079. */
  46080. layoutMode: {type: 'box', ignoreSize: true},
  46081. /**
  46082. * @protected
  46083. */
  46084. defaultOption: {
  46085. show: true,
  46086. zlevel: 0,
  46087. z: 4,
  46088. seriesIndex: null, // 所控制的series indices,默认所有有value的series.
  46089. // set min: 0, max: 200, only for campatible with ec2.
  46090. // In fact min max should not have default value.
  46091. min: 0, // min value, must specified if pieces is not specified.
  46092. max: 200, // max value, must specified if pieces is not specified.
  46093. dimension: null,
  46094. inRange: null, // 'color', 'colorHue', 'colorSaturation', 'colorLightness', 'colorAlpha',
  46095. // 'symbol', 'symbolSize'
  46096. outOfRange: null, // 'color', 'colorHue', 'colorSaturation',
  46097. // 'colorLightness', 'colorAlpha',
  46098. // 'symbol', 'symbolSize'
  46099. left: 0, // 'center' ¦ 'left' ¦ 'right' ¦ {number} (px)
  46100. right: null, // The same as left.
  46101. top: null, // 'top' ¦ 'bottom' ¦ 'center' ¦ {number} (px)
  46102. bottom: 0, // The same as top.
  46103. itemWidth: null,
  46104. itemHeight: null,
  46105. inverse: false,
  46106. orient: 'vertical', // 'horizontal' ¦ 'vertical'
  46107. backgroundColor: 'rgba(0,0,0,0)',
  46108. borderColor: '#ccc', // 值域边框颜色
  46109. contentColor: '#5793f3',
  46110. inactiveColor: '#aaa',
  46111. borderWidth: 0, // 值域边框线宽,单位px,默认为0(无边框)
  46112. padding: 5, // 值域内边距,单位px,默认各方向内边距为5,
  46113. // 接受数组分别设定上右下左边距,同css
  46114. textGap: 10, //
  46115. precision: 0, // 小数精度,默认为0,无小数点
  46116. color: null, //颜色(deprecated,兼容ec2,顺序同pieces,不同于inRange/outOfRange)
  46117. formatter: null,
  46118. text: null, // 文本,如['高', '低'],兼容ec2,text[0]对应高值,text[1]对应低值
  46119. textStyle: {
  46120. color: '#333' // 值域文字颜色
  46121. }
  46122. },
  46123. /**
  46124. * @protected
  46125. */
  46126. init: function (option, parentModel, ecModel) {
  46127. /**
  46128. * @private
  46129. * @type {Array.<number>}
  46130. */
  46131. this._dataExtent;
  46132. /**
  46133. * @readOnly
  46134. */
  46135. this.targetVisuals = {};
  46136. /**
  46137. * @readOnly
  46138. */
  46139. this.controllerVisuals = {};
  46140. /**
  46141. * @readOnly
  46142. */
  46143. this.textStyleModel;
  46144. /**
  46145. * [width, height]
  46146. * @readOnly
  46147. * @type {Array.<number>}
  46148. */
  46149. this.itemSize;
  46150. this.mergeDefaultAndTheme(option, ecModel);
  46151. },
  46152. /**
  46153. * @protected
  46154. */
  46155. optionUpdated: function (newOption, isInit) {
  46156. var thisOption = this.option;
  46157. // FIXME
  46158. // necessary?
  46159. // Disable realtime view update if canvas is not supported.
  46160. if (!env.canvasSupported) {
  46161. thisOption.realtime = false;
  46162. }
  46163. !isInit && visualSolution.replaceVisualOption(
  46164. thisOption, newOption, this.replacableOptionKeys
  46165. );
  46166. this.textStyleModel = this.getModel('textStyle');
  46167. this.resetItemSize();
  46168. this.completeVisualOption();
  46169. },
  46170. /**
  46171. * @protected
  46172. */
  46173. resetVisual: function (supplementVisualOption) {
  46174. var stateList = this.stateList;
  46175. supplementVisualOption = zrUtil.bind(supplementVisualOption, this);
  46176. this.controllerVisuals = visualSolution.createVisualMappings(
  46177. this.option.controller, stateList, supplementVisualOption
  46178. );
  46179. this.targetVisuals = visualSolution.createVisualMappings(
  46180. this.option.target, stateList, supplementVisualOption
  46181. );
  46182. },
  46183. /**
  46184. * @protected
  46185. */
  46186. resetTargetSeries: function () {
  46187. var thisOption = this.option;
  46188. var allSeriesIndex = thisOption.seriesIndex == null;
  46189. thisOption.seriesIndex = allSeriesIndex
  46190. ? [] : modelUtil.normalizeToArray(thisOption.seriesIndex);
  46191. allSeriesIndex && this.ecModel.eachSeries(function (seriesModel, index) {
  46192. thisOption.seriesIndex.push(index);
  46193. });
  46194. },
  46195. /**
  46196. * @public
  46197. */
  46198. eachTargetSeries: function (callback, context) {
  46199. zrUtil.each(this.option.seriesIndex, function (seriesIndex) {
  46200. callback.call(context, this.ecModel.getSeriesByIndex(seriesIndex));
  46201. }, this);
  46202. },
  46203. /**
  46204. * @pubilc
  46205. */
  46206. isTargetSeries: function (seriesModel) {
  46207. var is = false;
  46208. this.eachTargetSeries(function (model) {
  46209. model === seriesModel && (is = true);
  46210. });
  46211. return is;
  46212. },
  46213. /**
  46214. * @example
  46215. * this.formatValueText(someVal); // format single numeric value to text.
  46216. * this.formatValueText(someVal, true); // format single category value to text.
  46217. * this.formatValueText([min, max]); // format numeric min-max to text.
  46218. * this.formatValueText([this.dataBound[0], max]); // using data lower bound.
  46219. * this.formatValueText([min, this.dataBound[1]]); // using data upper bound.
  46220. *
  46221. * @param {number|Array.<number>} value Real value, or this.dataBound[0 or 1].
  46222. * @param {boolean} [isCategory=false] Only available when value is number.
  46223. * @param {Array.<string>} edgeSymbols Open-close symbol when value is interval.
  46224. * @return {string}
  46225. * @protected
  46226. */
  46227. formatValueText: function(value, isCategory, edgeSymbols) {
  46228. var option = this.option;
  46229. var precision = option.precision;
  46230. var dataBound = this.dataBound;
  46231. var formatter = option.formatter;
  46232. var isMinMax;
  46233. var textValue;
  46234. edgeSymbols = edgeSymbols || ['<', '>'];
  46235. if (zrUtil.isArray(value)) {
  46236. value = value.slice();
  46237. isMinMax = true;
  46238. }
  46239. textValue = isCategory
  46240. ? value
  46241. : (isMinMax
  46242. ? [toFixed(value[0]), toFixed(value[1])]
  46243. : toFixed(value)
  46244. );
  46245. if (zrUtil.isString(formatter)) {
  46246. return formatter
  46247. .replace('{value}', isMinMax ? textValue[0] : textValue)
  46248. .replace('{value2}', isMinMax ? textValue[1] : textValue);
  46249. }
  46250. else if (zrUtil.isFunction(formatter)) {
  46251. return isMinMax
  46252. ? formatter(value[0], value[1])
  46253. : formatter(value);
  46254. }
  46255. if (isMinMax) {
  46256. if (value[0] === dataBound[0]) {
  46257. return edgeSymbols[0] + ' ' + textValue[1];
  46258. }
  46259. else if (value[1] === dataBound[1]) {
  46260. return edgeSymbols[1] + ' ' + textValue[0];
  46261. }
  46262. else {
  46263. return textValue[0] + ' - ' + textValue[1];
  46264. }
  46265. }
  46266. else { // Format single value (includes category case).
  46267. return textValue;
  46268. }
  46269. function toFixed(val) {
  46270. return val === dataBound[0]
  46271. ? 'min'
  46272. : val === dataBound[1]
  46273. ? 'max'
  46274. : (+val).toFixed(precision);
  46275. }
  46276. },
  46277. /**
  46278. * @protected
  46279. */
  46280. resetExtent: function () {
  46281. var thisOption = this.option;
  46282. // Can not calculate data extent by data here.
  46283. // Because series and data may be modified in processing stage.
  46284. // So we do not support the feature "auto min/max".
  46285. var extent = asc([thisOption.min, thisOption.max]);
  46286. this._dataExtent = extent;
  46287. },
  46288. /**
  46289. * @public
  46290. * @param {module:echarts/data/List} list
  46291. * @return {string} Concrete dimention. If return null/undefined,
  46292. * no dimension used.
  46293. */
  46294. getDataDimension: function (list) {
  46295. var optDim = this.option.dimension;
  46296. return optDim != null
  46297. ? optDim : list.dimensions.length - 1;
  46298. },
  46299. /**
  46300. * @public
  46301. * @override
  46302. */
  46303. getExtent: function () {
  46304. return this._dataExtent.slice();
  46305. },
  46306. /**
  46307. * @protected
  46308. */
  46309. completeVisualOption: function () {
  46310. var thisOption = this.option;
  46311. var base = {inRange: thisOption.inRange, outOfRange: thisOption.outOfRange};
  46312. var target = thisOption.target || (thisOption.target = {});
  46313. var controller = thisOption.controller || (thisOption.controller = {});
  46314. zrUtil.merge(target, base); // Do not override
  46315. zrUtil.merge(controller, base); // Do not override
  46316. var isCategory = this.isCategory();
  46317. completeSingle.call(this, target);
  46318. completeSingle.call(this, controller);
  46319. completeInactive.call(this, target, 'inRange', 'outOfRange');
  46320. // completeInactive.call(this, target, 'outOfRange', 'inRange');
  46321. completeController.call(this, controller);
  46322. function completeSingle(base) {
  46323. // Compatible with ec2 dataRange.color.
  46324. // The mapping order of dataRange.color is: [high value, ..., low value]
  46325. // whereas inRange.color and outOfRange.color is [low value, ..., high value]
  46326. // Notice: ec2 has no inverse.
  46327. if (isArray(thisOption.color)
  46328. // If there has been inRange: {symbol: ...}, adding color is a mistake.
  46329. // So adding color only when no inRange defined.
  46330. && !base.inRange
  46331. ) {
  46332. base.inRange = {color: thisOption.color.slice().reverse()};
  46333. }
  46334. // Compatible with previous logic, always give a defautl color, otherwise
  46335. // simple config with no inRange and outOfRange will not work.
  46336. // Originally we use visualMap.color as the default color, but setOption at
  46337. // the second time the default color will be erased. So we change to use
  46338. // constant DEFAULT_COLOR.
  46339. // If user do not want the defualt color, set inRange: {color: null}.
  46340. base.inRange = base.inRange || {color: DEFAULT_COLOR};
  46341. // If using shortcut like: {inRange: 'symbol'}, complete default value.
  46342. each(this.stateList, function (state) {
  46343. var visualType = base[state];
  46344. if (zrUtil.isString(visualType)) {
  46345. var defa = visualDefault.get(visualType, 'active', isCategory);
  46346. if (defa) {
  46347. base[state] = {};
  46348. base[state][visualType] = defa;
  46349. }
  46350. else {
  46351. // Mark as not specified.
  46352. delete base[state];
  46353. }
  46354. }
  46355. }, this);
  46356. }
  46357. function completeInactive(base, stateExist, stateAbsent) {
  46358. var optExist = base[stateExist];
  46359. var optAbsent = base[stateAbsent];
  46360. if (optExist && !optAbsent) {
  46361. optAbsent = base[stateAbsent] = {};
  46362. each(optExist, function (visualData, visualType) {
  46363. if (!VisualMapping.isValidType(visualType)) {
  46364. return;
  46365. }
  46366. var defa = visualDefault.get(visualType, 'inactive', isCategory);
  46367. if (defa != null) {
  46368. optAbsent[visualType] = defa;
  46369. // Compatibable with ec2:
  46370. // Only inactive color to rgba(0,0,0,0) can not
  46371. // make label transparent, so use opacity also.
  46372. if (visualType === 'color'
  46373. && !optAbsent.hasOwnProperty('opacity')
  46374. && !optAbsent.hasOwnProperty('colorAlpha')
  46375. ) {
  46376. optAbsent.opacity = [0, 0];
  46377. }
  46378. }
  46379. });
  46380. }
  46381. }
  46382. function completeController(controller) {
  46383. var symbolExists = (controller.inRange || {}).symbol
  46384. || (controller.outOfRange || {}).symbol;
  46385. var symbolSizeExists = (controller.inRange || {}).symbolSize
  46386. || (controller.outOfRange || {}).symbolSize;
  46387. var inactiveColor = this.get('inactiveColor');
  46388. each(this.stateList, function (state) {
  46389. var itemSize = this.itemSize;
  46390. var visuals = controller[state];
  46391. // Set inactive color for controller if no other color
  46392. // attr (like colorAlpha) specified.
  46393. if (!visuals) {
  46394. visuals = controller[state] = {
  46395. color: isCategory ? inactiveColor : [inactiveColor]
  46396. };
  46397. }
  46398. // Consistent symbol and symbolSize if not specified.
  46399. if (visuals.symbol == null) {
  46400. visuals.symbol = symbolExists
  46401. && zrUtil.clone(symbolExists)
  46402. || (isCategory ? 'roundRect' : ['roundRect']);
  46403. }
  46404. if (visuals.symbolSize == null) {
  46405. visuals.symbolSize = symbolSizeExists
  46406. && zrUtil.clone(symbolSizeExists)
  46407. || (isCategory ? itemSize[0] : [itemSize[0], itemSize[0]]);
  46408. }
  46409. // Filter square and none.
  46410. visuals.symbol = mapVisual(visuals.symbol, function (symbol) {
  46411. return (symbol === 'none' || symbol === 'square') ? 'roundRect' : symbol;
  46412. });
  46413. // Normalize symbolSize
  46414. var symbolSize = visuals.symbolSize;
  46415. if (symbolSize != null) {
  46416. var max = -Infinity;
  46417. // symbolSize can be object when categories defined.
  46418. eachVisual(symbolSize, function (value) {
  46419. value > max && (max = value);
  46420. });
  46421. visuals.symbolSize = mapVisual(symbolSize, function (value) {
  46422. return linearMap(value, [0, max], [0, itemSize[0]], true);
  46423. });
  46424. }
  46425. }, this);
  46426. }
  46427. },
  46428. /**
  46429. * @protected
  46430. */
  46431. resetItemSize: function () {
  46432. this.itemSize = [
  46433. parseFloat(this.get('itemWidth')),
  46434. parseFloat(this.get('itemHeight'))
  46435. ];
  46436. },
  46437. /**
  46438. * @public
  46439. */
  46440. isCategory: function () {
  46441. return !!this.option.categories;
  46442. },
  46443. /**
  46444. * @public
  46445. * @abstract
  46446. */
  46447. setSelected: noop,
  46448. /**
  46449. * @public
  46450. * @abstract
  46451. * @param {*|module:echarts/data/List} valueOrData
  46452. * @param {number} dataIndex
  46453. * @return {string} state See this.stateList
  46454. */
  46455. getValueState: noop
  46456. });
  46457. module.exports = VisualMapModel;
  46458. /***/ },
  46459. /* 336 */
  46460. /***/ function(module, exports, __webpack_require__) {
  46461. /**
  46462. * @file Visual mapping.
  46463. */
  46464. var zrUtil = __webpack_require__(4);
  46465. var visualDefault = {
  46466. /**
  46467. * @public
  46468. */
  46469. get: function (visualType, key, isCategory) {
  46470. var value = zrUtil.clone(
  46471. (defaultOption[visualType] || {})[key]
  46472. );
  46473. return isCategory
  46474. ? (zrUtil.isArray(value) ? value[value.length - 1] : value)
  46475. : value;
  46476. }
  46477. };
  46478. var defaultOption = {
  46479. color: {
  46480. active: ['#006edd', '#e0ffff'],
  46481. inactive: ['rgba(0,0,0,0)']
  46482. },
  46483. colorHue: {
  46484. active: [0, 360],
  46485. inactive: [0, 0]
  46486. },
  46487. colorSaturation: {
  46488. active: [0.3, 1],
  46489. inactive: [0, 0]
  46490. },
  46491. colorLightness: {
  46492. active: [0.9, 0.5],
  46493. inactive: [0, 0]
  46494. },
  46495. colorAlpha: {
  46496. active: [0.3, 1],
  46497. inactive: [0, 0]
  46498. },
  46499. opacity: {
  46500. active: [0.3, 1],
  46501. inactive: [0, 0]
  46502. },
  46503. symbol: {
  46504. active: ['circle', 'roundRect', 'diamond'],
  46505. inactive: ['none']
  46506. },
  46507. symbolSize: {
  46508. active: [10, 50],
  46509. inactive: [0, 0]
  46510. }
  46511. };
  46512. module.exports = visualDefault;
  46513. /***/ },
  46514. /* 337 */
  46515. /***/ function(module, exports, __webpack_require__) {
  46516. var VisualMapView = __webpack_require__(338);
  46517. var graphic = __webpack_require__(43);
  46518. var zrUtil = __webpack_require__(4);
  46519. var numberUtil = __webpack_require__(7);
  46520. var sliderMove = __webpack_require__(323);
  46521. var LinearGradient = __webpack_require__(79);
  46522. var helper = __webpack_require__(339);
  46523. var modelUtil = __webpack_require__(5);
  46524. var linearMap = numberUtil.linearMap;
  46525. var each = zrUtil.each;
  46526. var mathMin = Math.min;
  46527. var mathMax = Math.max;
  46528. // Arbitrary value
  46529. var HOVER_LINK_SIZE = 12;
  46530. var HOVER_LINK_OUT = 6;
  46531. // Notice:
  46532. // Any "interval" should be by the order of [low, high].
  46533. // "handle0" (handleIndex === 0) maps to
  46534. // low data value: this._dataInterval[0] and has low coord.
  46535. // "handle1" (handleIndex === 1) maps to
  46536. // high data value: this._dataInterval[1] and has high coord.
  46537. // The logic of transform is implemented in this._createBarGroup.
  46538. var ContinuousView = VisualMapView.extend({
  46539. type: 'visualMap.continuous',
  46540. /**
  46541. * @override
  46542. */
  46543. init: function () {
  46544. ContinuousView.superApply(this, 'init', arguments);
  46545. /**
  46546. * @private
  46547. */
  46548. this._shapes = {};
  46549. /**
  46550. * @private
  46551. */
  46552. this._dataInterval = [];
  46553. /**
  46554. * @private
  46555. */
  46556. this._handleEnds = [];
  46557. /**
  46558. * @private
  46559. */
  46560. this._orient;
  46561. /**
  46562. * @private
  46563. */
  46564. this._useHandle;
  46565. /**
  46566. * @private
  46567. */
  46568. this._hoverLinkDataIndices = [];
  46569. /**
  46570. * @private
  46571. */
  46572. this._dragging;
  46573. /**
  46574. * @private
  46575. */
  46576. this._hovering;
  46577. },
  46578. /**
  46579. * @protected
  46580. * @override
  46581. */
  46582. doRender: function (visualMapModel, ecModel, api, payload) {
  46583. if (!payload || payload.type !== 'selectDataRange' || payload.from !== this.uid) {
  46584. this._buildView();
  46585. }
  46586. },
  46587. /**
  46588. * @private
  46589. */
  46590. _buildView: function () {
  46591. this.group.removeAll();
  46592. var visualMapModel = this.visualMapModel;
  46593. var thisGroup = this.group;
  46594. this._orient = visualMapModel.get('orient');
  46595. this._useHandle = visualMapModel.get('calculable');
  46596. this._resetInterval();
  46597. this._renderBar(thisGroup);
  46598. var dataRangeText = visualMapModel.get('text');
  46599. this._renderEndsText(thisGroup, dataRangeText, 0);
  46600. this._renderEndsText(thisGroup, dataRangeText, 1);
  46601. // Do this for background size calculation.
  46602. this._updateView(true);
  46603. // After updating view, inner shapes is built completely,
  46604. // and then background can be rendered.
  46605. this.renderBackground(thisGroup);
  46606. // Real update view
  46607. this._updateView();
  46608. this._enableHoverLinkToSeries();
  46609. this._enableHoverLinkFromSeries();
  46610. this.positionGroup(thisGroup);
  46611. },
  46612. /**
  46613. * @private
  46614. */
  46615. _renderEndsText: function (group, dataRangeText, endsIndex) {
  46616. if (!dataRangeText) {
  46617. return;
  46618. }
  46619. // Compatible with ec2, text[0] map to high value, text[1] map low value.
  46620. var text = dataRangeText[1 - endsIndex];
  46621. text = text != null ? text + '' : '';
  46622. var visualMapModel = this.visualMapModel;
  46623. var textGap = visualMapModel.get('textGap');
  46624. var itemSize = visualMapModel.itemSize;
  46625. var barGroup = this._shapes.barGroup;
  46626. var position = this._applyTransform(
  46627. [
  46628. itemSize[0] / 2,
  46629. endsIndex === 0 ? -textGap : itemSize[1] + textGap
  46630. ],
  46631. barGroup
  46632. );
  46633. var align = this._applyTransform(
  46634. endsIndex === 0 ? 'bottom' : 'top',
  46635. barGroup
  46636. );
  46637. var orient = this._orient;
  46638. var textStyleModel = this.visualMapModel.textStyleModel;
  46639. this.group.add(new graphic.Text({
  46640. style: {
  46641. x: position[0],
  46642. y: position[1],
  46643. textVerticalAlign: orient === 'horizontal' ? 'middle' : align,
  46644. textAlign: orient === 'horizontal' ? align : 'center',
  46645. text: text,
  46646. textFont: textStyleModel.getFont(),
  46647. fill: textStyleModel.getTextColor()
  46648. }
  46649. }));
  46650. },
  46651. /**
  46652. * @private
  46653. */
  46654. _renderBar: function (targetGroup) {
  46655. var visualMapModel = this.visualMapModel;
  46656. var shapes = this._shapes;
  46657. var itemSize = visualMapModel.itemSize;
  46658. var orient = this._orient;
  46659. var useHandle = this._useHandle;
  46660. var itemAlign = helper.getItemAlign(visualMapModel, this.api, itemSize);
  46661. var barGroup = shapes.barGroup = this._createBarGroup(itemAlign);
  46662. // Bar
  46663. barGroup.add(shapes.outOfRange = createPolygon());
  46664. barGroup.add(shapes.inRange = createPolygon(
  46665. null,
  46666. useHandle ? 'move' : null,
  46667. zrUtil.bind(this._dragHandle, this, 'all', false),
  46668. zrUtil.bind(this._dragHandle, this, 'all', true)
  46669. ));
  46670. var textRect = visualMapModel.textStyleModel.getTextRect('国');
  46671. var textSize = mathMax(textRect.width, textRect.height);
  46672. // Handle
  46673. if (useHandle) {
  46674. shapes.handleThumbs = [];
  46675. shapes.handleLabels = [];
  46676. shapes.handleLabelPoints = [];
  46677. this._createHandle(barGroup, 0, itemSize, textSize, orient, itemAlign);
  46678. this._createHandle(barGroup, 1, itemSize, textSize, orient, itemAlign);
  46679. }
  46680. this._createIndicator(barGroup, itemSize, textSize, orient);
  46681. targetGroup.add(barGroup);
  46682. },
  46683. /**
  46684. * @private
  46685. */
  46686. _createHandle: function (barGroup, handleIndex, itemSize, textSize, orient) {
  46687. var onDrift = zrUtil.bind(this._dragHandle, this, handleIndex, false);
  46688. var onDragEnd = zrUtil.bind(this._dragHandle, this, handleIndex, true);
  46689. var handleThumb = createPolygon(
  46690. createHandlePoints(handleIndex, textSize),
  46691. 'move',
  46692. onDrift,
  46693. onDragEnd
  46694. );
  46695. handleThumb.position[0] = itemSize[0];
  46696. barGroup.add(handleThumb);
  46697. // Text is always horizontal layout but should not be effected by
  46698. // transform (orient/inverse). So label is built separately but not
  46699. // use zrender/graphic/helper/RectText, and is located based on view
  46700. // group (according to handleLabelPoint) but not barGroup.
  46701. var textStyleModel = this.visualMapModel.textStyleModel;
  46702. var handleLabel = new graphic.Text({
  46703. draggable: true,
  46704. drift: onDrift,
  46705. ondragend: onDragEnd,
  46706. style: {
  46707. x: 0, y: 0, text: '',
  46708. textFont: textStyleModel.getFont(),
  46709. fill: textStyleModel.getTextColor()
  46710. }
  46711. });
  46712. this.group.add(handleLabel);
  46713. var handleLabelPoint = [
  46714. orient === 'horizontal'
  46715. ? textSize / 2
  46716. : textSize * 1.5,
  46717. orient === 'horizontal'
  46718. ? (handleIndex === 0 ? -(textSize * 1.5) : (textSize * 1.5))
  46719. : (handleIndex === 0 ? -textSize / 2 : textSize / 2)
  46720. ];
  46721. var shapes = this._shapes;
  46722. shapes.handleThumbs[handleIndex] = handleThumb;
  46723. shapes.handleLabelPoints[handleIndex] = handleLabelPoint;
  46724. shapes.handleLabels[handleIndex] = handleLabel;
  46725. },
  46726. /**
  46727. * @private
  46728. */
  46729. _createIndicator: function (barGroup, itemSize, textSize, orient) {
  46730. var indicator = createPolygon([[0, 0]], 'move');
  46731. indicator.position[0] = itemSize[0];
  46732. indicator.attr({invisible: true, silent: true});
  46733. barGroup.add(indicator);
  46734. var textStyleModel = this.visualMapModel.textStyleModel;
  46735. var indicatorLabel = new graphic.Text({
  46736. silent: true,
  46737. invisible: true,
  46738. style: {
  46739. x: 0, y: 0, text: '',
  46740. textFont: textStyleModel.getFont(),
  46741. fill: textStyleModel.getTextColor()
  46742. }
  46743. });
  46744. this.group.add(indicatorLabel);
  46745. var indicatorLabelPoint = [
  46746. orient === 'horizontal' ? textSize / 2 : HOVER_LINK_OUT + 3,
  46747. 0
  46748. ];
  46749. var shapes = this._shapes;
  46750. shapes.indicator = indicator;
  46751. shapes.indicatorLabel = indicatorLabel;
  46752. shapes.indicatorLabelPoint = indicatorLabelPoint;
  46753. },
  46754. /**
  46755. * @private
  46756. */
  46757. _dragHandle: function (handleIndex, isEnd, dx, dy) {
  46758. if (!this._useHandle) {
  46759. return;
  46760. }
  46761. this._dragging = !isEnd;
  46762. if (!isEnd) {
  46763. // Transform dx, dy to bar coordination.
  46764. var vertex = this._applyTransform([dx, dy], this._shapes.barGroup, true);
  46765. this._updateInterval(handleIndex, vertex[1]);
  46766. // Considering realtime, update view should be executed
  46767. // before dispatch action.
  46768. this._updateView();
  46769. }
  46770. // dragEnd do not dispatch action when realtime.
  46771. if (isEnd === !this.visualMapModel.get('realtime')) { // jshint ignore:line
  46772. this.api.dispatchAction({
  46773. type: 'selectDataRange',
  46774. from: this.uid,
  46775. visualMapId: this.visualMapModel.id,
  46776. selected: this._dataInterval.slice()
  46777. });
  46778. }
  46779. if (isEnd) {
  46780. !this._hovering && this._clearHoverLinkToSeries();
  46781. }
  46782. else if (useHoverLinkOnHandle(this.visualMapModel)) {
  46783. this._doHoverLinkToSeries(this._handleEnds[handleIndex], false);
  46784. }
  46785. },
  46786. /**
  46787. * @private
  46788. */
  46789. _resetInterval: function () {
  46790. var visualMapModel = this.visualMapModel;
  46791. var dataInterval = this._dataInterval = visualMapModel.getSelected();
  46792. var dataExtent = visualMapModel.getExtent();
  46793. var sizeExtent = [0, visualMapModel.itemSize[1]];
  46794. this._handleEnds = [
  46795. linearMap(dataInterval[0], dataExtent, sizeExtent, true),
  46796. linearMap(dataInterval[1], dataExtent, sizeExtent, true)
  46797. ];
  46798. },
  46799. /**
  46800. * @private
  46801. * @param {(number|string)} handleIndex 0 or 1 or 'all'
  46802. * @param {number} dx
  46803. * @param {number} dy
  46804. */
  46805. _updateInterval: function (handleIndex, delta) {
  46806. delta = delta || 0;
  46807. var visualMapModel = this.visualMapModel;
  46808. var handleEnds = this._handleEnds;
  46809. sliderMove(
  46810. delta,
  46811. handleEnds,
  46812. [0, visualMapModel.itemSize[1]],
  46813. handleIndex === 'all' ? 'rigid' : 'push',
  46814. handleIndex
  46815. );
  46816. var dataExtent = visualMapModel.getExtent();
  46817. var sizeExtent = [0, visualMapModel.itemSize[1]];
  46818. // Update data interval.
  46819. this._dataInterval = [
  46820. linearMap(handleEnds[0], sizeExtent, dataExtent, true),
  46821. linearMap(handleEnds[1], sizeExtent, dataExtent, true)
  46822. ];
  46823. },
  46824. /**
  46825. * @private
  46826. */
  46827. _updateView: function (forSketch) {
  46828. var visualMapModel = this.visualMapModel;
  46829. var dataExtent = visualMapModel.getExtent();
  46830. var shapes = this._shapes;
  46831. var outOfRangeHandleEnds = [0, visualMapModel.itemSize[1]];
  46832. var inRangeHandleEnds = forSketch ? outOfRangeHandleEnds : this._handleEnds;
  46833. var visualInRange = this._createBarVisual(
  46834. this._dataInterval, dataExtent, inRangeHandleEnds, 'inRange'
  46835. );
  46836. var visualOutOfRange = this._createBarVisual(
  46837. dataExtent, dataExtent, outOfRangeHandleEnds, 'outOfRange'
  46838. );
  46839. shapes.inRange
  46840. .setStyle({
  46841. fill: visualInRange.barColor,
  46842. opacity: visualInRange.opacity
  46843. })
  46844. .setShape('points', visualInRange.barPoints);
  46845. shapes.outOfRange
  46846. .setStyle({
  46847. fill: visualOutOfRange.barColor,
  46848. opacity: visualOutOfRange.opacity
  46849. })
  46850. .setShape('points', visualOutOfRange.barPoints);
  46851. this._updateHandle(inRangeHandleEnds, visualInRange);
  46852. },
  46853. /**
  46854. * @private
  46855. */
  46856. _createBarVisual: function (dataInterval, dataExtent, handleEnds, forceState) {
  46857. var opts = {
  46858. forceState: forceState,
  46859. convertOpacityToAlpha: true
  46860. };
  46861. var colorStops = this._makeColorGradient(dataInterval, opts);
  46862. var symbolSizes = [
  46863. this.getControllerVisual(dataInterval[0], 'symbolSize', opts),
  46864. this.getControllerVisual(dataInterval[1], 'symbolSize', opts)
  46865. ];
  46866. var barPoints = this._createBarPoints(handleEnds, symbolSizes);
  46867. return {
  46868. barColor: new LinearGradient(0, 0, 1, 1, colorStops),
  46869. barPoints: barPoints,
  46870. handlesColor: [
  46871. colorStops[0].color,
  46872. colorStops[colorStops.length - 1].color
  46873. ]
  46874. };
  46875. },
  46876. /**
  46877. * @private
  46878. */
  46879. _makeColorGradient: function (dataInterval, opts) {
  46880. // Considering colorHue, which is not linear, so we have to sample
  46881. // to calculate gradient color stops, but not only caculate head
  46882. // and tail.
  46883. var sampleNumber = 100; // Arbitrary value.
  46884. var colorStops = [];
  46885. var step = (dataInterval[1] - dataInterval[0]) / sampleNumber;
  46886. colorStops.push({
  46887. color: this.getControllerVisual(dataInterval[0], 'color', opts),
  46888. offset: 0
  46889. });
  46890. for (var i = 1; i < sampleNumber; i++) {
  46891. var currValue = dataInterval[0] + step * i;
  46892. if (currValue > dataInterval[1]) {
  46893. break;
  46894. }
  46895. colorStops.push({
  46896. color: this.getControllerVisual(currValue, 'color', opts),
  46897. offset: i / sampleNumber
  46898. });
  46899. }
  46900. colorStops.push({
  46901. color: this.getControllerVisual(dataInterval[1], 'color', opts),
  46902. offset: 1
  46903. });
  46904. return colorStops;
  46905. },
  46906. /**
  46907. * @private
  46908. */
  46909. _createBarPoints: function (handleEnds, symbolSizes) {
  46910. var itemSize = this.visualMapModel.itemSize;
  46911. return [
  46912. [itemSize[0] - symbolSizes[0], handleEnds[0]],
  46913. [itemSize[0], handleEnds[0]],
  46914. [itemSize[0], handleEnds[1]],
  46915. [itemSize[0] - symbolSizes[1], handleEnds[1]]
  46916. ];
  46917. },
  46918. /**
  46919. * @private
  46920. */
  46921. _createBarGroup: function (itemAlign) {
  46922. var orient = this._orient;
  46923. var inverse = this.visualMapModel.get('inverse');
  46924. return new graphic.Group(
  46925. (orient === 'horizontal' && !inverse)
  46926. ? {scale: itemAlign === 'bottom' ? [1, 1] : [-1, 1], rotation: Math.PI / 2}
  46927. : (orient === 'horizontal' && inverse)
  46928. ? {scale: itemAlign === 'bottom' ? [-1, 1] : [1, 1], rotation: -Math.PI / 2}
  46929. : (orient === 'vertical' && !inverse)
  46930. ? {scale: itemAlign === 'left' ? [1, -1] : [-1, -1]}
  46931. : {scale: itemAlign === 'left' ? [1, 1] : [-1, 1]}
  46932. );
  46933. },
  46934. /**
  46935. * @private
  46936. */
  46937. _updateHandle: function (handleEnds, visualInRange) {
  46938. if (!this._useHandle) {
  46939. return;
  46940. }
  46941. var shapes = this._shapes;
  46942. var visualMapModel = this.visualMapModel;
  46943. var handleThumbs = shapes.handleThumbs;
  46944. var handleLabels = shapes.handleLabels;
  46945. each([0, 1], function (handleIndex) {
  46946. var handleThumb = handleThumbs[handleIndex];
  46947. handleThumb.setStyle('fill', visualInRange.handlesColor[handleIndex]);
  46948. handleThumb.position[1] = handleEnds[handleIndex];
  46949. // Update handle label position.
  46950. var textPoint = graphic.applyTransform(
  46951. shapes.handleLabelPoints[handleIndex],
  46952. graphic.getTransform(handleThumb, this.group)
  46953. );
  46954. handleLabels[handleIndex].setStyle({
  46955. x: textPoint[0],
  46956. y: textPoint[1],
  46957. text: visualMapModel.formatValueText(this._dataInterval[handleIndex]),
  46958. textVerticalAlign: 'middle',
  46959. textAlign: this._applyTransform(
  46960. this._orient === 'horizontal'
  46961. ? (handleIndex === 0 ? 'bottom' : 'top')
  46962. : 'left',
  46963. shapes.barGroup
  46964. )
  46965. });
  46966. }, this);
  46967. },
  46968. /**
  46969. * @private
  46970. * @param {number} cursorValue
  46971. * @param {number} textValue
  46972. * @param {string} [rangeSymbol]
  46973. * @param {number} [halfHoverLinkSize]
  46974. */
  46975. _showIndicator: function (cursorValue, textValue, rangeSymbol, halfHoverLinkSize) {
  46976. var visualMapModel = this.visualMapModel;
  46977. var dataExtent = visualMapModel.getExtent();
  46978. var itemSize = visualMapModel.itemSize;
  46979. var sizeExtent = [0, itemSize[1]];
  46980. var pos = linearMap(cursorValue, dataExtent, sizeExtent, true);
  46981. var shapes = this._shapes;
  46982. var indicator = shapes.indicator;
  46983. if (!indicator) {
  46984. return;
  46985. }
  46986. indicator.position[1] = pos;
  46987. indicator.attr('invisible', false);
  46988. indicator.setShape('points', createIndicatorPoints(
  46989. !!rangeSymbol, halfHoverLinkSize, pos, itemSize[1]
  46990. ));
  46991. var opts = {convertOpacityToAlpha: true};
  46992. var color = this.getControllerVisual(cursorValue, 'color', opts);
  46993. indicator.setStyle('fill', color);
  46994. // Update handle label position.
  46995. var textPoint = graphic.applyTransform(
  46996. shapes.indicatorLabelPoint,
  46997. graphic.getTransform(indicator, this.group)
  46998. );
  46999. var indicatorLabel = shapes.indicatorLabel;
  47000. indicatorLabel.attr('invisible', false);
  47001. var align = this._applyTransform('left', shapes.barGroup);
  47002. var orient = this._orient;
  47003. indicatorLabel.setStyle({
  47004. text: (rangeSymbol ? rangeSymbol : '') + visualMapModel.formatValueText(textValue),
  47005. textVerticalAlign: orient === 'horizontal' ? align : 'middle',
  47006. textAlign: orient === 'horizontal' ? 'center' : align,
  47007. x: textPoint[0],
  47008. y: textPoint[1]
  47009. });
  47010. },
  47011. /**
  47012. * @private
  47013. */
  47014. _enableHoverLinkToSeries: function () {
  47015. var self = this;
  47016. this._shapes.barGroup
  47017. .on('mousemove', function (e) {
  47018. self._hovering = true;
  47019. if (!self._dragging) {
  47020. var itemSize = self.visualMapModel.itemSize;
  47021. var pos = self._applyTransform(
  47022. [e.offsetX, e.offsetY], self._shapes.barGroup, true, true
  47023. );
  47024. // For hover link show when hover handle, which might be
  47025. // below or upper than sizeExtent.
  47026. pos[1] = mathMin(mathMax(0, pos[1]), itemSize[1]);
  47027. self._doHoverLinkToSeries(
  47028. pos[1],
  47029. 0 <= pos[0] && pos[0] <= itemSize[0]
  47030. );
  47031. }
  47032. })
  47033. .on('mouseout', function () {
  47034. // When mouse is out of handle, hoverLink still need
  47035. // to be displayed when realtime is set as false.
  47036. self._hovering = false;
  47037. !self._dragging && self._clearHoverLinkToSeries();
  47038. });
  47039. },
  47040. /**
  47041. * @private
  47042. */
  47043. _enableHoverLinkFromSeries: function () {
  47044. var zr = this.api.getZr();
  47045. if (this.visualMapModel.option.hoverLink) {
  47046. zr.on('mouseover', this._hoverLinkFromSeriesMouseOver, this);
  47047. zr.on('mouseout', this._hideIndicator, this);
  47048. }
  47049. else {
  47050. this._clearHoverLinkFromSeries();
  47051. }
  47052. },
  47053. /**
  47054. * @private
  47055. */
  47056. _doHoverLinkToSeries: function (cursorPos, hoverOnBar) {
  47057. var visualMapModel = this.visualMapModel;
  47058. var itemSize = visualMapModel.itemSize;
  47059. if (!visualMapModel.option.hoverLink) {
  47060. return;
  47061. }
  47062. var sizeExtent = [0, itemSize[1]];
  47063. var dataExtent = visualMapModel.getExtent();
  47064. // For hover link show when hover handle, which might be below or upper than sizeExtent.
  47065. cursorPos = mathMin(mathMax(sizeExtent[0], cursorPos), sizeExtent[1]);
  47066. var halfHoverLinkSize = getHalfHoverLinkSize(visualMapModel, dataExtent, sizeExtent);
  47067. var hoverRange = [cursorPos - halfHoverLinkSize, cursorPos + halfHoverLinkSize];
  47068. var cursorValue = linearMap(cursorPos, sizeExtent, dataExtent, true);
  47069. var valueRange = [
  47070. linearMap(hoverRange[0], sizeExtent, dataExtent, true),
  47071. linearMap(hoverRange[1], sizeExtent, dataExtent, true)
  47072. ];
  47073. // Consider data range is out of visualMap range, see test/visualMap-continuous.html,
  47074. // where china and india has very large population.
  47075. hoverRange[0] < sizeExtent[0] && (valueRange[0] = -Infinity);
  47076. hoverRange[1] > sizeExtent[1] && (valueRange[1] = Infinity);
  47077. // Do not show indicator when mouse is over handle,
  47078. // otherwise labels overlap, especially when dragging.
  47079. if (hoverOnBar) {
  47080. if (valueRange[0] === -Infinity) {
  47081. this._showIndicator(cursorValue, valueRange[1], '< ', halfHoverLinkSize);
  47082. }
  47083. else if (valueRange[1] === Infinity) {
  47084. this._showIndicator(cursorValue, valueRange[0], '> ', halfHoverLinkSize);
  47085. }
  47086. else {
  47087. this._showIndicator(cursorValue, cursorValue, '≈ ', halfHoverLinkSize);
  47088. }
  47089. }
  47090. // When realtime is set as false, handles, which are in barGroup,
  47091. // also trigger hoverLink, which help user to realize where they
  47092. // focus on when dragging. (see test/heatmap-large.html)
  47093. // When realtime is set as true, highlight will not show when hover
  47094. // handle, because the label on handle, which displays a exact value
  47095. // but not range, might mislead users.
  47096. var oldBatch = this._hoverLinkDataIndices;
  47097. var newBatch = [];
  47098. if (hoverOnBar || useHoverLinkOnHandle(visualMapModel)) {
  47099. newBatch = this._hoverLinkDataIndices = visualMapModel.findTargetDataIndices(valueRange);
  47100. }
  47101. var resultBatches = modelUtil.compressBatches(oldBatch, newBatch);
  47102. this._dispatchHighDown('downplay', resultBatches[0]);
  47103. this._dispatchHighDown('highlight', resultBatches[1]);
  47104. },
  47105. /**
  47106. * @private
  47107. */
  47108. _hoverLinkFromSeriesMouseOver: function (e) {
  47109. var el = e.target;
  47110. if (!el || el.dataIndex == null) {
  47111. return;
  47112. }
  47113. var dataModel = el.dataModel || this.ecModel.getSeriesByIndex(el.seriesIndex);
  47114. var data = dataModel.getData(el.dataType);
  47115. var dim = data.getDimension(this.visualMapModel.getDataDimension(data));
  47116. var value = data.get(dim, el.dataIndex, true);
  47117. if (!isNaN(value)) {
  47118. this._showIndicator(value, value);
  47119. }
  47120. },
  47121. /**
  47122. * @private
  47123. */
  47124. _hideIndicator: function () {
  47125. var shapes = this._shapes;
  47126. shapes.indicator && shapes.indicator.attr('invisible', true);
  47127. shapes.indicatorLabel && shapes.indicatorLabel.attr('invisible', true);
  47128. },
  47129. /**
  47130. * @private
  47131. */
  47132. _clearHoverLinkToSeries: function () {
  47133. this._hideIndicator();
  47134. var indices = this._hoverLinkDataIndices;
  47135. this._dispatchHighDown('downplay', indices);
  47136. indices.length = 0;
  47137. },
  47138. /**
  47139. * @private
  47140. */
  47141. _clearHoverLinkFromSeries: function () {
  47142. this._hideIndicator();
  47143. var zr = this.api.getZr();
  47144. zr.off('mouseover', this._hoverLinkFromSeriesMouseOver);
  47145. zr.off('mouseout', this._hideIndicator);
  47146. },
  47147. /**
  47148. * @private
  47149. */
  47150. _applyTransform: function (vertex, element, inverse, global) {
  47151. var transform = graphic.getTransform(element, global ? null : this.group);
  47152. return graphic[
  47153. zrUtil.isArray(vertex) ? 'applyTransform' : 'transformDirection'
  47154. ](vertex, transform, inverse);
  47155. },
  47156. /**
  47157. * @private
  47158. */
  47159. _dispatchHighDown: function (type, batch) {
  47160. batch && batch.length && this.api.dispatchAction({
  47161. type: type,
  47162. batch: batch
  47163. });
  47164. },
  47165. /**
  47166. * @override
  47167. */
  47168. dispose: function () {
  47169. this._clearHoverLinkFromSeries();
  47170. this._clearHoverLinkToSeries();
  47171. },
  47172. /**
  47173. * @override
  47174. */
  47175. remove: function () {
  47176. this._clearHoverLinkFromSeries();
  47177. this._clearHoverLinkToSeries();
  47178. }
  47179. });
  47180. function createPolygon(points, cursor, onDrift, onDragEnd) {
  47181. return new graphic.Polygon({
  47182. shape: {points: points},
  47183. draggable: !!onDrift,
  47184. cursor: cursor,
  47185. drift: onDrift,
  47186. ondragend: onDragEnd
  47187. });
  47188. }
  47189. function createHandlePoints(handleIndex, textSize) {
  47190. return handleIndex === 0
  47191. ? [[0, 0], [textSize, 0], [textSize, -textSize]]
  47192. : [[0, 0], [textSize, 0], [textSize, textSize]];
  47193. }
  47194. function createIndicatorPoints(isRange, halfHoverLinkSize, pos, extentMax) {
  47195. return isRange
  47196. ? [ // indicate range
  47197. [0, -mathMin(halfHoverLinkSize, mathMax(pos, 0))],
  47198. [HOVER_LINK_OUT, 0],
  47199. [0, mathMin(halfHoverLinkSize, mathMax(extentMax - pos, 0))]
  47200. ]
  47201. : [ // indicate single value
  47202. [0, 0], [5, -5], [5, 5]
  47203. ];
  47204. }
  47205. function getHalfHoverLinkSize(visualMapModel, dataExtent, sizeExtent) {
  47206. var halfHoverLinkSize = HOVER_LINK_SIZE / 2;
  47207. var hoverLinkDataSize = visualMapModel.get('hoverLinkDataSize');
  47208. if (hoverLinkDataSize) {
  47209. halfHoverLinkSize = linearMap(hoverLinkDataSize, dataExtent, sizeExtent, true) / 2;
  47210. }
  47211. return halfHoverLinkSize;
  47212. }
  47213. function useHoverLinkOnHandle(visualMapModel) {
  47214. return !visualMapModel.get('realtime') && visualMapModel.get('hoverLinkOnHandle');
  47215. }
  47216. module.exports = ContinuousView;
  47217. /***/ },
  47218. /* 338 */
  47219. /***/ function(module, exports, __webpack_require__) {
  47220. var zrUtil = __webpack_require__(4);
  47221. var graphic = __webpack_require__(43);
  47222. var formatUtil = __webpack_require__(6);
  47223. var layout = __webpack_require__(21);
  47224. var echarts = __webpack_require__(1);
  47225. var VisualMapping = __webpack_require__(192);
  47226. module.exports = echarts.extendComponentView({
  47227. type: 'visualMap',
  47228. /**
  47229. * @readOnly
  47230. * @type {Object}
  47231. */
  47232. autoPositionValues: {left: 1, right: 1, top: 1, bottom: 1},
  47233. init: function (ecModel, api) {
  47234. /**
  47235. * @readOnly
  47236. * @type {module:echarts/model/Global}
  47237. */
  47238. this.ecModel = ecModel;
  47239. /**
  47240. * @readOnly
  47241. * @type {module:echarts/ExtensionAPI}
  47242. */
  47243. this.api = api;
  47244. /**
  47245. * @readOnly
  47246. * @type {module:echarts/component/visualMap/visualMapModel}
  47247. */
  47248. this.visualMapModel;
  47249. },
  47250. /**
  47251. * @protected
  47252. */
  47253. render: function (visualMapModel, ecModel, api, payload) {
  47254. this.visualMapModel = visualMapModel;
  47255. if (visualMapModel.get('show') === false) {
  47256. this.group.removeAll();
  47257. return;
  47258. }
  47259. this.doRender.apply(this, arguments);
  47260. },
  47261. /**
  47262. * @protected
  47263. */
  47264. renderBackground: function (group) {
  47265. var visualMapModel = this.visualMapModel;
  47266. var padding = formatUtil.normalizeCssArray(visualMapModel.get('padding') || 0);
  47267. var rect = group.getBoundingRect();
  47268. group.add(new graphic.Rect({
  47269. z2: -1, // Lay background rect on the lowest layer.
  47270. silent: true,
  47271. shape: {
  47272. x: rect.x - padding[3],
  47273. y: rect.y - padding[0],
  47274. width: rect.width + padding[3] + padding[1],
  47275. height: rect.height + padding[0] + padding[2]
  47276. },
  47277. style: {
  47278. fill: visualMapModel.get('backgroundColor'),
  47279. stroke: visualMapModel.get('borderColor'),
  47280. lineWidth: visualMapModel.get('borderWidth')
  47281. }
  47282. }));
  47283. },
  47284. /**
  47285. * @protected
  47286. * @param {number} targetValue
  47287. * @param {string=} visualCluster Only can be 'color' 'opacity' 'symbol' 'symbolSize'
  47288. * @param {Object} [opts]
  47289. * @param {string=} [opts.forceState] Specify state, instead of using getValueState method.
  47290. * @param {string=} [opts.convertOpacityToAlpha=false] For color gradient in controller widget.
  47291. * @return {*} Visual value.
  47292. */
  47293. getControllerVisual: function (targetValue, visualCluster, opts) {
  47294. opts = opts || {};
  47295. var forceState = opts.forceState;
  47296. var visualMapModel = this.visualMapModel;
  47297. var visualObj = {};
  47298. // Default values.
  47299. if (visualCluster === 'symbol') {
  47300. visualObj.symbol = visualMapModel.get('itemSymbol');
  47301. }
  47302. if (visualCluster === 'color') {
  47303. var defaultColor = visualMapModel.get('contentColor');
  47304. visualObj.color = defaultColor;
  47305. }
  47306. function getter(key) {
  47307. return visualObj[key];
  47308. }
  47309. function setter(key, value) {
  47310. visualObj[key] = value;
  47311. }
  47312. var mappings = visualMapModel.controllerVisuals[
  47313. forceState || visualMapModel.getValueState(targetValue)
  47314. ];
  47315. var visualTypes = VisualMapping.prepareVisualTypes(mappings);
  47316. zrUtil.each(visualTypes, function (type) {
  47317. var visualMapping = mappings[type];
  47318. if (opts.convertOpacityToAlpha && type === 'opacity') {
  47319. type = 'colorAlpha';
  47320. visualMapping = mappings.__alphaForOpacity;
  47321. }
  47322. if (VisualMapping.dependsOn(type, visualCluster)) {
  47323. visualMapping && visualMapping.applyVisual(
  47324. targetValue, getter, setter
  47325. );
  47326. }
  47327. });
  47328. return visualObj[visualCluster];
  47329. },
  47330. /**
  47331. * @protected
  47332. */
  47333. positionGroup: function (group) {
  47334. var model = this.visualMapModel;
  47335. var api = this.api;
  47336. layout.positionGroup(
  47337. group,
  47338. model.getBoxLayoutParams(),
  47339. {width: api.getWidth(), height: api.getHeight()}
  47340. );
  47341. },
  47342. /**
  47343. * @protected
  47344. * @abstract
  47345. */
  47346. doRender: zrUtil.noop
  47347. });
  47348. /***/ },
  47349. /* 339 */
  47350. /***/ function(module, exports, __webpack_require__) {
  47351. var layout = __webpack_require__(21);
  47352. var helper = {
  47353. /**
  47354. * @param {module:echarts/component/visualMap/VisualMapModel} visualMapModel\
  47355. * @param {module:echarts/ExtensionAPI} api
  47356. * @param {Array.<number>} itemSize always [short, long]
  47357. * @return {string} 'left' or 'right' or 'top' or 'bottom'
  47358. */
  47359. getItemAlign: function (visualMapModel, api, itemSize) {
  47360. var modelOption = visualMapModel.option;
  47361. var itemAlign = modelOption.align;
  47362. if (itemAlign != null && itemAlign !== 'auto') {
  47363. return itemAlign;
  47364. }
  47365. // Auto decision align.
  47366. var ecSize = {width: api.getWidth(), height: api.getHeight()};
  47367. var realIndex = modelOption.orient === 'horizontal' ? 1 : 0;
  47368. var paramsSet = [
  47369. ['left', 'right', 'width'],
  47370. ['top', 'bottom', 'height']
  47371. ];
  47372. var reals = paramsSet[realIndex];
  47373. var fakeValue = [0, null, 10];
  47374. var layoutInput = {};
  47375. for (var i = 0; i < 3; i++) {
  47376. layoutInput[paramsSet[1 - realIndex][i]] = fakeValue[i];
  47377. layoutInput[reals[i]] = i === 2 ? itemSize[0] : modelOption[reals[i]];
  47378. }
  47379. var rParam = [['x', 'width', 3], ['y', 'height', 0]][realIndex];
  47380. var rect = layout.getLayoutRect(layoutInput, ecSize, modelOption.padding);
  47381. return reals[
  47382. (rect.margin[rParam[2]] || 0) + rect[rParam[0]] + rect[rParam[1]] * 0.5
  47383. < ecSize[rParam[1]] * 0.5 ? 0 : 1
  47384. ];
  47385. }
  47386. };
  47387. module.exports = helper;
  47388. /***/ },
  47389. /* 340 */
  47390. /***/ function(module, exports, __webpack_require__) {
  47391. /**
  47392. * @file Data range action
  47393. */
  47394. var echarts = __webpack_require__(1);
  47395. var actionInfo = {
  47396. type: 'selectDataRange',
  47397. event: 'dataRangeSelected',
  47398. // FIXME use updateView appears wrong
  47399. update: 'update'
  47400. };
  47401. echarts.registerAction(actionInfo, function (payload, ecModel) {
  47402. ecModel.eachComponent({mainType: 'visualMap', query: payload}, function (model) {
  47403. model.setSelected(payload.selected);
  47404. });
  47405. });
  47406. /***/ },
  47407. /* 341 */
  47408. /***/ function(module, exports, __webpack_require__) {
  47409. /**
  47410. * DataZoom component entry
  47411. */
  47412. __webpack_require__(1).registerPreprocessor(
  47413. __webpack_require__(331)
  47414. );
  47415. __webpack_require__(332);
  47416. __webpack_require__(333);
  47417. __webpack_require__(342);
  47418. __webpack_require__(343);
  47419. __webpack_require__(340);
  47420. /***/ },
  47421. /* 342 */
  47422. /***/ function(module, exports, __webpack_require__) {
  47423. var VisualMapModel = __webpack_require__(335);
  47424. var zrUtil = __webpack_require__(4);
  47425. var VisualMapping = __webpack_require__(192);
  47426. var PiecewiseModel = VisualMapModel.extend({
  47427. type: 'visualMap.piecewise',
  47428. /**
  47429. * Order Rule:
  47430. *
  47431. * option.categories / option.pieces / option.text / option.selected:
  47432. * If !option.inverse,
  47433. * Order when vertical: ['top', ..., 'bottom'].
  47434. * Order when horizontal: ['left', ..., 'right'].
  47435. * If option.inverse, the meaning of
  47436. * the order should be reversed.
  47437. *
  47438. * this._pieceList:
  47439. * The order is always [low, ..., high].
  47440. *
  47441. * Mapping from location to low-high:
  47442. * If !option.inverse
  47443. * When vertical, top is high.
  47444. * When horizontal, right is high.
  47445. * If option.inverse, reverse.
  47446. */
  47447. /**
  47448. * @protected
  47449. */
  47450. defaultOption: {
  47451. selected: null, // Object. If not specified, means selected.
  47452. // When pieces and splitNumber: {'0': true, '5': true}
  47453. // When categories: {'cate1': false, 'cate3': true}
  47454. // When selected === false, means all unselected.
  47455. align: 'auto', // 'auto', 'left', 'right'
  47456. itemWidth: 20, // When put the controller vertically, it is the length of
  47457. // horizontal side of each item. Otherwise, vertical side.
  47458. itemHeight: 14, // When put the controller vertically, it is the length of
  47459. // vertical side of each item. Otherwise, horizontal side.
  47460. itemSymbol: 'roundRect',
  47461. pieceList: null, // Each item is Object, with some of those attrs:
  47462. // {min, max, lt, gt, lte, gte, value,
  47463. // color, colorSaturation, colorAlpha, opacity,
  47464. // symbol, symbolSize}, which customize the range or visual
  47465. // coding of the certain piece. Besides, see "Order Rule".
  47466. categories: null, // category names, like: ['some1', 'some2', 'some3'].
  47467. // Attr min/max are ignored when categories set. See "Order Rule"
  47468. splitNumber: 5, // If set to 5, auto split five pieces equally.
  47469. // If set to 0 and component type not set, component type will be
  47470. // determined as "continuous". (It is less reasonable but for ec2
  47471. // compatibility, see echarts/component/visualMap/typeDefaulter)
  47472. selectedMode: 'multiple', // Can be 'multiple' or 'single'.
  47473. itemGap: 10, // The gap between two items, in px.
  47474. hoverLink: true // Enable hover highlight.
  47475. },
  47476. /**
  47477. * @override
  47478. */
  47479. optionUpdated: function (newOption, isInit) {
  47480. PiecewiseModel.superApply(this, 'optionUpdated', arguments);
  47481. /**
  47482. * The order is always [low, ..., high].
  47483. * [{text: string, interval: Array.<number>}, ...]
  47484. * @private
  47485. * @type {Array.<Object>}
  47486. */
  47487. this._pieceList = [];
  47488. this.resetTargetSeries();
  47489. this.resetExtent();
  47490. /**
  47491. * 'pieces', 'categories', 'splitNumber'
  47492. * @type {string}
  47493. */
  47494. var mode = this._mode = this._determineMode();
  47495. resetMethods[this._mode].call(this);
  47496. this._resetSelected(newOption, isInit);
  47497. var categories = this.option.categories;
  47498. this.resetVisual(function (mappingOption, state) {
  47499. if (mode === 'categories') {
  47500. mappingOption.mappingMethod = 'category';
  47501. mappingOption.categories = zrUtil.clone(categories);
  47502. }
  47503. else {
  47504. mappingOption.dataExtent = this.getExtent();
  47505. mappingOption.mappingMethod = 'piecewise';
  47506. mappingOption.pieceList = zrUtil.map(this._pieceList, function (piece) {
  47507. var piece = zrUtil.clone(piece);
  47508. if (state !== 'inRange') {
  47509. piece.visual = null;
  47510. }
  47511. return piece;
  47512. });
  47513. }
  47514. });
  47515. },
  47516. _resetSelected: function (newOption, isInit) {
  47517. var thisOption = this.option;
  47518. var pieceList = this._pieceList;
  47519. // Selected do not merge but all override.
  47520. var selected = (isInit ? thisOption : newOption).selected || {};
  47521. thisOption.selected = selected;
  47522. // Consider 'not specified' means true.
  47523. zrUtil.each(pieceList, function (piece, index) {
  47524. var key = this.getSelectedMapKey(piece);
  47525. if (!(key in selected)) {
  47526. selected[key] = true;
  47527. }
  47528. }, this);
  47529. if (thisOption.selectedMode === 'single') {
  47530. // Ensure there is only one selected.
  47531. var hasSel = false;
  47532. zrUtil.each(pieceList, function (piece, index) {
  47533. var key = this.getSelectedMapKey(piece);
  47534. if (selected[key]) {
  47535. hasSel
  47536. ? (selected[key] = false)
  47537. : (hasSel = true);
  47538. }
  47539. }, this);
  47540. }
  47541. // thisOption.selectedMode === 'multiple', default: all selected.
  47542. },
  47543. /**
  47544. * @public
  47545. */
  47546. getSelectedMapKey: function (piece) {
  47547. return this._mode === 'categories'
  47548. ? piece.value + '' : piece.index + '';
  47549. },
  47550. /**
  47551. * @public
  47552. */
  47553. getPieceList: function () {
  47554. return this._pieceList;
  47555. },
  47556. /**
  47557. * @private
  47558. * @return {string}
  47559. */
  47560. _determineMode: function () {
  47561. var option = this.option;
  47562. return option.pieces && option.pieces.length > 0
  47563. ? 'pieces'
  47564. : this.option.categories
  47565. ? 'categories'
  47566. : 'splitNumber';
  47567. },
  47568. /**
  47569. * @public
  47570. * @override
  47571. */
  47572. setSelected: function (selected) {
  47573. this.option.selected = zrUtil.clone(selected);
  47574. },
  47575. /**
  47576. * @public
  47577. * @override
  47578. */
  47579. getValueState: function (value) {
  47580. var index = VisualMapping.findPieceIndex(value, this._pieceList);
  47581. return index != null
  47582. ? (this.option.selected[this.getSelectedMapKey(this._pieceList[index])]
  47583. ? 'inRange' : 'outOfRange'
  47584. )
  47585. : 'outOfRange';
  47586. },
  47587. /**
  47588. * @public
  47589. * @params {number} pieceIndex piece index in visualMapModel.getPieceList()
  47590. * @return {Array.<Object>} [{seriesId, dataIndices: <Array.<number>>}, ...]
  47591. */
  47592. findTargetDataIndices: function (pieceIndex) {
  47593. var result = [];
  47594. this.eachTargetSeries(function (seriesModel) {
  47595. var dataIndices = [];
  47596. var data = seriesModel.getData();
  47597. data.each(this.getDataDimension(data), function (value, dataIndex) {
  47598. // Should always base on model pieceList, because it is order sensitive.
  47599. var pIdx = VisualMapping.findPieceIndex(value, this._pieceList);
  47600. pIdx === pieceIndex && dataIndices.push(dataIndex);
  47601. }, true, this);
  47602. result.push({seriesId: seriesModel.id, dataIndex: dataIndices});
  47603. }, this);
  47604. return result;
  47605. },
  47606. /**
  47607. * @private
  47608. */
  47609. getRepresentValue: function (piece) {
  47610. var representValue;
  47611. if (this.isCategory()) {
  47612. representValue = piece.value;
  47613. }
  47614. else {
  47615. if (piece.value != null) {
  47616. representValue = piece.value;
  47617. }
  47618. else {
  47619. var pieceInterval = piece.interval || [];
  47620. representValue = (pieceInterval[0] + pieceInterval[1]) / 2;
  47621. }
  47622. }
  47623. return representValue;
  47624. },
  47625. getStops: function (seriesModel, getColorVisual) {
  47626. var result = [];
  47627. var model = this;
  47628. var curr = -Infinity;
  47629. zrUtil.each(this._pieceList, function (piece) {
  47630. // Do not support category yet.
  47631. var interval = piece.interval;
  47632. if (interval) {
  47633. interval[0] > curr && setPiece({
  47634. interval: [curr, interval[0]],
  47635. valueState: 'outOfRange'
  47636. });
  47637. setPiece({
  47638. interval: interval.slice(),
  47639. valueState: this.getValueState((interval[0] + interval[1]) / 2)
  47640. });
  47641. curr = interval[1];
  47642. }
  47643. }, this);
  47644. return result;
  47645. function setPiece(piece) {
  47646. result.push(piece);
  47647. piece.color = getColorVisual(
  47648. model, model.getRepresentValue(piece), piece.valueState
  47649. );
  47650. }
  47651. }
  47652. });
  47653. /**
  47654. * Key is this._mode
  47655. * @type {Object}
  47656. * @this {module:echarts/component/viusalMap/PiecewiseMode}
  47657. */
  47658. var resetMethods = {
  47659. splitNumber: function () {
  47660. var thisOption = this.option;
  47661. var pieceList = this._pieceList;
  47662. var precision = thisOption.precision;
  47663. var dataExtent = this.getExtent();
  47664. var splitNumber = thisOption.splitNumber;
  47665. splitNumber = Math.max(parseInt(splitNumber, 10), 1);
  47666. thisOption.splitNumber = splitNumber;
  47667. var splitStep = (dataExtent[1] - dataExtent[0]) / splitNumber;
  47668. // Precision auto-adaption
  47669. while (+splitStep.toFixed(precision) !== splitStep && precision < 5) {
  47670. precision++;
  47671. }
  47672. thisOption.precision = precision;
  47673. splitStep = +splitStep.toFixed(precision);
  47674. for (var i = 0, curr = dataExtent[0]; i < splitNumber; i++, curr += splitStep) {
  47675. var max = i === splitNumber - 1 ? dataExtent[1] : (curr + splitStep);
  47676. pieceList.push({
  47677. index: i,
  47678. interval: [curr, max],
  47679. close: [1, 1]
  47680. });
  47681. }
  47682. normalizePieces(pieceList);
  47683. zrUtil.each(pieceList, function (piece) {
  47684. piece.text = this.formatValueText(piece.interval);
  47685. }, this);
  47686. },
  47687. categories: function () {
  47688. var thisOption = this.option;
  47689. zrUtil.each(thisOption.categories, function (cate) {
  47690. // FIXME category模式也使用pieceList,但在visualMapping中不是使用pieceList。
  47691. // 是否改一致。
  47692. this._pieceList.push({
  47693. text: this.formatValueText(cate, true),
  47694. value: cate
  47695. });
  47696. }, this);
  47697. // See "Order Rule".
  47698. normalizeReverse(thisOption, this._pieceList);
  47699. },
  47700. pieces: function () {
  47701. var thisOption = this.option;
  47702. var pieceList = this._pieceList;
  47703. zrUtil.each(thisOption.pieces, function (pieceListItem, index) {
  47704. if (!zrUtil.isObject(pieceListItem)) {
  47705. pieceListItem = {value: pieceListItem};
  47706. }
  47707. var item = {text: '', index: index};
  47708. if (pieceListItem.label != null) {
  47709. item.text = pieceListItem.label;
  47710. }
  47711. if (pieceListItem.hasOwnProperty('value')) {
  47712. var value = item.value = pieceListItem.value;
  47713. item.interval = [value, value];
  47714. item.close = [1, 1];
  47715. }
  47716. else {
  47717. // `min` `max` is legacy option.
  47718. // `lt` `gt` `lte` `gte` is recommanded.
  47719. var interval = item.interval = [];
  47720. var close = item.close = [0, 0];
  47721. var closeList = [1, 0, 1];
  47722. var infinityList = [-Infinity, Infinity];
  47723. var useMinMax = [];
  47724. for (var lg = 0; lg < 2; lg++) {
  47725. var names = [['gte', 'gt', 'min'], ['lte', 'lt', 'max']][lg];
  47726. for (var i = 0; i < 3 && interval[lg] == null; i++) {
  47727. interval[lg] = pieceListItem[names[i]];
  47728. close[lg] = closeList[i];
  47729. useMinMax[lg] = i === 2;
  47730. }
  47731. interval[lg] == null && (interval[lg] = infinityList[lg]);
  47732. }
  47733. useMinMax[0] && interval[1] === Infinity && (close[0] = 0);
  47734. useMinMax[1] && interval[0] === -Infinity && (close[1] = 0);
  47735. if (true) {
  47736. if (interval[0] > interval[1]) {
  47737. console.warn(
  47738. 'Piece ' + index + 'is illegal: ' + interval
  47739. + ' lower bound should not greater then uppper bound.'
  47740. );
  47741. }
  47742. }
  47743. if (interval[0] === interval[1] && close[0] && close[1]) {
  47744. // Consider: [{min: 5, max: 5, visual: {...}}, {min: 0, max: 5}],
  47745. // we use value to lift the priority when min === max
  47746. item.value = interval[0];
  47747. }
  47748. }
  47749. item.visual = VisualMapping.retrieveVisuals(pieceListItem);
  47750. pieceList.push(item);
  47751. }, this);
  47752. // See "Order Rule".
  47753. normalizeReverse(thisOption, pieceList);
  47754. // Only pieces
  47755. normalizePieces(pieceList);
  47756. zrUtil.each(pieceList, function (piece) {
  47757. var close = piece.close;
  47758. var edgeSymbols = [['<', '≤'][close[1]], ['>', '≥'][close[0]]];
  47759. piece.text = piece.text || this.formatValueText(
  47760. piece.value != null ? piece.value : piece.interval,
  47761. false,
  47762. edgeSymbols
  47763. );
  47764. }, this);
  47765. }
  47766. };
  47767. function normalizeReverse(thisOption, pieceList) {
  47768. var inverse = thisOption.inverse;
  47769. if (thisOption.orient === 'vertical' ? !inverse : inverse) {
  47770. pieceList.reverse();
  47771. }
  47772. }
  47773. // Reorder, remove duplicate, which are needed when using gradient.
  47774. // Not applicable for categories.
  47775. function normalizePieces(pieceList) {
  47776. pieceList.sort(function (a, b) {
  47777. return littleThan(a, b) ? -1 : 1;
  47778. });
  47779. var curr = -Infinity;
  47780. for (var i = 0; i < pieceList.length; i++) {
  47781. var interval = pieceList[i].interval;
  47782. var close = pieceList[i].close;
  47783. for (var lg = 0; lg < 2; lg++) {
  47784. if (interval[lg] < curr) {
  47785. interval[lg] = curr;
  47786. close[lg] = 1 - lg;
  47787. }
  47788. curr = interval[lg];
  47789. }
  47790. }
  47791. // console.log(JSON.stringify(pieceList.map(a => a.interval)));
  47792. function littleThan(piece, standard, lg) {
  47793. lg = lg || 0;
  47794. return piece.interval[lg] < standard.interval[lg]
  47795. || (
  47796. piece.interval[lg] === standard.interval[lg]
  47797. && (
  47798. +piece.close[lg] > standard.close[lg]
  47799. || littleThan(piece, standard, 1)
  47800. )
  47801. );
  47802. }
  47803. }
  47804. module.exports = PiecewiseModel;
  47805. /***/ },
  47806. /* 343 */
  47807. /***/ function(module, exports, __webpack_require__) {
  47808. var VisualMapView = __webpack_require__(338);
  47809. var zrUtil = __webpack_require__(4);
  47810. var graphic = __webpack_require__(43);
  47811. var symbolCreators = __webpack_require__(106);
  47812. var layout = __webpack_require__(21);
  47813. var helper = __webpack_require__(339);
  47814. var PiecewiseVisualMapView = VisualMapView.extend({
  47815. type: 'visualMap.piecewise',
  47816. /**
  47817. * @protected
  47818. * @override
  47819. */
  47820. doRender: function () {
  47821. var thisGroup = this.group;
  47822. thisGroup.removeAll();
  47823. var visualMapModel = this.visualMapModel;
  47824. var textGap = visualMapModel.get('textGap');
  47825. var textStyleModel = visualMapModel.textStyleModel;
  47826. var textFont = textStyleModel.getFont();
  47827. var textFill = textStyleModel.getTextColor();
  47828. var itemAlign = this._getItemAlign();
  47829. var itemSize = visualMapModel.itemSize;
  47830. var viewData = this._getViewData();
  47831. var showLabel = !viewData.endsText;
  47832. var showEndsText = !showLabel;
  47833. showEndsText && this._renderEndsText(thisGroup, viewData.endsText[0], itemSize);
  47834. zrUtil.each(viewData.viewPieceList, renderItem, this);
  47835. showEndsText && this._renderEndsText(thisGroup, viewData.endsText[1], itemSize);
  47836. layout.box(
  47837. visualMapModel.get('orient'), thisGroup, visualMapModel.get('itemGap')
  47838. );
  47839. this.renderBackground(thisGroup);
  47840. this.positionGroup(thisGroup);
  47841. function renderItem(item) {
  47842. var piece = item.piece;
  47843. var itemGroup = new graphic.Group();
  47844. itemGroup.onclick = zrUtil.bind(this._onItemClick, this, piece);
  47845. this._enableHoverLink(itemGroup, item.indexInModelPieceList);
  47846. var representValue = visualMapModel.getRepresentValue(piece);
  47847. this._createItemSymbol(
  47848. itemGroup, representValue, [0, 0, itemSize[0], itemSize[1]]
  47849. );
  47850. if (showLabel) {
  47851. var visualState = this.visualMapModel.getValueState(representValue);
  47852. itemGroup.add(new graphic.Text({
  47853. style: {
  47854. x: itemAlign === 'right' ? -textGap : itemSize[0] + textGap,
  47855. y: itemSize[1] / 2,
  47856. text: piece.text,
  47857. textVerticalAlign: 'middle',
  47858. textAlign: itemAlign,
  47859. textFont: textFont,
  47860. fill: textFill,
  47861. opacity: visualState === 'outOfRange' ? 0.5 : 1
  47862. }
  47863. }));
  47864. }
  47865. thisGroup.add(itemGroup);
  47866. }
  47867. },
  47868. /**
  47869. * @private
  47870. */
  47871. _enableHoverLink: function (itemGroup, pieceIndex) {
  47872. itemGroup
  47873. .on('mouseover', zrUtil.bind(onHoverLink, this, 'highlight'))
  47874. .on('mouseout', zrUtil.bind(onHoverLink, this, 'downplay'));
  47875. function onHoverLink(method) {
  47876. var visualMapModel = this.visualMapModel;
  47877. visualMapModel.option.hoverLink && this.api.dispatchAction({
  47878. type: method,
  47879. batch: visualMapModel.findTargetDataIndices(pieceIndex)
  47880. });
  47881. }
  47882. },
  47883. /**
  47884. * @private
  47885. */
  47886. _getItemAlign: function () {
  47887. var visualMapModel = this.visualMapModel;
  47888. var modelOption = visualMapModel.option;
  47889. if (modelOption.orient === 'vertical') {
  47890. return helper.getItemAlign(
  47891. visualMapModel, this.api, visualMapModel.itemSize
  47892. );
  47893. }
  47894. else { // horizontal, most case left unless specifying right.
  47895. var align = modelOption.align;
  47896. if (!align || align === 'auto') {
  47897. align = 'left';
  47898. }
  47899. return align;
  47900. }
  47901. },
  47902. /**
  47903. * @private
  47904. */
  47905. _renderEndsText: function (group, text, itemSize) {
  47906. if (!text) {
  47907. return;
  47908. }
  47909. var itemGroup = new graphic.Group();
  47910. var textStyleModel = this.visualMapModel.textStyleModel;
  47911. itemGroup.add(new graphic.Text({
  47912. style: {
  47913. x: itemSize[0] / 2,
  47914. y: itemSize[1] / 2,
  47915. textVerticalAlign: 'middle',
  47916. textAlign: 'center',
  47917. text: text,
  47918. textFont: textStyleModel.getFont(),
  47919. fill: textStyleModel.getTextColor()
  47920. }
  47921. }));
  47922. group.add(itemGroup);
  47923. },
  47924. /**
  47925. * @private
  47926. * @return {Object} {peiceList, endsText} The order is the same as screen pixel order.
  47927. */
  47928. _getViewData: function () {
  47929. var visualMapModel = this.visualMapModel;
  47930. var viewPieceList = zrUtil.map(visualMapModel.getPieceList(), function (piece, index) {
  47931. return {piece: piece, indexInModelPieceList: index};
  47932. });
  47933. var endsText = visualMapModel.get('text');
  47934. // Consider orient and inverse.
  47935. var orient = visualMapModel.get('orient');
  47936. var inverse = visualMapModel.get('inverse');
  47937. // Order of model pieceList is always [low, ..., high]
  47938. if (orient === 'horizontal' ? inverse : !inverse) {
  47939. viewPieceList.reverse();
  47940. }
  47941. // Origin order of endsText is [high, low]
  47942. else if (endsText) {
  47943. endsText = endsText.slice().reverse();
  47944. }
  47945. return {viewPieceList: viewPieceList, endsText: endsText};
  47946. },
  47947. /**
  47948. * @private
  47949. */
  47950. _createItemSymbol: function (group, representValue, shapeParam) {
  47951. group.add(symbolCreators.createSymbol(
  47952. this.getControllerVisual(representValue, 'symbol'),
  47953. shapeParam[0], shapeParam[1], shapeParam[2], shapeParam[3],
  47954. this.getControllerVisual(representValue, 'color')
  47955. ));
  47956. },
  47957. /**
  47958. * @private
  47959. */
  47960. _onItemClick: function (piece) {
  47961. var visualMapModel = this.visualMapModel;
  47962. var option = visualMapModel.option;
  47963. var selected = zrUtil.clone(option.selected);
  47964. var newKey = visualMapModel.getSelectedMapKey(piece);
  47965. if (option.selectedMode === 'single') {
  47966. selected[newKey] = true;
  47967. zrUtil.each(selected, function (o, key) {
  47968. selected[key] = key === newKey;
  47969. });
  47970. }
  47971. else {
  47972. selected[newKey] = !selected[newKey];
  47973. }
  47974. this.api.dispatchAction({
  47975. type: 'selectDataRange',
  47976. from: this.uid,
  47977. visualMapId: this.visualMapModel.id,
  47978. selected: selected
  47979. });
  47980. }
  47981. });
  47982. module.exports = PiecewiseVisualMapView;
  47983. /***/ },
  47984. /* 344 */
  47985. /***/ function(module, exports, __webpack_require__) {
  47986. // HINT Markpoint can't be used too much
  47987. __webpack_require__(345);
  47988. __webpack_require__(347);
  47989. __webpack_require__(1).registerPreprocessor(function (opt) {
  47990. // Make sure markPoint component is enabled
  47991. opt.markPoint = opt.markPoint || {};
  47992. });
  47993. /***/ },
  47994. /* 345 */
  47995. /***/ function(module, exports, __webpack_require__) {
  47996. module.exports = __webpack_require__(346).extend({
  47997. type: 'markPoint',
  47998. defaultOption: {
  47999. zlevel: 0,
  48000. z: 5,
  48001. symbol: 'pin',
  48002. symbolSize: 50,
  48003. //symbolRotate: 0,
  48004. //symbolOffset: [0, 0]
  48005. tooltip: {
  48006. trigger: 'item'
  48007. },
  48008. label: {
  48009. normal: {
  48010. show: true,
  48011. position: 'inside'
  48012. },
  48013. emphasis: {
  48014. show: true
  48015. }
  48016. },
  48017. itemStyle: {
  48018. normal: {
  48019. borderWidth: 2
  48020. }
  48021. }
  48022. }
  48023. });
  48024. /***/ },
  48025. /* 346 */
  48026. /***/ function(module, exports, __webpack_require__) {
  48027. var modelUtil = __webpack_require__(5);
  48028. var zrUtil = __webpack_require__(4);
  48029. var env = __webpack_require__(2);
  48030. var formatUtil = __webpack_require__(6);
  48031. var addCommas = formatUtil.addCommas;
  48032. var encodeHTML = formatUtil.encodeHTML;
  48033. function fillLabel(opt) {
  48034. modelUtil.defaultEmphasis(
  48035. opt.label,
  48036. modelUtil.LABEL_OPTIONS
  48037. );
  48038. }
  48039. var MarkerModel = __webpack_require__(1).extendComponentModel({
  48040. type: 'marker',
  48041. dependencies: ['series', 'grid', 'polar', 'geo'],
  48042. /**
  48043. * @overrite
  48044. */
  48045. init: function (option, parentModel, ecModel, extraOpt) {
  48046. if (true) {
  48047. if (this.type === 'marker') {
  48048. throw new Error('Marker component is abstract component. Use markLine, markPoint, markArea instead.');
  48049. }
  48050. }
  48051. this.mergeDefaultAndTheme(option, ecModel);
  48052. this.mergeOption(option, ecModel, extraOpt.createdBySelf, true);
  48053. },
  48054. /**
  48055. * @return {boolean}
  48056. */
  48057. ifEnableAnimation: function () {
  48058. if (env.node) {
  48059. return false;
  48060. }
  48061. var hostSeries = this.__hostSeries;
  48062. return this.getShallow('animation') && hostSeries && hostSeries.ifEnableAnimation();
  48063. },
  48064. mergeOption: function (newOpt, ecModel, createdBySelf, isInit) {
  48065. var MarkerModel = this.constructor;
  48066. var modelPropName = this.mainType + 'Model';
  48067. if (!createdBySelf) {
  48068. ecModel.eachSeries(function (seriesModel) {
  48069. var markerOpt = seriesModel.get(this.mainType);
  48070. var markerModel = seriesModel[modelPropName];
  48071. if (!markerOpt || !markerOpt.data) {
  48072. seriesModel[modelPropName] = null;
  48073. return;
  48074. }
  48075. if (!markerModel) {
  48076. if (isInit) {
  48077. // Default label emphasis `position` and `show`
  48078. fillLabel(markerOpt);
  48079. }
  48080. zrUtil.each(markerOpt.data, function (item) {
  48081. // FIXME Overwrite fillLabel method ?
  48082. if (item instanceof Array) {
  48083. fillLabel(item[0]);
  48084. fillLabel(item[1]);
  48085. }
  48086. else {
  48087. fillLabel(item);
  48088. }
  48089. });
  48090. var opt = {
  48091. mainType: this.mainType,
  48092. // Use the same series index and name
  48093. seriesIndex: seriesModel.seriesIndex,
  48094. name: seriesModel.name,
  48095. createdBySelf: true
  48096. };
  48097. markerModel = new MarkerModel(
  48098. markerOpt, this, ecModel, opt
  48099. );
  48100. markerModel.__hostSeries = seriesModel;
  48101. }
  48102. else {
  48103. markerModel.mergeOption(markerOpt, ecModel, true);
  48104. }
  48105. seriesModel[modelPropName] = markerModel;
  48106. }, this);
  48107. }
  48108. },
  48109. formatTooltip: function (dataIndex) {
  48110. var data = this.getData();
  48111. var value = this.getRawValue(dataIndex);
  48112. var formattedValue = zrUtil.isArray(value)
  48113. ? zrUtil.map(value, addCommas).join(', ') : addCommas(value);
  48114. var name = data.getName(dataIndex);
  48115. var html = this.name;
  48116. if (value != null || name) {
  48117. html += '<br />';
  48118. }
  48119. if (name) {
  48120. html += encodeHTML(name);
  48121. if (value != null) {
  48122. html += ' : ';
  48123. }
  48124. }
  48125. if (value != null) {
  48126. html += formattedValue;
  48127. }
  48128. return html;
  48129. },
  48130. getData: function () {
  48131. return this._data;
  48132. },
  48133. setData: function (data) {
  48134. this._data = data;
  48135. }
  48136. });
  48137. zrUtil.mixin(MarkerModel, modelUtil.dataFormatMixin);
  48138. module.exports = MarkerModel;
  48139. /***/ },
  48140. /* 347 */
  48141. /***/ function(module, exports, __webpack_require__) {
  48142. var SymbolDraw = __webpack_require__(104);
  48143. var zrUtil = __webpack_require__(4);
  48144. var numberUtil = __webpack_require__(7);
  48145. var List = __webpack_require__(97);
  48146. var markerHelper = __webpack_require__(348);
  48147. function updateMarkerLayout(mpData, seriesModel, api) {
  48148. var coordSys = seriesModel.coordinateSystem;
  48149. mpData.each(function (idx) {
  48150. var itemModel = mpData.getItemModel(idx);
  48151. var point;
  48152. var xPx = numberUtil.parsePercent(itemModel.get('x'), api.getWidth());
  48153. var yPx = numberUtil.parsePercent(itemModel.get('y'), api.getHeight());
  48154. if (!isNaN(xPx) && !isNaN(yPx)) {
  48155. point = [xPx, yPx];
  48156. }
  48157. // Chart like bar may have there own marker positioning logic
  48158. else if (seriesModel.getMarkerPosition) {
  48159. // Use the getMarkerPoisition
  48160. point = seriesModel.getMarkerPosition(
  48161. mpData.getValues(mpData.dimensions, idx)
  48162. );
  48163. }
  48164. else if (coordSys) {
  48165. var x = mpData.get(coordSys.dimensions[0], idx);
  48166. var y = mpData.get(coordSys.dimensions[1], idx);
  48167. point = coordSys.dataToPoint([x, y]);
  48168. }
  48169. // Use x, y if has any
  48170. if (!isNaN(xPx)) {
  48171. point[0] = xPx;
  48172. }
  48173. if (!isNaN(yPx)) {
  48174. point[1] = yPx;
  48175. }
  48176. mpData.setItemLayout(idx, point);
  48177. });
  48178. }
  48179. __webpack_require__(349).extend({
  48180. type: 'markPoint',
  48181. updateLayout: function (markPointModel, ecModel, api) {
  48182. ecModel.eachSeries(function (seriesModel) {
  48183. var mpModel = seriesModel.markPointModel;
  48184. if (mpModel) {
  48185. updateMarkerLayout(mpModel.getData(), seriesModel, api);
  48186. this.markerGroupMap[seriesModel.name].updateLayout(mpModel);
  48187. }
  48188. }, this);
  48189. },
  48190. renderSeries: function (seriesModel, mpModel, ecModel, api) {
  48191. var coordSys = seriesModel.coordinateSystem;
  48192. var seriesName = seriesModel.name;
  48193. var seriesData = seriesModel.getData();
  48194. var symbolDrawMap = this.markerGroupMap;
  48195. var symbolDraw = symbolDrawMap[seriesName];
  48196. if (!symbolDraw) {
  48197. symbolDraw = symbolDrawMap[seriesName] = new SymbolDraw();
  48198. }
  48199. var mpData = createList(coordSys, seriesModel, mpModel);
  48200. // FIXME
  48201. mpModel.setData(mpData);
  48202. updateMarkerLayout(mpModel.getData(), seriesModel, api);
  48203. mpData.each(function (idx) {
  48204. var itemModel = mpData.getItemModel(idx);
  48205. var symbolSize = itemModel.getShallow('symbolSize');
  48206. if (typeof symbolSize === 'function') {
  48207. // FIXME 这里不兼容 ECharts 2.x,2.x 貌似参数是整个数据?
  48208. symbolSize = symbolSize(
  48209. mpModel.getRawValue(idx), mpModel.getDataParams(idx)
  48210. );
  48211. }
  48212. mpData.setItemVisual(idx, {
  48213. symbolSize: symbolSize,
  48214. color: itemModel.get('itemStyle.normal.color')
  48215. || seriesData.getVisual('color'),
  48216. symbol: itemModel.getShallow('symbol')
  48217. });
  48218. });
  48219. // TODO Text are wrong
  48220. symbolDraw.updateData(mpData);
  48221. this.group.add(symbolDraw.group);
  48222. // Set host model for tooltip
  48223. // FIXME
  48224. mpData.eachItemGraphicEl(function (el) {
  48225. el.traverse(function (child) {
  48226. child.dataModel = mpModel;
  48227. });
  48228. });
  48229. symbolDraw.__keep = true;
  48230. symbolDraw.group.silent = mpModel.get('silent') || seriesModel.get('silent');
  48231. }
  48232. });
  48233. /**
  48234. * @inner
  48235. * @param {module:echarts/coord/*} [coordSys]
  48236. * @param {module:echarts/model/Series} seriesModel
  48237. * @param {module:echarts/model/Model} mpModel
  48238. */
  48239. function createList(coordSys, seriesModel, mpModel) {
  48240. var coordDimsInfos;
  48241. if (coordSys) {
  48242. coordDimsInfos = zrUtil.map(coordSys && coordSys.dimensions, function (coordDim) {
  48243. var info = seriesModel.getData().getDimensionInfo(
  48244. seriesModel.coordDimToDataDim(coordDim)[0]
  48245. ) || {}; // In map series data don't have lng and lat dimension. Fallback to same with coordSys
  48246. info.name = coordDim;
  48247. return info;
  48248. });
  48249. }
  48250. else {
  48251. coordDimsInfos =[{
  48252. name: 'value',
  48253. type: 'float'
  48254. }];
  48255. }
  48256. var mpData = new List(coordDimsInfos, mpModel);
  48257. var dataOpt = zrUtil.map(mpModel.get('data'), zrUtil.curry(
  48258. markerHelper.dataTransform, seriesModel
  48259. ));
  48260. if (coordSys) {
  48261. dataOpt = zrUtil.filter(
  48262. dataOpt, zrUtil.curry(markerHelper.dataFilter, coordSys)
  48263. );
  48264. }
  48265. mpData.initData(dataOpt, null,
  48266. coordSys ? markerHelper.dimValueGetter : function (item) {
  48267. return item.value;
  48268. }
  48269. );
  48270. return mpData;
  48271. }
  48272. /***/ },
  48273. /* 348 */
  48274. /***/ function(module, exports, __webpack_require__) {
  48275. var zrUtil = __webpack_require__(4);
  48276. var numberUtil = __webpack_require__(7);
  48277. var indexOf = zrUtil.indexOf;
  48278. function hasXOrY(item) {
  48279. return !(isNaN(parseFloat(item.x)) && isNaN(parseFloat(item.y)));
  48280. }
  48281. function hasXAndY(item) {
  48282. return !isNaN(parseFloat(item.x)) && !isNaN(parseFloat(item.y));
  48283. }
  48284. function getPrecision(data, valueAxisDim, dataIndex) {
  48285. var precision = -1;
  48286. do {
  48287. precision = Math.max(
  48288. numberUtil.getPrecision(data.get(
  48289. valueAxisDim, dataIndex
  48290. )),
  48291. precision
  48292. );
  48293. data = data.stackedOn;
  48294. } while (data);
  48295. return precision;
  48296. }
  48297. function markerTypeCalculatorWithExtent(
  48298. mlType, data, otherDataDim, targetDataDim, otherCoordIndex, targetCoordIndex
  48299. ) {
  48300. var coordArr = [];
  48301. var value = numCalculate(data, targetDataDim, mlType);
  48302. var dataIndex = data.indexOfNearest(targetDataDim, value, true);
  48303. coordArr[otherCoordIndex] = data.get(otherDataDim, dataIndex, true);
  48304. coordArr[targetCoordIndex] = data.get(targetDataDim, dataIndex, true);
  48305. var precision = getPrecision(data, targetDataDim, dataIndex);
  48306. if (precision >= 0) {
  48307. coordArr[targetCoordIndex] = +coordArr[targetCoordIndex].toFixed(precision);
  48308. }
  48309. return coordArr;
  48310. }
  48311. var curry = zrUtil.curry;
  48312. // TODO Specified percent
  48313. var markerTypeCalculator = {
  48314. /**
  48315. * @method
  48316. * @param {module:echarts/data/List} data
  48317. * @param {string} baseAxisDim
  48318. * @param {string} valueAxisDim
  48319. */
  48320. min: curry(markerTypeCalculatorWithExtent, 'min'),
  48321. /**
  48322. * @method
  48323. * @param {module:echarts/data/List} data
  48324. * @param {string} baseAxisDim
  48325. * @param {string} valueAxisDim
  48326. */
  48327. max: curry(markerTypeCalculatorWithExtent, 'max'),
  48328. /**
  48329. * @method
  48330. * @param {module:echarts/data/List} data
  48331. * @param {string} baseAxisDim
  48332. * @param {string} valueAxisDim
  48333. */
  48334. average: curry(markerTypeCalculatorWithExtent, 'average')
  48335. };
  48336. /**
  48337. * Transform markPoint data item to format used in List by do the following
  48338. * 1. Calculate statistic like `max`, `min`, `average`
  48339. * 2. Convert `item.xAxis`, `item.yAxis` to `item.coord` array
  48340. * @param {module:echarts/model/Series} seriesModel
  48341. * @param {module:echarts/coord/*} [coordSys]
  48342. * @param {Object} item
  48343. * @return {Object}
  48344. */
  48345. var dataTransform = function (seriesModel, item) {
  48346. var data = seriesModel.getData();
  48347. var coordSys = seriesModel.coordinateSystem;
  48348. // 1. If not specify the position with pixel directly
  48349. // 2. If `coord` is not a data array. Which uses `xAxis`,
  48350. // `yAxis` to specify the coord on each dimension
  48351. // parseFloat first because item.x and item.y can be percent string like '20%'
  48352. if (item && !hasXAndY(item) && !zrUtil.isArray(item.coord) && coordSys) {
  48353. var dims = coordSys.dimensions;
  48354. var axisInfo = getAxisInfo(item, data, coordSys, seriesModel);
  48355. // Clone the option
  48356. // Transform the properties xAxis, yAxis, radiusAxis, angleAxis, geoCoord to value
  48357. item = zrUtil.clone(item);
  48358. if (item.type
  48359. && markerTypeCalculator[item.type]
  48360. && axisInfo.baseAxis && axisInfo.valueAxis
  48361. ) {
  48362. var otherCoordIndex = indexOf(dims, axisInfo.baseAxis.dim);
  48363. var targetCoordIndex = indexOf(dims, axisInfo.valueAxis.dim);
  48364. item.coord = markerTypeCalculator[item.type](
  48365. data, axisInfo.baseDataDim, axisInfo.valueDataDim,
  48366. otherCoordIndex, targetCoordIndex
  48367. );
  48368. // Force to use the value of calculated value.
  48369. item.value = item.coord[targetCoordIndex];
  48370. }
  48371. else {
  48372. // FIXME Only has one of xAxis and yAxis.
  48373. var coord = [
  48374. item.xAxis != null ? item.xAxis : item.radiusAxis,
  48375. item.yAxis != null ? item.yAxis : item.angleAxis
  48376. ];
  48377. // Each coord support max, min, average
  48378. for (var i = 0; i < 2; i++) {
  48379. if (markerTypeCalculator[coord[i]]) {
  48380. var dataDim = seriesModel.coordDimToDataDim(dims[i])[0];
  48381. coord[i] = numCalculate(data, dataDim, coord[i]);
  48382. }
  48383. }
  48384. item.coord = coord;
  48385. }
  48386. }
  48387. return item;
  48388. };
  48389. var getAxisInfo = function (item, data, coordSys, seriesModel) {
  48390. var ret = {};
  48391. if (item.valueIndex != null || item.valueDim != null) {
  48392. ret.valueDataDim = item.valueIndex != null
  48393. ? data.getDimension(item.valueIndex) : item.valueDim;
  48394. ret.valueAxis = coordSys.getAxis(seriesModel.dataDimToCoordDim(ret.valueDataDim));
  48395. ret.baseAxis = coordSys.getOtherAxis(ret.valueAxis);
  48396. ret.baseDataDim = seriesModel.coordDimToDataDim(ret.baseAxis.dim)[0];
  48397. }
  48398. else {
  48399. ret.baseAxis = seriesModel.getBaseAxis();
  48400. ret.valueAxis = coordSys.getOtherAxis(ret.baseAxis);
  48401. ret.baseDataDim = seriesModel.coordDimToDataDim(ret.baseAxis.dim)[0];
  48402. ret.valueDataDim = seriesModel.coordDimToDataDim(ret.valueAxis.dim)[0];
  48403. }
  48404. return ret;
  48405. };
  48406. /**
  48407. * Filter data which is out of coordinateSystem range
  48408. * [dataFilter description]
  48409. * @param {module:echarts/coord/*} [coordSys]
  48410. * @param {Object} item
  48411. * @return {boolean}
  48412. */
  48413. var dataFilter = function (coordSys, item) {
  48414. // Alwalys return true if there is no coordSys
  48415. return (coordSys && coordSys.containData && item.coord && !hasXOrY(item))
  48416. ? coordSys.containData(item.coord) : true;
  48417. };
  48418. var dimValueGetter = function (item, dimName, dataIndex, dimIndex) {
  48419. // x, y, radius, angle
  48420. if (dimIndex < 2) {
  48421. return item.coord && item.coord[dimIndex];
  48422. }
  48423. return item.value;
  48424. };
  48425. var numCalculate = function (data, valueDataDim, type) {
  48426. if (type === 'average') {
  48427. var sum = 0;
  48428. var count = 0;
  48429. data.each(valueDataDim, function (val, idx) {
  48430. if (!isNaN(val)) {
  48431. sum += val;
  48432. count++;
  48433. }
  48434. }, true);
  48435. return sum / count;
  48436. }
  48437. else {
  48438. return data.getDataExtent(valueDataDim, true)[type === 'max' ? 1 : 0];
  48439. }
  48440. };
  48441. module.exports = {
  48442. dataTransform: dataTransform,
  48443. dataFilter: dataFilter,
  48444. dimValueGetter: dimValueGetter,
  48445. getAxisInfo: getAxisInfo,
  48446. numCalculate: numCalculate
  48447. };
  48448. /***/ },
  48449. /* 349 */
  48450. /***/ function(module, exports, __webpack_require__) {
  48451. module.exports = __webpack_require__(1).extendComponentView({
  48452. type: 'marker',
  48453. init: function () {
  48454. /**
  48455. * Markline grouped by series
  48456. * @private
  48457. * @type {Object}
  48458. */
  48459. this.markerGroupMap = {};
  48460. },
  48461. render: function (markerModel, ecModel, api) {
  48462. var markerGroupMap = this.markerGroupMap;
  48463. for (var name in markerGroupMap) {
  48464. markerGroupMap[name].__keep = false;
  48465. }
  48466. var markerModelKey = this.type + 'Model';
  48467. ecModel.eachSeries(function (seriesModel) {
  48468. var markerModel = seriesModel[markerModelKey];
  48469. markerModel && this.renderSeries(seriesModel, markerModel, ecModel, api);
  48470. }, this);
  48471. for (var name in markerGroupMap) {
  48472. if (!markerGroupMap[name].__keep) {
  48473. this.group.remove(markerGroupMap[name].group);
  48474. }
  48475. }
  48476. },
  48477. renderSeries: function () {}
  48478. });
  48479. /***/ },
  48480. /* 350 */
  48481. /***/ function(module, exports, __webpack_require__) {
  48482. __webpack_require__(351);
  48483. __webpack_require__(352);
  48484. __webpack_require__(1).registerPreprocessor(function (opt) {
  48485. // Make sure markLine component is enabled
  48486. opt.markLine = opt.markLine || {};
  48487. });
  48488. /***/ },
  48489. /* 351 */
  48490. /***/ function(module, exports, __webpack_require__) {
  48491. module.exports = __webpack_require__(346).extend({
  48492. type: 'markLine',
  48493. defaultOption: {
  48494. zlevel: 0,
  48495. z: 5,
  48496. symbol: ['circle', 'arrow'],
  48497. symbolSize: [8, 16],
  48498. //symbolRotate: 0,
  48499. precision: 2,
  48500. tooltip: {
  48501. trigger: 'item'
  48502. },
  48503. label: {
  48504. normal: {
  48505. show: true,
  48506. position: 'end'
  48507. },
  48508. emphasis: {
  48509. show: true
  48510. }
  48511. },
  48512. lineStyle: {
  48513. normal: {
  48514. type: 'dashed'
  48515. },
  48516. emphasis: {
  48517. width: 3
  48518. }
  48519. },
  48520. animationEasing: 'linear'
  48521. }
  48522. });
  48523. /***/ },
  48524. /* 352 */
  48525. /***/ function(module, exports, __webpack_require__) {
  48526. var zrUtil = __webpack_require__(4);
  48527. var List = __webpack_require__(97);
  48528. var numberUtil = __webpack_require__(7);
  48529. var markerHelper = __webpack_require__(348);
  48530. var LineDraw = __webpack_require__(199);
  48531. var markLineTransform = function (seriesModel, coordSys, mlModel, item) {
  48532. var data = seriesModel.getData();
  48533. // Special type markLine like 'min', 'max', 'average'
  48534. var mlType = item.type;
  48535. if (!zrUtil.isArray(item)
  48536. && (
  48537. mlType === 'min' || mlType === 'max' || mlType === 'average'
  48538. // In case
  48539. // data: [{
  48540. // yAxis: 10
  48541. // }]
  48542. || (item.xAxis != null || item.yAxis != null)
  48543. )
  48544. ) {
  48545. var valueAxis;
  48546. var valueDataDim;
  48547. var value;
  48548. if (item.yAxis != null || item.xAxis != null) {
  48549. valueDataDim = item.yAxis != null ? 'y' : 'x';
  48550. valueAxis = coordSys.getAxis(valueDataDim);
  48551. value = zrUtil.retrieve(item.yAxis, item.xAxis);
  48552. }
  48553. else {
  48554. var axisInfo = markerHelper.getAxisInfo(item, data, coordSys, seriesModel);
  48555. valueDataDim = axisInfo.valueDataDim;
  48556. valueAxis = axisInfo.valueAxis;
  48557. value = markerHelper.numCalculate(data, valueDataDim, mlType);
  48558. }
  48559. var valueIndex = valueDataDim === 'x' ? 0 : 1;
  48560. var baseIndex = 1 - valueIndex;
  48561. var mlFrom = zrUtil.clone(item);
  48562. var mlTo = {};
  48563. mlFrom.type = null;
  48564. mlFrom.coord = [];
  48565. mlTo.coord = [];
  48566. mlFrom.coord[baseIndex] = -Infinity;
  48567. mlTo.coord[baseIndex] = Infinity;
  48568. var precision = mlModel.get('precision');
  48569. if (precision >= 0) {
  48570. value = +value.toFixed(precision);
  48571. }
  48572. mlFrom.coord[valueIndex] = mlTo.coord[valueIndex] = value;
  48573. item = [mlFrom, mlTo, { // Extra option for tooltip and label
  48574. type: mlType,
  48575. valueIndex: item.valueIndex,
  48576. // Force to use the value of calculated value.
  48577. value: value
  48578. }];
  48579. }
  48580. item = [
  48581. markerHelper.dataTransform(seriesModel, item[0]),
  48582. markerHelper.dataTransform(seriesModel, item[1]),
  48583. zrUtil.extend({}, item[2])
  48584. ];
  48585. // Avoid line data type is extended by from(to) data type
  48586. item[2].type = item[2].type || '';
  48587. // Merge from option and to option into line option
  48588. zrUtil.merge(item[2], item[0]);
  48589. zrUtil.merge(item[2], item[1]);
  48590. return item;
  48591. };
  48592. function isInifinity(val) {
  48593. return !isNaN(val) && !isFinite(val);
  48594. }
  48595. // If a markLine has one dim
  48596. function ifMarkLineHasOnlyDim(dimIndex, fromCoord, toCoord, coordSys) {
  48597. var otherDimIndex = 1 - dimIndex;
  48598. var dimName = coordSys.dimensions[dimIndex];
  48599. return isInifinity(fromCoord[otherDimIndex]) && isInifinity(toCoord[otherDimIndex])
  48600. && fromCoord[dimIndex] === toCoord[dimIndex] && coordSys.getAxis(dimName).containData(fromCoord[dimIndex]);
  48601. }
  48602. function markLineFilter(coordSys, item) {
  48603. if (coordSys.type === 'cartesian2d') {
  48604. var fromCoord = item[0].coord;
  48605. var toCoord = item[1].coord;
  48606. // In case
  48607. // {
  48608. // markLine: {
  48609. // data: [{ yAxis: 2 }]
  48610. // }
  48611. // }
  48612. if (
  48613. fromCoord && toCoord &&
  48614. (ifMarkLineHasOnlyDim(1, fromCoord, toCoord, coordSys)
  48615. || ifMarkLineHasOnlyDim(0, fromCoord, toCoord, coordSys))
  48616. ) {
  48617. return true;
  48618. }
  48619. }
  48620. return markerHelper.dataFilter(coordSys, item[0])
  48621. && markerHelper.dataFilter(coordSys, item[1]);
  48622. }
  48623. function updateSingleMarkerEndLayout(
  48624. data, idx, isFrom, seriesModel, api
  48625. ) {
  48626. var coordSys = seriesModel.coordinateSystem;
  48627. var itemModel = data.getItemModel(idx);
  48628. var point;
  48629. var xPx = numberUtil.parsePercent(itemModel.get('x'), api.getWidth());
  48630. var yPx = numberUtil.parsePercent(itemModel.get('y'), api.getHeight());
  48631. if (!isNaN(xPx) && !isNaN(yPx)) {
  48632. point = [xPx, yPx];
  48633. }
  48634. else {
  48635. // Chart like bar may have there own marker positioning logic
  48636. if (seriesModel.getMarkerPosition) {
  48637. // Use the getMarkerPoisition
  48638. point = seriesModel.getMarkerPosition(
  48639. data.getValues(data.dimensions, idx)
  48640. );
  48641. }
  48642. else {
  48643. var dims = coordSys.dimensions;
  48644. var x = data.get(dims[0], idx);
  48645. var y = data.get(dims[1], idx);
  48646. point = coordSys.dataToPoint([x, y]);
  48647. }
  48648. // Expand line to the edge of grid if value on one axis is Inifnity
  48649. // In case
  48650. // markLine: {
  48651. // data: [{
  48652. // yAxis: 2
  48653. // // or
  48654. // type: 'average'
  48655. // }]
  48656. // }
  48657. if (coordSys.type === 'cartesian2d') {
  48658. var xAxis = coordSys.getAxis('x');
  48659. var yAxis = coordSys.getAxis('y');
  48660. var dims = coordSys.dimensions;
  48661. if (isInifinity(data.get(dims[0], idx))) {
  48662. point[0] = xAxis.toGlobalCoord(xAxis.getExtent()[isFrom ? 0 : 1]);
  48663. }
  48664. else if (isInifinity(data.get(dims[1], idx))) {
  48665. point[1] = yAxis.toGlobalCoord(yAxis.getExtent()[isFrom ? 0 : 1]);
  48666. }
  48667. }
  48668. // Use x, y if has any
  48669. if (!isNaN(xPx)) {
  48670. point[0] = xPx;
  48671. }
  48672. if (!isNaN(yPx)) {
  48673. point[1] = yPx;
  48674. }
  48675. }
  48676. data.setItemLayout(idx, point);
  48677. }
  48678. __webpack_require__(349).extend({
  48679. type: 'markLine',
  48680. updateLayout: function (markLineModel, ecModel, api) {
  48681. ecModel.eachSeries(function (seriesModel) {
  48682. var mlModel = seriesModel.markLineModel;
  48683. if (mlModel) {
  48684. var mlData = mlModel.getData();
  48685. var fromData = mlModel.__from;
  48686. var toData = mlModel.__to;
  48687. // Update visual and layout of from symbol and to symbol
  48688. fromData.each(function (idx) {
  48689. updateSingleMarkerEndLayout(fromData, idx, true, seriesModel, api);
  48690. updateSingleMarkerEndLayout(toData, idx, false, seriesModel, api);
  48691. });
  48692. // Update layout of line
  48693. mlData.each(function (idx) {
  48694. mlData.setItemLayout(idx, [
  48695. fromData.getItemLayout(idx),
  48696. toData.getItemLayout(idx)
  48697. ]);
  48698. });
  48699. this.markerGroupMap[seriesModel.name].updateLayout();
  48700. }
  48701. }, this);
  48702. },
  48703. renderSeries: function (seriesModel, mlModel, ecModel, api) {
  48704. var coordSys = seriesModel.coordinateSystem;
  48705. var seriesName = seriesModel.name;
  48706. var seriesData = seriesModel.getData();
  48707. var lineDrawMap = this.markerGroupMap;
  48708. var lineDraw = lineDrawMap[seriesName];
  48709. if (!lineDraw) {
  48710. lineDraw = lineDrawMap[seriesName] = new LineDraw();
  48711. }
  48712. this.group.add(lineDraw.group);
  48713. var mlData = createList(coordSys, seriesModel, mlModel);
  48714. var fromData = mlData.from;
  48715. var toData = mlData.to;
  48716. var lineData = mlData.line;
  48717. mlModel.__from = fromData;
  48718. mlModel.__to = toData;
  48719. // Line data for tooltip and formatter
  48720. mlModel.setData(lineData);
  48721. var symbolType = mlModel.get('symbol');
  48722. var symbolSize = mlModel.get('symbolSize');
  48723. if (!zrUtil.isArray(symbolType)) {
  48724. symbolType = [symbolType, symbolType];
  48725. }
  48726. if (typeof symbolSize === 'number') {
  48727. symbolSize = [symbolSize, symbolSize];
  48728. }
  48729. // Update visual and layout of from symbol and to symbol
  48730. mlData.from.each(function (idx) {
  48731. updateDataVisualAndLayout(fromData, idx, true);
  48732. updateDataVisualAndLayout(toData, idx, false);
  48733. });
  48734. // Update visual and layout of line
  48735. lineData.each(function (idx) {
  48736. var lineColor = lineData.getItemModel(idx).get('lineStyle.normal.color');
  48737. lineData.setItemVisual(idx, {
  48738. color: lineColor || fromData.getItemVisual(idx, 'color')
  48739. });
  48740. lineData.setItemLayout(idx, [
  48741. fromData.getItemLayout(idx),
  48742. toData.getItemLayout(idx)
  48743. ]);
  48744. lineData.setItemVisual(idx, {
  48745. 'fromSymbolSize': fromData.getItemVisual(idx, 'symbolSize'),
  48746. 'fromSymbol': fromData.getItemVisual(idx, 'symbol'),
  48747. 'toSymbolSize': toData.getItemVisual(idx, 'symbolSize'),
  48748. 'toSymbol': toData.getItemVisual(idx, 'symbol')
  48749. });
  48750. });
  48751. lineDraw.updateData(lineData);
  48752. // Set host model for tooltip
  48753. // FIXME
  48754. mlData.line.eachItemGraphicEl(function (el, idx) {
  48755. el.traverse(function (child) {
  48756. child.dataModel = mlModel;
  48757. });
  48758. });
  48759. function updateDataVisualAndLayout(data, idx, isFrom) {
  48760. var itemModel = data.getItemModel(idx);
  48761. updateSingleMarkerEndLayout(
  48762. data, idx, isFrom, seriesModel, api
  48763. );
  48764. data.setItemVisual(idx, {
  48765. symbolSize: itemModel.get('symbolSize') || symbolSize[isFrom ? 0 : 1],
  48766. symbol: itemModel.get('symbol', true) || symbolType[isFrom ? 0 : 1],
  48767. color: itemModel.get('itemStyle.normal.color') || seriesData.getVisual('color')
  48768. });
  48769. }
  48770. lineDraw.__keep = true;
  48771. lineDraw.group.silent = mlModel.get('silent') || seriesModel.get('silent');
  48772. }
  48773. });
  48774. /**
  48775. * @inner
  48776. * @param {module:echarts/coord/*} coordSys
  48777. * @param {module:echarts/model/Series} seriesModel
  48778. * @param {module:echarts/model/Model} mpModel
  48779. */
  48780. function createList(coordSys, seriesModel, mlModel) {
  48781. var coordDimsInfos;
  48782. if (coordSys) {
  48783. coordDimsInfos = zrUtil.map(coordSys && coordSys.dimensions, function (coordDim) {
  48784. var info = seriesModel.getData().getDimensionInfo(
  48785. seriesModel.coordDimToDataDim(coordDim)[0]
  48786. ) || {}; // In map series data don't have lng and lat dimension. Fallback to same with coordSys
  48787. info.name = coordDim;
  48788. return info;
  48789. });
  48790. }
  48791. else {
  48792. coordDimsInfos =[{
  48793. name: 'value',
  48794. type: 'float'
  48795. }];
  48796. }
  48797. var fromData = new List(coordDimsInfos, mlModel);
  48798. var toData = new List(coordDimsInfos, mlModel);
  48799. // No dimensions
  48800. var lineData = new List([], mlModel);
  48801. var optData = zrUtil.map(mlModel.get('data'), zrUtil.curry(
  48802. markLineTransform, seriesModel, coordSys, mlModel
  48803. ));
  48804. if (coordSys) {
  48805. optData = zrUtil.filter(
  48806. optData, zrUtil.curry(markLineFilter, coordSys)
  48807. );
  48808. }
  48809. var dimValueGetter = coordSys ? markerHelper.dimValueGetter : function (item) {
  48810. return item.value;
  48811. };
  48812. fromData.initData(
  48813. zrUtil.map(optData, function (item) { return item[0]; }),
  48814. null, dimValueGetter
  48815. );
  48816. toData.initData(
  48817. zrUtil.map(optData, function (item) { return item[1]; }),
  48818. null, dimValueGetter
  48819. );
  48820. lineData.initData(
  48821. zrUtil.map(optData, function (item) { return item[2]; })
  48822. );
  48823. lineData.hasItemOption = true;
  48824. return {
  48825. from: fromData,
  48826. to: toData,
  48827. line: lineData
  48828. };
  48829. }
  48830. /***/ },
  48831. /* 353 */
  48832. /***/ function(module, exports, __webpack_require__) {
  48833. __webpack_require__(354);
  48834. __webpack_require__(355);
  48835. __webpack_require__(1).registerPreprocessor(function (opt) {
  48836. // Make sure markArea component is enabled
  48837. opt.markArea = opt.markArea || {};
  48838. });
  48839. /***/ },
  48840. /* 354 */
  48841. /***/ function(module, exports, __webpack_require__) {
  48842. module.exports = __webpack_require__(346).extend({
  48843. type: 'markArea',
  48844. defaultOption: {
  48845. zlevel: 0,
  48846. // PENDING
  48847. z: 1,
  48848. tooltip: {
  48849. trigger: 'item'
  48850. },
  48851. // markArea should fixed on the coordinate system
  48852. animation: false,
  48853. label: {
  48854. normal: {
  48855. show: true,
  48856. position: 'top'
  48857. },
  48858. emphasis: {
  48859. show: true,
  48860. position: 'top'
  48861. }
  48862. },
  48863. itemStyle: {
  48864. normal: {
  48865. // color and borderColor default to use color from series
  48866. // color: 'auto'
  48867. // borderColor: 'auto'
  48868. borderWidth: 0
  48869. }
  48870. }
  48871. }
  48872. });
  48873. /***/ },
  48874. /* 355 */
  48875. /***/ function(module, exports, __webpack_require__) {
  48876. // TODO Better on polar
  48877. var zrUtil = __webpack_require__(4);
  48878. var List = __webpack_require__(97);
  48879. var numberUtil = __webpack_require__(7);
  48880. var graphic = __webpack_require__(43);
  48881. var colorUtil = __webpack_require__(39);
  48882. var markerHelper = __webpack_require__(348);
  48883. var markAreaTransform = function (seriesModel, coordSys, maModel, item) {
  48884. var lt = markerHelper.dataTransform(seriesModel, item[0]);
  48885. var rb = markerHelper.dataTransform(seriesModel, item[1]);
  48886. var retrieve = zrUtil.retrieve;
  48887. // FIXME make sure lt is less than rb
  48888. var ltCoord = lt.coord;
  48889. var rbCoord = rb.coord;
  48890. ltCoord[0] = retrieve(ltCoord[0], -Infinity);
  48891. ltCoord[1] = retrieve(ltCoord[1], -Infinity);
  48892. rbCoord[0] = retrieve(rbCoord[0], Infinity);
  48893. rbCoord[1] = retrieve(rbCoord[1], Infinity);
  48894. // Merge option into one
  48895. var result = zrUtil.mergeAll([{}, lt, rb]);
  48896. result.coord = [
  48897. lt.coord, rb.coord
  48898. ];
  48899. result.x0 = lt.x;
  48900. result.y0 = lt.y;
  48901. result.x1 = rb.x;
  48902. result.y1 = rb.y;
  48903. return result;
  48904. };
  48905. function isInifinity(val) {
  48906. return !isNaN(val) && !isFinite(val);
  48907. }
  48908. // If a markArea has one dim
  48909. function ifMarkLineHasOnlyDim(dimIndex, fromCoord, toCoord, coordSys) {
  48910. var otherDimIndex = 1 - dimIndex;
  48911. return isInifinity(fromCoord[otherDimIndex]) && isInifinity(toCoord[otherDimIndex]);
  48912. }
  48913. function markAreaFilter(coordSys, item) {
  48914. var fromCoord = item.coord[0];
  48915. var toCoord = item.coord[1];
  48916. if (coordSys.type === 'cartesian2d') {
  48917. // In case
  48918. // {
  48919. // markArea: {
  48920. // data: [{ yAxis: 2 }]
  48921. // }
  48922. // }
  48923. if (
  48924. fromCoord && toCoord &&
  48925. (ifMarkLineHasOnlyDim(1, fromCoord, toCoord, coordSys)
  48926. || ifMarkLineHasOnlyDim(0, fromCoord, toCoord, coordSys))
  48927. ) {
  48928. return true;
  48929. }
  48930. }
  48931. return markerHelper.dataFilter(coordSys, {
  48932. coord: fromCoord,
  48933. x: item.x0,
  48934. y: item.y0
  48935. })
  48936. || markerHelper.dataFilter(coordSys, {
  48937. coord: toCoord,
  48938. x: item.x1,
  48939. y: item.y1
  48940. });
  48941. }
  48942. // dims can be ['x0', 'y0'], ['x1', 'y1'], ['x0', 'y1'], ['x1', 'y0']
  48943. function getSingleMarkerEndPoint(data, idx, dims, seriesModel, api) {
  48944. var coordSys = seriesModel.coordinateSystem;
  48945. var itemModel = data.getItemModel(idx);
  48946. var point;
  48947. var xPx = numberUtil.parsePercent(itemModel.get(dims[0]), api.getWidth());
  48948. var yPx = numberUtil.parsePercent(itemModel.get(dims[1]), api.getHeight());
  48949. if (!isNaN(xPx) && !isNaN(yPx)) {
  48950. point = [xPx, yPx];
  48951. }
  48952. else {
  48953. // Chart like bar may have there own marker positioning logic
  48954. if (seriesModel.getMarkerPosition) {
  48955. // Use the getMarkerPoisition
  48956. point = seriesModel.getMarkerPosition(
  48957. data.getValues(dims, idx)
  48958. );
  48959. }
  48960. else {
  48961. var x = data.get(dims[0], idx);
  48962. var y = data.get(dims[1], idx);
  48963. point = coordSys.dataToPoint([x, y], true);
  48964. }
  48965. if (coordSys.type === 'cartesian2d') {
  48966. var xAxis = coordSys.getAxis('x');
  48967. var yAxis = coordSys.getAxis('y');
  48968. var x = data.get(dims[0], idx);
  48969. var y = data.get(dims[1], idx);
  48970. if (isInifinity(x)) {
  48971. point[0] = xAxis.toGlobalCoord(xAxis.getExtent()[dims[0] === 'x0' ? 0 : 1]);
  48972. }
  48973. else if (isInifinity(y)) {
  48974. point[1] = yAxis.toGlobalCoord(yAxis.getExtent()[dims[1] === 'y0' ? 0 : 1]);
  48975. }
  48976. }
  48977. // Use x, y if has any
  48978. if (!isNaN(xPx)) {
  48979. point[0] = xPx;
  48980. }
  48981. if (!isNaN(yPx)) {
  48982. point[1] = yPx;
  48983. }
  48984. }
  48985. return point;
  48986. }
  48987. var dimPermutations = [['x0', 'y0'], ['x1', 'y0'], ['x1', 'y1'], ['x0', 'y1']];
  48988. __webpack_require__(349).extend({
  48989. type: 'markArea',
  48990. updateLayout: function (markAreaModel, ecModel, api) {
  48991. ecModel.eachSeries(function (seriesModel) {
  48992. var maModel = seriesModel.markAreaModel;
  48993. if (maModel) {
  48994. var areaData = maModel.getData();
  48995. areaData.each(function (idx) {
  48996. var points = zrUtil.map(dimPermutations, function (dim) {
  48997. return getSingleMarkerEndPoint(areaData, idx, dim, seriesModel, api);
  48998. });
  48999. // Layout
  49000. areaData.setItemLayout(idx, points);
  49001. var el = areaData.getItemGraphicEl(idx);
  49002. el.setShape('points', points);
  49003. });
  49004. }
  49005. }, this);
  49006. },
  49007. renderSeries: function (seriesModel, maModel, ecModel, api) {
  49008. var coordSys = seriesModel.coordinateSystem;
  49009. var seriesName = seriesModel.name;
  49010. var seriesData = seriesModel.getData();
  49011. var areaGroupMap = this.markerGroupMap;
  49012. var polygonGroup = areaGroupMap[seriesName];
  49013. if (!polygonGroup) {
  49014. polygonGroup = areaGroupMap[seriesName] = {
  49015. group: new graphic.Group()
  49016. };
  49017. }
  49018. this.group.add(polygonGroup.group);
  49019. polygonGroup.__keep = true;
  49020. var areaData = createList(coordSys, seriesModel, maModel);
  49021. // Line data for tooltip and formatter
  49022. maModel.setData(areaData);
  49023. // Update visual and layout of line
  49024. areaData.each(function (idx) {
  49025. // Layout
  49026. areaData.setItemLayout(idx, zrUtil.map(dimPermutations, function (dim) {
  49027. return getSingleMarkerEndPoint(areaData, idx, dim, seriesModel, api);
  49028. }));
  49029. // Visual
  49030. areaData.setItemVisual(idx, {
  49031. color: seriesData.getVisual('color')
  49032. });
  49033. });
  49034. areaData.diff(polygonGroup.__data)
  49035. .add(function (idx) {
  49036. var polygon = new graphic.Polygon({
  49037. shape: {
  49038. points: areaData.getItemLayout(idx)
  49039. }
  49040. });
  49041. areaData.setItemGraphicEl(idx, polygon);
  49042. polygonGroup.group.add(polygon);
  49043. })
  49044. .update(function (newIdx, oldIdx) {
  49045. var polygon = polygonGroup.__data.getItemGraphicEl(oldIdx);
  49046. graphic.updateProps(polygon, {
  49047. shape: {
  49048. points: areaData.getItemLayout(newIdx)
  49049. }
  49050. }, maModel, newIdx);
  49051. polygonGroup.group.add(polygon);
  49052. areaData.setItemGraphicEl(newIdx, polygon);
  49053. })
  49054. .remove(function (idx) {
  49055. var polygon = polygonGroup.__data.getItemGraphicEl(idx);
  49056. polygonGroup.group.remove(polygon);
  49057. })
  49058. .execute();
  49059. areaData.eachItemGraphicEl(function (polygon, idx) {
  49060. var itemModel = areaData.getItemModel(idx);
  49061. var labelModel = itemModel.getModel('label.normal');
  49062. var labelHoverModel = itemModel.getModel('label.emphasis');
  49063. var color = areaData.getItemVisual(idx, 'color');
  49064. polygon.useStyle(
  49065. zrUtil.defaults(
  49066. itemModel.getModel('itemStyle.normal').getItemStyle(),
  49067. {
  49068. fill: colorUtil.modifyAlpha(color, 0.4),
  49069. stroke: color
  49070. }
  49071. )
  49072. );
  49073. polygon.hoverStyle = itemModel.getModel('itemStyle.normal').getItemStyle();
  49074. var defaultValue = areaData.getName(idx) || '';
  49075. var textColor = color || polygon.style.fill;
  49076. graphic.setText(polygon.style, labelModel, textColor);
  49077. polygon.style.text = zrUtil.retrieve(
  49078. maModel.getFormattedLabel(idx, 'normal'),
  49079. defaultValue
  49080. );
  49081. graphic.setText(polygon.hoverStyle, labelHoverModel, textColor);
  49082. polygon.hoverStyle.text = zrUtil.retrieve(
  49083. maModel.getFormattedLabel(idx, 'emphasis'),
  49084. defaultValue
  49085. );
  49086. graphic.setHoverStyle(polygon, {});
  49087. polygon.dataModel = maModel;
  49088. });
  49089. polygonGroup.__data = areaData;
  49090. polygonGroup.group.silent = maModel.get('silent') || seriesModel.get('silent');
  49091. }
  49092. });
  49093. /**
  49094. * @inner
  49095. * @param {module:echarts/coord/*} coordSys
  49096. * @param {module:echarts/model/Series} seriesModel
  49097. * @param {module:echarts/model/Model} mpModel
  49098. */
  49099. function createList(coordSys, seriesModel, maModel) {
  49100. var coordDimsInfos;
  49101. var areaData;
  49102. var dims = ['x0', 'y0', 'x1', 'y1'];
  49103. if (coordSys) {
  49104. coordDimsInfos = zrUtil.map(coordSys && coordSys.dimensions, function (coordDim) {
  49105. var info = seriesModel.getData().getDimensionInfo(
  49106. seriesModel.coordDimToDataDim(coordDim)[0]
  49107. ) || {}; // In map series data don't have lng and lat dimension. Fallback to same with coordSys
  49108. info.name = coordDim;
  49109. return info;
  49110. });
  49111. areaData = new List(zrUtil.map(dims, function (dim, idx) {
  49112. return {
  49113. name: dim,
  49114. type: coordDimsInfos[idx % 2].type
  49115. };
  49116. }), maModel);
  49117. }
  49118. else {
  49119. coordDimsInfos =[{
  49120. name: 'value',
  49121. type: 'float'
  49122. }];
  49123. areaData = new List(coordDimsInfos, maModel);
  49124. }
  49125. var optData = zrUtil.map(maModel.get('data'), zrUtil.curry(
  49126. markAreaTransform, seriesModel, coordSys, maModel
  49127. ));
  49128. if (coordSys) {
  49129. optData = zrUtil.filter(
  49130. optData, zrUtil.curry(markAreaFilter, coordSys)
  49131. );
  49132. }
  49133. var dimValueGetter = coordSys ? function (item, dimName, dataIndex, dimIndex) {
  49134. return item.coord[Math.floor(dimIndex / 2)][dimIndex % 2];
  49135. } : function (item) {
  49136. return item.value;
  49137. };
  49138. areaData.initData(optData, null, dimValueGetter);
  49139. areaData.hasItemOption = true;
  49140. return areaData;
  49141. }
  49142. /***/ },
  49143. /* 356 */
  49144. /***/ function(module, exports, __webpack_require__) {
  49145. /**
  49146. * DataZoom component entry
  49147. */
  49148. var echarts = __webpack_require__(1);
  49149. echarts.registerPreprocessor(__webpack_require__(357));
  49150. __webpack_require__(358);
  49151. __webpack_require__(359);
  49152. __webpack_require__(360);
  49153. __webpack_require__(362);
  49154. /***/ },
  49155. /* 357 */
  49156. /***/ function(module, exports, __webpack_require__) {
  49157. /**
  49158. * @file Timeline preprocessor
  49159. */
  49160. var zrUtil = __webpack_require__(4);
  49161. module.exports = function (option) {
  49162. var timelineOpt = option && option.timeline;
  49163. if (!zrUtil.isArray(timelineOpt)) {
  49164. timelineOpt = timelineOpt ? [timelineOpt] : [];
  49165. }
  49166. zrUtil.each(timelineOpt, function (opt) {
  49167. if (!opt) {
  49168. return;
  49169. }
  49170. compatibleEC2(opt);
  49171. });
  49172. };
  49173. function compatibleEC2(opt) {
  49174. var type = opt.type;
  49175. var ec2Types = {'number': 'value', 'time': 'time'};
  49176. // Compatible with ec2
  49177. if (ec2Types[type]) {
  49178. opt.axisType = ec2Types[type];
  49179. delete opt.type;
  49180. }
  49181. transferItem(opt);
  49182. if (has(opt, 'controlPosition')) {
  49183. var controlStyle = opt.controlStyle || (opt.controlStyle = {});
  49184. if (!has(controlStyle, 'position')) {
  49185. controlStyle.position = opt.controlPosition;
  49186. }
  49187. if (controlStyle.position === 'none' && !has(controlStyle, 'show')) {
  49188. controlStyle.show = false;
  49189. delete controlStyle.position;
  49190. }
  49191. delete opt.controlPosition;
  49192. }
  49193. zrUtil.each(opt.data || [], function (dataItem) {
  49194. if (zrUtil.isObject(dataItem) && !zrUtil.isArray(dataItem)) {
  49195. if (!has(dataItem, 'value') && has(dataItem, 'name')) {
  49196. // In ec2, using name as value.
  49197. dataItem.value = dataItem.name;
  49198. }
  49199. transferItem(dataItem);
  49200. }
  49201. });
  49202. }
  49203. function transferItem(opt) {
  49204. var itemStyle = opt.itemStyle || (opt.itemStyle = {});
  49205. var itemStyleEmphasis = itemStyle.emphasis || (itemStyle.emphasis = {});
  49206. // Transfer label out
  49207. var label = opt.label || (opt.label || {});
  49208. var labelNormal = label.normal || (label.normal = {});
  49209. var excludeLabelAttr = {normal: 1, emphasis: 1};
  49210. zrUtil.each(label, function (value, name) {
  49211. if (!excludeLabelAttr[name] && !has(labelNormal, name)) {
  49212. labelNormal[name] = value;
  49213. }
  49214. });
  49215. if (itemStyleEmphasis.label && !has(label, 'emphasis')) {
  49216. label.emphasis = itemStyleEmphasis.label;
  49217. delete itemStyleEmphasis.label;
  49218. }
  49219. }
  49220. function has(obj, attr) {
  49221. return obj.hasOwnProperty(attr);
  49222. }
  49223. /***/ },
  49224. /* 358 */
  49225. /***/ function(module, exports, __webpack_require__) {
  49226. __webpack_require__(19).registerSubTypeDefaulter('timeline', function () {
  49227. // Only slider now.
  49228. return 'slider';
  49229. });
  49230. /***/ },
  49231. /* 359 */
  49232. /***/ function(module, exports, __webpack_require__) {
  49233. /**
  49234. * @file Timeilne action
  49235. */
  49236. var echarts = __webpack_require__(1);
  49237. echarts.registerAction(
  49238. {type: 'timelineChange', event: 'timelineChanged', update: 'prepareAndUpdate'},
  49239. function (payload, ecModel) {
  49240. var timelineModel = ecModel.getComponent('timeline');
  49241. if (timelineModel && payload.currentIndex != null) {
  49242. timelineModel.setCurrentIndex(payload.currentIndex);
  49243. if (!timelineModel.get('loop', true) && timelineModel.isIndexMax()) {
  49244. timelineModel.setPlayState(false);
  49245. }
  49246. }
  49247. ecModel.resetOption('timeline');
  49248. }
  49249. );
  49250. echarts.registerAction(
  49251. {type: 'timelinePlayChange', event: 'timelinePlayChanged', update: 'update'},
  49252. function (payload, ecModel) {
  49253. var timelineModel = ecModel.getComponent('timeline');
  49254. if (timelineModel && payload.playState != null) {
  49255. timelineModel.setPlayState(payload.playState);
  49256. }
  49257. }
  49258. );
  49259. /***/ },
  49260. /* 360 */
  49261. /***/ function(module, exports, __webpack_require__) {
  49262. /**
  49263. * @file Silder timeline model
  49264. */
  49265. var TimelineModel = __webpack_require__(361);
  49266. var zrUtil = __webpack_require__(4);
  49267. var modelUtil = __webpack_require__(5);
  49268. var SliderTimelineModel = TimelineModel.extend({
  49269. type: 'timeline.slider',
  49270. /**
  49271. * @protected
  49272. */
  49273. defaultOption: {
  49274. backgroundColor: 'rgba(0,0,0,0)', // 时间轴背景颜色
  49275. borderColor: '#ccc', // 时间轴边框颜色
  49276. borderWidth: 0, // 时间轴边框线宽,单位px,默认为0(无边框)
  49277. orient: 'horizontal', // 'vertical'
  49278. inverse: false,
  49279. tooltip: { // boolean or Object
  49280. trigger: 'item' // data item may also have tootip attr.
  49281. },
  49282. symbol: 'emptyCircle',
  49283. symbolSize: 10,
  49284. lineStyle: {
  49285. show: true,
  49286. width: 2,
  49287. color: '#304654'
  49288. },
  49289. label: { // 文本标签
  49290. position: 'auto', // auto left right top bottom
  49291. // When using number, label position is not
  49292. // restricted by viewRect.
  49293. // positive: right/bottom, negative: left/top
  49294. normal: {
  49295. show: true,
  49296. interval: 'auto',
  49297. rotate: 0,
  49298. // formatter: null,
  49299. textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  49300. color: '#304654'
  49301. }
  49302. },
  49303. emphasis: {
  49304. show: true,
  49305. textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  49306. color: '#c23531'
  49307. }
  49308. }
  49309. },
  49310. itemStyle: {
  49311. normal: {
  49312. color: '#304654',
  49313. borderWidth: 1
  49314. },
  49315. emphasis: {
  49316. color: '#c23531'
  49317. }
  49318. },
  49319. checkpointStyle: {
  49320. symbol: 'circle',
  49321. symbolSize: 13,
  49322. color: '#c23531',
  49323. borderWidth: 5,
  49324. borderColor: 'rgba(194,53,49, 0.5)',
  49325. animation: true,
  49326. animationDuration: 300,
  49327. animationEasing: 'quinticInOut'
  49328. },
  49329. controlStyle: {
  49330. show: true,
  49331. showPlayBtn: true,
  49332. showPrevBtn: true,
  49333. showNextBtn: true,
  49334. itemSize: 22,
  49335. itemGap: 12,
  49336. position: 'left', // 'left' 'right' 'top' 'bottom'
  49337. 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
  49338. 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
  49339. 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
  49340. 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
  49341. normal: {
  49342. color: '#304654',
  49343. borderColor: '#304654',
  49344. borderWidth: 1
  49345. },
  49346. emphasis: {
  49347. color: '#c23531',
  49348. borderColor: '#c23531',
  49349. borderWidth: 2
  49350. }
  49351. },
  49352. data: []
  49353. }
  49354. });
  49355. zrUtil.mixin(SliderTimelineModel, modelUtil.dataFormatMixin);
  49356. module.exports = SliderTimelineModel;
  49357. /***/ },
  49358. /* 361 */
  49359. /***/ function(module, exports, __webpack_require__) {
  49360. /**
  49361. * @file Timeline model
  49362. */
  49363. var ComponentModel = __webpack_require__(19);
  49364. var List = __webpack_require__(97);
  49365. var zrUtil = __webpack_require__(4);
  49366. var modelUtil = __webpack_require__(5);
  49367. var TimelineModel = ComponentModel.extend({
  49368. type: 'timeline',
  49369. layoutMode: 'box',
  49370. /**
  49371. * @protected
  49372. */
  49373. defaultOption: {
  49374. zlevel: 0, // 一级层叠
  49375. z: 4, // 二级层叠
  49376. show: true,
  49377. axisType: 'time', // 模式是时间类型,支持 value, category
  49378. realtime: true,
  49379. left: '20%',
  49380. top: null,
  49381. right: '20%',
  49382. bottom: 0,
  49383. width: null,
  49384. height: 40,
  49385. padding: 5,
  49386. controlPosition: 'left', // 'left' 'right' 'top' 'bottom' 'none'
  49387. autoPlay: false,
  49388. rewind: false, // 反向播放
  49389. loop: true,
  49390. playInterval: 2000, // 播放时间间隔,单位ms
  49391. currentIndex: 0,
  49392. itemStyle: {
  49393. normal: {},
  49394. emphasis: {}
  49395. },
  49396. label: {
  49397. normal: {
  49398. textStyle: {
  49399. color: '#000'
  49400. }
  49401. },
  49402. emphasis: {}
  49403. },
  49404. data: []
  49405. },
  49406. /**
  49407. * @override
  49408. */
  49409. init: function (option, parentModel, ecModel) {
  49410. /**
  49411. * @private
  49412. * @type {module:echarts/data/List}
  49413. */
  49414. this._data;
  49415. /**
  49416. * @private
  49417. * @type {Array.<string>}
  49418. */
  49419. this._names;
  49420. this.mergeDefaultAndTheme(option, ecModel);
  49421. this._initData();
  49422. },
  49423. /**
  49424. * @override
  49425. */
  49426. mergeOption: function (option) {
  49427. TimelineModel.superApply(this, 'mergeOption', arguments);
  49428. this._initData();
  49429. },
  49430. /**
  49431. * @param {number} [currentIndex]
  49432. */
  49433. setCurrentIndex: function (currentIndex) {
  49434. if (currentIndex == null) {
  49435. currentIndex = this.option.currentIndex;
  49436. }
  49437. var count = this._data.count();
  49438. if (this.option.loop) {
  49439. currentIndex = (currentIndex % count + count) % count;
  49440. }
  49441. else {
  49442. currentIndex >= count && (currentIndex = count - 1);
  49443. currentIndex < 0 && (currentIndex = 0);
  49444. }
  49445. this.option.currentIndex = currentIndex;
  49446. },
  49447. /**
  49448. * @return {number} currentIndex
  49449. */
  49450. getCurrentIndex: function () {
  49451. return this.option.currentIndex;
  49452. },
  49453. /**
  49454. * @return {boolean}
  49455. */
  49456. isIndexMax: function () {
  49457. return this.getCurrentIndex() >= this._data.count() - 1;
  49458. },
  49459. /**
  49460. * @param {boolean} state true: play, false: stop
  49461. */
  49462. setPlayState: function (state) {
  49463. this.option.autoPlay = !!state;
  49464. },
  49465. /**
  49466. * @return {boolean} true: play, false: stop
  49467. */
  49468. getPlayState: function () {
  49469. return !!this.option.autoPlay;
  49470. },
  49471. /**
  49472. * @private
  49473. */
  49474. _initData: function () {
  49475. var thisOption = this.option;
  49476. var dataArr = thisOption.data || [];
  49477. var axisType = thisOption.axisType;
  49478. var names = this._names = [];
  49479. if (axisType === 'category') {
  49480. var idxArr = [];
  49481. zrUtil.each(dataArr, function (item, index) {
  49482. var value = modelUtil.getDataItemValue(item);
  49483. var newItem;
  49484. if (zrUtil.isObject(item)) {
  49485. newItem = zrUtil.clone(item);
  49486. newItem.value = index;
  49487. }
  49488. else {
  49489. newItem = index;
  49490. }
  49491. idxArr.push(newItem);
  49492. if (!zrUtil.isString(value) && (value == null || isNaN(value))) {
  49493. value = '';
  49494. }
  49495. names.push(value + '');
  49496. });
  49497. dataArr = idxArr;
  49498. }
  49499. var dimType = ({category: 'ordinal', time: 'time'})[axisType] || 'number';
  49500. var data = this._data = new List([{name: 'value', type: dimType}], this);
  49501. data.initData(dataArr, names);
  49502. },
  49503. getData: function () {
  49504. return this._data;
  49505. },
  49506. /**
  49507. * @public
  49508. * @return {Array.<string>} categoreis
  49509. */
  49510. getCategories: function () {
  49511. if (this.get('axisType') === 'category') {
  49512. return this._names.slice();
  49513. }
  49514. }
  49515. });
  49516. module.exports = TimelineModel;
  49517. /***/ },
  49518. /* 362 */
  49519. /***/ function(module, exports, __webpack_require__) {
  49520. /**
  49521. * @file Silder timeline view
  49522. */
  49523. var zrUtil = __webpack_require__(4);
  49524. var graphic = __webpack_require__(43);
  49525. var layout = __webpack_require__(21);
  49526. var TimelineView = __webpack_require__(363);
  49527. var TimelineAxis = __webpack_require__(364);
  49528. var symbolUtil = __webpack_require__(106);
  49529. var axisHelper = __webpack_require__(114);
  49530. var BoundingRect = __webpack_require__(9);
  49531. var matrix = __webpack_require__(11);
  49532. var numberUtil = __webpack_require__(7);
  49533. var formatUtil = __webpack_require__(6);
  49534. var encodeHTML = formatUtil.encodeHTML;
  49535. var bind = zrUtil.bind;
  49536. var each = zrUtil.each;
  49537. var PI = Math.PI;
  49538. module.exports = TimelineView.extend({
  49539. type: 'timeline.slider',
  49540. init: function (ecModel, api) {
  49541. this.api = api;
  49542. /**
  49543. * @private
  49544. * @type {module:echarts/component/timeline/TimelineAxis}
  49545. */
  49546. this._axis;
  49547. /**
  49548. * @private
  49549. * @type {module:zrender/core/BoundingRect}
  49550. */
  49551. this._viewRect;
  49552. /**
  49553. * @type {number}
  49554. */
  49555. this._timer;
  49556. /**
  49557. * @type {module:zrende/Element}
  49558. */
  49559. this._currentPointer;
  49560. /**
  49561. * @type {module:zrender/container/Group}
  49562. */
  49563. this._mainGroup;
  49564. /**
  49565. * @type {module:zrender/container/Group}
  49566. */
  49567. this._labelGroup;
  49568. },
  49569. /**
  49570. * @override
  49571. */
  49572. render: function (timelineModel, ecModel, api, payload) {
  49573. this.model = timelineModel;
  49574. this.api = api;
  49575. this.ecModel = ecModel;
  49576. this.group.removeAll();
  49577. if (timelineModel.get('show', true)) {
  49578. var layoutInfo = this._layout(timelineModel, api);
  49579. var mainGroup = this._createGroup('mainGroup');
  49580. var labelGroup = this._createGroup('labelGroup');
  49581. /**
  49582. * @private
  49583. * @type {module:echarts/component/timeline/TimelineAxis}
  49584. */
  49585. var axis = this._axis = this._createAxis(layoutInfo, timelineModel);
  49586. timelineModel.formatTooltip = function (dataIndex) {
  49587. return encodeHTML(axis.scale.getLabel(dataIndex));
  49588. };
  49589. each(
  49590. ['AxisLine', 'AxisTick', 'Control', 'CurrentPointer'],
  49591. function (name) {
  49592. this['_render' + name](layoutInfo, mainGroup, axis, timelineModel);
  49593. },
  49594. this
  49595. );
  49596. this._renderAxisLabel(layoutInfo, labelGroup, axis, timelineModel);
  49597. this._position(layoutInfo, timelineModel);
  49598. }
  49599. this._doPlayStop();
  49600. },
  49601. /**
  49602. * @override
  49603. */
  49604. remove: function () {
  49605. this._clearTimer();
  49606. this.group.removeAll();
  49607. },
  49608. /**
  49609. * @override
  49610. */
  49611. dispose: function () {
  49612. this._clearTimer();
  49613. },
  49614. _layout: function (timelineModel, api) {
  49615. var labelPosOpt = timelineModel.get('label.normal.position');
  49616. var orient = timelineModel.get('orient');
  49617. var viewRect = getViewRect(timelineModel, api);
  49618. // Auto label offset.
  49619. if (labelPosOpt == null || labelPosOpt === 'auto') {
  49620. labelPosOpt = orient === 'horizontal'
  49621. ? ((viewRect.y + viewRect.height / 2) < api.getHeight() / 2 ? '-' : '+')
  49622. : ((viewRect.x + viewRect.width / 2) < api.getWidth() / 2 ? '+' : '-');
  49623. }
  49624. else if (isNaN(labelPosOpt)) {
  49625. labelPosOpt = ({
  49626. horizontal: {top: '-', bottom: '+'},
  49627. vertical: {left: '-', right: '+'}
  49628. })[orient][labelPosOpt];
  49629. }
  49630. // FIXME
  49631. // 暂没有实现用户传入
  49632. // var labelAlign = timelineModel.get('label.normal.textStyle.align');
  49633. // var labelBaseline = timelineModel.get('label.normal.textStyle.baseline');
  49634. var labelAlignMap = {
  49635. horizontal: 'center',
  49636. vertical: (labelPosOpt >= 0 || labelPosOpt === '+') ? 'left' : 'right'
  49637. };
  49638. var labelBaselineMap = {
  49639. horizontal: (labelPosOpt >= 0 || labelPosOpt === '+') ? 'top' : 'bottom',
  49640. vertical: 'middle'
  49641. };
  49642. var rotationMap = {
  49643. horizontal: 0,
  49644. vertical: PI / 2
  49645. };
  49646. // Position
  49647. var mainLength = orient === 'vertical' ? viewRect.height : viewRect.width;
  49648. var controlModel = timelineModel.getModel('controlStyle');
  49649. var showControl = controlModel.get('show');
  49650. var controlSize = showControl ? controlModel.get('itemSize') : 0;
  49651. var controlGap = showControl ? controlModel.get('itemGap') : 0;
  49652. var sizePlusGap = controlSize + controlGap;
  49653. // Special label rotate.
  49654. var labelRotation = timelineModel.get('label.normal.rotate') || 0;
  49655. labelRotation = labelRotation * PI / 180; // To radian.
  49656. var playPosition;
  49657. var prevBtnPosition;
  49658. var nextBtnPosition;
  49659. var axisExtent;
  49660. var controlPosition = controlModel.get('position', true);
  49661. var showControl = controlModel.get('show', true);
  49662. var showPlayBtn = showControl && controlModel.get('showPlayBtn', true);
  49663. var showPrevBtn = showControl && controlModel.get('showPrevBtn', true);
  49664. var showNextBtn = showControl && controlModel.get('showNextBtn', true);
  49665. var xLeft = 0;
  49666. var xRight = mainLength;
  49667. // position[0] means left, position[1] means middle.
  49668. if (controlPosition === 'left' || controlPosition === 'bottom') {
  49669. showPlayBtn && (playPosition = [0, 0], xLeft += sizePlusGap);
  49670. showPrevBtn && (prevBtnPosition = [xLeft, 0], xLeft += sizePlusGap);
  49671. showNextBtn && (nextBtnPosition = [xRight - controlSize, 0], xRight -= sizePlusGap);
  49672. }
  49673. else { // 'top' 'right'
  49674. showPlayBtn && (playPosition = [xRight - controlSize, 0], xRight -= sizePlusGap);
  49675. showPrevBtn && (prevBtnPosition = [0, 0], xLeft += sizePlusGap);
  49676. showNextBtn && (nextBtnPosition = [xRight - controlSize, 0], xRight -= sizePlusGap);
  49677. }
  49678. axisExtent = [xLeft, xRight];
  49679. if (timelineModel.get('inverse')) {
  49680. axisExtent.reverse();
  49681. }
  49682. return {
  49683. viewRect: viewRect,
  49684. mainLength: mainLength,
  49685. orient: orient,
  49686. rotation: rotationMap[orient],
  49687. labelRotation: labelRotation,
  49688. labelPosOpt: labelPosOpt,
  49689. labelAlign: labelAlignMap[orient],
  49690. labelBaseline: labelBaselineMap[orient],
  49691. // Based on mainGroup.
  49692. playPosition: playPosition,
  49693. prevBtnPosition: prevBtnPosition,
  49694. nextBtnPosition: nextBtnPosition,
  49695. axisExtent: axisExtent,
  49696. controlSize: controlSize,
  49697. controlGap: controlGap
  49698. };
  49699. },
  49700. _position: function (layoutInfo, timelineModel) {
  49701. // Position is be called finally, because bounding rect is needed for
  49702. // adapt content to fill viewRect (auto adapt offset).
  49703. // Timeline may be not all in the viewRect when 'offset' is specified
  49704. // as a number, because it is more appropriate that label aligns at
  49705. // 'offset' but not the other edge defined by viewRect.
  49706. var mainGroup = this._mainGroup;
  49707. var labelGroup = this._labelGroup;
  49708. var viewRect = layoutInfo.viewRect;
  49709. if (layoutInfo.orient === 'vertical') {
  49710. // transfrom to horizontal, inverse rotate by left-top point.
  49711. var m = matrix.create();
  49712. var rotateOriginX = viewRect.x;
  49713. var rotateOriginY = viewRect.y + viewRect.height;
  49714. matrix.translate(m, m, [-rotateOriginX, -rotateOriginY]);
  49715. matrix.rotate(m, m, -PI / 2);
  49716. matrix.translate(m, m, [rotateOriginX, rotateOriginY]);
  49717. viewRect = viewRect.clone();
  49718. viewRect.applyTransform(m);
  49719. }
  49720. var viewBound = getBound(viewRect);
  49721. var mainBound = getBound(mainGroup.getBoundingRect());
  49722. var labelBound = getBound(labelGroup.getBoundingRect());
  49723. var mainPosition = mainGroup.position;
  49724. var labelsPosition = labelGroup.position;
  49725. labelsPosition[0] = mainPosition[0] = viewBound[0][0];
  49726. var labelPosOpt = layoutInfo.labelPosOpt;
  49727. if (isNaN(labelPosOpt)) { // '+' or '-'
  49728. var mainBoundIdx = labelPosOpt === '+' ? 0 : 1;
  49729. toBound(mainPosition, mainBound, viewBound, 1, mainBoundIdx);
  49730. toBound(labelsPosition, labelBound, viewBound, 1, 1 - mainBoundIdx);
  49731. }
  49732. else {
  49733. var mainBoundIdx = labelPosOpt >= 0 ? 0 : 1;
  49734. toBound(mainPosition, mainBound, viewBound, 1, mainBoundIdx);
  49735. labelsPosition[1] = mainPosition[1] + labelPosOpt;
  49736. }
  49737. mainGroup.attr('position', mainPosition);
  49738. labelGroup.attr('position', labelsPosition);
  49739. mainGroup.rotation = labelGroup.rotation = layoutInfo.rotation;
  49740. setOrigin(mainGroup);
  49741. setOrigin(labelGroup);
  49742. function setOrigin(targetGroup) {
  49743. var pos = targetGroup.position;
  49744. targetGroup.origin = [
  49745. viewBound[0][0] - pos[0],
  49746. viewBound[1][0] - pos[1]
  49747. ];
  49748. }
  49749. function getBound(rect) {
  49750. // [[xmin, xmax], [ymin, ymax]]
  49751. return [
  49752. [rect.x, rect.x + rect.width],
  49753. [rect.y, rect.y + rect.height]
  49754. ];
  49755. }
  49756. function toBound(fromPos, from, to, dimIdx, boundIdx) {
  49757. fromPos[dimIdx] += to[dimIdx][boundIdx] - from[dimIdx][boundIdx];
  49758. }
  49759. },
  49760. _createAxis: function (layoutInfo, timelineModel) {
  49761. var data = timelineModel.getData();
  49762. var axisType = timelineModel.get('axisType');
  49763. var scale = axisHelper.createScaleByModel(timelineModel, axisType);
  49764. var dataExtent = data.getDataExtent('value');
  49765. scale.setExtent(dataExtent[0], dataExtent[1]);
  49766. this._customizeScale(scale, data);
  49767. scale.niceTicks();
  49768. var axis = new TimelineAxis('value', scale, layoutInfo.axisExtent, axisType);
  49769. axis.model = timelineModel;
  49770. return axis;
  49771. },
  49772. _customizeScale: function (scale, data) {
  49773. scale.getTicks = function () {
  49774. return data.mapArray(['value'], function (value) {
  49775. return value;
  49776. });
  49777. };
  49778. scale.getTicksLabels = function () {
  49779. return zrUtil.map(this.getTicks(), scale.getLabel, scale);
  49780. };
  49781. },
  49782. _createGroup: function (name) {
  49783. var newGroup = this['_' + name] = new graphic.Group();
  49784. this.group.add(newGroup);
  49785. return newGroup;
  49786. },
  49787. _renderAxisLine: function (layoutInfo, group, axis, timelineModel) {
  49788. var axisExtent = axis.getExtent();
  49789. if (!timelineModel.get('lineStyle.show')) {
  49790. return;
  49791. }
  49792. group.add(new graphic.Line({
  49793. shape: {
  49794. x1: axisExtent[0], y1: 0,
  49795. x2: axisExtent[1], y2: 0
  49796. },
  49797. style: zrUtil.extend(
  49798. {lineCap: 'round'},
  49799. timelineModel.getModel('lineStyle').getLineStyle()
  49800. ),
  49801. silent: true,
  49802. z2: 1
  49803. }));
  49804. },
  49805. /**
  49806. * @private
  49807. */
  49808. _renderAxisTick: function (layoutInfo, group, axis, timelineModel) {
  49809. var data = timelineModel.getData();
  49810. var ticks = axis.scale.getTicks();
  49811. each(ticks, function (value, dataIndex) {
  49812. var tickCoord = axis.dataToCoord(value);
  49813. var itemModel = data.getItemModel(dataIndex);
  49814. var itemStyleModel = itemModel.getModel('itemStyle.normal');
  49815. var hoverStyleModel = itemModel.getModel('itemStyle.emphasis');
  49816. var symbolOpt = {
  49817. position: [tickCoord, 0],
  49818. onclick: bind(this._changeTimeline, this, dataIndex)
  49819. };
  49820. var el = giveSymbol(itemModel, itemStyleModel, group, symbolOpt);
  49821. graphic.setHoverStyle(el, hoverStyleModel.getItemStyle());
  49822. if (itemModel.get('tooltip')) {
  49823. el.dataIndex = dataIndex;
  49824. el.dataModel = timelineModel;
  49825. }
  49826. else {
  49827. el.dataIndex = el.dataModel = null;
  49828. }
  49829. }, this);
  49830. },
  49831. /**
  49832. * @private
  49833. */
  49834. _renderAxisLabel: function (layoutInfo, group, axis, timelineModel) {
  49835. var labelModel = timelineModel.getModel('label.normal');
  49836. if (!labelModel.get('show')) {
  49837. return;
  49838. }
  49839. var data = timelineModel.getData();
  49840. var ticks = axis.scale.getTicks();
  49841. var labels = axisHelper.getFormattedLabels(
  49842. axis, labelModel.get('formatter')
  49843. );
  49844. var labelInterval = axis.getLabelInterval();
  49845. each(ticks, function (tick, dataIndex) {
  49846. if (axis.isLabelIgnored(dataIndex, labelInterval)) {
  49847. return;
  49848. }
  49849. var itemModel = data.getItemModel(dataIndex);
  49850. var itemTextStyleModel = itemModel.getModel('label.normal.textStyle');
  49851. var hoverTextStyleModel = itemModel.getModel('label.emphasis.textStyle');
  49852. var tickCoord = axis.dataToCoord(tick);
  49853. var textEl = new graphic.Text({
  49854. style: {
  49855. text: labels[dataIndex],
  49856. textAlign: layoutInfo.labelAlign,
  49857. textVerticalAlign: layoutInfo.labelBaseline,
  49858. textFont: itemTextStyleModel.getFont(),
  49859. fill: itemTextStyleModel.getTextColor()
  49860. },
  49861. position: [tickCoord, 0],
  49862. rotation: layoutInfo.labelRotation - layoutInfo.rotation,
  49863. onclick: bind(this._changeTimeline, this, dataIndex),
  49864. silent: false
  49865. });
  49866. group.add(textEl);
  49867. graphic.setHoverStyle(textEl, hoverTextStyleModel.getItemStyle());
  49868. }, this);
  49869. },
  49870. /**
  49871. * @private
  49872. */
  49873. _renderControl: function (layoutInfo, group, axis, timelineModel) {
  49874. var controlSize = layoutInfo.controlSize;
  49875. var rotation = layoutInfo.rotation;
  49876. var itemStyle = timelineModel.getModel('controlStyle.normal').getItemStyle();
  49877. var hoverStyle = timelineModel.getModel('controlStyle.emphasis').getItemStyle();
  49878. var rect = [0, -controlSize / 2, controlSize, controlSize];
  49879. var playState = timelineModel.getPlayState();
  49880. var inverse = timelineModel.get('inverse', true);
  49881. makeBtn(
  49882. layoutInfo.nextBtnPosition,
  49883. 'controlStyle.nextIcon',
  49884. bind(this._changeTimeline, this, inverse ? '-' : '+')
  49885. );
  49886. makeBtn(
  49887. layoutInfo.prevBtnPosition,
  49888. 'controlStyle.prevIcon',
  49889. bind(this._changeTimeline, this, inverse ? '+' : '-')
  49890. );
  49891. makeBtn(
  49892. layoutInfo.playPosition,
  49893. 'controlStyle.' + (playState ? 'stopIcon' : 'playIcon'),
  49894. bind(this._handlePlayClick, this, !playState),
  49895. true
  49896. );
  49897. function makeBtn(position, iconPath, onclick, willRotate) {
  49898. if (!position) {
  49899. return;
  49900. }
  49901. var opt = {
  49902. position: position,
  49903. origin: [controlSize / 2, 0],
  49904. rotation: willRotate ? -rotation : 0,
  49905. rectHover: true,
  49906. style: itemStyle,
  49907. onclick: onclick
  49908. };
  49909. var btn = makeIcon(timelineModel, iconPath, rect, opt);
  49910. group.add(btn);
  49911. graphic.setHoverStyle(btn, hoverStyle);
  49912. }
  49913. },
  49914. _renderCurrentPointer: function (layoutInfo, group, axis, timelineModel) {
  49915. var data = timelineModel.getData();
  49916. var currentIndex = timelineModel.getCurrentIndex();
  49917. var pointerModel = data.getItemModel(currentIndex).getModel('checkpointStyle');
  49918. var me = this;
  49919. var callback = {
  49920. onCreate: function (pointer) {
  49921. pointer.draggable = true;
  49922. pointer.drift = bind(me._handlePointerDrag, me);
  49923. pointer.ondragend = bind(me._handlePointerDragend, me);
  49924. pointerMoveTo(pointer, currentIndex, axis, timelineModel, true);
  49925. },
  49926. onUpdate: function (pointer) {
  49927. pointerMoveTo(pointer, currentIndex, axis, timelineModel);
  49928. }
  49929. };
  49930. // Reuse when exists, for animation and drag.
  49931. this._currentPointer = giveSymbol(
  49932. pointerModel, pointerModel, this._mainGroup, {}, this._currentPointer, callback
  49933. );
  49934. },
  49935. _handlePlayClick: function (nextState) {
  49936. this._clearTimer();
  49937. this.api.dispatchAction({
  49938. type: 'timelinePlayChange',
  49939. playState: nextState,
  49940. from: this.uid
  49941. });
  49942. },
  49943. _handlePointerDrag: function (dx, dy, e) {
  49944. this._clearTimer();
  49945. this._pointerChangeTimeline([e.offsetX, e.offsetY]);
  49946. },
  49947. _handlePointerDragend: function (e) {
  49948. this._pointerChangeTimeline([e.offsetX, e.offsetY], true);
  49949. },
  49950. _pointerChangeTimeline: function (mousePos, trigger) {
  49951. var toCoord = this._toAxisCoord(mousePos)[0];
  49952. var axis = this._axis;
  49953. var axisExtent = numberUtil.asc(axis.getExtent().slice());
  49954. toCoord > axisExtent[1] && (toCoord = axisExtent[1]);
  49955. toCoord < axisExtent[0] && (toCoord = axisExtent[0]);
  49956. this._currentPointer.position[0] = toCoord;
  49957. this._currentPointer.dirty();
  49958. var targetDataIndex = this._findNearestTick(toCoord);
  49959. var timelineModel = this.model;
  49960. if (trigger || (
  49961. targetDataIndex !== timelineModel.getCurrentIndex()
  49962. && timelineModel.get('realtime')
  49963. )) {
  49964. this._changeTimeline(targetDataIndex);
  49965. }
  49966. },
  49967. _doPlayStop: function () {
  49968. this._clearTimer();
  49969. if (this.model.getPlayState()) {
  49970. this._timer = setTimeout(
  49971. bind(handleFrame, this),
  49972. this.model.get('playInterval')
  49973. );
  49974. }
  49975. function handleFrame() {
  49976. // Do not cache
  49977. var timelineModel = this.model;
  49978. this._changeTimeline(
  49979. timelineModel.getCurrentIndex()
  49980. + (timelineModel.get('rewind', true) ? -1 : 1)
  49981. );
  49982. }
  49983. },
  49984. _toAxisCoord: function (vertex) {
  49985. var trans = this._mainGroup.getLocalTransform();
  49986. return graphic.applyTransform(vertex, trans, true);
  49987. },
  49988. _findNearestTick: function (axisCoord) {
  49989. var data = this.model.getData();
  49990. var dist = Infinity;
  49991. var targetDataIndex;
  49992. var axis = this._axis;
  49993. data.each(['value'], function (value, dataIndex) {
  49994. var coord = axis.dataToCoord(value);
  49995. var d = Math.abs(coord - axisCoord);
  49996. if (d < dist) {
  49997. dist = d;
  49998. targetDataIndex = dataIndex;
  49999. }
  50000. });
  50001. return targetDataIndex;
  50002. },
  50003. _clearTimer: function () {
  50004. if (this._timer) {
  50005. clearTimeout(this._timer);
  50006. this._timer = null;
  50007. }
  50008. },
  50009. _changeTimeline: function (nextIndex) {
  50010. var currentIndex = this.model.getCurrentIndex();
  50011. if (nextIndex === '+') {
  50012. nextIndex = currentIndex + 1;
  50013. }
  50014. else if (nextIndex === '-') {
  50015. nextIndex = currentIndex - 1;
  50016. }
  50017. this.api.dispatchAction({
  50018. type: 'timelineChange',
  50019. currentIndex: nextIndex,
  50020. from: this.uid
  50021. });
  50022. }
  50023. });
  50024. function getViewRect(model, api) {
  50025. return layout.getLayoutRect(
  50026. model.getBoxLayoutParams(),
  50027. {
  50028. width: api.getWidth(),
  50029. height: api.getHeight()
  50030. },
  50031. model.get('padding')
  50032. );
  50033. }
  50034. function makeIcon(timelineModel, objPath, rect, opts) {
  50035. var icon = graphic.makePath(
  50036. timelineModel.get(objPath).replace(/^path:\/\//, ''),
  50037. zrUtil.clone(opts || {}),
  50038. new BoundingRect(rect[0], rect[1], rect[2], rect[3]),
  50039. 'center'
  50040. );
  50041. return icon;
  50042. }
  50043. /**
  50044. * Create symbol or update symbol
  50045. */
  50046. function giveSymbol(hostModel, itemStyleModel, group, opt, symbol, callback) {
  50047. var symbolType = hostModel.get('symbol');
  50048. var color = itemStyleModel.get('color');
  50049. var symbolSize = hostModel.get('symbolSize');
  50050. var halfSymbolSize = symbolSize / 2;
  50051. var itemStyle = itemStyleModel.getItemStyle(['color', 'symbol', 'symbolSize']);
  50052. if (!symbol) {
  50053. symbol = symbolUtil.createSymbol(
  50054. symbolType, -halfSymbolSize, -halfSymbolSize, symbolSize, symbolSize, color
  50055. );
  50056. group.add(symbol);
  50057. callback && callback.onCreate(symbol);
  50058. }
  50059. else {
  50060. symbol.setStyle(itemStyle);
  50061. symbol.setColor(color);
  50062. group.add(symbol); // Group may be new, also need to add.
  50063. callback && callback.onUpdate(symbol);
  50064. }
  50065. opt = zrUtil.merge({
  50066. rectHover: true,
  50067. style: itemStyle,
  50068. z2: 100
  50069. }, opt, true);
  50070. symbol.attr(opt);
  50071. return symbol;
  50072. }
  50073. function pointerMoveTo(pointer, dataIndex, axis, timelineModel, noAnimation) {
  50074. if (pointer.dragging) {
  50075. return;
  50076. }
  50077. var pointerModel = timelineModel.getModel('checkpointStyle');
  50078. var toCoord = axis.dataToCoord(timelineModel.getData().get(['value'], dataIndex));
  50079. if (noAnimation || !pointerModel.get('animation', true)) {
  50080. pointer.attr({position: [toCoord, 0]});
  50081. }
  50082. else {
  50083. pointer.stopAnimation(true);
  50084. pointer.animateTo(
  50085. {position: [toCoord, 0]},
  50086. pointerModel.get('animationDuration', true),
  50087. pointerModel.get('animationEasing', true)
  50088. );
  50089. }
  50090. }
  50091. /***/ },
  50092. /* 363 */
  50093. /***/ function(module, exports, __webpack_require__) {
  50094. /**
  50095. * @file Timeline view
  50096. */
  50097. // var zrUtil = require('zrender/lib/core/util');
  50098. // var graphic = require('../../util/graphic');
  50099. var ComponentView = __webpack_require__(29);
  50100. module.exports = ComponentView.extend({
  50101. type: 'timeline'
  50102. });
  50103. /***/ },
  50104. /* 364 */
  50105. /***/ function(module, exports, __webpack_require__) {
  50106. var zrUtil = __webpack_require__(4);
  50107. var Axis = __webpack_require__(123);
  50108. var axisHelper = __webpack_require__(114);
  50109. /**
  50110. * Extend axis 2d
  50111. * @constructor module:echarts/coord/cartesian/Axis2D
  50112. * @extends {module:echarts/coord/cartesian/Axis}
  50113. * @param {string} dim
  50114. * @param {*} scale
  50115. * @param {Array.<number>} coordExtent
  50116. * @param {string} axisType
  50117. * @param {string} position
  50118. */
  50119. var TimelineAxis = function (dim, scale, coordExtent, axisType) {
  50120. Axis.call(this, dim, scale, coordExtent);
  50121. /**
  50122. * Axis type
  50123. * - 'category'
  50124. * - 'value'
  50125. * - 'time'
  50126. * - 'log'
  50127. * @type {string}
  50128. */
  50129. this.type = axisType || 'value';
  50130. /**
  50131. * @private
  50132. * @type {number}
  50133. */
  50134. this._autoLabelInterval;
  50135. /**
  50136. * Axis model
  50137. * @param {module:echarts/component/TimelineModel}
  50138. */
  50139. this.model = null;
  50140. };
  50141. TimelineAxis.prototype = {
  50142. constructor: TimelineAxis,
  50143. /**
  50144. * @public
  50145. * @return {number}
  50146. */
  50147. getLabelInterval: function () {
  50148. var timelineModel = this.model;
  50149. var labelModel = timelineModel.getModel('label.normal');
  50150. var labelInterval = labelModel.get('interval');
  50151. if (labelInterval != null && labelInterval != 'auto') {
  50152. return labelInterval;
  50153. }
  50154. var labelInterval = this._autoLabelInterval;
  50155. if (!labelInterval) {
  50156. labelInterval = this._autoLabelInterval = axisHelper.getAxisLabelInterval(
  50157. zrUtil.map(this.scale.getTicks(), this.dataToCoord, this),
  50158. axisHelper.getFormattedLabels(this, labelModel.get('formatter')),
  50159. labelModel.getModel('textStyle').getFont(),
  50160. timelineModel.get('orient') === 'horizontal'
  50161. );
  50162. }
  50163. return labelInterval;
  50164. },
  50165. /**
  50166. * If label is ignored.
  50167. * Automatically used when axis is category and label can not be all shown
  50168. * @public
  50169. * @param {number} idx
  50170. * @return {boolean}
  50171. */
  50172. isLabelIgnored: function (idx) {
  50173. if (this.type === 'category') {
  50174. var labelInterval = this.getLabelInterval();
  50175. return ((typeof labelInterval === 'function')
  50176. && !labelInterval(idx, this.scale.getLabel(idx)))
  50177. || idx % (labelInterval + 1);
  50178. }
  50179. }
  50180. };
  50181. zrUtil.inherits(TimelineAxis, Axis);
  50182. module.exports = TimelineAxis;
  50183. /***/ },
  50184. /* 365 */
  50185. /***/ function(module, exports, __webpack_require__) {
  50186. __webpack_require__(366);
  50187. __webpack_require__(367);
  50188. __webpack_require__(369);
  50189. __webpack_require__(370);
  50190. __webpack_require__(371);
  50191. __webpack_require__(372);
  50192. __webpack_require__(377);
  50193. /***/ },
  50194. /* 366 */
  50195. /***/ function(module, exports, __webpack_require__) {
  50196. var featureManager = __webpack_require__(314);
  50197. var zrUtil = __webpack_require__(4);
  50198. var ToolboxModel = __webpack_require__(1).extendComponentModel({
  50199. type: 'toolbox',
  50200. layoutMode: {
  50201. type: 'box',
  50202. ignoreSize: true
  50203. },
  50204. mergeDefaultAndTheme: function (option) {
  50205. ToolboxModel.superApply(this, 'mergeDefaultAndTheme', arguments);
  50206. zrUtil.each(this.option.feature, function (featureOpt, featureName) {
  50207. var Feature = featureManager.get(featureName);
  50208. Feature && zrUtil.merge(featureOpt, Feature.defaultOption);
  50209. });
  50210. },
  50211. defaultOption: {
  50212. show: true,
  50213. z: 6,
  50214. zlevel: 0,
  50215. orient: 'horizontal',
  50216. left: 'right',
  50217. top: 'top',
  50218. // right
  50219. // bottom
  50220. backgroundColor: 'transparent',
  50221. borderColor: '#ccc',
  50222. borderWidth: 0,
  50223. padding: 5,
  50224. itemSize: 15,
  50225. itemGap: 8,
  50226. showTitle: true,
  50227. iconStyle: {
  50228. normal: {
  50229. borderColor: '#666',
  50230. color: 'none'
  50231. },
  50232. emphasis: {
  50233. borderColor: '#3E98C5'
  50234. }
  50235. }
  50236. // textStyle: {},
  50237. // feature
  50238. }
  50239. });
  50240. module.exports = ToolboxModel;
  50241. /***/ },
  50242. /* 367 */
  50243. /***/ function(module, exports, __webpack_require__) {
  50244. /* WEBPACK VAR INJECTION */(function(process) {
  50245. var featureManager = __webpack_require__(314);
  50246. var zrUtil = __webpack_require__(4);
  50247. var graphic = __webpack_require__(43);
  50248. var Model = __webpack_require__(12);
  50249. var DataDiffer = __webpack_require__(98);
  50250. var listComponentHelper = __webpack_require__(277);
  50251. var textContain = __webpack_require__(8);
  50252. module.exports = __webpack_require__(1).extendComponentView({
  50253. type: 'toolbox',
  50254. render: function (toolboxModel, ecModel, api, payload) {
  50255. var group = this.group;
  50256. group.removeAll();
  50257. if (!toolboxModel.get('show')) {
  50258. return;
  50259. }
  50260. var itemSize = +toolboxModel.get('itemSize');
  50261. var featureOpts = toolboxModel.get('feature') || {};
  50262. var features = this._features || (this._features = {});
  50263. var featureNames = [];
  50264. zrUtil.each(featureOpts, function (opt, name) {
  50265. featureNames.push(name);
  50266. });
  50267. (new DataDiffer(this._featureNames || [], featureNames))
  50268. .add(process)
  50269. .update(process)
  50270. .remove(zrUtil.curry(process, null))
  50271. .execute();
  50272. // Keep for diff.
  50273. this._featureNames = featureNames;
  50274. function process(newIndex, oldIndex) {
  50275. var featureName = featureNames[newIndex];
  50276. var oldName = featureNames[oldIndex];
  50277. var featureOpt = featureOpts[featureName];
  50278. var featureModel = new Model(featureOpt, toolboxModel, toolboxModel.ecModel);
  50279. var feature;
  50280. if (featureName && !oldName) { // Create
  50281. if (isUserFeatureName(featureName)) {
  50282. feature = {
  50283. model: featureModel,
  50284. onclick: featureModel.option.onclick,
  50285. featureName: featureName
  50286. };
  50287. }
  50288. else {
  50289. var Feature = featureManager.get(featureName);
  50290. if (!Feature) {
  50291. return;
  50292. }
  50293. feature = new Feature(featureModel, ecModel, api);
  50294. }
  50295. features[featureName] = feature;
  50296. }
  50297. else {
  50298. feature = features[oldName];
  50299. // If feature does not exsit.
  50300. if (!feature) {
  50301. return;
  50302. }
  50303. feature.model = featureModel;
  50304. feature.ecModel = ecModel;
  50305. feature.api = api;
  50306. }
  50307. if (!featureName && oldName) {
  50308. feature.dispose && feature.dispose(ecModel, api);
  50309. return;
  50310. }
  50311. if (!featureModel.get('show') || feature.unusable) {
  50312. feature.remove && feature.remove(ecModel, api);
  50313. return;
  50314. }
  50315. createIconPaths(featureModel, feature, featureName);
  50316. featureModel.setIconStatus = function (iconName, status) {
  50317. var option = this.option;
  50318. var iconPaths = this.iconPaths;
  50319. option.iconStatus = option.iconStatus || {};
  50320. option.iconStatus[iconName] = status;
  50321. // FIXME
  50322. iconPaths[iconName] && iconPaths[iconName].trigger(status);
  50323. };
  50324. if (feature.render) {
  50325. feature.render(featureModel, ecModel, api, payload);
  50326. }
  50327. }
  50328. function createIconPaths(featureModel, feature, featureName) {
  50329. var iconStyleModel = featureModel.getModel('iconStyle');
  50330. // If one feature has mutiple icon. they are orginaized as
  50331. // {
  50332. // icon: {
  50333. // foo: '',
  50334. // bar: ''
  50335. // },
  50336. // title: {
  50337. // foo: '',
  50338. // bar: ''
  50339. // }
  50340. // }
  50341. var icons = feature.getIcons ? feature.getIcons() : featureModel.get('icon');
  50342. var titles = featureModel.get('title') || {};
  50343. if (typeof icons === 'string') {
  50344. var icon = icons;
  50345. var title = titles;
  50346. icons = {};
  50347. titles = {};
  50348. icons[featureName] = icon;
  50349. titles[featureName] = title;
  50350. }
  50351. var iconPaths = featureModel.iconPaths = {};
  50352. zrUtil.each(icons, function (icon, iconName) {
  50353. var normalStyle = iconStyleModel.getModel('normal').getItemStyle();
  50354. var hoverStyle = iconStyleModel.getModel('emphasis').getItemStyle();
  50355. var style = {
  50356. x: -itemSize / 2,
  50357. y: -itemSize / 2,
  50358. width: itemSize,
  50359. height: itemSize
  50360. };
  50361. var path = icon.indexOf('image://') === 0
  50362. ? (
  50363. style.image = icon.slice(8),
  50364. new graphic.Image({style: style})
  50365. )
  50366. : graphic.makePath(
  50367. icon.replace('path://', ''),
  50368. {
  50369. style: normalStyle,
  50370. hoverStyle: hoverStyle,
  50371. rectHover: true
  50372. },
  50373. style,
  50374. 'center'
  50375. );
  50376. graphic.setHoverStyle(path);
  50377. if (toolboxModel.get('showTitle')) {
  50378. path.__title = titles[iconName];
  50379. path.on('mouseover', function () {
  50380. path.setStyle({
  50381. text: titles[iconName],
  50382. textPosition: hoverStyle.textPosition || 'bottom',
  50383. textFill: hoverStyle.fill || hoverStyle.stroke || '#000',
  50384. textAlign: hoverStyle.textAlign || 'center'
  50385. });
  50386. })
  50387. .on('mouseout', function () {
  50388. path.setStyle({
  50389. textFill: null
  50390. });
  50391. });
  50392. }
  50393. path.trigger(featureModel.get('iconStatus.' + iconName) || 'normal');
  50394. group.add(path);
  50395. path.on('click', zrUtil.bind(
  50396. feature.onclick, feature, ecModel, api, iconName
  50397. ));
  50398. iconPaths[iconName] = path;
  50399. });
  50400. }
  50401. listComponentHelper.layout(group, toolboxModel, api);
  50402. // Render background after group is layout
  50403. // FIXME
  50404. listComponentHelper.addBackground(group, toolboxModel);
  50405. // Adjust icon title positions to avoid them out of screen
  50406. group.eachChild(function (icon) {
  50407. var titleText = icon.__title;
  50408. var hoverStyle = icon.hoverStyle;
  50409. // May be background element
  50410. if (hoverStyle && titleText) {
  50411. var rect = textContain.getBoundingRect(
  50412. titleText, hoverStyle.font
  50413. );
  50414. var offsetX = icon.position[0] + group.position[0];
  50415. var offsetY = icon.position[1] + group.position[1] + itemSize;
  50416. var needPutOnTop = false;
  50417. if (offsetY + rect.height > api.getHeight()) {
  50418. hoverStyle.textPosition = 'top';
  50419. needPutOnTop = true;
  50420. }
  50421. var topOffset = needPutOnTop ? (-5 - rect.height) : (itemSize + 8);
  50422. if (offsetX + rect.width / 2 > api.getWidth()) {
  50423. hoverStyle.textPosition = ['100%', topOffset];
  50424. hoverStyle.textAlign = 'right';
  50425. }
  50426. else if (offsetX - rect.width / 2 < 0) {
  50427. hoverStyle.textPosition = [0, topOffset];
  50428. hoverStyle.textAlign = 'left';
  50429. }
  50430. }
  50431. });
  50432. },
  50433. updateView: function (toolboxModel, ecModel, api, payload) {
  50434. zrUtil.each(this._features, function (feature) {
  50435. feature.updateView && feature.updateView(feature.model, ecModel, api, payload);
  50436. });
  50437. },
  50438. updateLayout: function (toolboxModel, ecModel, api, payload) {
  50439. zrUtil.each(this._features, function (feature) {
  50440. feature.updateLayout && feature.updateLayout(feature.model, ecModel, api, payload);
  50441. });
  50442. },
  50443. remove: function (ecModel, api) {
  50444. zrUtil.each(this._features, function (feature) {
  50445. feature.remove && feature.remove(ecModel, api);
  50446. });
  50447. this.group.removeAll();
  50448. },
  50449. dispose: function (ecModel, api) {
  50450. zrUtil.each(this._features, function (feature) {
  50451. feature.dispose && feature.dispose(ecModel, api);
  50452. });
  50453. }
  50454. });
  50455. function isUserFeatureName(featureName) {
  50456. return featureName.indexOf('my') === 0;
  50457. }
  50458. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(368)))
  50459. /***/ },
  50460. /* 368 */
  50461. /***/ function(module, exports) {
  50462. // shim for using process in browser
  50463. var process = module.exports = {};
  50464. var queue = [];
  50465. var draining = false;
  50466. var currentQueue;
  50467. var queueIndex = -1;
  50468. function cleanUpNextTick() {
  50469. draining = false;
  50470. if (currentQueue.length) {
  50471. queue = currentQueue.concat(queue);
  50472. } else {
  50473. queueIndex = -1;
  50474. }
  50475. if (queue.length) {
  50476. drainQueue();
  50477. }
  50478. }
  50479. function drainQueue() {
  50480. if (draining) {
  50481. return;
  50482. }
  50483. var timeout = setTimeout(cleanUpNextTick);
  50484. draining = true;
  50485. var len = queue.length;
  50486. while(len) {
  50487. currentQueue = queue;
  50488. queue = [];
  50489. while (++queueIndex < len) {
  50490. if (currentQueue) {
  50491. currentQueue[queueIndex].run();
  50492. }
  50493. }
  50494. queueIndex = -1;
  50495. len = queue.length;
  50496. }
  50497. currentQueue = null;
  50498. draining = false;
  50499. clearTimeout(timeout);
  50500. }
  50501. process.nextTick = function (fun) {
  50502. var args = new Array(arguments.length - 1);
  50503. if (arguments.length > 1) {
  50504. for (var i = 1; i < arguments.length; i++) {
  50505. args[i - 1] = arguments[i];
  50506. }
  50507. }
  50508. queue.push(new Item(fun, args));
  50509. if (queue.length === 1 && !draining) {
  50510. setTimeout(drainQueue, 0);
  50511. }
  50512. };
  50513. // v8 likes predictible objects
  50514. function Item(fun, array) {
  50515. this.fun = fun;
  50516. this.array = array;
  50517. }
  50518. Item.prototype.run = function () {
  50519. this.fun.apply(null, this.array);
  50520. };
  50521. process.title = 'browser';
  50522. process.browser = true;
  50523. process.env = {};
  50524. process.argv = [];
  50525. process.version = ''; // empty string to avoid regexp issues
  50526. process.versions = {};
  50527. function noop() {}
  50528. process.on = noop;
  50529. process.addListener = noop;
  50530. process.once = noop;
  50531. process.off = noop;
  50532. process.removeListener = noop;
  50533. process.removeAllListeners = noop;
  50534. process.emit = noop;
  50535. process.binding = function (name) {
  50536. throw new Error('process.binding is not supported');
  50537. };
  50538. process.cwd = function () { return '/' };
  50539. process.chdir = function (dir) {
  50540. throw new Error('process.chdir is not supported');
  50541. };
  50542. process.umask = function() { return 0; };
  50543. /***/ },
  50544. /* 369 */
  50545. /***/ function(module, exports, __webpack_require__) {
  50546. var env = __webpack_require__(2);
  50547. function SaveAsImage (model) {
  50548. this.model = model;
  50549. }
  50550. SaveAsImage.defaultOption = {
  50551. show: true,
  50552. 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',
  50553. title: '保存为图片',
  50554. type: 'png',
  50555. // Default use option.backgroundColor
  50556. // backgroundColor: '#fff',
  50557. name: '',
  50558. excludeComponents: ['toolbox'],
  50559. pixelRatio: 1,
  50560. lang: ['右键另存为图片']
  50561. };
  50562. SaveAsImage.prototype.unusable = !env.canvasSupported;
  50563. var proto = SaveAsImage.prototype;
  50564. proto.onclick = function (ecModel, api) {
  50565. var model = this.model;
  50566. var title = model.get('name') || ecModel.get('title.0.text') || 'echarts';
  50567. var $a = document.createElement('a');
  50568. var type = model.get('type', true) || 'png';
  50569. $a.download = title + '.' + type;
  50570. $a.target = '_blank';
  50571. var url = api.getConnectedDataURL({
  50572. type: type,
  50573. backgroundColor: model.get('backgroundColor', true)
  50574. || ecModel.get('backgroundColor') || '#fff',
  50575. excludeComponents: model.get('excludeComponents'),
  50576. pixelRatio: model.get('pixelRatio')
  50577. });
  50578. $a.href = url;
  50579. // Chrome and Firefox
  50580. if (typeof MouseEvent === 'function') {
  50581. var evt = new MouseEvent('click', {
  50582. view: window,
  50583. bubbles: true,
  50584. cancelable: false
  50585. });
  50586. $a.dispatchEvent(evt);
  50587. }
  50588. // IE
  50589. else {
  50590. var lang = model.get('lang');
  50591. var html = ''
  50592. + '<body style="margin:0;">'
  50593. + '<img src="' + url + '" style="max-width:100%;" title="' + ((lang && lang[0]) || '') + '" />'
  50594. + '</body>';
  50595. var tab = window.open();
  50596. tab.document.write(html);
  50597. }
  50598. };
  50599. __webpack_require__(314).register(
  50600. 'saveAsImage', SaveAsImage
  50601. );
  50602. module.exports = SaveAsImage;
  50603. /***/ },
  50604. /* 370 */
  50605. /***/ function(module, exports, __webpack_require__) {
  50606. 'use strict';
  50607. var zrUtil = __webpack_require__(4);
  50608. function MagicType(model) {
  50609. this.model = model;
  50610. }
  50611. MagicType.defaultOption = {
  50612. show: true,
  50613. type: [],
  50614. // Icon group
  50615. icon: {
  50616. line: 'M4.1,28.9h7.1l9.3-22l7.4,38l9.7-19.7l3,12.8h14.9M4.1,58h51.4',
  50617. bar: 'M6.7,22.9h10V48h-10V22.9zM24.9,13h10v35h-10V13zM43.2,2h10v46h-10V2zM3.1,58h53.7',
  50618. 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
  50619. tiled: 'M2.3,2.2h22.8V25H2.3V2.2z M35,2.2h22.8V25H35V2.2zM2.3,35h22.8v22.8H2.3V35z M35,35h22.8v22.8H35V35z'
  50620. },
  50621. title: {
  50622. line: '切换为折线图',
  50623. bar: '切换为柱状图',
  50624. stack: '切换为堆叠',
  50625. tiled: '切换为平铺'
  50626. },
  50627. option: {},
  50628. seriesIndex: {}
  50629. };
  50630. var proto = MagicType.prototype;
  50631. proto.getIcons = function () {
  50632. var model = this.model;
  50633. var availableIcons = model.get('icon');
  50634. var icons = {};
  50635. zrUtil.each(model.get('type'), function (type) {
  50636. if (availableIcons[type]) {
  50637. icons[type] = availableIcons[type];
  50638. }
  50639. });
  50640. return icons;
  50641. };
  50642. var seriesOptGenreator = {
  50643. 'line': function (seriesType, seriesId, seriesModel, model) {
  50644. if (seriesType === 'bar') {
  50645. return zrUtil.merge({
  50646. id: seriesId,
  50647. type: 'line',
  50648. // Preserve data related option
  50649. data: seriesModel.get('data'),
  50650. stack: seriesModel.get('stack'),
  50651. markPoint: seriesModel.get('markPoint'),
  50652. markLine: seriesModel.get('markLine')
  50653. }, model.get('option.line') || {}, true);
  50654. }
  50655. },
  50656. 'bar': function (seriesType, seriesId, seriesModel, model) {
  50657. if (seriesType === 'line') {
  50658. return zrUtil.merge({
  50659. id: seriesId,
  50660. type: 'bar',
  50661. // Preserve data related option
  50662. data: seriesModel.get('data'),
  50663. stack: seriesModel.get('stack'),
  50664. markPoint: seriesModel.get('markPoint'),
  50665. markLine: seriesModel.get('markLine')
  50666. }, model.get('option.bar') || {}, true);
  50667. }
  50668. },
  50669. 'stack': function (seriesType, seriesId, seriesModel, model) {
  50670. if (seriesType === 'line' || seriesType === 'bar') {
  50671. return zrUtil.merge({
  50672. id: seriesId,
  50673. stack: '__ec_magicType_stack__'
  50674. }, model.get('option.stack') || {}, true);
  50675. }
  50676. },
  50677. 'tiled': function (seriesType, seriesId, seriesModel, model) {
  50678. if (seriesType === 'line' || seriesType === 'bar') {
  50679. return zrUtil.merge({
  50680. id: seriesId,
  50681. stack: ''
  50682. }, model.get('option.tiled') || {}, true);
  50683. }
  50684. }
  50685. };
  50686. var radioTypes = [
  50687. ['line', 'bar'],
  50688. ['stack', 'tiled']
  50689. ];
  50690. proto.onclick = function (ecModel, api, type) {
  50691. var model = this.model;
  50692. var seriesIndex = model.get('seriesIndex.' + type);
  50693. // Not supported magicType
  50694. if (!seriesOptGenreator[type]) {
  50695. return;
  50696. }
  50697. var newOption = {
  50698. series: []
  50699. };
  50700. var generateNewSeriesTypes = function (seriesModel) {
  50701. var seriesType = seriesModel.subType;
  50702. var seriesId = seriesModel.id;
  50703. var newSeriesOpt = seriesOptGenreator[type](
  50704. seriesType, seriesId, seriesModel, model
  50705. );
  50706. if (newSeriesOpt) {
  50707. // PENDING If merge original option?
  50708. zrUtil.defaults(newSeriesOpt, seriesModel.option);
  50709. newOption.series.push(newSeriesOpt);
  50710. }
  50711. // Modify boundaryGap
  50712. var coordSys = seriesModel.coordinateSystem;
  50713. if (coordSys && coordSys.type === 'cartesian2d' && (type === 'line' || type === 'bar')) {
  50714. var categoryAxis = coordSys.getAxesByScale('ordinal')[0];
  50715. if (categoryAxis) {
  50716. var axisDim = categoryAxis.dim;
  50717. var axisIndex = seriesModel.get(axisDim + 'AxisIndex');
  50718. var axisKey = axisDim + 'Axis';
  50719. newOption[axisKey] = newOption[axisKey] || [];
  50720. for (var i = 0; i <= axisIndex; i++) {
  50721. newOption[axisKey][axisIndex] = newOption[axisKey][axisIndex] || {};
  50722. }
  50723. newOption[axisKey][axisIndex].boundaryGap = type === 'bar' ? true : false;
  50724. }
  50725. }
  50726. };
  50727. zrUtil.each(radioTypes, function (radio) {
  50728. if (zrUtil.indexOf(radio, type) >= 0) {
  50729. zrUtil.each(radio, function (item) {
  50730. model.setIconStatus(item, 'normal');
  50731. });
  50732. }
  50733. });
  50734. model.setIconStatus(type, 'emphasis');
  50735. ecModel.eachComponent(
  50736. {
  50737. mainType: 'series',
  50738. query: seriesIndex == null ? null : {
  50739. seriesIndex: seriesIndex
  50740. }
  50741. }, generateNewSeriesTypes
  50742. );
  50743. api.dispatchAction({
  50744. type: 'changeMagicType',
  50745. currentType: type,
  50746. newOption: newOption
  50747. });
  50748. };
  50749. var echarts = __webpack_require__(1);
  50750. echarts.registerAction({
  50751. type: 'changeMagicType',
  50752. event: 'magicTypeChanged',
  50753. update: 'prepareAndUpdate'
  50754. }, function (payload, ecModel) {
  50755. ecModel.mergeOption(payload.newOption);
  50756. });
  50757. __webpack_require__(314).register('magicType', MagicType);
  50758. module.exports = MagicType;
  50759. /***/ },
  50760. /* 371 */
  50761. /***/ function(module, exports, __webpack_require__) {
  50762. /**
  50763. * @module echarts/component/toolbox/feature/DataView
  50764. */
  50765. var zrUtil = __webpack_require__(4);
  50766. var eventTool = __webpack_require__(87);
  50767. var BLOCK_SPLITER = new Array(60).join('-');
  50768. var ITEM_SPLITER = '\t';
  50769. /**
  50770. * Group series into two types
  50771. * 1. on category axis, like line, bar
  50772. * 2. others, like scatter, pie
  50773. * @param {module:echarts/model/Global} ecModel
  50774. * @return {Object}
  50775. * @inner
  50776. */
  50777. function groupSeries(ecModel) {
  50778. var seriesGroupByCategoryAxis = {};
  50779. var otherSeries = [];
  50780. var meta = [];
  50781. ecModel.eachRawSeries(function (seriesModel) {
  50782. var coordSys = seriesModel.coordinateSystem;
  50783. if (coordSys && (coordSys.type === 'cartesian2d' || coordSys.type === 'polar')) {
  50784. var baseAxis = coordSys.getBaseAxis();
  50785. if (baseAxis.type === 'category') {
  50786. var key = baseAxis.dim + '_' + baseAxis.index;
  50787. if (!seriesGroupByCategoryAxis[key]) {
  50788. seriesGroupByCategoryAxis[key] = {
  50789. categoryAxis: baseAxis,
  50790. valueAxis: coordSys.getOtherAxis(baseAxis),
  50791. series: []
  50792. };
  50793. meta.push({
  50794. axisDim: baseAxis.dim,
  50795. axisIndex: baseAxis.index
  50796. });
  50797. }
  50798. seriesGroupByCategoryAxis[key].series.push(seriesModel);
  50799. }
  50800. else {
  50801. otherSeries.push(seriesModel);
  50802. }
  50803. }
  50804. else {
  50805. otherSeries.push(seriesModel);
  50806. }
  50807. });
  50808. return {
  50809. seriesGroupByCategoryAxis: seriesGroupByCategoryAxis,
  50810. other: otherSeries,
  50811. meta: meta
  50812. };
  50813. }
  50814. /**
  50815. * Assemble content of series on cateogory axis
  50816. * @param {Array.<module:echarts/model/Series>} series
  50817. * @return {string}
  50818. * @inner
  50819. */
  50820. function assembleSeriesWithCategoryAxis(series) {
  50821. var tables = [];
  50822. zrUtil.each(series, function (group, key) {
  50823. var categoryAxis = group.categoryAxis;
  50824. var valueAxis = group.valueAxis;
  50825. var valueAxisDim = valueAxis.dim;
  50826. var headers = [' '].concat(zrUtil.map(group.series, function (series) {
  50827. return series.name;
  50828. }));
  50829. var columns = [categoryAxis.model.getCategories()];
  50830. zrUtil.each(group.series, function (series) {
  50831. columns.push(series.getRawData().mapArray(valueAxisDim, function (val) {
  50832. return val;
  50833. }));
  50834. });
  50835. // Assemble table content
  50836. var lines = [headers.join(ITEM_SPLITER)];
  50837. for (var i = 0; i < columns[0].length; i++) {
  50838. var items = [];
  50839. for (var j = 0; j < columns.length; j++) {
  50840. items.push(columns[j][i]);
  50841. }
  50842. lines.push(items.join(ITEM_SPLITER));
  50843. }
  50844. tables.push(lines.join('\n'));
  50845. });
  50846. return tables.join('\n\n' + BLOCK_SPLITER + '\n\n');
  50847. }
  50848. /**
  50849. * Assemble content of other series
  50850. * @param {Array.<module:echarts/model/Series>} series
  50851. * @return {string}
  50852. * @inner
  50853. */
  50854. function assembleOtherSeries(series) {
  50855. return zrUtil.map(series, function (series) {
  50856. var data = series.getRawData();
  50857. var lines = [series.name];
  50858. var vals = [];
  50859. data.each(data.dimensions, function () {
  50860. var argLen = arguments.length;
  50861. var dataIndex = arguments[argLen - 1];
  50862. var name = data.getName(dataIndex);
  50863. for (var i = 0; i < argLen - 1; i++) {
  50864. vals[i] = arguments[i];
  50865. }
  50866. lines.push((name ? (name + ITEM_SPLITER) : '') + vals.join(ITEM_SPLITER));
  50867. });
  50868. return lines.join('\n');
  50869. }).join('\n\n' + BLOCK_SPLITER + '\n\n');
  50870. }
  50871. /**
  50872. * @param {module:echarts/model/Global}
  50873. * @return {string}
  50874. * @inner
  50875. */
  50876. function getContentFromModel(ecModel) {
  50877. var result = groupSeries(ecModel);
  50878. return {
  50879. value: zrUtil.filter([
  50880. assembleSeriesWithCategoryAxis(result.seriesGroupByCategoryAxis),
  50881. assembleOtherSeries(result.other)
  50882. ], function (str) {
  50883. return str.replace(/[\n\t\s]/g, '');
  50884. }).join('\n\n' + BLOCK_SPLITER + '\n\n'),
  50885. meta: result.meta
  50886. };
  50887. }
  50888. function trim(str) {
  50889. return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
  50890. }
  50891. /**
  50892. * If a block is tsv format
  50893. */
  50894. function isTSVFormat(block) {
  50895. // Simple method to find out if a block is tsv format
  50896. var firstLine = block.slice(0, block.indexOf('\n'));
  50897. if (firstLine.indexOf(ITEM_SPLITER) >= 0) {
  50898. return true;
  50899. }
  50900. }
  50901. var itemSplitRegex = new RegExp('[' + ITEM_SPLITER + ']+', 'g');
  50902. /**
  50903. * @param {string} tsv
  50904. * @return {Array.<Object>}
  50905. */
  50906. function parseTSVContents(tsv) {
  50907. var tsvLines = tsv.split(/\n+/g);
  50908. var headers = trim(tsvLines.shift()).split(itemSplitRegex);
  50909. var categories = [];
  50910. var series = zrUtil.map(headers, function (header) {
  50911. return {
  50912. name: header,
  50913. data: []
  50914. };
  50915. });
  50916. for (var i = 0; i < tsvLines.length; i++) {
  50917. var items = trim(tsvLines[i]).split(itemSplitRegex);
  50918. categories.push(items.shift());
  50919. for (var j = 0; j < items.length; j++) {
  50920. series[j] && (series[j].data[i] = items[j]);
  50921. }
  50922. }
  50923. return {
  50924. series: series,
  50925. categories: categories
  50926. };
  50927. }
  50928. /**
  50929. * @param {string} str
  50930. * @return {Array.<Object>}
  50931. * @inner
  50932. */
  50933. function parseListContents(str) {
  50934. var lines = str.split(/\n+/g);
  50935. var seriesName = trim(lines.shift());
  50936. var data = [];
  50937. for (var i = 0; i < lines.length; i++) {
  50938. var items = trim(lines[i]).split(itemSplitRegex);
  50939. var name = '';
  50940. var value;
  50941. var hasName = false;
  50942. if (isNaN(items[0])) { // First item is name
  50943. hasName = true;
  50944. name = items[0];
  50945. items = items.slice(1);
  50946. data[i] = {
  50947. name: name,
  50948. value: []
  50949. };
  50950. value = data[i].value;
  50951. }
  50952. else {
  50953. value = data[i] = [];
  50954. }
  50955. for (var j = 0; j < items.length; j++) {
  50956. value.push(+items[j]);
  50957. }
  50958. if (value.length === 1) {
  50959. hasName ? (data[i].value = value[0]) : (data[i] = value[0]);
  50960. }
  50961. }
  50962. return {
  50963. name: seriesName,
  50964. data: data
  50965. };
  50966. }
  50967. /**
  50968. * @param {string} str
  50969. * @param {Array.<Object>} blockMetaList
  50970. * @return {Object}
  50971. * @inner
  50972. */
  50973. function parseContents(str, blockMetaList) {
  50974. var blocks = str.split(new RegExp('\n*' + BLOCK_SPLITER + '\n*', 'g'));
  50975. var newOption = {
  50976. series: []
  50977. };
  50978. zrUtil.each(blocks, function (block, idx) {
  50979. if (isTSVFormat(block)) {
  50980. var result = parseTSVContents(block);
  50981. var blockMeta = blockMetaList[idx];
  50982. var axisKey = blockMeta.axisDim + 'Axis';
  50983. if (blockMeta) {
  50984. newOption[axisKey] = newOption[axisKey] || [];
  50985. newOption[axisKey][blockMeta.axisIndex] = {
  50986. data: result.categories
  50987. };
  50988. newOption.series = newOption.series.concat(result.series);
  50989. }
  50990. }
  50991. else {
  50992. var result = parseListContents(block);
  50993. newOption.series.push(result);
  50994. }
  50995. });
  50996. return newOption;
  50997. }
  50998. /**
  50999. * @alias {module:echarts/component/toolbox/feature/DataView}
  51000. * @constructor
  51001. * @param {module:echarts/model/Model} model
  51002. */
  51003. function DataView(model) {
  51004. this._dom = null;
  51005. this.model = model;
  51006. }
  51007. DataView.defaultOption = {
  51008. show: true,
  51009. readOnly: false,
  51010. optionToContent: null,
  51011. contentToOption: null,
  51012. 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',
  51013. title: '数据视图',
  51014. lang: ['数据视图', '关闭', '刷新'],
  51015. backgroundColor: '#fff',
  51016. textColor: '#000',
  51017. textareaColor: '#fff',
  51018. textareaBorderColor: '#333',
  51019. buttonColor: '#c23531',
  51020. buttonTextColor: '#fff'
  51021. };
  51022. DataView.prototype.onclick = function (ecModel, api) {
  51023. var container = api.getDom();
  51024. var model = this.model;
  51025. if (this._dom) {
  51026. container.removeChild(this._dom);
  51027. }
  51028. var root = document.createElement('div');
  51029. root.style.cssText = 'position:absolute;left:5px;top:5px;bottom:5px;right:5px;';
  51030. root.style.backgroundColor = model.get('backgroundColor') || '#fff';
  51031. // Create elements
  51032. var header = document.createElement('h4');
  51033. var lang = model.get('lang') || [];
  51034. header.innerHTML = lang[0] || model.get('title');
  51035. header.style.cssText = 'margin: 10px 20px;';
  51036. header.style.color = model.get('textColor');
  51037. var viewMain = document.createElement('div');
  51038. var textarea = document.createElement('textarea');
  51039. viewMain.style.cssText = 'display:block;width:100%;overflow:hidden;';
  51040. var optionToContent = model.get('optionToContent');
  51041. var contentToOption = model.get('contentToOption');
  51042. var result = getContentFromModel(ecModel);
  51043. if (typeof optionToContent === 'function') {
  51044. var htmlOrDom = optionToContent(api.getOption());
  51045. if (typeof htmlOrDom === 'string') {
  51046. viewMain.innerHTML = htmlOrDom;
  51047. }
  51048. else if (zrUtil.isDom(htmlOrDom)) {
  51049. viewMain.appendChild(htmlOrDom);
  51050. }
  51051. }
  51052. else {
  51053. // Use default textarea
  51054. viewMain.appendChild(textarea);
  51055. textarea.readOnly = model.get('readOnly');
  51056. textarea.style.cssText = 'width:100%;height:100%;font-family:monospace;font-size:14px;line-height:1.6rem;';
  51057. textarea.style.color = model.get('textColor');
  51058. textarea.style.borderColor = model.get('textareaBorderColor');
  51059. textarea.style.backgroundColor = model.get('textareaColor');
  51060. textarea.value = result.value;
  51061. }
  51062. var blockMetaList = result.meta;
  51063. var buttonContainer = document.createElement('div');
  51064. buttonContainer.style.cssText = 'position:absolute;bottom:0;left:0;right:0;';
  51065. var buttonStyle = 'float:right;margin-right:20px;border:none;'
  51066. + 'cursor:pointer;padding:2px 5px;font-size:12px;border-radius:3px';
  51067. var closeButton = document.createElement('div');
  51068. var refreshButton = document.createElement('div');
  51069. buttonStyle += ';background-color:' + model.get('buttonColor');
  51070. buttonStyle += ';color:' + model.get('buttonTextColor');
  51071. var self = this;
  51072. function close() {
  51073. container.removeChild(root);
  51074. self._dom = null;
  51075. }
  51076. eventTool.addEventListener(closeButton, 'click', close);
  51077. eventTool.addEventListener(refreshButton, 'click', function () {
  51078. var newOption;
  51079. try {
  51080. if (typeof contentToOption === 'function') {
  51081. newOption = contentToOption(viewMain, api.getOption());
  51082. }
  51083. else {
  51084. newOption = parseContents(textarea.value, blockMetaList);
  51085. }
  51086. }
  51087. catch (e) {
  51088. close();
  51089. throw new Error('Data view format error ' + e);
  51090. }
  51091. if (newOption) {
  51092. api.dispatchAction({
  51093. type: 'changeDataView',
  51094. newOption: newOption
  51095. });
  51096. }
  51097. close();
  51098. });
  51099. closeButton.innerHTML = lang[1];
  51100. refreshButton.innerHTML = lang[2];
  51101. refreshButton.style.cssText = buttonStyle;
  51102. closeButton.style.cssText = buttonStyle;
  51103. !model.get('readOnly') && buttonContainer.appendChild(refreshButton);
  51104. buttonContainer.appendChild(closeButton);
  51105. // http://stackoverflow.com/questions/6637341/use-tab-to-indent-in-textarea
  51106. eventTool.addEventListener(textarea, 'keydown', function (e) {
  51107. if ((e.keyCode || e.which) === 9) {
  51108. // get caret position/selection
  51109. var val = this.value;
  51110. var start = this.selectionStart;
  51111. var end = this.selectionEnd;
  51112. // set textarea value to: text before caret + tab + text after caret
  51113. this.value = val.substring(0, start) + ITEM_SPLITER + val.substring(end);
  51114. // put caret at right position again
  51115. this.selectionStart = this.selectionEnd = start + 1;
  51116. // prevent the focus lose
  51117. eventTool.stop(e);
  51118. }
  51119. });
  51120. root.appendChild(header);
  51121. root.appendChild(viewMain);
  51122. root.appendChild(buttonContainer);
  51123. viewMain.style.height = (container.clientHeight - 80) + 'px';
  51124. container.appendChild(root);
  51125. this._dom = root;
  51126. };
  51127. DataView.prototype.remove = function (ecModel, api) {
  51128. this._dom && api.getDom().removeChild(this._dom);
  51129. };
  51130. DataView.prototype.dispose = function (ecModel, api) {
  51131. this.remove(ecModel, api);
  51132. };
  51133. /**
  51134. * @inner
  51135. */
  51136. function tryMergeDataOption(newData, originalData) {
  51137. return zrUtil.map(newData, function (newVal, idx) {
  51138. var original = originalData && originalData[idx];
  51139. if (zrUtil.isObject(original) && !zrUtil.isArray(original)) {
  51140. if (zrUtil.isObject(newVal) && !zrUtil.isArray(newVal)) {
  51141. newVal = newVal.value;
  51142. }
  51143. // Original data has option
  51144. return zrUtil.defaults({
  51145. value: newVal
  51146. }, original);
  51147. }
  51148. else {
  51149. return newVal;
  51150. }
  51151. });
  51152. }
  51153. __webpack_require__(314).register('dataView', DataView);
  51154. __webpack_require__(1).registerAction({
  51155. type: 'changeDataView',
  51156. event: 'dataViewChanged',
  51157. update: 'prepareAndUpdate'
  51158. }, function (payload, ecModel) {
  51159. var newSeriesOptList = [];
  51160. zrUtil.each(payload.newOption.series, function (seriesOpt) {
  51161. var seriesModel = ecModel.getSeriesByName(seriesOpt.name)[0];
  51162. if (!seriesModel) {
  51163. // New created series
  51164. // Geuss the series type
  51165. newSeriesOptList.push(zrUtil.extend({
  51166. // Default is scatter
  51167. type: 'scatter'
  51168. }, seriesOpt));
  51169. }
  51170. else {
  51171. var originalData = seriesModel.get('data');
  51172. newSeriesOptList.push({
  51173. name: seriesOpt.name,
  51174. data: tryMergeDataOption(seriesOpt.data, originalData)
  51175. });
  51176. }
  51177. });
  51178. ecModel.mergeOption(zrUtil.defaults({
  51179. series: newSeriesOptList
  51180. }, payload.newOption));
  51181. });
  51182. module.exports = DataView;
  51183. /***/ },
  51184. /* 372 */
  51185. /***/ function(module, exports, __webpack_require__) {
  51186. 'use strict';
  51187. var zrUtil = __webpack_require__(4);
  51188. var BrushController = __webpack_require__(233);
  51189. var brushHelper = __webpack_require__(309);
  51190. var history = __webpack_require__(373);
  51191. var each = zrUtil.each;
  51192. // Use dataZoomSelect
  51193. __webpack_require__(374);
  51194. // Spectial component id start with \0ec\0, see echarts/model/Global.js~hasInnerId
  51195. var DATA_ZOOM_ID_BASE = '\0_ec_\0toolbox-dataZoom_';
  51196. function DataZoom(model, ecModel, api) {
  51197. /**
  51198. * @private
  51199. * @type {module:echarts/component/helper/BrushController}
  51200. */
  51201. (this._brushController = new BrushController(api.getZr()))
  51202. .on('brush', zrUtil.bind(this._onBrush, this))
  51203. .mount();
  51204. /**
  51205. * @private
  51206. * @type {boolean}
  51207. */
  51208. this._isZoomActive;
  51209. }
  51210. DataZoom.defaultOption = {
  51211. show: true,
  51212. // Icon group
  51213. icon: {
  51214. zoom: 'M0,13.5h26.9 M13.5,26.9V0 M32.1,13.5H58V58H13.5 V32.1',
  51215. back: 'M22,1.4L9.9,13.5l12.3,12.3 M10.3,13.5H54.9v44.6 H10.3v-26'
  51216. },
  51217. title: {
  51218. zoom: '区域缩放',
  51219. back: '区域缩放还原'
  51220. }
  51221. };
  51222. var proto = DataZoom.prototype;
  51223. proto.render = function (featureModel, ecModel, api, payload) {
  51224. this.model = featureModel;
  51225. this.ecModel = ecModel;
  51226. this.api = api;
  51227. updateZoomBtnStatus(featureModel, ecModel, this, payload);
  51228. updateBackBtnStatus(featureModel, ecModel);
  51229. };
  51230. proto.onclick = function (ecModel, api, type) {
  51231. handlers[type].call(this);
  51232. };
  51233. proto.remove = function (ecModel, api) {
  51234. this._brushController.unmount();
  51235. };
  51236. proto.dispose = function (ecModel, api) {
  51237. this._brushController.dispose();
  51238. };
  51239. /**
  51240. * @private
  51241. */
  51242. var handlers = {
  51243. zoom: function () {
  51244. var nextActive = !this._isZoomActive;
  51245. this.api.dispatchAction({
  51246. type: 'takeGlobalCursor',
  51247. key: 'dataZoomSelect',
  51248. dataZoomSelectActive: nextActive
  51249. });
  51250. },
  51251. back: function () {
  51252. this._dispatchZoomAction(history.pop(this.ecModel));
  51253. }
  51254. };
  51255. /**
  51256. * @private
  51257. */
  51258. proto._onBrush = function (areas, opt) {
  51259. if (!opt.isEnd || !areas.length) {
  51260. return;
  51261. }
  51262. var snapshot = {};
  51263. var ecModel = this.ecModel;
  51264. this._brushController.updateCovers([]); // remove cover
  51265. var coordInfoList = brushHelper.makeCoordInfoList(
  51266. retrieveAxisSetting(this.model.option), ecModel
  51267. );
  51268. var rangesCoordInfoList = [];
  51269. brushHelper.parseOutputRanges(areas, coordInfoList, ecModel, rangesCoordInfoList);
  51270. var area = areas[0]; // dataZoom can not multiple area.
  51271. var coordInfo = rangesCoordInfoList[0];
  51272. var coordRange = area.coordRange;
  51273. var brushType = area.brushType;
  51274. if (coordInfo && coordRange) {
  51275. if (brushType === 'rect') {
  51276. setBatch('xAxis', coordRange[0], coordInfo);
  51277. setBatch('yAxis', coordRange[1], coordInfo);
  51278. }
  51279. else {
  51280. var axisNames = {lineX: 'xAxis', lineY: 'yAxis'};
  51281. setBatch(axisNames[brushType], coordRange, coordInfo);
  51282. }
  51283. }
  51284. history.push(ecModel, snapshot);
  51285. this._dispatchZoomAction(snapshot);
  51286. function setBatch(axisName, minMax, coordInfo) {
  51287. var dataZoomModel = findDataZoom(axisName, coordInfo[axisName], ecModel);
  51288. if (dataZoomModel) {
  51289. snapshot[dataZoomModel.id] = {
  51290. dataZoomId: dataZoomModel.id,
  51291. startValue: minMax[0],
  51292. endValue: minMax[1]
  51293. };
  51294. }
  51295. }
  51296. function findDataZoom(axisName, axisModel, ecModel) {
  51297. var dataZoomModel;
  51298. ecModel.eachComponent(
  51299. {mainType: 'dataZoom', subType: 'select'},
  51300. function (dzModel, dataZoomIndex) {
  51301. var axisIndex = dzModel.get(axisName + 'Index');
  51302. if (axisIndex != null
  51303. && ecModel.getComponent(axisName, axisIndex) === axisModel
  51304. ) {
  51305. dataZoomModel = dzModel;
  51306. }
  51307. }
  51308. );
  51309. return dataZoomModel;
  51310. }
  51311. };
  51312. /**
  51313. * @private
  51314. */
  51315. proto._dispatchZoomAction = function (snapshot) {
  51316. var batch = [];
  51317. // Convert from hash map to array.
  51318. each(snapshot, function (batchItem, dataZoomId) {
  51319. batch.push(zrUtil.clone(batchItem));
  51320. });
  51321. batch.length && this.api.dispatchAction({
  51322. type: 'dataZoom',
  51323. from: this.uid,
  51324. batch: batch
  51325. });
  51326. };
  51327. function retrieveAxisSetting(option) {
  51328. var setting = {};
  51329. // Compatible with previous setting: null => all axis, false => no axis.
  51330. zrUtil.each(['xAxisIndex', 'yAxisIndex'], function (name) {
  51331. setting[name] = option[name];
  51332. setting[name] == null && (setting[name] = 'all');
  51333. (setting[name] === false || setting[name] === 'none') && (setting[name] = []);
  51334. });
  51335. return setting;
  51336. }
  51337. function updateBackBtnStatus(featureModel, ecModel) {
  51338. featureModel.setIconStatus(
  51339. 'back',
  51340. history.count(ecModel) > 1 ? 'emphasis' : 'normal'
  51341. );
  51342. }
  51343. function updateZoomBtnStatus(featureModel, ecModel, view, payload) {
  51344. var zoomActive = view._isZoomActive;
  51345. if (payload && payload.type === 'takeGlobalCursor') {
  51346. zoomActive = payload.key === 'dataZoomSelect'
  51347. ? payload.dataZoomSelectActive : false;
  51348. }
  51349. view._isZoomActive = zoomActive;
  51350. featureModel.setIconStatus('zoom', zoomActive ? 'emphasis' : 'normal');
  51351. var coordInfoList = brushHelper.makeCoordInfoList(
  51352. retrieveAxisSetting(featureModel.option), ecModel
  51353. );
  51354. var brushType = (coordInfoList.xAxisHas && !coordInfoList.yAxisHas)
  51355. ? 'lineX'
  51356. : (!coordInfoList.xAxisHas && coordInfoList.yAxisHas)
  51357. ? 'lineY'
  51358. : 'rect';
  51359. view._brushController
  51360. .setPanels(brushHelper.makePanelOpts(coordInfoList))
  51361. .enableBrush(
  51362. zoomActive
  51363. ? {
  51364. brushType: brushType,
  51365. brushStyle: { // FIXME user customized?
  51366. lineWidth: 0,
  51367. // stroke: '#333',
  51368. fill: 'rgba(0,0,0,0.2)'
  51369. }
  51370. }
  51371. : false
  51372. );
  51373. }
  51374. __webpack_require__(314).register('dataZoom', DataZoom);
  51375. // Create special dataZoom option for select
  51376. __webpack_require__(1).registerPreprocessor(function (option) {
  51377. if (!option) {
  51378. return;
  51379. }
  51380. var dataZoomOpts = option.dataZoom || (option.dataZoom = []);
  51381. if (!zrUtil.isArray(dataZoomOpts)) {
  51382. option.dataZoom = dataZoomOpts = [dataZoomOpts];
  51383. }
  51384. var toolboxOpt = option.toolbox;
  51385. if (toolboxOpt) {
  51386. // Assume there is only one toolbox
  51387. if (zrUtil.isArray(toolboxOpt)) {
  51388. toolboxOpt = toolboxOpt[0];
  51389. }
  51390. if (toolboxOpt && toolboxOpt.feature) {
  51391. var dataZoomOpt = toolboxOpt.feature.dataZoom;
  51392. addForAxis('xAxis', dataZoomOpt);
  51393. addForAxis('yAxis', dataZoomOpt);
  51394. }
  51395. }
  51396. function addForAxis(axisName, dataZoomOpt) {
  51397. if (!dataZoomOpt) {
  51398. return;
  51399. }
  51400. // Try not to modify model, because it is not merged yet.
  51401. var axisIndicesName = axisName + 'Index';
  51402. var givenAxisIndices = dataZoomOpt[axisIndicesName];
  51403. if (givenAxisIndices != null
  51404. && givenAxisIndices != 'all'
  51405. && !zrUtil.isArray(givenAxisIndices)
  51406. ) {
  51407. givenAxisIndices = (givenAxisIndices === false || givenAxisIndices === 'none') ? [] : [givenAxisIndices];
  51408. }
  51409. forEachComponent(axisName, function (axisOpt, axisIndex) {
  51410. if (givenAxisIndices != null
  51411. && givenAxisIndices != 'all'
  51412. && zrUtil.indexOf(givenAxisIndices, axisIndex) === -1
  51413. ) {
  51414. return;
  51415. }
  51416. var newOpt = {
  51417. type: 'select',
  51418. $fromToolbox: true,
  51419. // Id for merge mapping.
  51420. id: DATA_ZOOM_ID_BASE + axisName + axisIndex
  51421. };
  51422. // FIXME
  51423. // Only support one axis now.
  51424. newOpt[axisIndicesName] = axisIndex;
  51425. dataZoomOpts.push(newOpt);
  51426. });
  51427. }
  51428. function forEachComponent(mainType, cb) {
  51429. var opts = option[mainType];
  51430. if (!zrUtil.isArray(opts)) {
  51431. opts = opts ? [opts] : [];
  51432. }
  51433. each(opts, cb);
  51434. }
  51435. });
  51436. module.exports = DataZoom;
  51437. /***/ },
  51438. /* 373 */
  51439. /***/ function(module, exports, __webpack_require__) {
  51440. /**
  51441. * @file History manager.
  51442. */
  51443. var zrUtil = __webpack_require__(4);
  51444. var each = zrUtil.each;
  51445. var ATTR = '\0_ec_hist_store';
  51446. var history = {
  51447. /**
  51448. * @public
  51449. * @param {module:echarts/model/Global} ecModel
  51450. * @param {Object} newSnapshot {dataZoomId, batch: [payloadInfo, ...]}
  51451. */
  51452. push: function (ecModel, newSnapshot) {
  51453. var store = giveStore(ecModel);
  51454. // If previous dataZoom can not be found,
  51455. // complete an range with current range.
  51456. each(newSnapshot, function (batchItem, dataZoomId) {
  51457. var i = store.length - 1;
  51458. for (; i >= 0; i--) {
  51459. var snapshot = store[i];
  51460. if (snapshot[dataZoomId]) {
  51461. break;
  51462. }
  51463. }
  51464. if (i < 0) {
  51465. // No origin range set, create one by current range.
  51466. var dataZoomModel = ecModel.queryComponents(
  51467. {mainType: 'dataZoom', subType: 'select', id: dataZoomId}
  51468. )[0];
  51469. if (dataZoomModel) {
  51470. var percentRange = dataZoomModel.getPercentRange();
  51471. store[0][dataZoomId] = {
  51472. dataZoomId: dataZoomId,
  51473. start: percentRange[0],
  51474. end: percentRange[1]
  51475. };
  51476. }
  51477. }
  51478. });
  51479. store.push(newSnapshot);
  51480. },
  51481. /**
  51482. * @public
  51483. * @param {module:echarts/model/Global} ecModel
  51484. * @return {Object} snapshot
  51485. */
  51486. pop: function (ecModel) {
  51487. var store = giveStore(ecModel);
  51488. var head = store[store.length - 1];
  51489. store.length > 1 && store.pop();
  51490. // Find top for all dataZoom.
  51491. var snapshot = {};
  51492. each(head, function (batchItem, dataZoomId) {
  51493. for (var i = store.length - 1; i >= 0; i--) {
  51494. var batchItem = store[i][dataZoomId];
  51495. if (batchItem) {
  51496. snapshot[dataZoomId] = batchItem;
  51497. break;
  51498. }
  51499. }
  51500. });
  51501. return snapshot;
  51502. },
  51503. /**
  51504. * @public
  51505. */
  51506. clear: function (ecModel) {
  51507. ecModel[ATTR] = null;
  51508. },
  51509. /**
  51510. * @public
  51511. * @param {module:echarts/model/Global} ecModel
  51512. * @return {number} records. always >= 1.
  51513. */
  51514. count: function (ecModel) {
  51515. return giveStore(ecModel).length;
  51516. }
  51517. };
  51518. /**
  51519. * [{key: dataZoomId, value: {dataZoomId, range}}, ...]
  51520. * History length of each dataZoom may be different.
  51521. * this._history[0] is used to store origin range.
  51522. * @type {Array.<Object>}
  51523. */
  51524. function giveStore(ecModel) {
  51525. var store = ecModel[ATTR];
  51526. if (!store) {
  51527. store = ecModel[ATTR] = [{}];
  51528. }
  51529. return store;
  51530. }
  51531. module.exports = history;
  51532. /***/ },
  51533. /* 374 */
  51534. /***/ function(module, exports, __webpack_require__) {
  51535. /**
  51536. * DataZoom component entry
  51537. */
  51538. __webpack_require__(317);
  51539. __webpack_require__(318);
  51540. __webpack_require__(320);
  51541. __webpack_require__(375);
  51542. __webpack_require__(376);
  51543. __webpack_require__(327);
  51544. __webpack_require__(328);
  51545. /***/ },
  51546. /* 375 */
  51547. /***/ function(module, exports, __webpack_require__) {
  51548. /**
  51549. * @file Data zoom model
  51550. */
  51551. var DataZoomModel = __webpack_require__(318);
  51552. module.exports = DataZoomModel.extend({
  51553. type: 'dataZoom.select'
  51554. });
  51555. /***/ },
  51556. /* 376 */
  51557. /***/ function(module, exports, __webpack_require__) {
  51558. module.exports = __webpack_require__(320).extend({
  51559. type: 'dataZoom.select'
  51560. });
  51561. /***/ },
  51562. /* 377 */
  51563. /***/ function(module, exports, __webpack_require__) {
  51564. 'use strict';
  51565. var history = __webpack_require__(373);
  51566. function Restore(model) {
  51567. this.model = model;
  51568. }
  51569. Restore.defaultOption = {
  51570. show: true,
  51571. 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',
  51572. title: '还原'
  51573. };
  51574. var proto = Restore.prototype;
  51575. proto.onclick = function (ecModel, api, type) {
  51576. history.clear(ecModel);
  51577. api.dispatchAction({
  51578. type: 'restore',
  51579. from: this.uid
  51580. });
  51581. };
  51582. __webpack_require__(314).register('restore', Restore);
  51583. __webpack_require__(1).registerAction(
  51584. {type: 'restore', event: 'restore', update: 'prepareAndUpdate'},
  51585. function (payload, ecModel) {
  51586. ecModel.resetOption('recreate');
  51587. }
  51588. );
  51589. module.exports = Restore;
  51590. /***/ },
  51591. /* 378 */
  51592. /***/ function(module, exports, __webpack_require__) {
  51593. __webpack_require__(379);
  51594. __webpack_require__(81).registerPainter('vml', __webpack_require__(381));
  51595. /***/ },
  51596. /* 379 */
  51597. /***/ function(module, exports, __webpack_require__) {
  51598. // http://www.w3.org/TR/NOTE-VML
  51599. // TODO Use proxy like svg instead of overwrite brush methods
  51600. if (!__webpack_require__(2).canvasSupported) {
  51601. var vec2 = __webpack_require__(10);
  51602. var BoundingRect = __webpack_require__(9);
  51603. var CMD = __webpack_require__(49).CMD;
  51604. var colorTool = __webpack_require__(39);
  51605. var textContain = __webpack_require__(8);
  51606. var RectText = __webpack_require__(48);
  51607. var Displayable = __webpack_require__(46);
  51608. var ZImage = __webpack_require__(62);
  51609. var Text = __webpack_require__(64);
  51610. var Path = __webpack_require__(45);
  51611. var Gradient = __webpack_require__(61);
  51612. var vmlCore = __webpack_require__(380);
  51613. var round = Math.round;
  51614. var sqrt = Math.sqrt;
  51615. var abs = Math.abs;
  51616. var cos = Math.cos;
  51617. var sin = Math.sin;
  51618. var mathMax = Math.max;
  51619. var applyTransform = vec2.applyTransform;
  51620. var comma = ',';
  51621. var imageTransformPrefix = 'progid:DXImageTransform.Microsoft';
  51622. var Z = 21600;
  51623. var Z2 = Z / 2;
  51624. var ZLEVEL_BASE = 100000;
  51625. var Z_BASE = 1000;
  51626. var initRootElStyle = function (el) {
  51627. el.style.cssText = 'position:absolute;left:0;top:0;width:1px;height:1px;';
  51628. el.coordsize = Z + ',' + Z;
  51629. el.coordorigin = '0,0';
  51630. };
  51631. var encodeHtmlAttribute = function (s) {
  51632. return String(s).replace(/&/g, '&amp;').replace(/"/g, '&quot;');
  51633. };
  51634. var rgb2Str = function (r, g, b) {
  51635. return 'rgb(' + [r, g, b].join(',') + ')';
  51636. };
  51637. var append = function (parent, child) {
  51638. if (child && parent && child.parentNode !== parent) {
  51639. parent.appendChild(child);
  51640. }
  51641. };
  51642. var remove = function (parent, child) {
  51643. if (child && parent && child.parentNode === parent) {
  51644. parent.removeChild(child);
  51645. }
  51646. };
  51647. var getZIndex = function (zlevel, z, z2) {
  51648. // z 的取值范围为 [0, 1000]
  51649. return (parseFloat(zlevel) || 0) * ZLEVEL_BASE + (parseFloat(z) || 0) * Z_BASE + z2;
  51650. };
  51651. var parsePercent = function (value, maxValue) {
  51652. if (typeof value === 'string') {
  51653. if (value.lastIndexOf('%') >= 0) {
  51654. return parseFloat(value) / 100 * maxValue;
  51655. }
  51656. return parseFloat(value);
  51657. }
  51658. return value;
  51659. };
  51660. /***************************************************
  51661. * PATH
  51662. **************************************************/
  51663. var setColorAndOpacity = function (el, color, opacity) {
  51664. var colorArr = colorTool.parse(color);
  51665. opacity = +opacity;
  51666. if (isNaN(opacity)) {
  51667. opacity = 1;
  51668. }
  51669. if (colorArr) {
  51670. el.color = rgb2Str(colorArr[0], colorArr[1], colorArr[2]);
  51671. el.opacity = opacity * colorArr[3];
  51672. }
  51673. };
  51674. var getColorAndAlpha = function (color) {
  51675. var colorArr = colorTool.parse(color);
  51676. return [
  51677. rgb2Str(colorArr[0], colorArr[1], colorArr[2]),
  51678. colorArr[3]
  51679. ];
  51680. };
  51681. var updateFillNode = function (el, style, zrEl) {
  51682. // TODO pattern
  51683. var fill = style.fill;
  51684. if (fill != null) {
  51685. // Modified from excanvas
  51686. if (fill instanceof Gradient) {
  51687. var gradientType;
  51688. var angle = 0;
  51689. var focus = [0, 0];
  51690. // additional offset
  51691. var shift = 0;
  51692. // scale factor for offset
  51693. var expansion = 1;
  51694. var rect = zrEl.getBoundingRect();
  51695. var rectWidth = rect.width;
  51696. var rectHeight = rect.height;
  51697. if (fill.type === 'linear') {
  51698. gradientType = 'gradient';
  51699. var transform = zrEl.transform;
  51700. var p0 = [fill.x * rectWidth, fill.y * rectHeight];
  51701. var p1 = [fill.x2 * rectWidth, fill.y2 * rectHeight];
  51702. if (transform) {
  51703. applyTransform(p0, p0, transform);
  51704. applyTransform(p1, p1, transform);
  51705. }
  51706. var dx = p1[0] - p0[0];
  51707. var dy = p1[1] - p0[1];
  51708. angle = Math.atan2(dx, dy) * 180 / Math.PI;
  51709. // The angle should be a non-negative number.
  51710. if (angle < 0) {
  51711. angle += 360;
  51712. }
  51713. // Very small angles produce an unexpected result because they are
  51714. // converted to a scientific notation string.
  51715. if (angle < 1e-6) {
  51716. angle = 0;
  51717. }
  51718. }
  51719. else {
  51720. gradientType = 'gradientradial';
  51721. var p0 = [fill.x * rectWidth, fill.y * rectHeight];
  51722. var transform = zrEl.transform;
  51723. var scale = zrEl.scale;
  51724. var width = rectWidth;
  51725. var height = rectHeight;
  51726. focus = [
  51727. // Percent in bounding rect
  51728. (p0[0] - rect.x) / width,
  51729. (p0[1] - rect.y) / height
  51730. ];
  51731. if (transform) {
  51732. applyTransform(p0, p0, transform);
  51733. }
  51734. width /= scale[0] * Z;
  51735. height /= scale[1] * Z;
  51736. var dimension = mathMax(width, height);
  51737. shift = 2 * 0 / dimension;
  51738. expansion = 2 * fill.r / dimension - shift;
  51739. }
  51740. // We need to sort the color stops in ascending order by offset,
  51741. // otherwise IE won't interpret it correctly.
  51742. var stops = fill.colorStops.slice();
  51743. stops.sort(function(cs1, cs2) {
  51744. return cs1.offset - cs2.offset;
  51745. });
  51746. var length = stops.length;
  51747. // Color and alpha list of first and last stop
  51748. var colorAndAlphaList = [];
  51749. var colors = [];
  51750. for (var i = 0; i < length; i++) {
  51751. var stop = stops[i];
  51752. var colorAndAlpha = getColorAndAlpha(stop.color);
  51753. colors.push(stop.offset * expansion + shift + ' ' + colorAndAlpha[0]);
  51754. if (i === 0 || i === length - 1) {
  51755. colorAndAlphaList.push(colorAndAlpha);
  51756. }
  51757. }
  51758. if (length >= 2) {
  51759. var color1 = colorAndAlphaList[0][0];
  51760. var color2 = colorAndAlphaList[1][0];
  51761. var opacity1 = colorAndAlphaList[0][1] * style.opacity;
  51762. var opacity2 = colorAndAlphaList[1][1] * style.opacity;
  51763. el.type = gradientType;
  51764. el.method = 'none';
  51765. el.focus = '100%';
  51766. el.angle = angle;
  51767. el.color = color1;
  51768. el.color2 = color2;
  51769. el.colors = colors.join(',');
  51770. // When colors attribute is used, the meanings of opacity and o:opacity2
  51771. // are reversed.
  51772. el.opacity = opacity2;
  51773. // FIXME g_o_:opacity ?
  51774. el.opacity2 = opacity1;
  51775. }
  51776. if (gradientType === 'radial') {
  51777. el.focusposition = focus.join(',');
  51778. }
  51779. }
  51780. else {
  51781. // FIXME Change from Gradient fill to color fill
  51782. setColorAndOpacity(el, fill, style.opacity);
  51783. }
  51784. }
  51785. };
  51786. var updateStrokeNode = function (el, style) {
  51787. // if (style.lineJoin != null) {
  51788. // el.joinstyle = style.lineJoin;
  51789. // }
  51790. // if (style.miterLimit != null) {
  51791. // el.miterlimit = style.miterLimit * Z;
  51792. // }
  51793. // if (style.lineCap != null) {
  51794. // el.endcap = style.lineCap;
  51795. // }
  51796. if (style.lineDash != null) {
  51797. el.dashstyle = style.lineDash.join(' ');
  51798. }
  51799. if (style.stroke != null && !(style.stroke instanceof Gradient)) {
  51800. setColorAndOpacity(el, style.stroke, style.opacity);
  51801. }
  51802. };
  51803. var updateFillAndStroke = function (vmlEl, type, style, zrEl) {
  51804. var isFill = type == 'fill';
  51805. var el = vmlEl.getElementsByTagName(type)[0];
  51806. // Stroke must have lineWidth
  51807. if (style[type] != null && style[type] !== 'none' && (isFill || (!isFill && style.lineWidth))) {
  51808. vmlEl[isFill ? 'filled' : 'stroked'] = 'true';
  51809. // FIXME Remove before updating, or set `colors` will throw error
  51810. if (style[type] instanceof Gradient) {
  51811. remove(vmlEl, el);
  51812. }
  51813. if (!el) {
  51814. el = vmlCore.createNode(type);
  51815. }
  51816. isFill ? updateFillNode(el, style, zrEl) : updateStrokeNode(el, style);
  51817. append(vmlEl, el);
  51818. }
  51819. else {
  51820. vmlEl[isFill ? 'filled' : 'stroked'] = 'false';
  51821. remove(vmlEl, el);
  51822. }
  51823. };
  51824. var points = [[], [], []];
  51825. var pathDataToString = function (data, m) {
  51826. var M = CMD.M;
  51827. var C = CMD.C;
  51828. var L = CMD.L;
  51829. var A = CMD.A;
  51830. var Q = CMD.Q;
  51831. var str = [];
  51832. var nPoint;
  51833. var cmdStr;
  51834. var cmd;
  51835. var i;
  51836. var xi;
  51837. var yi;
  51838. for (i = 0; i < data.length;) {
  51839. cmd = data[i++];
  51840. cmdStr = '';
  51841. nPoint = 0;
  51842. switch (cmd) {
  51843. case M:
  51844. cmdStr = ' m ';
  51845. nPoint = 1;
  51846. xi = data[i++];
  51847. yi = data[i++];
  51848. points[0][0] = xi;
  51849. points[0][1] = yi;
  51850. break;
  51851. case L:
  51852. cmdStr = ' l ';
  51853. nPoint = 1;
  51854. xi = data[i++];
  51855. yi = data[i++];
  51856. points[0][0] = xi;
  51857. points[0][1] = yi;
  51858. break;
  51859. case Q:
  51860. case C:
  51861. cmdStr = ' c ';
  51862. nPoint = 3;
  51863. var x1 = data[i++];
  51864. var y1 = data[i++];
  51865. var x2 = data[i++];
  51866. var y2 = data[i++];
  51867. var x3;
  51868. var y3;
  51869. if (cmd === Q) {
  51870. // Convert quadratic to cubic using degree elevation
  51871. x3 = x2;
  51872. y3 = y2;
  51873. x2 = (x2 + 2 * x1) / 3;
  51874. y2 = (y2 + 2 * y1) / 3;
  51875. x1 = (xi + 2 * x1) / 3;
  51876. y1 = (yi + 2 * y1) / 3;
  51877. }
  51878. else {
  51879. x3 = data[i++];
  51880. y3 = data[i++];
  51881. }
  51882. points[0][0] = x1;
  51883. points[0][1] = y1;
  51884. points[1][0] = x2;
  51885. points[1][1] = y2;
  51886. points[2][0] = x3;
  51887. points[2][1] = y3;
  51888. xi = x3;
  51889. yi = y3;
  51890. break;
  51891. case A:
  51892. var x = 0;
  51893. var y = 0;
  51894. var sx = 1;
  51895. var sy = 1;
  51896. var angle = 0;
  51897. if (m) {
  51898. // Extract SRT from matrix
  51899. x = m[4];
  51900. y = m[5];
  51901. sx = sqrt(m[0] * m[0] + m[1] * m[1]);
  51902. sy = sqrt(m[2] * m[2] + m[3] * m[3]);
  51903. angle = Math.atan2(-m[1] / sy, m[0] / sx);
  51904. }
  51905. var cx = data[i++];
  51906. var cy = data[i++];
  51907. var rx = data[i++];
  51908. var ry = data[i++];
  51909. var startAngle = data[i++] + angle;
  51910. var endAngle = data[i++] + startAngle + angle;
  51911. // FIXME
  51912. // var psi = data[i++];
  51913. i++;
  51914. var clockwise = data[i++];
  51915. var x0 = cx + cos(startAngle) * rx;
  51916. var y0 = cy + sin(startAngle) * ry;
  51917. var x1 = cx + cos(endAngle) * rx;
  51918. var y1 = cy + sin(endAngle) * ry;
  51919. var type = clockwise ? ' wa ' : ' at ';
  51920. if (Math.abs(x0 - x1) < 1e-10) {
  51921. // IE won't render arches drawn counter clockwise if x0 == x1.
  51922. if (Math.abs(endAngle - startAngle) > 1e-2) {
  51923. // Offset x0 by 1/80 of a pixel. Use something
  51924. // that can be represented in binary
  51925. if (clockwise) {
  51926. x0 += 270 / Z;
  51927. }
  51928. }
  51929. else {
  51930. // Avoid case draw full circle
  51931. if (Math.abs(y0 - cy) < 1e-10) {
  51932. if ((clockwise && x0 < cx) || (!clockwise && x0 > cx)) {
  51933. y1 -= 270 / Z;
  51934. }
  51935. else {
  51936. y1 += 270 / Z;
  51937. }
  51938. }
  51939. else if ((clockwise && y0 < cy) || (!clockwise && y0 > cy)) {
  51940. x1 += 270 / Z;
  51941. }
  51942. else {
  51943. x1 -= 270 / Z;
  51944. }
  51945. }
  51946. }
  51947. str.push(
  51948. type,
  51949. round(((cx - rx) * sx + x) * Z - Z2), comma,
  51950. round(((cy - ry) * sy + y) * Z - Z2), comma,
  51951. round(((cx + rx) * sx + x) * Z - Z2), comma,
  51952. round(((cy + ry) * sy + y) * Z - Z2), comma,
  51953. round((x0 * sx + x) * Z - Z2), comma,
  51954. round((y0 * sy + y) * Z - Z2), comma,
  51955. round((x1 * sx + x) * Z - Z2), comma,
  51956. round((y1 * sy + y) * Z - Z2)
  51957. );
  51958. xi = x1;
  51959. yi = y1;
  51960. break;
  51961. case CMD.R:
  51962. var p0 = points[0];
  51963. var p1 = points[1];
  51964. // x0, y0
  51965. p0[0] = data[i++];
  51966. p0[1] = data[i++];
  51967. // x1, y1
  51968. p1[0] = p0[0] + data[i++];
  51969. p1[1] = p0[1] + data[i++];
  51970. if (m) {
  51971. applyTransform(p0, p0, m);
  51972. applyTransform(p1, p1, m);
  51973. }
  51974. p0[0] = round(p0[0] * Z - Z2);
  51975. p1[0] = round(p1[0] * Z - Z2);
  51976. p0[1] = round(p0[1] * Z - Z2);
  51977. p1[1] = round(p1[1] * Z - Z2);
  51978. str.push(
  51979. // x0, y0
  51980. ' m ', p0[0], comma, p0[1],
  51981. // x1, y0
  51982. ' l ', p1[0], comma, p0[1],
  51983. // x1, y1
  51984. ' l ', p1[0], comma, p1[1],
  51985. // x0, y1
  51986. ' l ', p0[0], comma, p1[1]
  51987. );
  51988. break;
  51989. case CMD.Z:
  51990. // FIXME Update xi, yi
  51991. str.push(' x ');
  51992. }
  51993. if (nPoint > 0) {
  51994. str.push(cmdStr);
  51995. for (var k = 0; k < nPoint; k++) {
  51996. var p = points[k];
  51997. m && applyTransform(p, p, m);
  51998. // 不 round 会非常慢
  51999. str.push(
  52000. round(p[0] * Z - Z2), comma, round(p[1] * Z - Z2),
  52001. k < nPoint - 1 ? comma : ''
  52002. );
  52003. }
  52004. }
  52005. }
  52006. return str.join('');
  52007. };
  52008. // Rewrite the original path method
  52009. Path.prototype.brushVML = function (vmlRoot) {
  52010. var style = this.style;
  52011. var vmlEl = this._vmlEl;
  52012. if (!vmlEl) {
  52013. vmlEl = vmlCore.createNode('shape');
  52014. initRootElStyle(vmlEl);
  52015. this._vmlEl = vmlEl;
  52016. }
  52017. updateFillAndStroke(vmlEl, 'fill', style, this);
  52018. updateFillAndStroke(vmlEl, 'stroke', style, this);
  52019. var m = this.transform;
  52020. var needTransform = m != null;
  52021. var strokeEl = vmlEl.getElementsByTagName('stroke')[0];
  52022. if (strokeEl) {
  52023. var lineWidth = style.lineWidth;
  52024. // Get the line scale.
  52025. // Determinant of this.m_ means how much the area is enlarged by the
  52026. // transformation. So its square root can be used as a scale factor
  52027. // for width.
  52028. if (needTransform && !style.strokeNoScale) {
  52029. var det = m[0] * m[3] - m[1] * m[2];
  52030. lineWidth *= sqrt(abs(det));
  52031. }
  52032. strokeEl.weight = lineWidth + 'px';
  52033. }
  52034. var path = this.path;
  52035. if (this.__dirtyPath) {
  52036. path.beginPath();
  52037. this.buildPath(path, this.shape);
  52038. path.toStatic();
  52039. this.__dirtyPath = false;
  52040. }
  52041. vmlEl.path = pathDataToString(path.data, this.transform);
  52042. vmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2);
  52043. // Append to root
  52044. append(vmlRoot, vmlEl);
  52045. // Text
  52046. if (style.text) {
  52047. this.drawRectText(vmlRoot, this.getBoundingRect());
  52048. }
  52049. else {
  52050. this.removeRectText(vmlRoot);
  52051. }
  52052. };
  52053. Path.prototype.onRemove = function (vmlRoot) {
  52054. remove(vmlRoot, this._vmlEl);
  52055. this.removeRectText(vmlRoot);
  52056. };
  52057. Path.prototype.onAdd = function (vmlRoot) {
  52058. append(vmlRoot, this._vmlEl);
  52059. this.appendRectText(vmlRoot);
  52060. };
  52061. /***************************************************
  52062. * IMAGE
  52063. **************************************************/
  52064. var isImage = function (img) {
  52065. // FIXME img instanceof Image 如果 img 是一个字符串的时候,IE8 下会报错
  52066. return (typeof img === 'object') && img.tagName && img.tagName.toUpperCase() === 'IMG';
  52067. // return img instanceof Image;
  52068. };
  52069. // Rewrite the original path method
  52070. ZImage.prototype.brushVML = function (vmlRoot) {
  52071. var style = this.style;
  52072. var image = style.image;
  52073. // Image original width, height
  52074. var ow;
  52075. var oh;
  52076. if (isImage(image)) {
  52077. var src = image.src;
  52078. if (src === this._imageSrc) {
  52079. ow = this._imageWidth;
  52080. oh = this._imageHeight;
  52081. }
  52082. else {
  52083. var imageRuntimeStyle = image.runtimeStyle;
  52084. var oldRuntimeWidth = imageRuntimeStyle.width;
  52085. var oldRuntimeHeight = imageRuntimeStyle.height;
  52086. imageRuntimeStyle.width = 'auto';
  52087. imageRuntimeStyle.height = 'auto';
  52088. // get the original size
  52089. ow = image.width;
  52090. oh = image.height;
  52091. // and remove overides
  52092. imageRuntimeStyle.width = oldRuntimeWidth;
  52093. imageRuntimeStyle.height = oldRuntimeHeight;
  52094. // Caching image original width, height and src
  52095. this._imageSrc = src;
  52096. this._imageWidth = ow;
  52097. this._imageHeight = oh;
  52098. }
  52099. image = src;
  52100. }
  52101. else {
  52102. if (image === this._imageSrc) {
  52103. ow = this._imageWidth;
  52104. oh = this._imageHeight;
  52105. }
  52106. }
  52107. if (!image) {
  52108. return;
  52109. }
  52110. var x = style.x || 0;
  52111. var y = style.y || 0;
  52112. var dw = style.width;
  52113. var dh = style.height;
  52114. var sw = style.sWidth;
  52115. var sh = style.sHeight;
  52116. var sx = style.sx || 0;
  52117. var sy = style.sy || 0;
  52118. var hasCrop = sw && sh;
  52119. var vmlEl = this._vmlEl;
  52120. if (!vmlEl) {
  52121. // FIXME 使用 group 在 left, top 都不是 0 的时候就无法显示了。
  52122. // vmlEl = vmlCore.createNode('group');
  52123. vmlEl = vmlCore.doc.createElement('div');
  52124. initRootElStyle(vmlEl);
  52125. this._vmlEl = vmlEl;
  52126. }
  52127. var vmlElStyle = vmlEl.style;
  52128. var hasRotation = false;
  52129. var m;
  52130. var scaleX = 1;
  52131. var scaleY = 1;
  52132. if (this.transform) {
  52133. m = this.transform;
  52134. scaleX = sqrt(m[0] * m[0] + m[1] * m[1]);
  52135. scaleY = sqrt(m[2] * m[2] + m[3] * m[3]);
  52136. hasRotation = m[1] || m[2];
  52137. }
  52138. if (hasRotation) {
  52139. // If filters are necessary (rotation exists), create them
  52140. // filters are bog-slow, so only create them if abbsolutely necessary
  52141. // The following check doesn't account for skews (which don't exist
  52142. // in the canvas spec (yet) anyway.
  52143. // From excanvas
  52144. var p0 = [x, y];
  52145. var p1 = [x + dw, y];
  52146. var p2 = [x, y + dh];
  52147. var p3 = [x + dw, y + dh];
  52148. applyTransform(p0, p0, m);
  52149. applyTransform(p1, p1, m);
  52150. applyTransform(p2, p2, m);
  52151. applyTransform(p3, p3, m);
  52152. var maxX = mathMax(p0[0], p1[0], p2[0], p3[0]);
  52153. var maxY = mathMax(p0[1], p1[1], p2[1], p3[1]);
  52154. var transformFilter = [];
  52155. transformFilter.push('M11=', m[0] / scaleX, comma,
  52156. 'M12=', m[2] / scaleY, comma,
  52157. 'M21=', m[1] / scaleX, comma,
  52158. 'M22=', m[3] / scaleY, comma,
  52159. 'Dx=', round(x * scaleX + m[4]), comma,
  52160. 'Dy=', round(y * scaleY + m[5]));
  52161. vmlElStyle.padding = '0 ' + round(maxX) + 'px ' + round(maxY) + 'px 0';
  52162. // FIXME DXImageTransform 在 IE11 的兼容模式下不起作用
  52163. vmlElStyle.filter = imageTransformPrefix + '.Matrix('
  52164. + transformFilter.join('') + ', SizingMethod=clip)';
  52165. }
  52166. else {
  52167. if (m) {
  52168. x = x * scaleX + m[4];
  52169. y = y * scaleY + m[5];
  52170. }
  52171. vmlElStyle.filter = '';
  52172. vmlElStyle.left = round(x) + 'px';
  52173. vmlElStyle.top = round(y) + 'px';
  52174. }
  52175. var imageEl = this._imageEl;
  52176. var cropEl = this._cropEl;
  52177. if (!imageEl) {
  52178. imageEl = vmlCore.doc.createElement('div');
  52179. this._imageEl = imageEl;
  52180. }
  52181. var imageELStyle = imageEl.style;
  52182. if (hasCrop) {
  52183. // Needs know image original width and height
  52184. if (! (ow && oh)) {
  52185. var tmpImage = new Image();
  52186. var self = this;
  52187. tmpImage.onload = function () {
  52188. tmpImage.onload = null;
  52189. ow = tmpImage.width;
  52190. oh = tmpImage.height;
  52191. // Adjust image width and height to fit the ratio destinationSize / sourceSize
  52192. imageELStyle.width = round(scaleX * ow * dw / sw) + 'px';
  52193. imageELStyle.height = round(scaleY * oh * dh / sh) + 'px';
  52194. // Caching image original width, height and src
  52195. self._imageWidth = ow;
  52196. self._imageHeight = oh;
  52197. self._imageSrc = image;
  52198. };
  52199. tmpImage.src = image;
  52200. }
  52201. else {
  52202. imageELStyle.width = round(scaleX * ow * dw / sw) + 'px';
  52203. imageELStyle.height = round(scaleY * oh * dh / sh) + 'px';
  52204. }
  52205. if (! cropEl) {
  52206. cropEl = vmlCore.doc.createElement('div');
  52207. cropEl.style.overflow = 'hidden';
  52208. this._cropEl = cropEl;
  52209. }
  52210. var cropElStyle = cropEl.style;
  52211. cropElStyle.width = round((dw + sx * dw / sw) * scaleX);
  52212. cropElStyle.height = round((dh + sy * dh / sh) * scaleY);
  52213. cropElStyle.filter = imageTransformPrefix + '.Matrix(Dx='
  52214. + (-sx * dw / sw * scaleX) + ',Dy=' + (-sy * dh / sh * scaleY) + ')';
  52215. if (! cropEl.parentNode) {
  52216. vmlEl.appendChild(cropEl);
  52217. }
  52218. if (imageEl.parentNode != cropEl) {
  52219. cropEl.appendChild(imageEl);
  52220. }
  52221. }
  52222. else {
  52223. imageELStyle.width = round(scaleX * dw) + 'px';
  52224. imageELStyle.height = round(scaleY * dh) + 'px';
  52225. vmlEl.appendChild(imageEl);
  52226. if (cropEl && cropEl.parentNode) {
  52227. vmlEl.removeChild(cropEl);
  52228. this._cropEl = null;
  52229. }
  52230. }
  52231. var filterStr = '';
  52232. var alpha = style.opacity;
  52233. if (alpha < 1) {
  52234. filterStr += '.Alpha(opacity=' + round(alpha * 100) + ') ';
  52235. }
  52236. filterStr += imageTransformPrefix + '.AlphaImageLoader(src=' + image + ', SizingMethod=scale)';
  52237. imageELStyle.filter = filterStr;
  52238. vmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2);
  52239. // Append to root
  52240. append(vmlRoot, vmlEl);
  52241. // Text
  52242. if (style.text) {
  52243. this.drawRectText(vmlRoot, this.getBoundingRect());
  52244. }
  52245. };
  52246. ZImage.prototype.onRemove = function (vmlRoot) {
  52247. remove(vmlRoot, this._vmlEl);
  52248. this._vmlEl = null;
  52249. this._cropEl = null;
  52250. this._imageEl = null;
  52251. this.removeRectText(vmlRoot);
  52252. };
  52253. ZImage.prototype.onAdd = function (vmlRoot) {
  52254. append(vmlRoot, this._vmlEl);
  52255. this.appendRectText(vmlRoot);
  52256. };
  52257. /***************************************************
  52258. * TEXT
  52259. **************************************************/
  52260. var DEFAULT_STYLE_NORMAL = 'normal';
  52261. var fontStyleCache = {};
  52262. var fontStyleCacheCount = 0;
  52263. var MAX_FONT_CACHE_SIZE = 100;
  52264. var fontEl = document.createElement('div');
  52265. var getFontStyle = function (fontString) {
  52266. var fontStyle = fontStyleCache[fontString];
  52267. if (!fontStyle) {
  52268. // Clear cache
  52269. if (fontStyleCacheCount > MAX_FONT_CACHE_SIZE) {
  52270. fontStyleCacheCount = 0;
  52271. fontStyleCache = {};
  52272. }
  52273. var style = fontEl.style;
  52274. var fontFamily;
  52275. try {
  52276. style.font = fontString;
  52277. fontFamily = style.fontFamily.split(',')[0];
  52278. }
  52279. catch (e) {
  52280. }
  52281. fontStyle = {
  52282. style: style.fontStyle || DEFAULT_STYLE_NORMAL,
  52283. variant: style.fontVariant || DEFAULT_STYLE_NORMAL,
  52284. weight: style.fontWeight || DEFAULT_STYLE_NORMAL,
  52285. size: parseFloat(style.fontSize || 12) | 0,
  52286. family: fontFamily || 'Microsoft YaHei'
  52287. };
  52288. fontStyleCache[fontString] = fontStyle;
  52289. fontStyleCacheCount++;
  52290. }
  52291. return fontStyle;
  52292. };
  52293. var textMeasureEl;
  52294. // Overwrite measure text method
  52295. textContain.measureText = function (text, textFont) {
  52296. var doc = vmlCore.doc;
  52297. if (!textMeasureEl) {
  52298. textMeasureEl = doc.createElement('div');
  52299. textMeasureEl.style.cssText = 'position:absolute;top:-20000px;left:0;'
  52300. + 'padding:0;margin:0;border:none;white-space:pre;';
  52301. vmlCore.doc.body.appendChild(textMeasureEl);
  52302. }
  52303. try {
  52304. textMeasureEl.style.font = textFont;
  52305. } catch (ex) {
  52306. // Ignore failures to set to invalid font.
  52307. }
  52308. textMeasureEl.innerHTML = '';
  52309. // Don't use innerHTML or innerText because they allow markup/whitespace.
  52310. textMeasureEl.appendChild(doc.createTextNode(text));
  52311. return {
  52312. width: textMeasureEl.offsetWidth
  52313. };
  52314. };
  52315. var tmpRect = new BoundingRect();
  52316. var drawRectText = function (vmlRoot, rect, textRect, fromTextEl) {
  52317. var style = this.style;
  52318. var text = style.text;
  52319. if (!text) {
  52320. return;
  52321. }
  52322. var x;
  52323. var y;
  52324. var align = style.textAlign;
  52325. var fontStyle = getFontStyle(style.textFont);
  52326. // FIXME encodeHtmlAttribute ?
  52327. var font = fontStyle.style + ' ' + fontStyle.variant + ' ' + fontStyle.weight + ' '
  52328. + fontStyle.size + 'px "' + fontStyle.family + '"';
  52329. var baseline = style.textBaseline;
  52330. var verticalAlign = style.textVerticalAlign;
  52331. textRect = textRect || textContain.getBoundingRect(text, font, align, baseline);
  52332. // Transform rect to view space
  52333. var m = this.transform;
  52334. // Ignore transform for text in other element
  52335. if (m && !fromTextEl) {
  52336. tmpRect.copy(rect);
  52337. tmpRect.applyTransform(m);
  52338. rect = tmpRect;
  52339. }
  52340. if (!fromTextEl) {
  52341. var textPosition = style.textPosition;
  52342. var distance = style.textDistance;
  52343. // Text position represented by coord
  52344. if (textPosition instanceof Array) {
  52345. x = rect.x + parsePercent(textPosition[0], rect.width);
  52346. y = rect.y + parsePercent(textPosition[1], rect.height);
  52347. align = align || 'left';
  52348. baseline = baseline || 'top';
  52349. }
  52350. else {
  52351. var res = textContain.adjustTextPositionOnRect(
  52352. textPosition, rect, textRect, distance
  52353. );
  52354. x = res.x;
  52355. y = res.y;
  52356. // Default align and baseline when has textPosition
  52357. align = align || res.textAlign;
  52358. baseline = baseline || res.textBaseline;
  52359. }
  52360. }
  52361. else {
  52362. x = rect.x;
  52363. y = rect.y;
  52364. }
  52365. if (verticalAlign) {
  52366. switch (verticalAlign) {
  52367. case 'middle':
  52368. y -= textRect.height / 2;
  52369. break;
  52370. case 'bottom':
  52371. y -= textRect.height;
  52372. break;
  52373. // 'top'
  52374. }
  52375. // Ignore baseline
  52376. baseline = 'top';
  52377. }
  52378. var fontSize = fontStyle.size;
  52379. // 1.75 is an arbitrary number, as there is no info about the text baseline
  52380. switch (baseline) {
  52381. case 'hanging':
  52382. case 'top':
  52383. y += fontSize / 1.75;
  52384. break;
  52385. case 'middle':
  52386. break;
  52387. default:
  52388. // case null:
  52389. // case 'alphabetic':
  52390. // case 'ideographic':
  52391. // case 'bottom':
  52392. y -= fontSize / 2.25;
  52393. break;
  52394. }
  52395. switch (align) {
  52396. case 'left':
  52397. break;
  52398. case 'center':
  52399. x -= textRect.width / 2;
  52400. break;
  52401. case 'right':
  52402. x -= textRect.width;
  52403. break;
  52404. // case 'end':
  52405. // align = elementStyle.direction == 'ltr' ? 'right' : 'left';
  52406. // break;
  52407. // case 'start':
  52408. // align = elementStyle.direction == 'rtl' ? 'right' : 'left';
  52409. // break;
  52410. // default:
  52411. // align = 'left';
  52412. }
  52413. var createNode = vmlCore.createNode;
  52414. var textVmlEl = this._textVmlEl;
  52415. var pathEl;
  52416. var textPathEl;
  52417. var skewEl;
  52418. if (!textVmlEl) {
  52419. textVmlEl = createNode('line');
  52420. pathEl = createNode('path');
  52421. textPathEl = createNode('textpath');
  52422. skewEl = createNode('skew');
  52423. // FIXME Why here is not cammel case
  52424. // Align 'center' seems wrong
  52425. textPathEl.style['v-text-align'] = 'left';
  52426. initRootElStyle(textVmlEl);
  52427. pathEl.textpathok = true;
  52428. textPathEl.on = true;
  52429. textVmlEl.from = '0 0';
  52430. textVmlEl.to = '1000 0.05';
  52431. append(textVmlEl, skewEl);
  52432. append(textVmlEl, pathEl);
  52433. append(textVmlEl, textPathEl);
  52434. this._textVmlEl = textVmlEl;
  52435. }
  52436. else {
  52437. // 这里是在前面 appendChild 保证顺序的前提下
  52438. skewEl = textVmlEl.firstChild;
  52439. pathEl = skewEl.nextSibling;
  52440. textPathEl = pathEl.nextSibling;
  52441. }
  52442. var coords = [x, y];
  52443. var textVmlElStyle = textVmlEl.style;
  52444. // Ignore transform for text in other element
  52445. if (m && fromTextEl) {
  52446. applyTransform(coords, coords, m);
  52447. skewEl.on = true;
  52448. skewEl.matrix = m[0].toFixed(3) + comma + m[2].toFixed(3) + comma +
  52449. m[1].toFixed(3) + comma + m[3].toFixed(3) + ',0,0';
  52450. // Text position
  52451. skewEl.offset = (round(coords[0]) || 0) + ',' + (round(coords[1]) || 0);
  52452. // Left top point as origin
  52453. skewEl.origin = '0 0';
  52454. textVmlElStyle.left = '0px';
  52455. textVmlElStyle.top = '0px';
  52456. }
  52457. else {
  52458. skewEl.on = false;
  52459. textVmlElStyle.left = round(x) + 'px';
  52460. textVmlElStyle.top = round(y) + 'px';
  52461. }
  52462. textPathEl.string = encodeHtmlAttribute(text);
  52463. // TODO
  52464. try {
  52465. textPathEl.style.font = font;
  52466. }
  52467. // Error font format
  52468. catch (e) {}
  52469. updateFillAndStroke(textVmlEl, 'fill', {
  52470. fill: fromTextEl ? style.fill : style.textFill,
  52471. opacity: style.opacity
  52472. }, this);
  52473. updateFillAndStroke(textVmlEl, 'stroke', {
  52474. stroke: fromTextEl ? style.stroke : style.textStroke,
  52475. opacity: style.opacity,
  52476. lineDash: style.lineDash
  52477. }, this);
  52478. textVmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2);
  52479. // Attached to root
  52480. append(vmlRoot, textVmlEl);
  52481. };
  52482. var removeRectText = function (vmlRoot) {
  52483. remove(vmlRoot, this._textVmlEl);
  52484. this._textVmlEl = null;
  52485. };
  52486. var appendRectText = function (vmlRoot) {
  52487. append(vmlRoot, this._textVmlEl);
  52488. };
  52489. var list = [RectText, Displayable, ZImage, Path, Text];
  52490. // In case Displayable has been mixed in RectText
  52491. for (var i = 0; i < list.length; i++) {
  52492. var proto = list[i].prototype;
  52493. proto.drawRectText = drawRectText;
  52494. proto.removeRectText = removeRectText;
  52495. proto.appendRectText = appendRectText;
  52496. }
  52497. Text.prototype.brushVML = function (vmlRoot) {
  52498. var style = this.style;
  52499. if (style.text) {
  52500. this.drawRectText(vmlRoot, {
  52501. x: style.x || 0, y: style.y || 0,
  52502. width: 0, height: 0
  52503. }, this.getBoundingRect(), true);
  52504. }
  52505. else {
  52506. this.removeRectText(vmlRoot);
  52507. }
  52508. };
  52509. Text.prototype.onRemove = function (vmlRoot) {
  52510. this.removeRectText(vmlRoot);
  52511. };
  52512. Text.prototype.onAdd = function (vmlRoot) {
  52513. this.appendRectText(vmlRoot);
  52514. };
  52515. }
  52516. /***/ },
  52517. /* 380 */
  52518. /***/ function(module, exports, __webpack_require__) {
  52519. if (!__webpack_require__(2).canvasSupported) {
  52520. var urn = 'urn:schemas-microsoft-com:vml';
  52521. var createNode;
  52522. var win = window;
  52523. var doc = win.document;
  52524. var vmlInited = false;
  52525. try {
  52526. !doc.namespaces.zrvml && doc.namespaces.add('zrvml', urn);
  52527. createNode = function (tagName) {
  52528. return doc.createElement('<zrvml:' + tagName + ' class="zrvml">');
  52529. };
  52530. }
  52531. catch (e) {
  52532. createNode = function (tagName) {
  52533. return doc.createElement('<' + tagName + ' xmlns="' + urn + '" class="zrvml">');
  52534. };
  52535. }
  52536. // From raphael
  52537. var initVML = function () {
  52538. if (vmlInited) {
  52539. return;
  52540. }
  52541. vmlInited = true;
  52542. var styleSheets = doc.styleSheets;
  52543. if (styleSheets.length < 31) {
  52544. doc.createStyleSheet().addRule('.zrvml', 'behavior:url(#default#VML)');
  52545. }
  52546. else {
  52547. // http://msdn.microsoft.com/en-us/library/ms531194%28VS.85%29.aspx
  52548. styleSheets[0].addRule('.zrvml', 'behavior:url(#default#VML)');
  52549. }
  52550. };
  52551. // Not useing return to avoid error when converting to CommonJS module
  52552. module.exports = {
  52553. doc: doc,
  52554. initVML: initVML,
  52555. createNode: createNode
  52556. };
  52557. }
  52558. /***/ },
  52559. /* 381 */
  52560. /***/ function(module, exports, __webpack_require__) {
  52561. /**
  52562. * VML Painter.
  52563. *
  52564. * @module zrender/vml/Painter
  52565. */
  52566. var zrLog = __webpack_require__(40);
  52567. var vmlCore = __webpack_require__(380);
  52568. function parseInt10(val) {
  52569. return parseInt(val, 10);
  52570. }
  52571. /**
  52572. * @alias module:zrender/vml/Painter
  52573. */
  52574. function VMLPainter(root, storage) {
  52575. vmlCore.initVML();
  52576. this.root = root;
  52577. this.storage = storage;
  52578. var vmlViewport = document.createElement('div');
  52579. var vmlRoot = document.createElement('div');
  52580. vmlViewport.style.cssText = 'display:inline-block;overflow:hidden;position:relative;width:300px;height:150px;';
  52581. vmlRoot.style.cssText = 'position:absolute;left:0;top:0;';
  52582. root.appendChild(vmlViewport);
  52583. this._vmlRoot = vmlRoot;
  52584. this._vmlViewport = vmlViewport;
  52585. this.resize();
  52586. // Modify storage
  52587. var oldDelFromMap = storage.delFromMap;
  52588. var oldAddToMap = storage.addToMap;
  52589. storage.delFromMap = function (elId) {
  52590. var el = storage.get(elId);
  52591. oldDelFromMap.call(storage, elId);
  52592. if (el) {
  52593. el.onRemove && el.onRemove(vmlRoot);
  52594. }
  52595. };
  52596. storage.addToMap = function (el) {
  52597. // Displayable already has a vml node
  52598. el.onAdd && el.onAdd(vmlRoot);
  52599. oldAddToMap.call(storage, el);
  52600. };
  52601. this._firstPaint = true;
  52602. }
  52603. VMLPainter.prototype = {
  52604. constructor: VMLPainter,
  52605. /**
  52606. * @return {HTMLDivElement}
  52607. */
  52608. getViewportRoot: function () {
  52609. return this._vmlViewport;
  52610. },
  52611. /**
  52612. * 刷新
  52613. */
  52614. refresh: function () {
  52615. var list = this.storage.getDisplayList(true, true);
  52616. this._paintList(list);
  52617. },
  52618. _paintList: function (list) {
  52619. var vmlRoot = this._vmlRoot;
  52620. for (var i = 0; i < list.length; i++) {
  52621. var el = list[i];
  52622. if (el.invisible || el.ignore) {
  52623. if (!el.__alreadyNotVisible) {
  52624. el.onRemove(vmlRoot);
  52625. }
  52626. // Set as already invisible
  52627. el.__alreadyNotVisible = true;
  52628. }
  52629. else {
  52630. if (el.__alreadyNotVisible) {
  52631. el.onAdd(vmlRoot);
  52632. }
  52633. el.__alreadyNotVisible = false;
  52634. if (el.__dirty) {
  52635. el.beforeBrush && el.beforeBrush();
  52636. (el.brushVML || el.brush).call(el, vmlRoot);
  52637. el.afterBrush && el.afterBrush();
  52638. }
  52639. }
  52640. el.__dirty = false;
  52641. }
  52642. if (this._firstPaint) {
  52643. // Detached from document at first time
  52644. // to avoid page refreshing too many times
  52645. // FIXME 如果每次都先 removeChild 可能会导致一些填充和描边的效果改变
  52646. this._vmlViewport.appendChild(vmlRoot);
  52647. this._firstPaint = false;
  52648. }
  52649. },
  52650. resize: function () {
  52651. var width = this._getWidth();
  52652. var height = this._getHeight();
  52653. if (this._width != width && this._height != height) {
  52654. this._width = width;
  52655. this._height = height;
  52656. var vmlViewportStyle = this._vmlViewport.style;
  52657. vmlViewportStyle.width = width + 'px';
  52658. vmlViewportStyle.height = height + 'px';
  52659. }
  52660. },
  52661. dispose: function () {
  52662. this.root.innerHTML = '';
  52663. this._vmlRoot =
  52664. this._vmlViewport =
  52665. this.storage = null;
  52666. },
  52667. getWidth: function () {
  52668. return this._width;
  52669. },
  52670. getHeight: function () {
  52671. return this._height;
  52672. },
  52673. clear: function () {
  52674. this.root.removeChild(this.vmlViewport);
  52675. },
  52676. _getWidth: function () {
  52677. var root = this.root;
  52678. var stl = root.currentStyle;
  52679. return ((root.clientWidth || parseInt10(stl.width))
  52680. - parseInt10(stl.paddingLeft)
  52681. - parseInt10(stl.paddingRight)) | 0;
  52682. },
  52683. _getHeight: function () {
  52684. var root = this.root;
  52685. var stl = root.currentStyle;
  52686. return ((root.clientHeight || parseInt10(stl.height))
  52687. - parseInt10(stl.paddingTop)
  52688. - parseInt10(stl.paddingBottom)) | 0;
  52689. }
  52690. };
  52691. // Not supported methods
  52692. function createMethodNotSupport(method) {
  52693. return function () {
  52694. zrLog('In IE8.0 VML mode painter not support method "' + method + '"');
  52695. };
  52696. }
  52697. var notSupportedMethods = [
  52698. 'getLayer', 'insertLayer', 'eachLayer', 'eachBuildinLayer', 'eachOtherLayer', 'getLayers',
  52699. 'modLayer', 'delLayer', 'clearLayer', 'toDataURL', 'pathToImage'
  52700. ];
  52701. for (var i = 0; i < notSupportedMethods.length; i++) {
  52702. var name = notSupportedMethods[i];
  52703. VMLPainter.prototype[name] = createMethodNotSupport(name);
  52704. }
  52705. module.exports = VMLPainter;
  52706. /***/ }
  52707. /******/ ])
  52708. });
  52709. ;