echarts.js 1.7 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282
  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__(92);
  51. __webpack_require__(128);
  52. __webpack_require__(133);
  53. __webpack_require__(142);
  54. __webpack_require__(146);
  55. __webpack_require__(156);
  56. __webpack_require__(177);
  57. __webpack_require__(189);
  58. __webpack_require__(210);
  59. __webpack_require__(214);
  60. __webpack_require__(218);
  61. __webpack_require__(233);
  62. __webpack_require__(239);
  63. __webpack_require__(246);
  64. __webpack_require__(252);
  65. __webpack_require__(256);
  66. __webpack_require__(261);
  67. __webpack_require__(107);
  68. __webpack_require__(265);
  69. __webpack_require__(271);
  70. __webpack_require__(275);
  71. __webpack_require__(286);
  72. __webpack_require__(219);
  73. __webpack_require__(289);
  74. __webpack_require__(290);
  75. __webpack_require__(304);
  76. __webpack_require__(319);
  77. __webpack_require__(323);
  78. __webpack_require__(326);
  79. __webpack_require__(335);
  80. __webpack_require__(349);
  81. /***/ },
  82. /* 1 */
  83. /***/ function(module, exports, __webpack_require__) {
  84. /*!
  85. * ECharts, a javascript interactive chart library.
  86. *
  87. * Copyright (c) 2015, Baidu Inc.
  88. * All rights reserved.
  89. *
  90. * LICENSE
  91. * https://github.com/ecomfe/echarts/blob/master/LICENSE.txt
  92. */
  93. /**
  94. * @module echarts
  95. */
  96. var GlobalModel = __webpack_require__(2);
  97. var ExtensionAPI = __webpack_require__(24);
  98. var CoordinateSystemManager = __webpack_require__(25);
  99. var OptionManager = __webpack_require__(26);
  100. var ComponentModel = __webpack_require__(19);
  101. var SeriesModel = __webpack_require__(27);
  102. var ComponentView = __webpack_require__(28);
  103. var ChartView = __webpack_require__(41);
  104. var graphic = __webpack_require__(42);
  105. var zrender = __webpack_require__(78);
  106. var zrUtil = __webpack_require__(3);
  107. var colorTool = __webpack_require__(38);
  108. var env = __webpack_require__(79);
  109. var Eventful = __webpack_require__(32);
  110. var each = zrUtil.each;
  111. var VISUAL_CODING_STAGES = ['echarts', 'chart', 'component'];
  112. // TODO Transform first or filter first
  113. var PROCESSOR_STAGES = ['transform', 'filter', 'statistic'];
  114. function createRegisterEventWithLowercaseName(method) {
  115. return function (eventName, handler, context) {
  116. // Event name is all lowercase
  117. eventName = eventName && eventName.toLowerCase();
  118. Eventful.prototype[method].call(this, eventName, handler, context);
  119. };
  120. }
  121. /**
  122. * @module echarts~MessageCenter
  123. */
  124. function MessageCenter() {
  125. Eventful.call(this);
  126. }
  127. MessageCenter.prototype.on = createRegisterEventWithLowercaseName('on');
  128. MessageCenter.prototype.off = createRegisterEventWithLowercaseName('off');
  129. MessageCenter.prototype.one = createRegisterEventWithLowercaseName('one');
  130. zrUtil.mixin(MessageCenter, Eventful);
  131. /**
  132. * @module echarts~ECharts
  133. */
  134. function ECharts (dom, theme, opts) {
  135. opts = opts || {};
  136. // Get theme by name
  137. if (typeof theme === 'string') {
  138. theme = themeStorage[theme];
  139. }
  140. if (theme) {
  141. each(optionPreprocessorFuncs, function (preProcess) {
  142. preProcess(theme);
  143. });
  144. }
  145. /**
  146. * @type {string}
  147. */
  148. this.id;
  149. /**
  150. * Group id
  151. * @type {string}
  152. */
  153. this.group;
  154. /**
  155. * @type {HTMLDomElement}
  156. * @private
  157. */
  158. this._dom = dom;
  159. /**
  160. * @type {module:zrender/ZRender}
  161. * @private
  162. */
  163. this._zr = zrender.init(dom, {
  164. renderer: opts.renderer || 'canvas',
  165. devicePixelRatio: opts.devicePixelRatio
  166. });
  167. /**
  168. * @type {Object}
  169. * @private
  170. */
  171. this._theme = zrUtil.clone(theme);
  172. /**
  173. * @type {Array.<module:echarts/view/Chart>}
  174. * @private
  175. */
  176. this._chartsViews = [];
  177. /**
  178. * @type {Object.<string, module:echarts/view/Chart>}
  179. * @private
  180. */
  181. this._chartsMap = {};
  182. /**
  183. * @type {Array.<module:echarts/view/Component>}
  184. * @private
  185. */
  186. this._componentsViews = [];
  187. /**
  188. * @type {Object.<string, module:echarts/view/Component>}
  189. * @private
  190. */
  191. this._componentsMap = {};
  192. /**
  193. * @type {module:echarts/ExtensionAPI}
  194. * @private
  195. */
  196. this._api = new ExtensionAPI(this);
  197. /**
  198. * @type {module:echarts/CoordinateSystem}
  199. * @private
  200. */
  201. this._coordSysMgr = new CoordinateSystemManager();
  202. Eventful.call(this);
  203. /**
  204. * @type {module:echarts~MessageCenter}
  205. * @private
  206. */
  207. this._messageCenter = new MessageCenter();
  208. // Init mouse events
  209. this._initEvents();
  210. // In case some people write `window.onresize = chart.resize`
  211. this.resize = zrUtil.bind(this.resize, this);
  212. }
  213. var echartsProto = ECharts.prototype;
  214. /**
  215. * @return {HTMLDomElement}
  216. */
  217. echartsProto.getDom = function () {
  218. return this._dom;
  219. };
  220. /**
  221. * @return {module:zrender~ZRender}
  222. */
  223. echartsProto.getZr = function () {
  224. return this._zr;
  225. };
  226. /**
  227. * @param {Object} option
  228. * @param {boolean} notMerge
  229. * @param {boolean} [notRefreshImmediately=false] Useful when setOption frequently.
  230. */
  231. echartsProto.setOption = function (option, notMerge, notRefreshImmediately) {
  232. if (!this._model || notMerge) {
  233. this._model = new GlobalModel(
  234. null, null, this._theme, new OptionManager(this._api)
  235. );
  236. }
  237. this._model.setOption(option, optionPreprocessorFuncs);
  238. updateMethods.prepareAndUpdate.call(this);
  239. !notRefreshImmediately && this._zr.refreshImmediately();
  240. };
  241. /**
  242. * @DEPRECATED
  243. */
  244. echartsProto.setTheme = function () {
  245. console.log('ECharts#setTheme() is DEPRECATED in ECharts 3.0');
  246. };
  247. /**
  248. * @return {module:echarts/model/Global}
  249. */
  250. echartsProto.getModel = function () {
  251. return this._model;
  252. };
  253. /**
  254. * @return {Object}
  255. */
  256. echartsProto.getOption = function () {
  257. return this._model.getOption();
  258. };
  259. /**
  260. * @return {number}
  261. */
  262. echartsProto.getWidth = function () {
  263. return this._zr.getWidth();
  264. };
  265. /**
  266. * @return {number}
  267. */
  268. echartsProto.getHeight = function () {
  269. return this._zr.getHeight();
  270. };
  271. /**
  272. * Get canvas which has all thing rendered
  273. * @param {Object} opts
  274. * @param {string} [opts.backgroundColor]
  275. */
  276. echartsProto.getRenderedCanvas = function (opts) {
  277. if (!env.canvasSupported) {
  278. return;
  279. }
  280. opts = opts || {};
  281. opts.pixelRatio = opts.pixelRatio || 1;
  282. opts.backgroundColor = opts.backgroundColor
  283. || this._model.get('backgroundColor');
  284. var zr = this._zr;
  285. var list = zr.storage.getDisplayList();
  286. // Stop animations
  287. zrUtil.each(list, function (el) {
  288. el.stopAnimation(true);
  289. });
  290. return zr.painter.getRenderedCanvas(opts);
  291. };
  292. /**
  293. * @return {string}
  294. * @param {Object} opts
  295. * @param {string} [opts.type='png']
  296. * @param {string} [opts.pixelRatio=1]
  297. * @param {string} [opts.backgroundColor]
  298. */
  299. echartsProto.getDataURL = function (opts) {
  300. opts = opts || {};
  301. var excludeComponents = opts.excludeComponents;
  302. var ecModel = this._model;
  303. var excludesComponentViews = [];
  304. var self = this;
  305. each(excludeComponents, function (componentType) {
  306. ecModel.eachComponent({
  307. mainType: componentType
  308. }, function (component) {
  309. var view = self._componentsMap[component.__viewId];
  310. if (!view.group.ignore) {
  311. excludesComponentViews.push(view);
  312. view.group.ignore = true;
  313. }
  314. });
  315. });
  316. var url = this.getRenderedCanvas(opts).toDataURL(
  317. 'image/' + (opts && opts.type || 'png')
  318. );
  319. each(excludesComponentViews, function (view) {
  320. view.group.ignore = false;
  321. });
  322. return url;
  323. };
  324. /**
  325. * @return {string}
  326. * @param {Object} opts
  327. * @param {string} [opts.type='png']
  328. * @param {string} [opts.pixelRatio=1]
  329. * @param {string} [opts.backgroundColor]
  330. */
  331. echartsProto.getConnectedDataURL = function (opts) {
  332. if (!env.canvasSupported) {
  333. return;
  334. }
  335. var groupId = this.group;
  336. var mathMin = Math.min;
  337. var mathMax = Math.max;
  338. var MAX_NUMBER = Infinity;
  339. if (connectedGroups[groupId]) {
  340. var left = MAX_NUMBER;
  341. var top = MAX_NUMBER;
  342. var right = -MAX_NUMBER;
  343. var bottom = -MAX_NUMBER;
  344. var canvasList = [];
  345. var dpr = (opts && opts.pixelRatio) || 1;
  346. for (var id in instances) {
  347. var chart = instances[id];
  348. if (chart.group === groupId) {
  349. var canvas = chart.getRenderedCanvas(
  350. zrUtil.clone(opts)
  351. );
  352. var boundingRect = chart.getDom().getBoundingClientRect();
  353. left = mathMin(boundingRect.left, left);
  354. top = mathMin(boundingRect.top, top);
  355. right = mathMax(boundingRect.right, right);
  356. bottom = mathMax(boundingRect.bottom, bottom);
  357. canvasList.push({
  358. dom: canvas,
  359. left: boundingRect.left,
  360. top: boundingRect.top
  361. });
  362. }
  363. }
  364. left *= dpr;
  365. top *= dpr;
  366. right *= dpr;
  367. bottom *= dpr;
  368. var width = right - left;
  369. var height = bottom - top;
  370. var targetCanvas = zrUtil.createCanvas();
  371. targetCanvas.width = width;
  372. targetCanvas.height = height;
  373. var zr = zrender.init(targetCanvas);
  374. each(canvasList, function (item) {
  375. var img = new graphic.Image({
  376. style: {
  377. x: item.left * dpr - left,
  378. y: item.top * dpr - top,
  379. image: item.dom
  380. }
  381. });
  382. zr.add(img);
  383. });
  384. zr.refreshImmediately();
  385. return targetCanvas.toDataURL('image/' + (opts && opts.type || 'png'));
  386. }
  387. else {
  388. return this.getDataURL(opts);
  389. }
  390. };
  391. var updateMethods = {
  392. /**
  393. * @param {Object} payload
  394. * @private
  395. */
  396. update: function (payload) {
  397. // console.time && console.time('update');
  398. var ecModel = this._model;
  399. var api = this._api;
  400. var coordSysMgr = this._coordSysMgr;
  401. // update before setOption
  402. if (!ecModel) {
  403. return;
  404. }
  405. // Fixme First time update ?
  406. ecModel.restoreData();
  407. // TODO
  408. // Save total ecModel here for undo/redo (after restoring data and before processing data).
  409. // Undo (restoration of total ecModel) can be carried out in 'action' or outside API call.
  410. // Create new coordinate system each update
  411. // In LineView may save the old coordinate system and use it to get the orignal point
  412. coordSysMgr.create(this._model, this._api);
  413. processData.call(this, ecModel, api);
  414. stackSeriesData.call(this, ecModel);
  415. coordSysMgr.update(ecModel, api);
  416. doLayout.call(this, ecModel, payload);
  417. doVisualCoding.call(this, ecModel, payload);
  418. doRender.call(this, ecModel, payload);
  419. // Set background
  420. var backgroundColor = ecModel.get('backgroundColor') || 'transparent';
  421. var painter = this._zr.painter;
  422. // TODO all use clearColor ?
  423. if (painter.isSingleCanvas && painter.isSingleCanvas()) {
  424. this._zr.configLayer(0, {
  425. clearColor: backgroundColor
  426. });
  427. }
  428. else {
  429. // In IE8
  430. if (!env.canvasSupported) {
  431. var colorArr = colorTool.parse(backgroundColor);
  432. backgroundColor = colorTool.stringify(colorArr, 'rgb');
  433. if (colorArr[3] === 0) {
  434. backgroundColor = 'transparent';
  435. }
  436. }
  437. backgroundColor = backgroundColor;
  438. this._dom.style.backgroundColor = backgroundColor;
  439. }
  440. // console.time && console.timeEnd('update');
  441. },
  442. // PENDING
  443. /**
  444. * @param {Object} payload
  445. * @private
  446. */
  447. updateView: function (payload) {
  448. var ecModel = this._model;
  449. // update before setOption
  450. if (!ecModel) {
  451. return;
  452. }
  453. doLayout.call(this, ecModel, payload);
  454. doVisualCoding.call(this, ecModel, payload);
  455. invokeUpdateMethod.call(this, 'updateView', ecModel, payload);
  456. },
  457. /**
  458. * @param {Object} payload
  459. * @private
  460. */
  461. updateVisual: function (payload) {
  462. var ecModel = this._model;
  463. // update before setOption
  464. if (!ecModel) {
  465. return;
  466. }
  467. doVisualCoding.call(this, ecModel, payload);
  468. invokeUpdateMethod.call(this, 'updateVisual', ecModel, payload);
  469. },
  470. /**
  471. * @param {Object} payload
  472. * @private
  473. */
  474. updateLayout: function (payload) {
  475. var ecModel = this._model;
  476. // update before setOption
  477. if (!ecModel) {
  478. return;
  479. }
  480. doLayout.call(this, ecModel, payload);
  481. invokeUpdateMethod.call(this, 'updateLayout', ecModel, payload);
  482. },
  483. /**
  484. * @param {Object} payload
  485. * @private
  486. */
  487. highlight: function (payload) {
  488. toggleHighlight.call(this, 'highlight', payload);
  489. },
  490. /**
  491. * @param {Object} payload
  492. * @private
  493. */
  494. downplay: function (payload) {
  495. toggleHighlight.call(this, 'downplay', payload);
  496. },
  497. /**
  498. * @param {Object} payload
  499. * @private
  500. */
  501. prepareAndUpdate: function (payload) {
  502. var ecModel = this._model;
  503. prepareView.call(this, 'component', ecModel);
  504. prepareView.call(this, 'chart', ecModel);
  505. updateMethods.update.call(this, payload);
  506. }
  507. };
  508. /**
  509. * @param {Object} payload
  510. * @private
  511. */
  512. function toggleHighlight(method, payload) {
  513. var ecModel = this._model;
  514. // dispatchAction before setOption
  515. if (!ecModel) {
  516. return;
  517. }
  518. ecModel.eachComponent(
  519. {mainType: 'series', query: payload},
  520. function (seriesModel, index) {
  521. var chartView = this._chartsMap[seriesModel.__viewId];
  522. if (chartView && chartView.__alive) {
  523. chartView[method](
  524. seriesModel, ecModel, this._api, payload
  525. );
  526. }
  527. },
  528. this
  529. );
  530. }
  531. /**
  532. * Resize the chart
  533. */
  534. echartsProto.resize = function () {
  535. this._zr.resize();
  536. var optionChanged = this._model && this._model.resetOption('media');
  537. updateMethods[optionChanged ? 'prepareAndUpdate' : 'update'].call(this);
  538. // Resize loading effect
  539. this._loadingFX && this._loadingFX.resize();
  540. };
  541. var defaultLoadingEffect = __webpack_require__(88);
  542. /**
  543. * Show loading effect
  544. * @param {string} [name='default']
  545. * @param {Object} [cfg]
  546. */
  547. echartsProto.showLoading = function (name, cfg) {
  548. if (zrUtil.isObject(name)) {
  549. cfg = name;
  550. name = 'default';
  551. }
  552. this.hideLoading();
  553. var el = defaultLoadingEffect(this._api, cfg);
  554. var zr = this._zr;
  555. this._loadingFX = el;
  556. zr.add(el);
  557. };
  558. /**
  559. * Hide loading effect
  560. */
  561. echartsProto.hideLoading = function () {
  562. this._loadingFX && this._zr.remove(this._loadingFX);
  563. this._loadingFX = null;
  564. };
  565. /**
  566. * @param {Object} eventObj
  567. * @return {Object}
  568. */
  569. echartsProto.makeActionFromEvent = function (eventObj) {
  570. var payload = zrUtil.extend({}, eventObj);
  571. payload.type = eventActionMap[eventObj.type];
  572. return payload;
  573. };
  574. /**
  575. * @pubilc
  576. * @param {Object} payload
  577. * @param {string} [payload.type] Action type
  578. * @param {boolean} [silent=false] Whether trigger event.
  579. */
  580. echartsProto.dispatchAction = function (payload, silent) {
  581. var actionWrap = actions[payload.type];
  582. if (actionWrap) {
  583. var actionInfo = actionWrap.actionInfo;
  584. var updateMethod = actionInfo.update || 'update';
  585. var payloads = [payload];
  586. var batched = false;
  587. // Batch action
  588. if (payload.batch) {
  589. batched = true;
  590. payloads = zrUtil.map(payload.batch, function (item) {
  591. item = zrUtil.defaults(zrUtil.extend({}, item), payload);
  592. item.batch = null;
  593. return item;
  594. });
  595. }
  596. var eventObjBatch = [];
  597. var eventObj;
  598. var isHighlightOrDownplay = payload.type === 'highlight' || payload.type === 'downplay';
  599. for (var i = 0; i < payloads.length; i++) {
  600. var batchItem = payloads[i];
  601. // Action can specify the event by return it.
  602. eventObj = actionWrap.action(batchItem, this._model);
  603. // Emit event outside
  604. eventObj = eventObj || zrUtil.extend({}, batchItem);
  605. // Convert type to eventType
  606. eventObj.type = actionInfo.event || eventObj.type;
  607. eventObjBatch.push(eventObj);
  608. // Highlight and downplay are special.
  609. isHighlightOrDownplay && updateMethods[updateMethod].call(this, batchItem);
  610. }
  611. (updateMethod !== 'none' && !isHighlightOrDownplay)
  612. && updateMethods[updateMethod].call(this, payload);
  613. if (!silent) {
  614. // Follow the rule of action batch
  615. if (batched) {
  616. eventObj = {
  617. type: actionInfo.event || payload.type,
  618. batch: eventObjBatch
  619. };
  620. }
  621. else {
  622. eventObj = eventObjBatch[0];
  623. }
  624. this._messageCenter.trigger(eventObj.type, eventObj);
  625. }
  626. }
  627. };
  628. /**
  629. * Register event
  630. * @method
  631. */
  632. echartsProto.on = createRegisterEventWithLowercaseName('on');
  633. echartsProto.off = createRegisterEventWithLowercaseName('off');
  634. echartsProto.one = createRegisterEventWithLowercaseName('one');
  635. /**
  636. * @param {string} methodName
  637. * @private
  638. */
  639. function invokeUpdateMethod(methodName, ecModel, payload) {
  640. var api = this._api;
  641. // Update all components
  642. each(this._componentsViews, function (component) {
  643. var componentModel = component.__model;
  644. component[methodName](componentModel, ecModel, api, payload);
  645. updateZ(componentModel, component);
  646. }, this);
  647. // Upate all charts
  648. ecModel.eachSeries(function (seriesModel, idx) {
  649. var chart = this._chartsMap[seriesModel.__viewId];
  650. chart[methodName](seriesModel, ecModel, api, payload);
  651. updateZ(seriesModel, chart);
  652. }, this);
  653. }
  654. /**
  655. * Prepare view instances of charts and components
  656. * @param {module:echarts/model/Global} ecModel
  657. * @private
  658. */
  659. function prepareView(type, ecModel) {
  660. var isComponent = type === 'component';
  661. var viewList = isComponent ? this._componentsViews : this._chartsViews;
  662. var viewMap = isComponent ? this._componentsMap : this._chartsMap;
  663. var zr = this._zr;
  664. for (var i = 0; i < viewList.length; i++) {
  665. viewList[i].__alive = false;
  666. }
  667. ecModel[isComponent ? 'eachComponent' : 'eachSeries'](function (componentType, model) {
  668. if (isComponent) {
  669. if (componentType === 'series') {
  670. return;
  671. }
  672. }
  673. else {
  674. model = componentType;
  675. }
  676. // Consider: id same and type changed.
  677. var viewId = model.id + '_' + model.type;
  678. var view = viewMap[viewId];
  679. if (!view) {
  680. var classType = ComponentModel.parseClassType(model.type);
  681. var Clazz = isComponent
  682. ? ComponentView.getClass(classType.main, classType.sub)
  683. : ChartView.getClass(classType.sub);
  684. if (Clazz) {
  685. view = new Clazz();
  686. view.init(ecModel, this._api);
  687. viewMap[viewId] = view;
  688. viewList.push(view);
  689. zr.add(view.group);
  690. }
  691. else {
  692. // Error
  693. return;
  694. }
  695. }
  696. model.__viewId = viewId;
  697. view.__alive = true;
  698. view.__id = viewId;
  699. view.__model = model;
  700. }, this);
  701. for (var i = 0; i < viewList.length;) {
  702. var view = viewList[i];
  703. if (!view.__alive) {
  704. zr.remove(view.group);
  705. view.dispose(ecModel, this._api);
  706. viewList.splice(i, 1);
  707. delete viewMap[view.__id];
  708. }
  709. else {
  710. i++;
  711. }
  712. }
  713. }
  714. /**
  715. * Processor data in each series
  716. *
  717. * @param {module:echarts/model/Global} ecModel
  718. * @private
  719. */
  720. function processData(ecModel, api) {
  721. each(PROCESSOR_STAGES, function (stage) {
  722. each(dataProcessorFuncs[stage] || [], function (process) {
  723. process(ecModel, api);
  724. });
  725. });
  726. }
  727. /**
  728. * @private
  729. */
  730. function stackSeriesData(ecModel) {
  731. var stackedDataMap = {};
  732. ecModel.eachSeries(function (series) {
  733. var stack = series.get('stack');
  734. var data = series.getData();
  735. if (stack && data.type === 'list') {
  736. var previousStack = stackedDataMap[stack];
  737. if (previousStack) {
  738. data.stackedOn = previousStack;
  739. }
  740. stackedDataMap[stack] = data;
  741. }
  742. });
  743. }
  744. /**
  745. * Layout before each chart render there series, after visual coding and data processing
  746. *
  747. * @param {module:echarts/model/Global} ecModel
  748. * @private
  749. */
  750. function doLayout(ecModel, payload) {
  751. var api = this._api;
  752. each(layoutFuncs, function (layout) {
  753. layout(ecModel, api, payload);
  754. });
  755. }
  756. /**
  757. * Code visual infomation from data after data processing
  758. *
  759. * @param {module:echarts/model/Global} ecModel
  760. * @private
  761. */
  762. function doVisualCoding(ecModel, payload) {
  763. each(VISUAL_CODING_STAGES, function (stage) {
  764. each(visualCodingFuncs[stage] || [], function (visualCoding) {
  765. visualCoding(ecModel, payload);
  766. });
  767. });
  768. }
  769. /**
  770. * Render each chart and component
  771. * @private
  772. */
  773. function doRender(ecModel, payload) {
  774. var api = this._api;
  775. // Render all components
  776. each(this._componentsViews, function (componentView) {
  777. var componentModel = componentView.__model;
  778. componentView.render(componentModel, ecModel, api, payload);
  779. updateZ(componentModel, componentView);
  780. }, this);
  781. each(this._chartsViews, function (chart) {
  782. chart.__alive = false;
  783. }, this);
  784. // Render all charts
  785. ecModel.eachSeries(function (seriesModel, idx) {
  786. var chartView = this._chartsMap[seriesModel.__viewId];
  787. chartView.__alive = true;
  788. chartView.render(seriesModel, ecModel, api, payload);
  789. chartView.group.silent = !!seriesModel.get('silent');
  790. updateZ(seriesModel, chartView);
  791. }, this);
  792. // Remove groups of unrendered charts
  793. each(this._chartsViews, function (chart) {
  794. if (!chart.__alive) {
  795. chart.remove(ecModel, api);
  796. }
  797. }, this);
  798. }
  799. var MOUSE_EVENT_NAMES = [
  800. 'click', 'dblclick', 'mouseover', 'mouseout', 'mousedown', 'mouseup', 'globalout'
  801. ];
  802. /**
  803. * @private
  804. */
  805. echartsProto._initEvents = function () {
  806. each(MOUSE_EVENT_NAMES, function (eveName) {
  807. this._zr.on(eveName, function (e) {
  808. var ecModel = this.getModel();
  809. var el = e.target;
  810. if (el && el.dataIndex != null) {
  811. var dataModel = el.dataModel || ecModel.getSeriesByIndex(el.seriesIndex);
  812. var params = dataModel && dataModel.getDataParams(el.dataIndex, el.dataType) || {};
  813. params.event = e;
  814. params.type = eveName;
  815. this.trigger(eveName, params);
  816. }
  817. // If element has custom eventData of components
  818. else if (el && el.eventData) {
  819. this.trigger(eveName, el.eventData);
  820. }
  821. }, this);
  822. }, this);
  823. each(eventActionMap, function (actionType, eventType) {
  824. this._messageCenter.on(eventType, function (event) {
  825. this.trigger(eventType, event);
  826. }, this);
  827. }, this);
  828. };
  829. /**
  830. * @return {boolean}
  831. */
  832. echartsProto.isDisposed = function () {
  833. return this._disposed;
  834. };
  835. /**
  836. * Clear
  837. */
  838. echartsProto.clear = function () {
  839. this.setOption({}, true);
  840. };
  841. /**
  842. * Dispose instance
  843. */
  844. echartsProto.dispose = function () {
  845. this._disposed = true;
  846. var api = this._api;
  847. var ecModel = this._model;
  848. each(this._componentsViews, function (component) {
  849. component.dispose(ecModel, api);
  850. });
  851. each(this._chartsViews, function (chart) {
  852. chart.dispose(ecModel, api);
  853. });
  854. this._zr.dispose();
  855. delete instances[this.id];
  856. };
  857. zrUtil.mixin(ECharts, Eventful);
  858. /**
  859. * @param {module:echarts/model/Series|module:echarts/model/Component} model
  860. * @param {module:echarts/view/Component|module:echarts/view/Chart} view
  861. * @return {string}
  862. */
  863. function updateZ(model, view) {
  864. var z = model.get('z');
  865. var zlevel = model.get('zlevel');
  866. // Set z and zlevel
  867. view.group.traverse(function (el) {
  868. z != null && (el.z = z);
  869. zlevel != null && (el.zlevel = zlevel);
  870. });
  871. }
  872. /**
  873. * @type {Array.<Function>}
  874. * @inner
  875. */
  876. var actions = [];
  877. /**
  878. * Map eventType to actionType
  879. * @type {Object}
  880. */
  881. var eventActionMap = {};
  882. /**
  883. * @type {Array.<Function>}
  884. * @inner
  885. */
  886. var layoutFuncs = [];
  887. /**
  888. * Data processor functions of each stage
  889. * @type {Array.<Object.<string, Function>>}
  890. * @inner
  891. */
  892. var dataProcessorFuncs = {};
  893. /**
  894. * @type {Array.<Function>}
  895. * @inner
  896. */
  897. var optionPreprocessorFuncs = [];
  898. /**
  899. * Visual coding functions of each stage
  900. * @type {Array.<Object.<string, Function>>}
  901. * @inner
  902. */
  903. var visualCodingFuncs = {};
  904. /**
  905. * Theme storage
  906. * @type {Object.<key, Object>}
  907. */
  908. var themeStorage = {};
  909. var instances = {};
  910. var connectedGroups = {};
  911. var idBase = new Date() - 0;
  912. var groupIdBase = new Date() - 0;
  913. var DOM_ATTRIBUTE_KEY = '_echarts_instance_';
  914. /**
  915. * @alias module:echarts
  916. */
  917. var echarts = {
  918. /**
  919. * @type {number}
  920. */
  921. version: '3.1.10',
  922. dependencies: {
  923. zrender: '3.1.0'
  924. }
  925. };
  926. function enableConnect(chart) {
  927. var STATUS_PENDING = 0;
  928. var STATUS_UPDATING = 1;
  929. var STATUS_UPDATED = 2;
  930. var STATUS_KEY = '__connectUpdateStatus';
  931. function updateConnectedChartsStatus(charts, status) {
  932. for (var i = 0; i < charts.length; i++) {
  933. var otherChart = charts[i];
  934. otherChart[STATUS_KEY] = status;
  935. }
  936. }
  937. zrUtil.each(eventActionMap, function (actionType, eventType) {
  938. chart._messageCenter.on(eventType, function (event) {
  939. if (connectedGroups[chart.group] && chart[STATUS_KEY] !== STATUS_PENDING) {
  940. var action = chart.makeActionFromEvent(event);
  941. var otherCharts = [];
  942. for (var id in instances) {
  943. var otherChart = instances[id];
  944. if (otherChart !== chart && otherChart.group === chart.group) {
  945. otherCharts.push(otherChart);
  946. }
  947. }
  948. updateConnectedChartsStatus(otherCharts, STATUS_PENDING);
  949. each(otherCharts, function (otherChart) {
  950. if (otherChart[STATUS_KEY] !== STATUS_UPDATING) {
  951. otherChart.dispatchAction(action);
  952. }
  953. });
  954. updateConnectedChartsStatus(otherCharts, STATUS_UPDATED);
  955. }
  956. });
  957. });
  958. }
  959. /**
  960. * @param {HTMLDomElement} dom
  961. * @param {Object} [theme]
  962. * @param {Object} opts
  963. */
  964. echarts.init = function (dom, theme, opts) {
  965. // Check version
  966. if ((zrender.version.replace('.', '') - 0) < (echarts.dependencies.zrender.replace('.', '') - 0)) {
  967. throw new Error(
  968. 'ZRender ' + zrender.version
  969. + ' is too old for ECharts ' + echarts.version
  970. + '. Current version need ZRender '
  971. + echarts.dependencies.zrender + '+'
  972. );
  973. }
  974. if (!dom) {
  975. throw new Error('Initialize failed: invalid dom.');
  976. }
  977. var chart = new ECharts(dom, theme, opts);
  978. chart.id = 'ec_' + idBase++;
  979. instances[chart.id] = chart;
  980. dom.setAttribute &&
  981. dom.setAttribute(DOM_ATTRIBUTE_KEY, chart.id);
  982. enableConnect(chart);
  983. return chart;
  984. };
  985. /**
  986. * @return {string|Array.<module:echarts~ECharts>} groupId
  987. */
  988. echarts.connect = function (groupId) {
  989. // Is array of charts
  990. if (zrUtil.isArray(groupId)) {
  991. var charts = groupId;
  992. groupId = null;
  993. // If any chart has group
  994. zrUtil.each(charts, function (chart) {
  995. if (chart.group != null) {
  996. groupId = chart.group;
  997. }
  998. });
  999. groupId = groupId || ('g_' + groupIdBase++);
  1000. zrUtil.each(charts, function (chart) {
  1001. chart.group = groupId;
  1002. });
  1003. }
  1004. connectedGroups[groupId] = true;
  1005. return groupId;
  1006. };
  1007. /**
  1008. * @return {string} groupId
  1009. */
  1010. echarts.disConnect = function (groupId) {
  1011. connectedGroups[groupId] = false;
  1012. };
  1013. /**
  1014. * Dispose a chart instance
  1015. * @param {module:echarts~ECharts|HTMLDomElement|string} chart
  1016. */
  1017. echarts.dispose = function (chart) {
  1018. if (zrUtil.isDom(chart)) {
  1019. chart = echarts.getInstanceByDom(chart);
  1020. }
  1021. else if (typeof chart === 'string') {
  1022. chart = instances[chart];
  1023. }
  1024. if ((chart instanceof ECharts) && !chart.isDisposed()) {
  1025. chart.dispose();
  1026. }
  1027. };
  1028. /**
  1029. * @param {HTMLDomElement} dom
  1030. * @return {echarts~ECharts}
  1031. */
  1032. echarts.getInstanceByDom = function (dom) {
  1033. var key = dom.getAttribute(DOM_ATTRIBUTE_KEY);
  1034. return instances[key];
  1035. };
  1036. /**
  1037. * @param {string} key
  1038. * @return {echarts~ECharts}
  1039. */
  1040. echarts.getInstanceById = function (key) {
  1041. return instances[key];
  1042. };
  1043. /**
  1044. * Register theme
  1045. */
  1046. echarts.registerTheme = function (name, theme) {
  1047. themeStorage[name] = theme;
  1048. };
  1049. /**
  1050. * Register option preprocessor
  1051. * @param {Function} preprocessorFunc
  1052. */
  1053. echarts.registerPreprocessor = function (preprocessorFunc) {
  1054. optionPreprocessorFuncs.push(preprocessorFunc);
  1055. };
  1056. /**
  1057. * @param {string} stage
  1058. * @param {Function} processorFunc
  1059. */
  1060. echarts.registerProcessor = function (stage, processorFunc) {
  1061. if (zrUtil.indexOf(PROCESSOR_STAGES, stage) < 0) {
  1062. throw new Error('stage should be one of ' + PROCESSOR_STAGES);
  1063. }
  1064. var funcs = dataProcessorFuncs[stage] || (dataProcessorFuncs[stage] = []);
  1065. funcs.push(processorFunc);
  1066. };
  1067. /**
  1068. * Usage:
  1069. * registerAction('someAction', 'someEvent', function () { ... });
  1070. * registerAction('someAction', function () { ... });
  1071. * registerAction(
  1072. * {type: 'someAction', event: 'someEvent', update: 'updateView'},
  1073. * function () { ... }
  1074. * );
  1075. *
  1076. * @param {(string|Object)} actionInfo
  1077. * @param {string} actionInfo.type
  1078. * @param {string} [actionInfo.event]
  1079. * @param {string} [actionInfo.update]
  1080. * @param {string} [eventName]
  1081. * @param {Function} action
  1082. */
  1083. echarts.registerAction = function (actionInfo, eventName, action) {
  1084. if (typeof eventName === 'function') {
  1085. action = eventName;
  1086. eventName = '';
  1087. }
  1088. var actionType = zrUtil.isObject(actionInfo)
  1089. ? actionInfo.type
  1090. : ([actionInfo, actionInfo = {
  1091. event: eventName
  1092. }][0]);
  1093. // Event name is all lowercase
  1094. actionInfo.event = (actionInfo.event || actionType).toLowerCase();
  1095. eventName = actionInfo.event;
  1096. if (!actions[actionType]) {
  1097. actions[actionType] = {action: action, actionInfo: actionInfo};
  1098. }
  1099. eventActionMap[eventName] = actionType;
  1100. };
  1101. /**
  1102. * @param {string} type
  1103. * @param {*} CoordinateSystem
  1104. */
  1105. echarts.registerCoordinateSystem = function (type, CoordinateSystem) {
  1106. CoordinateSystemManager.register(type, CoordinateSystem);
  1107. };
  1108. /**
  1109. * @param {*} layout
  1110. */
  1111. echarts.registerLayout = function (layout) {
  1112. // PENDING All functions ?
  1113. if (zrUtil.indexOf(layoutFuncs, layout) < 0) {
  1114. layoutFuncs.push(layout);
  1115. }
  1116. };
  1117. /**
  1118. * @param {string} stage
  1119. * @param {Function} visualCodingFunc
  1120. */
  1121. echarts.registerVisualCoding = function (stage, visualCodingFunc) {
  1122. if (zrUtil.indexOf(VISUAL_CODING_STAGES, stage) < 0) {
  1123. throw new Error('stage should be one of ' + VISUAL_CODING_STAGES);
  1124. }
  1125. var funcs = visualCodingFuncs[stage] || (visualCodingFuncs[stage] = []);
  1126. funcs.push(visualCodingFunc);
  1127. };
  1128. /**
  1129. * @param {Object} opts
  1130. */
  1131. echarts.extendChartView = function (opts) {
  1132. return ChartView.extend(opts);
  1133. };
  1134. /**
  1135. * @param {Object} opts
  1136. */
  1137. echarts.extendComponentModel = function (opts) {
  1138. return ComponentModel.extend(opts);
  1139. };
  1140. /**
  1141. * @param {Object} opts
  1142. */
  1143. echarts.extendSeriesModel = function (opts) {
  1144. return SeriesModel.extend(opts);
  1145. };
  1146. /**
  1147. * @param {Object} opts
  1148. */
  1149. echarts.extendComponentView = function (opts) {
  1150. return ComponentView.extend(opts);
  1151. };
  1152. /**
  1153. * ZRender need a canvas context to do measureText.
  1154. * But in node environment canvas may be created by node-canvas.
  1155. * So we need to specify how to create a canvas instead of using document.createElement('canvas')
  1156. *
  1157. * Be careful of using it in the browser.
  1158. *
  1159. * @param {Function} creator
  1160. * @example
  1161. * var Canvas = require('canvas');
  1162. * var echarts = require('echarts');
  1163. * echarts.setCanvasCreator(function () {
  1164. * // Small size is enough.
  1165. * return new Canvas(32, 32);
  1166. * });
  1167. */
  1168. echarts.setCanvasCreator = function (creator) {
  1169. zrUtil.createCanvas = creator;
  1170. };
  1171. echarts.registerVisualCoding('echarts', zrUtil.curry(
  1172. __webpack_require__(89), '', 'itemStyle'
  1173. ));
  1174. echarts.registerPreprocessor(__webpack_require__(90));
  1175. // Default action
  1176. echarts.registerAction({
  1177. type: 'highlight',
  1178. event: 'highlight',
  1179. update: 'highlight'
  1180. }, zrUtil.noop);
  1181. echarts.registerAction({
  1182. type: 'downplay',
  1183. event: 'downplay',
  1184. update: 'downplay'
  1185. }, zrUtil.noop);
  1186. // --------
  1187. // Exports
  1188. // --------
  1189. echarts.graphic = __webpack_require__(42);
  1190. echarts.number = __webpack_require__(7);
  1191. echarts.format = __webpack_require__(6);
  1192. echarts.matrix = __webpack_require__(17);
  1193. echarts.vector = __webpack_require__(16);
  1194. echarts.util = {};
  1195. each([
  1196. 'map', 'each', 'filter', 'indexOf', 'inherits',
  1197. 'reduce', 'filter', 'bind', 'curry', 'isArray',
  1198. 'isString', 'isObject', 'isFunction', 'extend'
  1199. ],
  1200. function (name) {
  1201. echarts.util[name] = zrUtil[name];
  1202. }
  1203. );
  1204. module.exports = echarts;
  1205. /***/ },
  1206. /* 2 */
  1207. /***/ function(module, exports, __webpack_require__) {
  1208. /**
  1209. * ECharts global model
  1210. *
  1211. * @module {echarts/model/Global}
  1212. *
  1213. */
  1214. var zrUtil = __webpack_require__(3);
  1215. var modelUtil = __webpack_require__(5);
  1216. var Model = __webpack_require__(8);
  1217. var each = zrUtil.each;
  1218. var filter = zrUtil.filter;
  1219. var map = zrUtil.map;
  1220. var isArray = zrUtil.isArray;
  1221. var indexOf = zrUtil.indexOf;
  1222. var isObject = zrUtil.isObject;
  1223. var ComponentModel = __webpack_require__(19);
  1224. var globalDefault = __webpack_require__(23);
  1225. var OPTION_INNER_KEY = '\0_ec_inner';
  1226. /**
  1227. * @alias module:echarts/model/Global
  1228. *
  1229. * @param {Object} option
  1230. * @param {module:echarts/model/Model} parentModel
  1231. * @param {Object} theme
  1232. */
  1233. var GlobalModel = Model.extend({
  1234. constructor: GlobalModel,
  1235. init: function (option, parentModel, theme, optionManager) {
  1236. theme = theme || {};
  1237. this.option = null; // Mark as not initialized.
  1238. /**
  1239. * @type {module:echarts/model/Model}
  1240. * @private
  1241. */
  1242. this._theme = new Model(theme);
  1243. /**
  1244. * @type {module:echarts/model/OptionManager}
  1245. */
  1246. this._optionManager = optionManager;
  1247. },
  1248. setOption: function (option, optionPreprocessorFuncs) {
  1249. zrUtil.assert(
  1250. !(OPTION_INNER_KEY in option),
  1251. 'please use chart.getOption()'
  1252. );
  1253. this._optionManager.setOption(option, optionPreprocessorFuncs);
  1254. this.resetOption();
  1255. },
  1256. /**
  1257. * @param {string} type null/undefined: reset all.
  1258. * 'recreate': force recreate all.
  1259. * 'timeline': only reset timeline option
  1260. * 'media': only reset media query option
  1261. * @return {boolean} Whether option changed.
  1262. */
  1263. resetOption: function (type) {
  1264. var optionChanged = false;
  1265. var optionManager = this._optionManager;
  1266. if (!type || type === 'recreate') {
  1267. var baseOption = optionManager.mountOption(type === 'recreate');
  1268. if (!this.option || type === 'recreate') {
  1269. initBase.call(this, baseOption);
  1270. }
  1271. else {
  1272. this.restoreData();
  1273. this.mergeOption(baseOption);
  1274. }
  1275. optionChanged = true;
  1276. }
  1277. if (type === 'timeline' || type === 'media') {
  1278. this.restoreData();
  1279. }
  1280. if (!type || type === 'recreate' || type === 'timeline') {
  1281. var timelineOption = optionManager.getTimelineOption(this);
  1282. timelineOption && (this.mergeOption(timelineOption), optionChanged = true);
  1283. }
  1284. if (!type || type === 'recreate' || type === 'media') {
  1285. var mediaOptions = optionManager.getMediaOption(this, this._api);
  1286. if (mediaOptions.length) {
  1287. each(mediaOptions, function (mediaOption) {
  1288. this.mergeOption(mediaOption, optionChanged = true);
  1289. }, this);
  1290. }
  1291. }
  1292. return optionChanged;
  1293. },
  1294. /**
  1295. * @protected
  1296. */
  1297. mergeOption: function (newOption) {
  1298. var option = this.option;
  1299. var componentsMap = this._componentsMap;
  1300. var newCptTypes = [];
  1301. // 如果不存在对应的 component model 则直接 merge
  1302. each(newOption, function (componentOption, mainType) {
  1303. if (componentOption == null) {
  1304. return;
  1305. }
  1306. if (!ComponentModel.hasClass(mainType)) {
  1307. option[mainType] = option[mainType] == null
  1308. ? zrUtil.clone(componentOption)
  1309. : zrUtil.merge(option[mainType], componentOption, true);
  1310. }
  1311. else {
  1312. newCptTypes.push(mainType);
  1313. }
  1314. });
  1315. // FIXME OPTION 同步是否要改回原来的
  1316. ComponentModel.topologicalTravel(
  1317. newCptTypes, ComponentModel.getAllClassMainTypes(), visitComponent, this
  1318. );
  1319. function visitComponent(mainType, dependencies) {
  1320. var newCptOptionList = modelUtil.normalizeToArray(newOption[mainType]);
  1321. var mapResult = modelUtil.mappingToExists(
  1322. componentsMap[mainType], newCptOptionList
  1323. );
  1324. makeKeyInfo(mainType, mapResult);
  1325. var dependentModels = getComponentsByTypes(
  1326. componentsMap, dependencies
  1327. );
  1328. option[mainType] = [];
  1329. componentsMap[mainType] = [];
  1330. each(mapResult, function (resultItem, index) {
  1331. var componentModel = resultItem.exist;
  1332. var newCptOption = resultItem.option;
  1333. zrUtil.assert(
  1334. isObject(newCptOption) || componentModel,
  1335. 'Empty component definition'
  1336. );
  1337. // Consider where is no new option and should be merged using {},
  1338. // see removeEdgeAndAdd in topologicalTravel and
  1339. // ComponentModel.getAllClassMainTypes.
  1340. if (!newCptOption) {
  1341. componentModel.mergeOption({}, this);
  1342. componentModel.optionUpdated(this);
  1343. }
  1344. else {
  1345. var ComponentModelClass = ComponentModel.getClass(
  1346. mainType, resultItem.keyInfo.subType, true
  1347. );
  1348. if (componentModel && componentModel instanceof ComponentModelClass) {
  1349. componentModel.mergeOption(newCptOption, this);
  1350. componentModel.optionUpdated(this);
  1351. }
  1352. else {
  1353. // PENDING Global as parent ?
  1354. componentModel = new ComponentModelClass(
  1355. newCptOption, this, this,
  1356. zrUtil.extend(
  1357. {
  1358. dependentModels: dependentModels,
  1359. componentIndex: index
  1360. },
  1361. resultItem.keyInfo
  1362. )
  1363. );
  1364. // Call optionUpdated after init
  1365. componentModel.optionUpdated(this);
  1366. }
  1367. }
  1368. componentsMap[mainType][index] = componentModel;
  1369. option[mainType][index] = componentModel.option;
  1370. }, this);
  1371. // Backup series for filtering.
  1372. if (mainType === 'series') {
  1373. this._seriesIndices = createSeriesIndices(componentsMap.series);
  1374. }
  1375. }
  1376. },
  1377. /**
  1378. * Get option for output (cloned option and inner info removed)
  1379. * @public
  1380. * @return {Object}
  1381. */
  1382. getOption: function () {
  1383. var option = zrUtil.clone(this.option);
  1384. each(option, function (opts, mainType) {
  1385. if (ComponentModel.hasClass(mainType)) {
  1386. var opts = modelUtil.normalizeToArray(opts);
  1387. for (var i = opts.length - 1; i >= 0; i--) {
  1388. // Remove options with inner id.
  1389. if (modelUtil.isIdInner(opts[i])) {
  1390. opts.splice(i, 1);
  1391. }
  1392. }
  1393. option[mainType] = opts;
  1394. }
  1395. });
  1396. delete option[OPTION_INNER_KEY];
  1397. return option;
  1398. },
  1399. /**
  1400. * @return {module:echarts/model/Model}
  1401. */
  1402. getTheme: function () {
  1403. return this._theme;
  1404. },
  1405. /**
  1406. * @param {string} mainType
  1407. * @param {number} [idx=0]
  1408. * @return {module:echarts/model/Component}
  1409. */
  1410. getComponent: function (mainType, idx) {
  1411. var list = this._componentsMap[mainType];
  1412. if (list) {
  1413. return list[idx || 0];
  1414. }
  1415. },
  1416. /**
  1417. * @param {Object} condition
  1418. * @param {string} condition.mainType
  1419. * @param {string} [condition.subType] If ignore, only query by mainType
  1420. * @param {number} [condition.index] Either input index or id or name.
  1421. * @param {string} [condition.id] Either input index or id or name.
  1422. * @param {string} [condition.name] Either input index or id or name.
  1423. * @return {Array.<module:echarts/model/Component>}
  1424. */
  1425. queryComponents: function (condition) {
  1426. var mainType = condition.mainType;
  1427. if (!mainType) {
  1428. return [];
  1429. }
  1430. var index = condition.index;
  1431. var id = condition.id;
  1432. var name = condition.name;
  1433. var cpts = this._componentsMap[mainType];
  1434. if (!cpts || !cpts.length) {
  1435. return [];
  1436. }
  1437. var result;
  1438. if (index != null) {
  1439. if (!isArray(index)) {
  1440. index = [index];
  1441. }
  1442. result = filter(map(index, function (idx) {
  1443. return cpts[idx];
  1444. }), function (val) {
  1445. return !!val;
  1446. });
  1447. }
  1448. else if (id != null) {
  1449. var isIdArray = isArray(id);
  1450. result = filter(cpts, function (cpt) {
  1451. return (isIdArray && indexOf(id, cpt.id) >= 0)
  1452. || (!isIdArray && cpt.id === id);
  1453. });
  1454. }
  1455. else if (name != null) {
  1456. var isNameArray = isArray(name);
  1457. result = filter(cpts, function (cpt) {
  1458. return (isNameArray && indexOf(name, cpt.name) >= 0)
  1459. || (!isNameArray && cpt.name === name);
  1460. });
  1461. }
  1462. return filterBySubType(result, condition);
  1463. },
  1464. /**
  1465. * The interface is different from queryComponents,
  1466. * which is convenient for inner usage.
  1467. *
  1468. * @usage
  1469. * var result = findComponents(
  1470. * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}}
  1471. * );
  1472. * var result = findComponents(
  1473. * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}}
  1474. * );
  1475. * var result = findComponents(
  1476. * {mainType: 'series'},
  1477. * function (model, index) {...}
  1478. * );
  1479. * // result like [component0, componnet1, ...]
  1480. *
  1481. * @param {Object} condition
  1482. * @param {string} condition.mainType Mandatory.
  1483. * @param {string} [condition.subType] Optional.
  1484. * @param {Object} [condition.query] like {xxxIndex, xxxId, xxxName},
  1485. * where xxx is mainType.
  1486. * If query attribute is null/undefined or has no index/id/name,
  1487. * do not filtering by query conditions, which is convenient for
  1488. * no-payload situations or when target of action is global.
  1489. * @param {Function} [condition.filter] parameter: component, return boolean.
  1490. * @return {Array.<module:echarts/model/Component>}
  1491. */
  1492. findComponents: function (condition) {
  1493. var query = condition.query;
  1494. var mainType = condition.mainType;
  1495. var queryCond = getQueryCond(query);
  1496. var result = queryCond
  1497. ? this.queryComponents(queryCond)
  1498. : this._componentsMap[mainType];
  1499. return doFilter(filterBySubType(result, condition));
  1500. function getQueryCond(q) {
  1501. var indexAttr = mainType + 'Index';
  1502. var idAttr = mainType + 'Id';
  1503. var nameAttr = mainType + 'Name';
  1504. return q && (
  1505. q.hasOwnProperty(indexAttr)
  1506. || q.hasOwnProperty(idAttr)
  1507. || q.hasOwnProperty(nameAttr)
  1508. )
  1509. ? {
  1510. mainType: mainType,
  1511. // subType will be filtered finally.
  1512. index: q[indexAttr],
  1513. id: q[idAttr],
  1514. name: q[nameAttr]
  1515. }
  1516. : null;
  1517. }
  1518. function doFilter(res) {
  1519. return condition.filter
  1520. ? filter(res, condition.filter)
  1521. : res;
  1522. }
  1523. },
  1524. /**
  1525. * @usage
  1526. * eachComponent('legend', function (legendModel, index) {
  1527. * ...
  1528. * });
  1529. * eachComponent(function (componentType, model, index) {
  1530. * // componentType does not include subType
  1531. * // (componentType is 'xxx' but not 'xxx.aa')
  1532. * });
  1533. * eachComponent(
  1534. * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}},
  1535. * function (model, index) {...}
  1536. * );
  1537. * eachComponent(
  1538. * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}},
  1539. * function (model, index) {...}
  1540. * );
  1541. *
  1542. * @param {string|Object=} mainType When mainType is object, the definition
  1543. * is the same as the method 'findComponents'.
  1544. * @param {Function} cb
  1545. * @param {*} context
  1546. */
  1547. eachComponent: function (mainType, cb, context) {
  1548. var componentsMap = this._componentsMap;
  1549. if (typeof mainType === 'function') {
  1550. context = cb;
  1551. cb = mainType;
  1552. each(componentsMap, function (components, componentType) {
  1553. each(components, function (component, index) {
  1554. cb.call(context, componentType, component, index);
  1555. });
  1556. });
  1557. }
  1558. else if (zrUtil.isString(mainType)) {
  1559. each(componentsMap[mainType], cb, context);
  1560. }
  1561. else if (isObject(mainType)) {
  1562. var queryResult = this.findComponents(mainType);
  1563. each(queryResult, cb, context);
  1564. }
  1565. },
  1566. /**
  1567. * @param {string} name
  1568. * @return {Array.<module:echarts/model/Series>}
  1569. */
  1570. getSeriesByName: function (name) {
  1571. var series = this._componentsMap.series;
  1572. return filter(series, function (oneSeries) {
  1573. return oneSeries.name === name;
  1574. });
  1575. },
  1576. /**
  1577. * @param {number} seriesIndex
  1578. * @return {module:echarts/model/Series}
  1579. */
  1580. getSeriesByIndex: function (seriesIndex) {
  1581. return this._componentsMap.series[seriesIndex];
  1582. },
  1583. /**
  1584. * @param {string} subType
  1585. * @return {Array.<module:echarts/model/Series>}
  1586. */
  1587. getSeriesByType: function (subType) {
  1588. var series = this._componentsMap.series;
  1589. return filter(series, function (oneSeries) {
  1590. return oneSeries.subType === subType;
  1591. });
  1592. },
  1593. /**
  1594. * @return {Array.<module:echarts/model/Series>}
  1595. */
  1596. getSeries: function () {
  1597. return this._componentsMap.series.slice();
  1598. },
  1599. /**
  1600. * After filtering, series may be different
  1601. * frome raw series.
  1602. *
  1603. * @param {Function} cb
  1604. * @param {*} context
  1605. */
  1606. eachSeries: function (cb, context) {
  1607. assertSeriesInitialized(this);
  1608. each(this._seriesIndices, function (rawSeriesIndex) {
  1609. var series = this._componentsMap.series[rawSeriesIndex];
  1610. cb.call(context, series, rawSeriesIndex);
  1611. }, this);
  1612. },
  1613. /**
  1614. * Iterate raw series before filtered.
  1615. *
  1616. * @param {Function} cb
  1617. * @param {*} context
  1618. */
  1619. eachRawSeries: function (cb, context) {
  1620. each(this._componentsMap.series, cb, context);
  1621. },
  1622. /**
  1623. * After filtering, series may be different.
  1624. * frome raw series.
  1625. *
  1626. * @parma {string} subType
  1627. * @param {Function} cb
  1628. * @param {*} context
  1629. */
  1630. eachSeriesByType: function (subType, cb, context) {
  1631. assertSeriesInitialized(this);
  1632. each(this._seriesIndices, function (rawSeriesIndex) {
  1633. var series = this._componentsMap.series[rawSeriesIndex];
  1634. if (series.subType === subType) {
  1635. cb.call(context, series, rawSeriesIndex);
  1636. }
  1637. }, this);
  1638. },
  1639. /**
  1640. * Iterate raw series before filtered of given type.
  1641. *
  1642. * @parma {string} subType
  1643. * @param {Function} cb
  1644. * @param {*} context
  1645. */
  1646. eachRawSeriesByType: function (subType, cb, context) {
  1647. return each(this.getSeriesByType(subType), cb, context);
  1648. },
  1649. /**
  1650. * @param {module:echarts/model/Series} seriesModel
  1651. */
  1652. isSeriesFiltered: function (seriesModel) {
  1653. assertSeriesInitialized(this);
  1654. return zrUtil.indexOf(this._seriesIndices, seriesModel.componentIndex) < 0;
  1655. },
  1656. /**
  1657. * @param {Function} cb
  1658. * @param {*} context
  1659. */
  1660. filterSeries: function (cb, context) {
  1661. assertSeriesInitialized(this);
  1662. var filteredSeries = filter(
  1663. this._componentsMap.series, cb, context
  1664. );
  1665. this._seriesIndices = createSeriesIndices(filteredSeries);
  1666. },
  1667. restoreData: function () {
  1668. var componentsMap = this._componentsMap;
  1669. this._seriesIndices = createSeriesIndices(componentsMap.series);
  1670. var componentTypes = [];
  1671. each(componentsMap, function (components, componentType) {
  1672. componentTypes.push(componentType);
  1673. });
  1674. ComponentModel.topologicalTravel(
  1675. componentTypes,
  1676. ComponentModel.getAllClassMainTypes(),
  1677. function (componentType, dependencies) {
  1678. each(componentsMap[componentType], function (component) {
  1679. component.restoreData();
  1680. });
  1681. }
  1682. );
  1683. }
  1684. });
  1685. /**
  1686. * @inner
  1687. */
  1688. function mergeTheme(option, theme) {
  1689. for (var name in theme) {
  1690. // 如果有 component model 则把具体的 merge 逻辑交给该 model 处理
  1691. if (!ComponentModel.hasClass(name)) {
  1692. if (typeof theme[name] === 'object') {
  1693. option[name] = !option[name]
  1694. ? zrUtil.clone(theme[name])
  1695. : zrUtil.merge(option[name], theme[name], false);
  1696. }
  1697. else {
  1698. if (option[name] == null) {
  1699. option[name] = theme[name];
  1700. }
  1701. }
  1702. }
  1703. }
  1704. }
  1705. function initBase(baseOption) {
  1706. baseOption = baseOption;
  1707. // Using OPTION_INNER_KEY to mark that this option can not be used outside,
  1708. // i.e. `chart.setOption(chart.getModel().option);` is forbiden.
  1709. this.option = {};
  1710. this.option[OPTION_INNER_KEY] = 1;
  1711. /**
  1712. * @type {Object.<string, Array.<module:echarts/model/Model>>}
  1713. * @private
  1714. */
  1715. this._componentsMap = {};
  1716. /**
  1717. * Mapping between filtered series list and raw series list.
  1718. * key: filtered series indices, value: raw series indices.
  1719. * @type {Array.<nubmer>}
  1720. * @private
  1721. */
  1722. this._seriesIndices = null;
  1723. mergeTheme(baseOption, this._theme.option);
  1724. // TODO Needs clone when merging to the unexisted property
  1725. zrUtil.merge(baseOption, globalDefault, false);
  1726. this.mergeOption(baseOption);
  1727. }
  1728. /**
  1729. * @inner
  1730. * @param {Array.<string>|string} types model types
  1731. * @return {Object} key: {string} type, value: {Array.<Object>} models
  1732. */
  1733. function getComponentsByTypes(componentsMap, types) {
  1734. if (!zrUtil.isArray(types)) {
  1735. types = types ? [types] : [];
  1736. }
  1737. var ret = {};
  1738. each(types, function (type) {
  1739. ret[type] = (componentsMap[type] || []).slice();
  1740. });
  1741. return ret;
  1742. }
  1743. /**
  1744. * @inner
  1745. */
  1746. function makeKeyInfo(mainType, mapResult) {
  1747. // We use this id to hash component models and view instances
  1748. // in echarts. id can be specified by user, or auto generated.
  1749. // The id generation rule ensures new view instance are able
  1750. // to mapped to old instance when setOption are called in
  1751. // no-merge mode. So we generate model id by name and plus
  1752. // type in view id.
  1753. // name can be duplicated among components, which is convenient
  1754. // to specify multi components (like series) by one name.
  1755. // Ensure that each id is distinct.
  1756. var idMap = {};
  1757. each(mapResult, function (item, index) {
  1758. var existCpt = item.exist;
  1759. existCpt && (idMap[existCpt.id] = item);
  1760. });
  1761. each(mapResult, function (item, index) {
  1762. var opt = item.option;
  1763. zrUtil.assert(
  1764. !opt || opt.id == null || !idMap[opt.id] || idMap[opt.id] === item,
  1765. 'id duplicates: ' + (opt && opt.id)
  1766. );
  1767. opt && opt.id != null && (idMap[opt.id] = item);
  1768. // Complete subType
  1769. if (isObject(opt)) {
  1770. var subType = determineSubType(mainType, opt, item.exist);
  1771. item.keyInfo = {mainType: mainType, subType: subType};
  1772. }
  1773. });
  1774. // Make name and id.
  1775. each(mapResult, function (item, index) {
  1776. var existCpt = item.exist;
  1777. var opt = item.option;
  1778. var keyInfo = item.keyInfo;
  1779. if (!isObject(opt)) {
  1780. return;
  1781. }
  1782. // name can be overwitten. Consider case: axis.name = '20km'.
  1783. // But id generated by name will not be changed, which affect
  1784. // only in that case: setOption with 'not merge mode' and view
  1785. // instance will be recreated, which can be accepted.
  1786. keyInfo.name = opt.name != null
  1787. ? opt.name + ''
  1788. : existCpt
  1789. ? existCpt.name
  1790. : '\0-';
  1791. if (existCpt) {
  1792. keyInfo.id = existCpt.id;
  1793. }
  1794. else if (opt.id != null) {
  1795. keyInfo.id = opt.id + '';
  1796. }
  1797. else {
  1798. // Consider this situatoin:
  1799. // optionA: [{name: 'a'}, {name: 'a'}, {..}]
  1800. // optionB [{..}, {name: 'a'}, {name: 'a'}]
  1801. // Series with the same name between optionA and optionB
  1802. // should be mapped.
  1803. var idNum = 0;
  1804. do {
  1805. keyInfo.id = '\0' + keyInfo.name + '\0' + idNum++;
  1806. }
  1807. while (idMap[keyInfo.id]);
  1808. }
  1809. idMap[keyInfo.id] = item;
  1810. });
  1811. }
  1812. /**
  1813. * @inner
  1814. */
  1815. function determineSubType(mainType, newCptOption, existComponent) {
  1816. var subType = newCptOption.type
  1817. ? newCptOption.type
  1818. : existComponent
  1819. ? existComponent.subType
  1820. // Use determineSubType only when there is no existComponent.
  1821. : ComponentModel.determineSubType(mainType, newCptOption);
  1822. // tooltip, markline, markpoint may always has no subType
  1823. return subType;
  1824. }
  1825. /**
  1826. * @inner
  1827. */
  1828. function createSeriesIndices(seriesModels) {
  1829. return map(seriesModels, function (series) {
  1830. return series.componentIndex;
  1831. }) || [];
  1832. }
  1833. /**
  1834. * @inner
  1835. */
  1836. function filterBySubType(components, condition) {
  1837. // Using hasOwnProperty for restrict. Consider
  1838. // subType is undefined in user payload.
  1839. return condition.hasOwnProperty('subType')
  1840. ? filter(components, function (cpt) {
  1841. return cpt.subType === condition.subType;
  1842. })
  1843. : components;
  1844. }
  1845. /**
  1846. * @inner
  1847. */
  1848. function assertSeriesInitialized(ecModel) {
  1849. // Components that use _seriesIndices should depends on series component,
  1850. // which make sure that their initialization is after series.
  1851. if (!ecModel._seriesIndices) {
  1852. throw new Error('Series has not been initialized yet.');
  1853. }
  1854. }
  1855. module.exports = GlobalModel;
  1856. /***/ },
  1857. /* 3 */
  1858. /***/ function(module, exports, __webpack_require__) {
  1859. /**
  1860. * @module zrender/core/util
  1861. */
  1862. var Gradient = __webpack_require__(4);
  1863. // 用于处理merge时无法遍历Date等对象的问题
  1864. var BUILTIN_OBJECT = {
  1865. '[object Function]': 1,
  1866. '[object RegExp]': 1,
  1867. '[object Date]': 1,
  1868. '[object Error]': 1,
  1869. '[object CanvasGradient]': 1
  1870. };
  1871. var objToString = Object.prototype.toString;
  1872. var arrayProto = Array.prototype;
  1873. var nativeForEach = arrayProto.forEach;
  1874. var nativeFilter = arrayProto.filter;
  1875. var nativeSlice = arrayProto.slice;
  1876. var nativeMap = arrayProto.map;
  1877. var nativeReduce = arrayProto.reduce;
  1878. /**
  1879. * @param {*} source
  1880. * @return {*} 拷贝后的新对象
  1881. */
  1882. function clone(source) {
  1883. if (typeof source == 'object' && source !== null) {
  1884. var result = source;
  1885. if (source instanceof Array) {
  1886. result = [];
  1887. for (var i = 0, len = source.length; i < len; i++) {
  1888. result[i] = clone(source[i]);
  1889. }
  1890. }
  1891. else if (
  1892. !isBuildInObject(source)
  1893. // 是否为 dom 对象
  1894. && !isDom(source)
  1895. ) {
  1896. result = {};
  1897. for (var key in source) {
  1898. if (source.hasOwnProperty(key)) {
  1899. result[key] = clone(source[key]);
  1900. }
  1901. }
  1902. }
  1903. return result;
  1904. }
  1905. return source;
  1906. }
  1907. /**
  1908. * @memberOf module:zrender/core/util
  1909. * @param {*} target
  1910. * @param {*} source
  1911. * @param {boolean} [overwrite=false]
  1912. */
  1913. function merge(target, source, overwrite) {
  1914. // We should escapse that source is string
  1915. // and enter for ... in ...
  1916. if (!isObject(source) || !isObject(target)) {
  1917. return overwrite ? clone(source) : target;
  1918. }
  1919. for (var key in source) {
  1920. if (source.hasOwnProperty(key)) {
  1921. var targetProp = target[key];
  1922. var sourceProp = source[key];
  1923. if (isObject(sourceProp)
  1924. && isObject(targetProp)
  1925. && !isArray(sourceProp)
  1926. && !isArray(targetProp)
  1927. && !isDom(sourceProp)
  1928. && !isDom(targetProp)
  1929. && !isBuildInObject(sourceProp)
  1930. && !isBuildInObject(targetProp)
  1931. ) {
  1932. // 如果需要递归覆盖,就递归调用merge
  1933. merge(targetProp, sourceProp, overwrite);
  1934. }
  1935. else if (overwrite || !(key in target)) {
  1936. // 否则只处理overwrite为true,或者在目标对象中没有此属性的情况
  1937. // NOTE,在 target[key] 不存在的时候也是直接覆盖
  1938. target[key] = clone(source[key], true);
  1939. }
  1940. }
  1941. }
  1942. return target;
  1943. }
  1944. /**
  1945. * @param {Array} targetAndSources The first item is target, and the rests are source.
  1946. * @param {boolean} [overwrite=false]
  1947. * @return {*} target
  1948. */
  1949. function mergeAll(targetAndSources, overwrite) {
  1950. var result = targetAndSources[0];
  1951. for (var i = 1, len = targetAndSources.length; i < len; i++) {
  1952. result = merge(result, targetAndSources[i], overwrite);
  1953. }
  1954. return result;
  1955. }
  1956. /**
  1957. * @param {*} target
  1958. * @param {*} source
  1959. * @memberOf module:zrender/core/util
  1960. */
  1961. function extend(target, source) {
  1962. for (var key in source) {
  1963. if (source.hasOwnProperty(key)) {
  1964. target[key] = source[key];
  1965. }
  1966. }
  1967. return target;
  1968. }
  1969. /**
  1970. * @param {*} target
  1971. * @param {*} source
  1972. * @param {boolen} [overlay=false]
  1973. * @memberOf module:zrender/core/util
  1974. */
  1975. function defaults(target, source, overlay) {
  1976. for (var key in source) {
  1977. if (source.hasOwnProperty(key)
  1978. && (overlay ? source[key] != null : target[key] == null)
  1979. ) {
  1980. target[key] = source[key];
  1981. }
  1982. }
  1983. return target;
  1984. }
  1985. function createCanvas() {
  1986. return document.createElement('canvas');
  1987. }
  1988. // FIXME
  1989. var _ctx;
  1990. function getContext() {
  1991. if (!_ctx) {
  1992. // Use util.createCanvas instead of createCanvas
  1993. // because createCanvas may be overwritten in different environment
  1994. _ctx = util.createCanvas().getContext('2d');
  1995. }
  1996. return _ctx;
  1997. }
  1998. /**
  1999. * 查询数组中元素的index
  2000. * @memberOf module:zrender/core/util
  2001. */
  2002. function indexOf(array, value) {
  2003. if (array) {
  2004. if (array.indexOf) {
  2005. return array.indexOf(value);
  2006. }
  2007. for (var i = 0, len = array.length; i < len; i++) {
  2008. if (array[i] === value) {
  2009. return i;
  2010. }
  2011. }
  2012. }
  2013. return -1;
  2014. }
  2015. /**
  2016. * 构造类继承关系
  2017. *
  2018. * @memberOf module:zrender/core/util
  2019. * @param {Function} clazz 源类
  2020. * @param {Function} baseClazz 基类
  2021. */
  2022. function inherits(clazz, baseClazz) {
  2023. var clazzPrototype = clazz.prototype;
  2024. function F() {}
  2025. F.prototype = baseClazz.prototype;
  2026. clazz.prototype = new F();
  2027. for (var prop in clazzPrototype) {
  2028. clazz.prototype[prop] = clazzPrototype[prop];
  2029. }
  2030. clazz.prototype.constructor = clazz;
  2031. clazz.superClass = baseClazz;
  2032. }
  2033. /**
  2034. * @memberOf module:zrender/core/util
  2035. * @param {Object|Function} target
  2036. * @param {Object|Function} sorce
  2037. * @param {boolean} overlay
  2038. */
  2039. function mixin(target, source, overlay) {
  2040. target = 'prototype' in target ? target.prototype : target;
  2041. source = 'prototype' in source ? source.prototype : source;
  2042. defaults(target, source, overlay);
  2043. }
  2044. /**
  2045. * @param {Array|TypedArray} data
  2046. */
  2047. function isArrayLike(data) {
  2048. if (! data) {
  2049. return;
  2050. }
  2051. if (typeof data == 'string') {
  2052. return false;
  2053. }
  2054. return typeof data.length == 'number';
  2055. }
  2056. /**
  2057. * 数组或对象遍历
  2058. * @memberOf module:zrender/core/util
  2059. * @param {Object|Array} obj
  2060. * @param {Function} cb
  2061. * @param {*} [context]
  2062. */
  2063. function each(obj, cb, context) {
  2064. if (!(obj && cb)) {
  2065. return;
  2066. }
  2067. if (obj.forEach && obj.forEach === nativeForEach) {
  2068. obj.forEach(cb, context);
  2069. }
  2070. else if (obj.length === +obj.length) {
  2071. for (var i = 0, len = obj.length; i < len; i++) {
  2072. cb.call(context, obj[i], i, obj);
  2073. }
  2074. }
  2075. else {
  2076. for (var key in obj) {
  2077. if (obj.hasOwnProperty(key)) {
  2078. cb.call(context, obj[key], key, obj);
  2079. }
  2080. }
  2081. }
  2082. }
  2083. /**
  2084. * 数组映射
  2085. * @memberOf module:zrender/core/util
  2086. * @param {Array} obj
  2087. * @param {Function} cb
  2088. * @param {*} [context]
  2089. * @return {Array}
  2090. */
  2091. function map(obj, cb, context) {
  2092. if (!(obj && cb)) {
  2093. return;
  2094. }
  2095. if (obj.map && obj.map === nativeMap) {
  2096. return obj.map(cb, context);
  2097. }
  2098. else {
  2099. var result = [];
  2100. for (var i = 0, len = obj.length; i < len; i++) {
  2101. result.push(cb.call(context, obj[i], i, obj));
  2102. }
  2103. return result;
  2104. }
  2105. }
  2106. /**
  2107. * @memberOf module:zrender/core/util
  2108. * @param {Array} obj
  2109. * @param {Function} cb
  2110. * @param {Object} [memo]
  2111. * @param {*} [context]
  2112. * @return {Array}
  2113. */
  2114. function reduce(obj, cb, memo, context) {
  2115. if (!(obj && cb)) {
  2116. return;
  2117. }
  2118. if (obj.reduce && obj.reduce === nativeReduce) {
  2119. return obj.reduce(cb, memo, context);
  2120. }
  2121. else {
  2122. for (var i = 0, len = obj.length; i < len; i++) {
  2123. memo = cb.call(context, memo, obj[i], i, obj);
  2124. }
  2125. return memo;
  2126. }
  2127. }
  2128. /**
  2129. * 数组过滤
  2130. * @memberOf module:zrender/core/util
  2131. * @param {Array} obj
  2132. * @param {Function} cb
  2133. * @param {*} [context]
  2134. * @return {Array}
  2135. */
  2136. function filter(obj, cb, context) {
  2137. if (!(obj && cb)) {
  2138. return;
  2139. }
  2140. if (obj.filter && obj.filter === nativeFilter) {
  2141. return obj.filter(cb, context);
  2142. }
  2143. else {
  2144. var result = [];
  2145. for (var i = 0, len = obj.length; i < len; i++) {
  2146. if (cb.call(context, obj[i], i, obj)) {
  2147. result.push(obj[i]);
  2148. }
  2149. }
  2150. return result;
  2151. }
  2152. }
  2153. /**
  2154. * 数组项查找
  2155. * @memberOf module:zrender/core/util
  2156. * @param {Array} obj
  2157. * @param {Function} cb
  2158. * @param {*} [context]
  2159. * @return {Array}
  2160. */
  2161. function find(obj, cb, context) {
  2162. if (!(obj && cb)) {
  2163. return;
  2164. }
  2165. for (var i = 0, len = obj.length; i < len; i++) {
  2166. if (cb.call(context, obj[i], i, obj)) {
  2167. return obj[i];
  2168. }
  2169. }
  2170. }
  2171. /**
  2172. * @memberOf module:zrender/core/util
  2173. * @param {Function} func
  2174. * @param {*} context
  2175. * @return {Function}
  2176. */
  2177. function bind(func, context) {
  2178. var args = nativeSlice.call(arguments, 2);
  2179. return function () {
  2180. return func.apply(context, args.concat(nativeSlice.call(arguments)));
  2181. };
  2182. }
  2183. /**
  2184. * @memberOf module:zrender/core/util
  2185. * @param {Function} func
  2186. * @return {Function}
  2187. */
  2188. function curry(func) {
  2189. var args = nativeSlice.call(arguments, 1);
  2190. return function () {
  2191. return func.apply(this, args.concat(nativeSlice.call(arguments)));
  2192. };
  2193. }
  2194. /**
  2195. * @memberOf module:zrender/core/util
  2196. * @param {*} value
  2197. * @return {boolean}
  2198. */
  2199. function isArray(value) {
  2200. return objToString.call(value) === '[object Array]';
  2201. }
  2202. /**
  2203. * @memberOf module:zrender/core/util
  2204. * @param {*} value
  2205. * @return {boolean}
  2206. */
  2207. function isFunction(value) {
  2208. return typeof value === 'function';
  2209. }
  2210. /**
  2211. * @memberOf module:zrender/core/util
  2212. * @param {*} value
  2213. * @return {boolean}
  2214. */
  2215. function isString(value) {
  2216. return objToString.call(value) === '[object String]';
  2217. }
  2218. /**
  2219. * @memberOf module:zrender/core/util
  2220. * @param {*} value
  2221. * @return {boolean}
  2222. */
  2223. function isObject(value) {
  2224. // Avoid a V8 JIT bug in Chrome 19-20.
  2225. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  2226. var type = typeof value;
  2227. return type === 'function' || (!!value && type == 'object');
  2228. }
  2229. /**
  2230. * @memberOf module:zrender/core/util
  2231. * @param {*} value
  2232. * @return {boolean}
  2233. */
  2234. function isBuildInObject(value) {
  2235. return !!BUILTIN_OBJECT[objToString.call(value)]
  2236. || (value instanceof Gradient);
  2237. }
  2238. /**
  2239. * @memberOf module:zrender/core/util
  2240. * @param {*} value
  2241. * @return {boolean}
  2242. */
  2243. function isDom(value) {
  2244. return value && value.nodeType === 1
  2245. && typeof(value.nodeName) == 'string';
  2246. }
  2247. /**
  2248. * If value1 is not null, then return value1, otherwise judget rest of values.
  2249. * @memberOf module:zrender/core/util
  2250. * @return {*} Final value
  2251. */
  2252. function retrieve(values) {
  2253. for (var i = 0, len = arguments.length; i < len; i++) {
  2254. if (arguments[i] != null) {
  2255. return arguments[i];
  2256. }
  2257. }
  2258. }
  2259. /**
  2260. * @memberOf module:zrender/core/util
  2261. * @param {Array} arr
  2262. * @param {number} startIndex
  2263. * @param {number} endIndex
  2264. * @return {Array}
  2265. */
  2266. function slice() {
  2267. return Function.call.apply(nativeSlice, arguments);
  2268. }
  2269. /**
  2270. * @memberOf module:zrender/core/util
  2271. * @param {boolean} condition
  2272. * @param {string} message
  2273. */
  2274. function assert(condition, message) {
  2275. if (!condition) {
  2276. throw new Error(message);
  2277. }
  2278. }
  2279. var util = {
  2280. inherits: inherits,
  2281. mixin: mixin,
  2282. clone: clone,
  2283. merge: merge,
  2284. mergeAll: mergeAll,
  2285. extend: extend,
  2286. defaults: defaults,
  2287. getContext: getContext,
  2288. createCanvas: createCanvas,
  2289. indexOf: indexOf,
  2290. slice: slice,
  2291. find: find,
  2292. isArrayLike: isArrayLike,
  2293. each: each,
  2294. map: map,
  2295. reduce: reduce,
  2296. filter: filter,
  2297. bind: bind,
  2298. curry: curry,
  2299. isArray: isArray,
  2300. isString: isString,
  2301. isObject: isObject,
  2302. isFunction: isFunction,
  2303. isBuildInObject: isBuildInObject,
  2304. isDom: isDom,
  2305. retrieve: retrieve,
  2306. assert: assert,
  2307. noop: function () {}
  2308. };
  2309. module.exports = util;
  2310. /***/ },
  2311. /* 4 */
  2312. /***/ function(module, exports) {
  2313. /**
  2314. * @param {Array.<Object>} colorStops
  2315. */
  2316. var Gradient = function (colorStops) {
  2317. this.colorStops = colorStops || [];
  2318. };
  2319. Gradient.prototype = {
  2320. constructor: Gradient,
  2321. addColorStop: function (offset, color) {
  2322. this.colorStops.push({
  2323. offset: offset,
  2324. color: color
  2325. });
  2326. }
  2327. };
  2328. module.exports = Gradient;
  2329. /***/ },
  2330. /* 5 */
  2331. /***/ function(module, exports, __webpack_require__) {
  2332. var formatUtil = __webpack_require__(6);
  2333. var nubmerUtil = __webpack_require__(7);
  2334. var zrUtil = __webpack_require__(3);
  2335. var AXIS_DIMS = ['x', 'y', 'z', 'radius', 'angle'];
  2336. var modelUtil = {};
  2337. /**
  2338. * Create "each" method to iterate names.
  2339. *
  2340. * @pubilc
  2341. * @param {Array.<string>} names
  2342. * @param {Array.<string>=} attrs
  2343. * @return {Function}
  2344. */
  2345. modelUtil.createNameEach = function (names, attrs) {
  2346. names = names.slice();
  2347. var capitalNames = zrUtil.map(names, modelUtil.capitalFirst);
  2348. attrs = (attrs || []).slice();
  2349. var capitalAttrs = zrUtil.map(attrs, modelUtil.capitalFirst);
  2350. return function (callback, context) {
  2351. zrUtil.each(names, function (name, index) {
  2352. var nameObj = {name: name, capital: capitalNames[index]};
  2353. for (var j = 0; j < attrs.length; j++) {
  2354. nameObj[attrs[j]] = name + capitalAttrs[j];
  2355. }
  2356. callback.call(context, nameObj);
  2357. });
  2358. };
  2359. };
  2360. /**
  2361. * @public
  2362. */
  2363. modelUtil.capitalFirst = function (str) {
  2364. return str ? str.charAt(0).toUpperCase() + str.substr(1) : str;
  2365. };
  2366. /**
  2367. * Iterate each dimension name.
  2368. *
  2369. * @public
  2370. * @param {Function} callback The parameter is like:
  2371. * {
  2372. * name: 'angle',
  2373. * capital: 'Angle',
  2374. * axis: 'angleAxis',
  2375. * axisIndex: 'angleAixs',
  2376. * index: 'angleIndex'
  2377. * }
  2378. * @param {Object} context
  2379. */
  2380. modelUtil.eachAxisDim = modelUtil.createNameEach(AXIS_DIMS, ['axisIndex', 'axis', 'index']);
  2381. /**
  2382. * If value is not array, then translate it to array.
  2383. * @param {*} value
  2384. * @return {Array} [value] or value
  2385. */
  2386. modelUtil.normalizeToArray = function (value) {
  2387. return zrUtil.isArray(value)
  2388. ? value
  2389. : value == null
  2390. ? []
  2391. : [value];
  2392. };
  2393. /**
  2394. * If tow dataZoomModels has the same axis controlled, we say that they are 'linked'.
  2395. * dataZoomModels and 'links' make up one or more graphics.
  2396. * This function finds the graphic where the source dataZoomModel is in.
  2397. *
  2398. * @public
  2399. * @param {Function} forEachNode Node iterator.
  2400. * @param {Function} forEachEdgeType edgeType iterator
  2401. * @param {Function} edgeIdGetter Giving node and edgeType, return an array of edge id.
  2402. * @return {Function} Input: sourceNode, Output: Like {nodes: [], dims: {}}
  2403. */
  2404. modelUtil.createLinkedNodesFinder = function (forEachNode, forEachEdgeType, edgeIdGetter) {
  2405. return function (sourceNode) {
  2406. var result = {
  2407. nodes: [],
  2408. records: {} // key: edgeType.name, value: Object (key: edge id, value: boolean).
  2409. };
  2410. forEachEdgeType(function (edgeType) {
  2411. result.records[edgeType.name] = {};
  2412. });
  2413. if (!sourceNode) {
  2414. return result;
  2415. }
  2416. absorb(sourceNode, result);
  2417. var existsLink;
  2418. do {
  2419. existsLink = false;
  2420. forEachNode(processSingleNode);
  2421. }
  2422. while (existsLink);
  2423. function processSingleNode(node) {
  2424. if (!isNodeAbsorded(node, result) && isLinked(node, result)) {
  2425. absorb(node, result);
  2426. existsLink = true;
  2427. }
  2428. }
  2429. return result;
  2430. };
  2431. function isNodeAbsorded(node, result) {
  2432. return zrUtil.indexOf(result.nodes, node) >= 0;
  2433. }
  2434. function isLinked(node, result) {
  2435. var hasLink = false;
  2436. forEachEdgeType(function (edgeType) {
  2437. zrUtil.each(edgeIdGetter(node, edgeType) || [], function (edgeId) {
  2438. result.records[edgeType.name][edgeId] && (hasLink = true);
  2439. });
  2440. });
  2441. return hasLink;
  2442. }
  2443. function absorb(node, result) {
  2444. result.nodes.push(node);
  2445. forEachEdgeType(function (edgeType) {
  2446. zrUtil.each(edgeIdGetter(node, edgeType) || [], function (edgeId) {
  2447. result.records[edgeType.name][edgeId] = true;
  2448. });
  2449. });
  2450. }
  2451. };
  2452. /**
  2453. * Sync default option between normal and emphasis like `position` and `show`
  2454. * In case some one will write code like
  2455. * label: {
  2456. * normal: {
  2457. * show: false,
  2458. * position: 'outside',
  2459. * textStyle: {
  2460. * fontSize: 18
  2461. * }
  2462. * },
  2463. * emphasis: {
  2464. * show: true
  2465. * }
  2466. * }
  2467. * @param {Object} opt
  2468. * @param {Array.<string>} subOpts
  2469. */
  2470. modelUtil.defaultEmphasis = function (opt, subOpts) {
  2471. if (opt) {
  2472. var emphasisOpt = opt.emphasis = opt.emphasis || {};
  2473. var normalOpt = opt.normal = opt.normal || {};
  2474. // Default emphasis option from normal
  2475. zrUtil.each(subOpts, function (subOptName) {
  2476. var val = zrUtil.retrieve(emphasisOpt[subOptName], normalOpt[subOptName]);
  2477. if (val != null) {
  2478. emphasisOpt[subOptName] = val;
  2479. }
  2480. });
  2481. }
  2482. };
  2483. modelUtil.LABEL_OPTIONS = ['position', 'show', 'textStyle', 'distance', 'formatter'];
  2484. /**
  2485. * data could be [12, 2323, {value: 223}, [1221, 23], {value: [2, 23]}]
  2486. * This helper method retieves value from data.
  2487. * @param {string|number|Date|Array|Object} dataItem
  2488. * @return {number|string|Date|Array.<number|string|Date>}
  2489. */
  2490. modelUtil.getDataItemValue = function (dataItem) {
  2491. // Performance sensitive.
  2492. return dataItem && (dataItem.value == null ? dataItem : dataItem.value);
  2493. };
  2494. /**
  2495. * This helper method convert value in data.
  2496. * @param {string|number|Date} value
  2497. * @param {Object|string} [dimInfo] If string (like 'x'), dimType defaults 'number'.
  2498. */
  2499. modelUtil.converDataValue = function (value, dimInfo) {
  2500. // Performance sensitive.
  2501. var dimType = dimInfo && dimInfo.type;
  2502. if (dimType === 'ordinal') {
  2503. return value;
  2504. }
  2505. if (dimType === 'time' && !isFinite(value) && value != null && value !== '-') {
  2506. value = +nubmerUtil.parseDate(value);
  2507. }
  2508. // dimType defaults 'number'.
  2509. // If dimType is not ordinal and value is null or undefined or NaN or '-',
  2510. // parse to NaN.
  2511. return (value == null || value === '')
  2512. ? NaN : +value; // If string (like '-'), using '+' parse to NaN
  2513. };
  2514. modelUtil.dataFormatMixin = {
  2515. /**
  2516. * Get params for formatter
  2517. * @param {number} dataIndex
  2518. * @param {string} [dataType]
  2519. * @return {Object}
  2520. */
  2521. getDataParams: function (dataIndex, dataType) {
  2522. var data = this.getData(dataType);
  2523. var seriesIndex = this.seriesIndex;
  2524. var seriesName = this.name;
  2525. var rawValue = this.getRawValue(dataIndex, dataType);
  2526. var rawDataIndex = data.getRawIndex(dataIndex);
  2527. var name = data.getName(dataIndex, true);
  2528. var itemOpt = data.getRawDataItem(dataIndex);
  2529. return {
  2530. componentType: this.mainType,
  2531. componentSubType: this.subType,
  2532. seriesType: this.mainType === 'series' ? this.subType : null,
  2533. seriesIndex: seriesIndex,
  2534. seriesName: seriesName,
  2535. name: name,
  2536. dataIndex: rawDataIndex,
  2537. data: itemOpt,
  2538. dataType: dataType,
  2539. value: rawValue,
  2540. color: data.getItemVisual(dataIndex, 'color'),
  2541. // Param name list for mapping `a`, `b`, `c`, `d`, `e`
  2542. $vars: ['seriesName', 'name', 'value']
  2543. };
  2544. },
  2545. /**
  2546. * Format label
  2547. * @param {number} dataIndex
  2548. * @param {string} [status='normal'] 'normal' or 'emphasis'
  2549. * @param {string} [dataType]
  2550. * @param {number} [dimIndex]
  2551. * @return {string}
  2552. */
  2553. getFormattedLabel: function (dataIndex, status, dataType, dimIndex) {
  2554. status = status || 'normal';
  2555. var data = this.getData(dataType);
  2556. var itemModel = data.getItemModel(dataIndex);
  2557. var params = this.getDataParams(dataIndex, dataType);
  2558. if (dimIndex != null && zrUtil.isArray(params.value)) {
  2559. params.value = params.value[dimIndex];
  2560. }
  2561. var formatter = itemModel.get(['label', status, 'formatter']);
  2562. if (typeof formatter === 'function') {
  2563. params.status = status;
  2564. return formatter(params);
  2565. }
  2566. else if (typeof formatter === 'string') {
  2567. return formatUtil.formatTpl(formatter, params);
  2568. }
  2569. },
  2570. /**
  2571. * Get raw value in option
  2572. * @param {number} idx
  2573. * @param {string} [dataType]
  2574. * @return {Object}
  2575. */
  2576. getRawValue: function (idx, dataType) {
  2577. var data = this.getData(dataType);
  2578. var dataItem = data.getRawDataItem(idx);
  2579. if (dataItem != null) {
  2580. return (zrUtil.isObject(dataItem) && !zrUtil.isArray(dataItem))
  2581. ? dataItem.value : dataItem;
  2582. }
  2583. },
  2584. /**
  2585. * Should be implemented.
  2586. * @param {number} dataIndex
  2587. * @param {boolean} [multipleSeries=false]
  2588. * @param {number} [dataType]
  2589. * @return {string} tooltip string
  2590. */
  2591. formatTooltip: zrUtil.noop
  2592. };
  2593. /**
  2594. * Mapping to exists for merge.
  2595. *
  2596. * @public
  2597. * @param {Array.<Object>|Array.<module:echarts/model/Component>} exists
  2598. * @param {Object|Array.<Object>} newCptOptions
  2599. * @return {Array.<Object>} Result, like [{exist: ..., option: ...}, {}],
  2600. * which order is the same as exists.
  2601. */
  2602. modelUtil.mappingToExists = function (exists, newCptOptions) {
  2603. // Mapping by the order by original option (but not order of
  2604. // new option) in merge mode. Because we should ensure
  2605. // some specified index (like xAxisIndex) is consistent with
  2606. // original option, which is easy to understand, espatially in
  2607. // media query. And in most case, merge option is used to
  2608. // update partial option but not be expected to change order.
  2609. newCptOptions = (newCptOptions || []).slice();
  2610. var result = zrUtil.map(exists || [], function (obj, index) {
  2611. return {exist: obj};
  2612. });
  2613. // Mapping by id or name if specified.
  2614. zrUtil.each(newCptOptions, function (cptOption, index) {
  2615. if (!zrUtil.isObject(cptOption)) {
  2616. return;
  2617. }
  2618. for (var i = 0; i < result.length; i++) {
  2619. var exist = result[i].exist;
  2620. if (!result[i].option // Consider name: two map to one.
  2621. && (
  2622. // id has highest priority.
  2623. (cptOption.id != null && exist.id === cptOption.id + '')
  2624. || (cptOption.name != null
  2625. && !modelUtil.isIdInner(cptOption)
  2626. && !modelUtil.isIdInner(exist)
  2627. && exist.name === cptOption.name + ''
  2628. )
  2629. )
  2630. ) {
  2631. result[i].option = cptOption;
  2632. newCptOptions[index] = null;
  2633. break;
  2634. }
  2635. }
  2636. });
  2637. // Otherwise mapping by index.
  2638. zrUtil.each(newCptOptions, function (cptOption, index) {
  2639. if (!zrUtil.isObject(cptOption)) {
  2640. return;
  2641. }
  2642. var i = 0;
  2643. for (; i < result.length; i++) {
  2644. var exist = result[i].exist;
  2645. if (!result[i].option
  2646. && !modelUtil.isIdInner(exist)
  2647. // Caution:
  2648. // Do not overwrite id. But name can be overwritten,
  2649. // because axis use name as 'show label text'.
  2650. // 'exist' always has id and name and we dont
  2651. // need to check it.
  2652. && cptOption.id == null
  2653. ) {
  2654. result[i].option = cptOption;
  2655. break;
  2656. }
  2657. }
  2658. if (i >= result.length) {
  2659. result.push({option: cptOption});
  2660. }
  2661. });
  2662. return result;
  2663. };
  2664. /**
  2665. * @public
  2666. * @param {Object} cptOption
  2667. * @return {boolean}
  2668. */
  2669. modelUtil.isIdInner = function (cptOption) {
  2670. return zrUtil.isObject(cptOption)
  2671. && cptOption.id
  2672. && (cptOption.id + '').indexOf('\0_ec_\0') === 0;
  2673. };
  2674. module.exports = modelUtil;
  2675. /***/ },
  2676. /* 6 */
  2677. /***/ function(module, exports, __webpack_require__) {
  2678. var zrUtil = __webpack_require__(3);
  2679. var numberUtil = __webpack_require__(7);
  2680. /**
  2681. * 每三位默认加,格式化
  2682. * @type {string|number} x
  2683. */
  2684. function addCommas(x) {
  2685. if (isNaN(x)) {
  2686. return '-';
  2687. }
  2688. x = (x + '').split('.');
  2689. return x[0].replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g,'$1,')
  2690. + (x.length > 1 ? ('.' + x[1]) : '');
  2691. }
  2692. /**
  2693. * @param {string} str
  2694. * @return {string} str
  2695. */
  2696. function toCamelCase(str) {
  2697. return str.toLowerCase().replace(/-(.)/g, function(match, group1) {
  2698. return group1.toUpperCase();
  2699. });
  2700. }
  2701. /**
  2702. * Normalize css liked array configuration
  2703. * e.g.
  2704. * 3 => [3, 3, 3, 3]
  2705. * [4, 2] => [4, 2, 4, 2]
  2706. * [4, 3, 2] => [4, 3, 2, 3]
  2707. * @param {number|Array.<number>} val
  2708. */
  2709. function normalizeCssArray(val) {
  2710. var len = val.length;
  2711. if (typeof (val) === 'number') {
  2712. return [val, val, val, val];
  2713. }
  2714. else if (len === 2) {
  2715. // vertical | horizontal
  2716. return [val[0], val[1], val[0], val[1]];
  2717. }
  2718. else if (len === 3) {
  2719. // top | horizontal | bottom
  2720. return [val[0], val[1], val[2], val[1]];
  2721. }
  2722. return val;
  2723. }
  2724. function encodeHTML(source) {
  2725. return String(source)
  2726. .replace(/&/g, '&amp;')
  2727. .replace(/</g, '&lt;')
  2728. .replace(/>/g, '&gt;')
  2729. .replace(/"/g, '&quot;')
  2730. .replace(/'/g, '&#39;');
  2731. }
  2732. var TPL_VAR_ALIAS = ['a', 'b', 'c', 'd', 'e', 'f', 'g'];
  2733. function wrapVar(varName, seriesIdx) {
  2734. return '{' + varName + (seriesIdx == null ? '' : seriesIdx) + '}';
  2735. }
  2736. /**
  2737. * Template formatter
  2738. * @param {string} tpl
  2739. * @param {Array.<Object>|Object} paramsList
  2740. * @return {string}
  2741. */
  2742. function formatTpl(tpl, paramsList) {
  2743. if (!zrUtil.isArray(paramsList)) {
  2744. paramsList = [paramsList];
  2745. }
  2746. var seriesLen = paramsList.length;
  2747. if (!seriesLen) {
  2748. return '';
  2749. }
  2750. var $vars = paramsList[0].$vars;
  2751. for (var i = 0; i < $vars.length; i++) {
  2752. var alias = TPL_VAR_ALIAS[i];
  2753. tpl = tpl.replace(wrapVar(alias), wrapVar(alias, 0));
  2754. }
  2755. for (var seriesIdx = 0; seriesIdx < seriesLen; seriesIdx++) {
  2756. for (var k = 0; k < $vars.length; k++) {
  2757. tpl = tpl.replace(
  2758. wrapVar(TPL_VAR_ALIAS[k], seriesIdx),
  2759. paramsList[seriesIdx][$vars[k]]
  2760. );
  2761. }
  2762. }
  2763. return tpl;
  2764. }
  2765. /**
  2766. * ISO Date format
  2767. * @param {string} tpl
  2768. * @param {number} value
  2769. * @inner
  2770. */
  2771. function formatTime(tpl, value) {
  2772. if (tpl === 'week'
  2773. || tpl === 'month'
  2774. || tpl === 'quarter'
  2775. || tpl === 'half-year'
  2776. || tpl === 'year'
  2777. ) {
  2778. tpl = 'MM-dd\nyyyy';
  2779. }
  2780. var date = numberUtil.parseDate(value);
  2781. var y = date.getFullYear();
  2782. var M = date.getMonth() + 1;
  2783. var d = date.getDate();
  2784. var h = date.getHours();
  2785. var m = date.getMinutes();
  2786. var s = date.getSeconds();
  2787. tpl = tpl.replace('MM', s2d(M))
  2788. .toLowerCase()
  2789. .replace('yyyy', y)
  2790. .replace('yy', y % 100)
  2791. .replace('dd', s2d(d))
  2792. .replace('d', d)
  2793. .replace('hh', s2d(h))
  2794. .replace('h', h)
  2795. .replace('mm', s2d(m))
  2796. .replace('m', m)
  2797. .replace('ss', s2d(s))
  2798. .replace('s', s);
  2799. return tpl;
  2800. }
  2801. /**
  2802. * @param {string} str
  2803. * @return {string}
  2804. * @inner
  2805. */
  2806. function s2d(str) {
  2807. return str < 10 ? ('0' + str) : str;
  2808. }
  2809. module.exports = {
  2810. normalizeCssArray: normalizeCssArray,
  2811. addCommas: addCommas,
  2812. toCamelCase: toCamelCase,
  2813. encodeHTML: encodeHTML,
  2814. formatTpl: formatTpl,
  2815. formatTime: formatTime
  2816. };
  2817. /***/ },
  2818. /* 7 */
  2819. /***/ function(module, exports) {
  2820. /**
  2821. * 数值处理模块
  2822. * @module echarts/util/number
  2823. */
  2824. var number = {};
  2825. var RADIAN_EPSILON = 1e-4;
  2826. function _trim(str) {
  2827. return str.replace(/^\s+/, '').replace(/\s+$/, '');
  2828. }
  2829. /**
  2830. * Linear mapping a value from domain to range
  2831. * @memberOf module:echarts/util/number
  2832. * @param {(number|Array.<number>)} val
  2833. * @param {Array.<number>} domain Domain extent domain[0] can be bigger than domain[1]
  2834. * @param {Array.<number>} range Range extent range[0] can be bigger than range[1]
  2835. * @param {boolean} clamp
  2836. * @return {(number|Array.<number>}
  2837. */
  2838. number.linearMap = function (val, domain, range, clamp) {
  2839. var subDomain = domain[1] - domain[0];
  2840. var subRange = range[1] - range[0];
  2841. if (subDomain === 0) {
  2842. return subRange === 0
  2843. ? range[0]
  2844. : (range[0] + range[1]) / 2;
  2845. }
  2846. // Avoid accuracy problem in edge, such as
  2847. // 146.39 - 62.83 === 83.55999999999999.
  2848. // See echarts/test/ut/spec/util/number.js#linearMap#accuracyError
  2849. // It is a little verbose for efficiency considering this method
  2850. // is a hotspot.
  2851. if (clamp) {
  2852. if (subDomain > 0) {
  2853. if (val <= domain[0]) {
  2854. return range[0];
  2855. }
  2856. else if (val >= domain[1]) {
  2857. return range[1];
  2858. }
  2859. }
  2860. else {
  2861. if (val >= domain[0]) {
  2862. return range[0];
  2863. }
  2864. else if (val <= domain[1]) {
  2865. return range[1];
  2866. }
  2867. }
  2868. }
  2869. else {
  2870. if (val === domain[0]) {
  2871. return range[0];
  2872. }
  2873. if (val === domain[1]) {
  2874. return range[1];
  2875. }
  2876. }
  2877. return (val - domain[0]) / subDomain * subRange + range[0];
  2878. };
  2879. /**
  2880. * Convert a percent string to absolute number.
  2881. * Returns NaN if percent is not a valid string or number
  2882. * @memberOf module:echarts/util/number
  2883. * @param {string|number} percent
  2884. * @param {number} all
  2885. * @return {number}
  2886. */
  2887. number.parsePercent = function(percent, all) {
  2888. switch (percent) {
  2889. case 'center':
  2890. case 'middle':
  2891. percent = '50%';
  2892. break;
  2893. case 'left':
  2894. case 'top':
  2895. percent = '0%';
  2896. break;
  2897. case 'right':
  2898. case 'bottom':
  2899. percent = '100%';
  2900. break;
  2901. }
  2902. if (typeof percent === 'string') {
  2903. if (_trim(percent).match(/%$/)) {
  2904. return parseFloat(percent) / 100 * all;
  2905. }
  2906. return parseFloat(percent);
  2907. }
  2908. return percent == null ? NaN : +percent;
  2909. };
  2910. /**
  2911. * Fix rounding error of float numbers
  2912. * @param {number} x
  2913. * @return {number}
  2914. */
  2915. number.round = function (x) {
  2916. // PENDING
  2917. return +(+x).toFixed(10);
  2918. };
  2919. number.asc = function (arr) {
  2920. arr.sort(function (a, b) {
  2921. return a - b;
  2922. });
  2923. return arr;
  2924. };
  2925. /**
  2926. * Get precision
  2927. * @param {number} val
  2928. */
  2929. number.getPrecision = function (val) {
  2930. if (isNaN(val)) {
  2931. return 0;
  2932. }
  2933. // It is much faster than methods converting number to string as follows
  2934. // var tmp = val.toString();
  2935. // return tmp.length - 1 - tmp.indexOf('.');
  2936. // especially when precision is low
  2937. var e = 1;
  2938. var count = 0;
  2939. while (Math.round(val * e) / e !== val) {
  2940. e *= 10;
  2941. count++;
  2942. }
  2943. return count;
  2944. };
  2945. /**
  2946. * @param {Array.<number>} dataExtent
  2947. * @param {Array.<number>} pixelExtent
  2948. * @return {number} precision
  2949. */
  2950. number.getPixelPrecision = function (dataExtent, pixelExtent) {
  2951. var log = Math.log;
  2952. var LN10 = Math.LN10;
  2953. var dataQuantity = Math.floor(log(dataExtent[1] - dataExtent[0]) / LN10);
  2954. var sizeQuantity = Math.round(log(Math.abs(pixelExtent[1] - pixelExtent[0])) / LN10);
  2955. return Math.max(
  2956. -dataQuantity + sizeQuantity,
  2957. 0
  2958. );
  2959. };
  2960. // Number.MAX_SAFE_INTEGER, ie do not support.
  2961. number.MAX_SAFE_INTEGER = 9007199254740991;
  2962. /**
  2963. * To 0 - 2 * PI, considering negative radian.
  2964. * @param {number} radian
  2965. * @return {number}
  2966. */
  2967. number.remRadian = function (radian) {
  2968. var pi2 = Math.PI * 2;
  2969. return (radian % pi2 + pi2) % pi2;
  2970. };
  2971. /**
  2972. * @param {type} radian
  2973. * @return {boolean}
  2974. */
  2975. number.isRadianAroundZero = function (val) {
  2976. return val > -RADIAN_EPSILON && val < RADIAN_EPSILON;
  2977. };
  2978. /**
  2979. * @param {string|Date|number} value
  2980. * @return {number} timestamp
  2981. */
  2982. number.parseDate = function (value) {
  2983. return value instanceof Date
  2984. ? value
  2985. : new Date(
  2986. typeof value === 'string'
  2987. ? value.replace(/-/g, '/')
  2988. : Math.round(value)
  2989. );
  2990. };
  2991. /**
  2992. * Quantity of a number. e.g. 0.1, 1, 10, 100
  2993. * @param {number} val
  2994. * @return {number}
  2995. */
  2996. number.quantity = function (val) {
  2997. return Math.pow(10, Math.floor(Math.log(val) / Math.LN10));
  2998. };
  2999. // "Nice Numbers for Graph Labels" of Graphic Gems
  3000. /**
  3001. * find a “nice” number approximately equal to x. Round the number if round = true, take ceiling if round = false
  3002. * The primary observation is that the “nicest” numbers in decimal are 1, 2, and 5, and all power-of-ten multiples of these numbers.
  3003. * @param {number} val
  3004. * @param {boolean} round
  3005. * @return {number}
  3006. */
  3007. number.nice = function (val, round) {
  3008. var exp10 = number.quantity(val);
  3009. var f = val / exp10; // between 1 and 10
  3010. var nf;
  3011. if (round) {
  3012. if (f < 1.5) { nf = 1; }
  3013. else if (f < 2.5) { nf = 2; }
  3014. else if (f < 4) { nf = 3; }
  3015. else if (f < 7) { nf = 5; }
  3016. else { nf = 10; }
  3017. }
  3018. else {
  3019. if (f < 1) { nf = 1; }
  3020. else if (f < 2) { nf = 2; }
  3021. else if (f < 3) { nf = 3; }
  3022. else if (f < 5) { nf = 5; }
  3023. else { nf = 10; }
  3024. }
  3025. return nf * exp10;
  3026. };
  3027. module.exports = number;
  3028. /***/ },
  3029. /* 8 */
  3030. /***/ function(module, exports, __webpack_require__) {
  3031. /**
  3032. * @module echarts/model/Model
  3033. */
  3034. var zrUtil = __webpack_require__(3);
  3035. var clazzUtil = __webpack_require__(9);
  3036. /**
  3037. * @alias module:echarts/model/Model
  3038. * @constructor
  3039. * @param {Object} option
  3040. * @param {module:echarts/model/Model} [parentModel]
  3041. * @param {module:echarts/model/Global} [ecModel]
  3042. * @param {Object} extraOpt
  3043. */
  3044. function Model(option, parentModel, ecModel, extraOpt) {
  3045. /**
  3046. * @type {module:echarts/model/Model}
  3047. * @readOnly
  3048. */
  3049. this.parentModel = parentModel;
  3050. /**
  3051. * @type {module:echarts/model/Global}
  3052. * @readOnly
  3053. */
  3054. this.ecModel = ecModel;
  3055. /**
  3056. * @type {Object}
  3057. * @protected
  3058. */
  3059. this.option = option;
  3060. // Simple optimization
  3061. if (this.init) {
  3062. if (arguments.length <= 4) {
  3063. this.init(option, parentModel, ecModel, extraOpt);
  3064. }
  3065. else {
  3066. this.init.apply(this, arguments);
  3067. }
  3068. }
  3069. }
  3070. Model.prototype = {
  3071. constructor: Model,
  3072. /**
  3073. * Model 的初始化函数
  3074. * @param {Object} option
  3075. */
  3076. init: null,
  3077. /**
  3078. * 从新的 Option merge
  3079. */
  3080. mergeOption: function (option) {
  3081. zrUtil.merge(this.option, option, true);
  3082. },
  3083. /**
  3084. * @param {string} path
  3085. * @param {boolean} [ignoreParent=false]
  3086. * @return {*}
  3087. */
  3088. get: function (path, ignoreParent) {
  3089. if (!path) {
  3090. return this.option;
  3091. }
  3092. if (typeof path === 'string') {
  3093. path = path.split('.');
  3094. }
  3095. var obj = this.option;
  3096. var parentModel = this.parentModel;
  3097. for (var i = 0; i < path.length; i++) {
  3098. // Ignore empty
  3099. if (!path[i]) {
  3100. continue;
  3101. }
  3102. // obj could be number/string/... (like 0)
  3103. obj = (obj && typeof obj === 'object') ? obj[path[i]] : null;
  3104. if (obj == null) {
  3105. break;
  3106. }
  3107. }
  3108. if (obj == null && parentModel && !ignoreParent) {
  3109. obj = parentModel.get(path);
  3110. }
  3111. return obj;
  3112. },
  3113. /**
  3114. * @param {string} key
  3115. * @param {boolean} [ignoreParent=false]
  3116. * @return {*}
  3117. */
  3118. getShallow: function (key, ignoreParent) {
  3119. var option = this.option;
  3120. var val = option && option[key];
  3121. var parentModel = this.parentModel;
  3122. if (val == null && parentModel && !ignoreParent) {
  3123. val = parentModel.getShallow(key);
  3124. }
  3125. return val;
  3126. },
  3127. /**
  3128. * @param {string} path
  3129. * @param {module:echarts/model/Model} [parentModel]
  3130. * @return {module:echarts/model/Model}
  3131. */
  3132. getModel: function (path, parentModel) {
  3133. var obj = this.get(path, true);
  3134. var thisParentModel = this.parentModel;
  3135. var model = new Model(
  3136. obj, parentModel || (thisParentModel && thisParentModel.getModel(path)),
  3137. this.ecModel
  3138. );
  3139. return model;
  3140. },
  3141. /**
  3142. * If model has option
  3143. */
  3144. isEmpty: function () {
  3145. return this.option == null;
  3146. },
  3147. restoreData: function () {},
  3148. // Pending
  3149. clone: function () {
  3150. var Ctor = this.constructor;
  3151. return new Ctor(zrUtil.clone(this.option));
  3152. },
  3153. setReadOnly: function (properties) {
  3154. clazzUtil.setReadOnly(this, properties);
  3155. }
  3156. };
  3157. // Enable Model.extend.
  3158. clazzUtil.enableClassExtend(Model);
  3159. var mixin = zrUtil.mixin;
  3160. mixin(Model, __webpack_require__(10));
  3161. mixin(Model, __webpack_require__(12));
  3162. mixin(Model, __webpack_require__(13));
  3163. mixin(Model, __webpack_require__(18));
  3164. module.exports = Model;
  3165. /***/ },
  3166. /* 9 */
  3167. /***/ function(module, exports, __webpack_require__) {
  3168. var zrUtil = __webpack_require__(3);
  3169. var clazz = {};
  3170. var TYPE_DELIMITER = '.';
  3171. var IS_CONTAINER = '___EC__COMPONENT__CONTAINER___';
  3172. /**
  3173. * @public
  3174. */
  3175. var parseClassType = clazz.parseClassType = function (componentType) {
  3176. var ret = {main: '', sub: ''};
  3177. if (componentType) {
  3178. componentType = componentType.split(TYPE_DELIMITER);
  3179. ret.main = componentType[0] || '';
  3180. ret.sub = componentType[1] || '';
  3181. }
  3182. return ret;
  3183. };
  3184. /**
  3185. * @public
  3186. */
  3187. clazz.enableClassExtend = function (RootClass, preConstruct) {
  3188. RootClass.extend = function (proto) {
  3189. var ExtendedClass = function () {
  3190. preConstruct && preConstruct.apply(this, arguments);
  3191. RootClass.apply(this, arguments);
  3192. };
  3193. zrUtil.extend(ExtendedClass.prototype, proto);
  3194. ExtendedClass.extend = this.extend;
  3195. ExtendedClass.superCall = superCall;
  3196. ExtendedClass.superApply = superApply;
  3197. zrUtil.inherits(ExtendedClass, this);
  3198. ExtendedClass.superClass = this;
  3199. return ExtendedClass;
  3200. };
  3201. };
  3202. // superCall should have class info, which can not be fetch from 'this'.
  3203. // Consider this case:
  3204. // class A has method f,
  3205. // class B inherits class A, overrides method f, f call superApply('f'),
  3206. // class C inherits class B, do not overrides method f,
  3207. // then when method of class C is called, dead loop occured.
  3208. function superCall(context, methodName) {
  3209. var args = zrUtil.slice(arguments, 2);
  3210. return this.superClass.prototype[methodName].apply(context, args);
  3211. }
  3212. function superApply(context, methodName, args) {
  3213. return this.superClass.prototype[methodName].apply(context, args);
  3214. }
  3215. /**
  3216. * @param {Object} entity
  3217. * @param {Object} options
  3218. * @param {boolean} [options.registerWhenExtend]
  3219. * @public
  3220. */
  3221. clazz.enableClassManagement = function (entity, options) {
  3222. options = options || {};
  3223. /**
  3224. * Component model classes
  3225. * key: componentType,
  3226. * value:
  3227. * componentClass, when componentType is 'xxx'
  3228. * or Object.<subKey, componentClass>, when componentType is 'xxx.yy'
  3229. * @type {Object}
  3230. */
  3231. var storage = {};
  3232. entity.registerClass = function (Clazz, componentType) {
  3233. if (componentType) {
  3234. componentType = parseClassType(componentType);
  3235. if (!componentType.sub) {
  3236. if (storage[componentType.main]) {
  3237. throw new Error(componentType.main + 'exists.');
  3238. }
  3239. storage[componentType.main] = Clazz;
  3240. }
  3241. else if (componentType.sub !== IS_CONTAINER) {
  3242. var container = makeContainer(componentType);
  3243. container[componentType.sub] = Clazz;
  3244. }
  3245. }
  3246. return Clazz;
  3247. };
  3248. entity.getClass = function (componentTypeMain, subType, throwWhenNotFound) {
  3249. var Clazz = storage[componentTypeMain];
  3250. if (Clazz && Clazz[IS_CONTAINER]) {
  3251. Clazz = subType ? Clazz[subType] : null;
  3252. }
  3253. if (throwWhenNotFound && !Clazz) {
  3254. throw new Error(
  3255. 'Component ' + componentTypeMain + '.' + (subType || '') + ' not exists. Load it first.'
  3256. );
  3257. }
  3258. return Clazz;
  3259. };
  3260. entity.getClassesByMainType = function (componentType) {
  3261. componentType = parseClassType(componentType);
  3262. var result = [];
  3263. var obj = storage[componentType.main];
  3264. if (obj && obj[IS_CONTAINER]) {
  3265. zrUtil.each(obj, function (o, type) {
  3266. type !== IS_CONTAINER && result.push(o);
  3267. });
  3268. }
  3269. else {
  3270. result.push(obj);
  3271. }
  3272. return result;
  3273. };
  3274. entity.hasClass = function (componentType) {
  3275. // Just consider componentType.main.
  3276. componentType = parseClassType(componentType);
  3277. return !!storage[componentType.main];
  3278. };
  3279. /**
  3280. * @return {Array.<string>} Like ['aa', 'bb'], but can not be ['aa.xx']
  3281. */
  3282. entity.getAllClassMainTypes = function () {
  3283. var types = [];
  3284. zrUtil.each(storage, function (obj, type) {
  3285. types.push(type);
  3286. });
  3287. return types;
  3288. };
  3289. /**
  3290. * If a main type is container and has sub types
  3291. * @param {string} mainType
  3292. * @return {boolean}
  3293. */
  3294. entity.hasSubTypes = function (componentType) {
  3295. componentType = parseClassType(componentType);
  3296. var obj = storage[componentType.main];
  3297. return obj && obj[IS_CONTAINER];
  3298. };
  3299. entity.parseClassType = parseClassType;
  3300. function makeContainer(componentType) {
  3301. var container = storage[componentType.main];
  3302. if (!container || !container[IS_CONTAINER]) {
  3303. container = storage[componentType.main] = {};
  3304. container[IS_CONTAINER] = true;
  3305. }
  3306. return container;
  3307. }
  3308. if (options.registerWhenExtend) {
  3309. var originalExtend = entity.extend;
  3310. if (originalExtend) {
  3311. entity.extend = function (proto) {
  3312. var ExtendedClass = originalExtend.call(this, proto);
  3313. return entity.registerClass(ExtendedClass, proto.type);
  3314. };
  3315. }
  3316. }
  3317. return entity;
  3318. };
  3319. /**
  3320. * @param {string|Array.<string>} properties
  3321. */
  3322. clazz.setReadOnly = function (obj, properties) {
  3323. // FIXME It seems broken in IE8 simulation of IE11
  3324. // if (!zrUtil.isArray(properties)) {
  3325. // properties = properties != null ? [properties] : [];
  3326. // }
  3327. // zrUtil.each(properties, function (prop) {
  3328. // var value = obj[prop];
  3329. // Object.defineProperty
  3330. // && Object.defineProperty(obj, prop, {
  3331. // value: value, writable: false
  3332. // });
  3333. // zrUtil.isArray(obj[prop])
  3334. // && Object.freeze
  3335. // && Object.freeze(obj[prop]);
  3336. // });
  3337. };
  3338. module.exports = clazz;
  3339. /***/ },
  3340. /* 10 */
  3341. /***/ function(module, exports, __webpack_require__) {
  3342. var getLineStyle = __webpack_require__(11)(
  3343. [
  3344. ['lineWidth', 'width'],
  3345. ['stroke', 'color'],
  3346. ['opacity'],
  3347. ['shadowBlur'],
  3348. ['shadowOffsetX'],
  3349. ['shadowOffsetY'],
  3350. ['shadowColor']
  3351. ]
  3352. );
  3353. module.exports = {
  3354. getLineStyle: function (excludes) {
  3355. var style = getLineStyle.call(this, excludes);
  3356. var lineDash = this.getLineDash();
  3357. lineDash && (style.lineDash = lineDash);
  3358. return style;
  3359. },
  3360. getLineDash: function () {
  3361. var lineType = this.get('type');
  3362. return (lineType === 'solid' || lineType == null) ? null
  3363. : (lineType === 'dashed' ? [5, 5] : [1, 1]);
  3364. }
  3365. };
  3366. /***/ },
  3367. /* 11 */
  3368. /***/ function(module, exports, __webpack_require__) {
  3369. // TODO Parse shadow style
  3370. // TODO Only shallow path support
  3371. var zrUtil = __webpack_require__(3);
  3372. module.exports = function (properties) {
  3373. // Normalize
  3374. for (var i = 0; i < properties.length; i++) {
  3375. if (!properties[i][1]) {
  3376. properties[i][1] = properties[i][0];
  3377. }
  3378. }
  3379. return function (excludes) {
  3380. var style = {};
  3381. for (var i = 0; i < properties.length; i++) {
  3382. var propName = properties[i][1];
  3383. if (excludes && zrUtil.indexOf(excludes, propName) >= 0) {
  3384. continue;
  3385. }
  3386. var val = this.getShallow(propName);
  3387. if (val != null) {
  3388. style[properties[i][0]] = val;
  3389. }
  3390. }
  3391. return style;
  3392. };
  3393. };
  3394. /***/ },
  3395. /* 12 */
  3396. /***/ function(module, exports, __webpack_require__) {
  3397. module.exports = {
  3398. getAreaStyle: __webpack_require__(11)(
  3399. [
  3400. ['fill', 'color'],
  3401. ['shadowBlur'],
  3402. ['shadowOffsetX'],
  3403. ['shadowOffsetY'],
  3404. ['opacity'],
  3405. ['shadowColor']
  3406. ]
  3407. )
  3408. };
  3409. /***/ },
  3410. /* 13 */
  3411. /***/ function(module, exports, __webpack_require__) {
  3412. var textContain = __webpack_require__(14);
  3413. function getShallow(model, path) {
  3414. return model && model.getShallow(path);
  3415. }
  3416. module.exports = {
  3417. /**
  3418. * Get color property or get color from option.textStyle.color
  3419. * @return {string}
  3420. */
  3421. getTextColor: function () {
  3422. var ecModel = this.ecModel;
  3423. return this.getShallow('color')
  3424. || (ecModel && ecModel.get('textStyle.color'));
  3425. },
  3426. /**
  3427. * Create font string from fontStyle, fontWeight, fontSize, fontFamily
  3428. * @return {string}
  3429. */
  3430. getFont: function () {
  3431. var ecModel = this.ecModel;
  3432. var gTextStyleModel = ecModel && ecModel.getModel('textStyle');
  3433. return [
  3434. // FIXME in node-canvas fontWeight is before fontStyle
  3435. this.getShallow('fontStyle') || getShallow(gTextStyleModel, 'fontStyle'),
  3436. this.getShallow('fontWeight') || getShallow(gTextStyleModel, 'fontWeight'),
  3437. (this.getShallow('fontSize') || getShallow(gTextStyleModel, 'fontSize') || 12) + 'px',
  3438. this.getShallow('fontFamily') || getShallow(gTextStyleModel, 'fontFamily') || 'sans-serif'
  3439. ].join(' ');
  3440. },
  3441. getTextRect: function (text) {
  3442. var textStyle = this.get('textStyle') || {};
  3443. return textContain.getBoundingRect(
  3444. text,
  3445. this.getFont(),
  3446. textStyle.align,
  3447. textStyle.baseline
  3448. );
  3449. },
  3450. ellipsis: function (text, containerWidth, options) {
  3451. return textContain.ellipsis(
  3452. text, this.getFont(), containerWidth, options
  3453. );
  3454. }
  3455. };
  3456. /***/ },
  3457. /* 14 */
  3458. /***/ function(module, exports, __webpack_require__) {
  3459. var textWidthCache = {};
  3460. var textWidthCacheCounter = 0;
  3461. var TEXT_CACHE_MAX = 5000;
  3462. var util = __webpack_require__(3);
  3463. var BoundingRect = __webpack_require__(15);
  3464. function getTextWidth(text, textFont) {
  3465. var key = text + ':' + textFont;
  3466. if (textWidthCache[key]) {
  3467. return textWidthCache[key];
  3468. }
  3469. var textLines = (text + '').split('\n');
  3470. var width = 0;
  3471. for (var i = 0, l = textLines.length; i < l; i++) {
  3472. // measureText 可以被覆盖以兼容不支持 Canvas 的环境
  3473. width = Math.max(textContain.measureText(textLines[i], textFont).width, width);
  3474. }
  3475. if (textWidthCacheCounter > TEXT_CACHE_MAX) {
  3476. textWidthCacheCounter = 0;
  3477. textWidthCache = {};
  3478. }
  3479. textWidthCacheCounter++;
  3480. textWidthCache[key] = width;
  3481. return width;
  3482. }
  3483. function getTextRect(text, textFont, textAlign, textBaseline) {
  3484. var textLineLen = ((text || '') + '').split('\n').length;
  3485. var width = getTextWidth(text, textFont);
  3486. // FIXME 高度计算比较粗暴
  3487. var lineHeight = getTextWidth('国', textFont);
  3488. var height = textLineLen * lineHeight;
  3489. var rect = new BoundingRect(0, 0, width, height);
  3490. // Text has a special line height property
  3491. rect.lineHeight = lineHeight;
  3492. switch (textBaseline) {
  3493. case 'bottom':
  3494. case 'alphabetic':
  3495. rect.y -= lineHeight;
  3496. break;
  3497. case 'middle':
  3498. rect.y -= lineHeight / 2;
  3499. break;
  3500. // case 'hanging':
  3501. // case 'top':
  3502. }
  3503. // FIXME Right to left language
  3504. switch (textAlign) {
  3505. case 'end':
  3506. case 'right':
  3507. rect.x -= rect.width;
  3508. break;
  3509. case 'center':
  3510. rect.x -= rect.width / 2;
  3511. break;
  3512. // case 'start':
  3513. // case 'left':
  3514. }
  3515. return rect;
  3516. }
  3517. function adjustTextPositionOnRect(textPosition, rect, textRect, distance) {
  3518. var x = rect.x;
  3519. var y = rect.y;
  3520. var height = rect.height;
  3521. var width = rect.width;
  3522. var textHeight = textRect.height;
  3523. var halfHeight = height / 2 - textHeight / 2;
  3524. var textAlign = 'left';
  3525. switch (textPosition) {
  3526. case 'left':
  3527. x -= distance;
  3528. y += halfHeight;
  3529. textAlign = 'right';
  3530. break;
  3531. case 'right':
  3532. x += distance + width;
  3533. y += halfHeight;
  3534. textAlign = 'left';
  3535. break;
  3536. case 'top':
  3537. x += width / 2;
  3538. y -= distance + textHeight;
  3539. textAlign = 'center';
  3540. break;
  3541. case 'bottom':
  3542. x += width / 2;
  3543. y += height + distance;
  3544. textAlign = 'center';
  3545. break;
  3546. case 'inside':
  3547. x += width / 2;
  3548. y += halfHeight;
  3549. textAlign = 'center';
  3550. break;
  3551. case 'insideLeft':
  3552. x += distance;
  3553. y += halfHeight;
  3554. textAlign = 'left';
  3555. break;
  3556. case 'insideRight':
  3557. x += width - distance;
  3558. y += halfHeight;
  3559. textAlign = 'right';
  3560. break;
  3561. case 'insideTop':
  3562. x += width / 2;
  3563. y += distance;
  3564. textAlign = 'center';
  3565. break;
  3566. case 'insideBottom':
  3567. x += width / 2;
  3568. y += height - textHeight - distance;
  3569. textAlign = 'center';
  3570. break;
  3571. case 'insideTopLeft':
  3572. x += distance;
  3573. y += distance;
  3574. textAlign = 'left';
  3575. break;
  3576. case 'insideTopRight':
  3577. x += width - distance;
  3578. y += distance;
  3579. textAlign = 'right';
  3580. break;
  3581. case 'insideBottomLeft':
  3582. x += distance;
  3583. y += height - textHeight - distance;
  3584. break;
  3585. case 'insideBottomRight':
  3586. x += width - distance;
  3587. y += height - textHeight - distance;
  3588. textAlign = 'right';
  3589. break;
  3590. }
  3591. return {
  3592. x: x,
  3593. y: y,
  3594. textAlign: textAlign,
  3595. textBaseline: 'top'
  3596. };
  3597. }
  3598. /**
  3599. * Show ellipsis if overflow.
  3600. *
  3601. * @param {string} text
  3602. * @param {string} textFont
  3603. * @param {string} containerWidth
  3604. * @param {Object} [options]
  3605. * @param {number} [options.ellipsis='...']
  3606. * @param {number} [options.maxIterations=3]
  3607. * @param {number} [options.minCharacters=3]
  3608. * @return {string}
  3609. */
  3610. function textEllipsis(text, textFont, containerWidth, options) {
  3611. if (!containerWidth) {
  3612. return '';
  3613. }
  3614. options = util.defaults({
  3615. ellipsis: '...',
  3616. minCharacters: 3,
  3617. maxIterations: 3,
  3618. cnCharWidth: getTextWidth('国', textFont),
  3619. // FIXME
  3620. // 未考虑非等宽字体
  3621. ascCharWidth: getTextWidth('a', textFont)
  3622. }, options, true);
  3623. containerWidth -= getTextWidth(options.ellipsis);
  3624. var textLines = (text + '').split('\n');
  3625. for (var i = 0, len = textLines.length; i < len; i++) {
  3626. textLines[i] = textLineTruncate(
  3627. textLines[i], textFont, containerWidth, options
  3628. );
  3629. }
  3630. return textLines.join('\n');
  3631. }
  3632. function textLineTruncate(text, textFont, containerWidth, options) {
  3633. // FIXME
  3634. // 粗糙得写的,尚未考虑性能和各种语言、字体的效果。
  3635. for (var i = 0;; i++) {
  3636. var lineWidth = getTextWidth(text, textFont);
  3637. if (lineWidth < containerWidth || i >= options.maxIterations) {
  3638. text += options.ellipsis;
  3639. break;
  3640. }
  3641. var subLength = i === 0
  3642. ? estimateLength(text, containerWidth, options)
  3643. : Math.floor(text.length * containerWidth / lineWidth);
  3644. if (subLength < options.minCharacters) {
  3645. text = '';
  3646. break;
  3647. }
  3648. text = text.substr(0, subLength);
  3649. }
  3650. return text;
  3651. }
  3652. function estimateLength(text, containerWidth, options) {
  3653. var width = 0;
  3654. var i = 0;
  3655. for (var len = text.length; i < len && width < containerWidth; i++) {
  3656. var charCode = text.charCodeAt(i);
  3657. width += (0 <= charCode && charCode <= 127)
  3658. ? options.ascCharWidth : options.cnCharWidth;
  3659. }
  3660. return i;
  3661. }
  3662. var textContain = {
  3663. getWidth: getTextWidth,
  3664. getBoundingRect: getTextRect,
  3665. adjustTextPositionOnRect: adjustTextPositionOnRect,
  3666. ellipsis: textEllipsis,
  3667. measureText: function (text, textFont) {
  3668. var ctx = util.getContext();
  3669. ctx.font = textFont;
  3670. return ctx.measureText(text);
  3671. }
  3672. };
  3673. module.exports = textContain;
  3674. /***/ },
  3675. /* 15 */
  3676. /***/ function(module, exports, __webpack_require__) {
  3677. 'use strict';
  3678. /**
  3679. * @module echarts/core/BoundingRect
  3680. */
  3681. var vec2 = __webpack_require__(16);
  3682. var matrix = __webpack_require__(17);
  3683. var v2ApplyTransform = vec2.applyTransform;
  3684. var mathMin = Math.min;
  3685. var mathAbs = Math.abs;
  3686. var mathMax = Math.max;
  3687. /**
  3688. * @alias module:echarts/core/BoundingRect
  3689. */
  3690. function BoundingRect(x, y, width, height) {
  3691. /**
  3692. * @type {number}
  3693. */
  3694. this.x = x;
  3695. /**
  3696. * @type {number}
  3697. */
  3698. this.y = y;
  3699. /**
  3700. * @type {number}
  3701. */
  3702. this.width = width;
  3703. /**
  3704. * @type {number}
  3705. */
  3706. this.height = height;
  3707. }
  3708. BoundingRect.prototype = {
  3709. constructor: BoundingRect,
  3710. /**
  3711. * @param {module:echarts/core/BoundingRect} other
  3712. */
  3713. union: function (other) {
  3714. var x = mathMin(other.x, this.x);
  3715. var y = mathMin(other.y, this.y);
  3716. this.width = mathMax(
  3717. other.x + other.width,
  3718. this.x + this.width
  3719. ) - x;
  3720. this.height = mathMax(
  3721. other.y + other.height,
  3722. this.y + this.height
  3723. ) - y;
  3724. this.x = x;
  3725. this.y = y;
  3726. },
  3727. /**
  3728. * @param {Array.<number>} m
  3729. * @methods
  3730. */
  3731. applyTransform: (function () {
  3732. var min = [];
  3733. var max = [];
  3734. return function (m) {
  3735. // In case usage like this
  3736. // el.getBoundingRect().applyTransform(el.transform)
  3737. // And element has no transform
  3738. if (!m) {
  3739. return;
  3740. }
  3741. min[0] = this.x;
  3742. min[1] = this.y;
  3743. max[0] = this.x + this.width;
  3744. max[1] = this.y + this.height;
  3745. v2ApplyTransform(min, min, m);
  3746. v2ApplyTransform(max, max, m);
  3747. this.x = mathMin(min[0], max[0]);
  3748. this.y = mathMin(min[1], max[1]);
  3749. this.width = mathAbs(max[0] - min[0]);
  3750. this.height = mathAbs(max[1] - min[1]);
  3751. };
  3752. })(),
  3753. /**
  3754. * Calculate matrix of transforming from self to target rect
  3755. * @param {module:zrender/core/BoundingRect} b
  3756. * @return {Array.<number>}
  3757. */
  3758. calculateTransform: function (b) {
  3759. var a = this;
  3760. var sx = b.width / a.width;
  3761. var sy = b.height / a.height;
  3762. var m = matrix.create();
  3763. // 矩阵右乘
  3764. matrix.translate(m, m, [-a.x, -a.y]);
  3765. matrix.scale(m, m, [sx, sy]);
  3766. matrix.translate(m, m, [b.x, b.y]);
  3767. return m;
  3768. },
  3769. /**
  3770. * @param {(module:echarts/core/BoundingRect|Object)} b
  3771. * @return {boolean}
  3772. */
  3773. intersect: function (b) {
  3774. var a = this;
  3775. var ax0 = a.x;
  3776. var ax1 = a.x + a.width;
  3777. var ay0 = a.y;
  3778. var ay1 = a.y + a.height;
  3779. var bx0 = b.x;
  3780. var bx1 = b.x + b.width;
  3781. var by0 = b.y;
  3782. var by1 = b.y + b.height;
  3783. return ! (ax1 < bx0 || bx1 < ax0 || ay1 < by0 || by1 < ay0);
  3784. },
  3785. contain: function (x, y) {
  3786. var rect = this;
  3787. return x >= rect.x
  3788. && x <= (rect.x + rect.width)
  3789. && y >= rect.y
  3790. && y <= (rect.y + rect.height);
  3791. },
  3792. /**
  3793. * @return {module:echarts/core/BoundingRect}
  3794. */
  3795. clone: function () {
  3796. return new BoundingRect(this.x, this.y, this.width, this.height);
  3797. },
  3798. /**
  3799. * Copy from another rect
  3800. */
  3801. copy: function (other) {
  3802. this.x = other.x;
  3803. this.y = other.y;
  3804. this.width = other.width;
  3805. this.height = other.height;
  3806. }
  3807. };
  3808. module.exports = BoundingRect;
  3809. /***/ },
  3810. /* 16 */
  3811. /***/ function(module, exports) {
  3812. var ArrayCtor = typeof Float32Array === 'undefined'
  3813. ? Array
  3814. : Float32Array;
  3815. /**
  3816. * @typedef {Float32Array|Array.<number>} Vector2
  3817. */
  3818. /**
  3819. * 二维向量类
  3820. * @exports zrender/tool/vector
  3821. */
  3822. var vector = {
  3823. /**
  3824. * 创建一个向量
  3825. * @param {number} [x=0]
  3826. * @param {number} [y=0]
  3827. * @return {Vector2}
  3828. */
  3829. create: function (x, y) {
  3830. var out = new ArrayCtor(2);
  3831. out[0] = x || 0;
  3832. out[1] = y || 0;
  3833. return out;
  3834. },
  3835. /**
  3836. * 复制向量数据
  3837. * @param {Vector2} out
  3838. * @param {Vector2} v
  3839. * @return {Vector2}
  3840. */
  3841. copy: function (out, v) {
  3842. out[0] = v[0];
  3843. out[1] = v[1];
  3844. return out;
  3845. },
  3846. /**
  3847. * 克隆一个向量
  3848. * @param {Vector2} v
  3849. * @return {Vector2}
  3850. */
  3851. clone: function (v) {
  3852. var out = new ArrayCtor(2);
  3853. out[0] = v[0];
  3854. out[1] = v[1];
  3855. return out;
  3856. },
  3857. /**
  3858. * 设置向量的两个项
  3859. * @param {Vector2} out
  3860. * @param {number} a
  3861. * @param {number} b
  3862. * @return {Vector2} 结果
  3863. */
  3864. set: function (out, a, b) {
  3865. out[0] = a;
  3866. out[1] = b;
  3867. return out;
  3868. },
  3869. /**
  3870. * 向量相加
  3871. * @param {Vector2} out
  3872. * @param {Vector2} v1
  3873. * @param {Vector2} v2
  3874. */
  3875. add: function (out, v1, v2) {
  3876. out[0] = v1[0] + v2[0];
  3877. out[1] = v1[1] + v2[1];
  3878. return out;
  3879. },
  3880. /**
  3881. * 向量缩放后相加
  3882. * @param {Vector2} out
  3883. * @param {Vector2} v1
  3884. * @param {Vector2} v2
  3885. * @param {number} a
  3886. */
  3887. scaleAndAdd: function (out, v1, v2, a) {
  3888. out[0] = v1[0] + v2[0] * a;
  3889. out[1] = v1[1] + v2[1] * a;
  3890. return out;
  3891. },
  3892. /**
  3893. * 向量相减
  3894. * @param {Vector2} out
  3895. * @param {Vector2} v1
  3896. * @param {Vector2} v2
  3897. */
  3898. sub: function (out, v1, v2) {
  3899. out[0] = v1[0] - v2[0];
  3900. out[1] = v1[1] - v2[1];
  3901. return out;
  3902. },
  3903. /**
  3904. * 向量长度
  3905. * @param {Vector2} v
  3906. * @return {number}
  3907. */
  3908. len: function (v) {
  3909. return Math.sqrt(this.lenSquare(v));
  3910. },
  3911. /**
  3912. * 向量长度平方
  3913. * @param {Vector2} v
  3914. * @return {number}
  3915. */
  3916. lenSquare: function (v) {
  3917. return v[0] * v[0] + v[1] * v[1];
  3918. },
  3919. /**
  3920. * 向量乘法
  3921. * @param {Vector2} out
  3922. * @param {Vector2} v1
  3923. * @param {Vector2} v2
  3924. */
  3925. mul: function (out, v1, v2) {
  3926. out[0] = v1[0] * v2[0];
  3927. out[1] = v1[1] * v2[1];
  3928. return out;
  3929. },
  3930. /**
  3931. * 向量除法
  3932. * @param {Vector2} out
  3933. * @param {Vector2} v1
  3934. * @param {Vector2} v2
  3935. */
  3936. div: function (out, v1, v2) {
  3937. out[0] = v1[0] / v2[0];
  3938. out[1] = v1[1] / v2[1];
  3939. return out;
  3940. },
  3941. /**
  3942. * 向量点乘
  3943. * @param {Vector2} v1
  3944. * @param {Vector2} v2
  3945. * @return {number}
  3946. */
  3947. dot: function (v1, v2) {
  3948. return v1[0] * v2[0] + v1[1] * v2[1];
  3949. },
  3950. /**
  3951. * 向量缩放
  3952. * @param {Vector2} out
  3953. * @param {Vector2} v
  3954. * @param {number} s
  3955. */
  3956. scale: function (out, v, s) {
  3957. out[0] = v[0] * s;
  3958. out[1] = v[1] * s;
  3959. return out;
  3960. },
  3961. /**
  3962. * 向量归一化
  3963. * @param {Vector2} out
  3964. * @param {Vector2} v
  3965. */
  3966. normalize: function (out, v) {
  3967. var d = vector.len(v);
  3968. if (d === 0) {
  3969. out[0] = 0;
  3970. out[1] = 0;
  3971. }
  3972. else {
  3973. out[0] = v[0] / d;
  3974. out[1] = v[1] / d;
  3975. }
  3976. return out;
  3977. },
  3978. /**
  3979. * 计算向量间距离
  3980. * @param {Vector2} v1
  3981. * @param {Vector2} v2
  3982. * @return {number}
  3983. */
  3984. distance: function (v1, v2) {
  3985. return Math.sqrt(
  3986. (v1[0] - v2[0]) * (v1[0] - v2[0])
  3987. + (v1[1] - v2[1]) * (v1[1] - v2[1])
  3988. );
  3989. },
  3990. /**
  3991. * 向量距离平方
  3992. * @param {Vector2} v1
  3993. * @param {Vector2} v2
  3994. * @return {number}
  3995. */
  3996. distanceSquare: function (v1, v2) {
  3997. return (v1[0] - v2[0]) * (v1[0] - v2[0])
  3998. + (v1[1] - v2[1]) * (v1[1] - v2[1]);
  3999. },
  4000. /**
  4001. * 求负向量
  4002. * @param {Vector2} out
  4003. * @param {Vector2} v
  4004. */
  4005. negate: function (out, v) {
  4006. out[0] = -v[0];
  4007. out[1] = -v[1];
  4008. return out;
  4009. },
  4010. /**
  4011. * 插值两个点
  4012. * @param {Vector2} out
  4013. * @param {Vector2} v1
  4014. * @param {Vector2} v2
  4015. * @param {number} t
  4016. */
  4017. lerp: function (out, v1, v2, t) {
  4018. out[0] = v1[0] + t * (v2[0] - v1[0]);
  4019. out[1] = v1[1] + t * (v2[1] - v1[1]);
  4020. return out;
  4021. },
  4022. /**
  4023. * 矩阵左乘向量
  4024. * @param {Vector2} out
  4025. * @param {Vector2} v
  4026. * @param {Vector2} m
  4027. */
  4028. applyTransform: function (out, v, m) {
  4029. var x = v[0];
  4030. var y = v[1];
  4031. out[0] = m[0] * x + m[2] * y + m[4];
  4032. out[1] = m[1] * x + m[3] * y + m[5];
  4033. return out;
  4034. },
  4035. /**
  4036. * 求两个向量最小值
  4037. * @param {Vector2} out
  4038. * @param {Vector2} v1
  4039. * @param {Vector2} v2
  4040. */
  4041. min: function (out, v1, v2) {
  4042. out[0] = Math.min(v1[0], v2[0]);
  4043. out[1] = Math.min(v1[1], v2[1]);
  4044. return out;
  4045. },
  4046. /**
  4047. * 求两个向量最大值
  4048. * @param {Vector2} out
  4049. * @param {Vector2} v1
  4050. * @param {Vector2} v2
  4051. */
  4052. max: function (out, v1, v2) {
  4053. out[0] = Math.max(v1[0], v2[0]);
  4054. out[1] = Math.max(v1[1], v2[1]);
  4055. return out;
  4056. }
  4057. };
  4058. vector.length = vector.len;
  4059. vector.lengthSquare = vector.lenSquare;
  4060. vector.dist = vector.distance;
  4061. vector.distSquare = vector.distanceSquare;
  4062. module.exports = vector;
  4063. /***/ },
  4064. /* 17 */
  4065. /***/ function(module, exports) {
  4066. var ArrayCtor = typeof Float32Array === 'undefined'
  4067. ? Array
  4068. : Float32Array;
  4069. /**
  4070. * 3x2矩阵操作类
  4071. * @exports zrender/tool/matrix
  4072. */
  4073. var matrix = {
  4074. /**
  4075. * 创建一个单位矩阵
  4076. * @return {Float32Array|Array.<number>}
  4077. */
  4078. create : function() {
  4079. var out = new ArrayCtor(6);
  4080. matrix.identity(out);
  4081. return out;
  4082. },
  4083. /**
  4084. * 设置矩阵为单位矩阵
  4085. * @param {Float32Array|Array.<number>} out
  4086. */
  4087. identity : function(out) {
  4088. out[0] = 1;
  4089. out[1] = 0;
  4090. out[2] = 0;
  4091. out[3] = 1;
  4092. out[4] = 0;
  4093. out[5] = 0;
  4094. return out;
  4095. },
  4096. /**
  4097. * 复制矩阵
  4098. * @param {Float32Array|Array.<number>} out
  4099. * @param {Float32Array|Array.<number>} m
  4100. */
  4101. copy: function(out, m) {
  4102. out[0] = m[0];
  4103. out[1] = m[1];
  4104. out[2] = m[2];
  4105. out[3] = m[3];
  4106. out[4] = m[4];
  4107. out[5] = m[5];
  4108. return out;
  4109. },
  4110. /**
  4111. * 矩阵相乘
  4112. * @param {Float32Array|Array.<number>} out
  4113. * @param {Float32Array|Array.<number>} m1
  4114. * @param {Float32Array|Array.<number>} m2
  4115. */
  4116. mul : function (out, m1, m2) {
  4117. // Consider matrix.mul(m, m2, m);
  4118. // where out is the same as m2.
  4119. // So use temp variable to escape error.
  4120. var out0 = m1[0] * m2[0] + m1[2] * m2[1];
  4121. var out1 = m1[1] * m2[0] + m1[3] * m2[1];
  4122. var out2 = m1[0] * m2[2] + m1[2] * m2[3];
  4123. var out3 = m1[1] * m2[2] + m1[3] * m2[3];
  4124. var out4 = m1[0] * m2[4] + m1[2] * m2[5] + m1[4];
  4125. var out5 = m1[1] * m2[4] + m1[3] * m2[5] + m1[5];
  4126. out[0] = out0;
  4127. out[1] = out1;
  4128. out[2] = out2;
  4129. out[3] = out3;
  4130. out[4] = out4;
  4131. out[5] = out5;
  4132. return out;
  4133. },
  4134. /**
  4135. * 平移变换
  4136. * @param {Float32Array|Array.<number>} out
  4137. * @param {Float32Array|Array.<number>} a
  4138. * @param {Float32Array|Array.<number>} v
  4139. */
  4140. translate : function(out, a, v) {
  4141. out[0] = a[0];
  4142. out[1] = a[1];
  4143. out[2] = a[2];
  4144. out[3] = a[3];
  4145. out[4] = a[4] + v[0];
  4146. out[5] = a[5] + v[1];
  4147. return out;
  4148. },
  4149. /**
  4150. * 旋转变换
  4151. * @param {Float32Array|Array.<number>} out
  4152. * @param {Float32Array|Array.<number>} a
  4153. * @param {number} rad
  4154. */
  4155. rotate : function(out, a, rad) {
  4156. var aa = a[0];
  4157. var ac = a[2];
  4158. var atx = a[4];
  4159. var ab = a[1];
  4160. var ad = a[3];
  4161. var aty = a[5];
  4162. var st = Math.sin(rad);
  4163. var ct = Math.cos(rad);
  4164. out[0] = aa * ct + ab * st;
  4165. out[1] = -aa * st + ab * ct;
  4166. out[2] = ac * ct + ad * st;
  4167. out[3] = -ac * st + ct * ad;
  4168. out[4] = ct * atx + st * aty;
  4169. out[5] = ct * aty - st * atx;
  4170. return out;
  4171. },
  4172. /**
  4173. * 缩放变换
  4174. * @param {Float32Array|Array.<number>} out
  4175. * @param {Float32Array|Array.<number>} a
  4176. * @param {Float32Array|Array.<number>} v
  4177. */
  4178. scale : function(out, a, v) {
  4179. var vx = v[0];
  4180. var vy = v[1];
  4181. out[0] = a[0] * vx;
  4182. out[1] = a[1] * vy;
  4183. out[2] = a[2] * vx;
  4184. out[3] = a[3] * vy;
  4185. out[4] = a[4] * vx;
  4186. out[5] = a[5] * vy;
  4187. return out;
  4188. },
  4189. /**
  4190. * 求逆矩阵
  4191. * @param {Float32Array|Array.<number>} out
  4192. * @param {Float32Array|Array.<number>} a
  4193. */
  4194. invert : function(out, a) {
  4195. var aa = a[0];
  4196. var ac = a[2];
  4197. var atx = a[4];
  4198. var ab = a[1];
  4199. var ad = a[3];
  4200. var aty = a[5];
  4201. var det = aa * ad - ab * ac;
  4202. if (!det) {
  4203. return null;
  4204. }
  4205. det = 1.0 / det;
  4206. out[0] = ad * det;
  4207. out[1] = -ab * det;
  4208. out[2] = -ac * det;
  4209. out[3] = aa * det;
  4210. out[4] = (ac * aty - ad * atx) * det;
  4211. out[5] = (ab * atx - aa * aty) * det;
  4212. return out;
  4213. }
  4214. };
  4215. module.exports = matrix;
  4216. /***/ },
  4217. /* 18 */
  4218. /***/ function(module, exports, __webpack_require__) {
  4219. module.exports = {
  4220. getItemStyle: __webpack_require__(11)(
  4221. [
  4222. ['fill', 'color'],
  4223. ['stroke', 'borderColor'],
  4224. ['lineWidth', 'borderWidth'],
  4225. ['opacity'],
  4226. ['shadowBlur'],
  4227. ['shadowOffsetX'],
  4228. ['shadowOffsetY'],
  4229. ['shadowColor']
  4230. ]
  4231. )
  4232. };
  4233. /***/ },
  4234. /* 19 */
  4235. /***/ function(module, exports, __webpack_require__) {
  4236. /**
  4237. * Component model
  4238. *
  4239. * @module echarts/model/Component
  4240. */
  4241. var Model = __webpack_require__(8);
  4242. var zrUtil = __webpack_require__(3);
  4243. var arrayPush = Array.prototype.push;
  4244. var componentUtil = __webpack_require__(20);
  4245. var clazzUtil = __webpack_require__(9);
  4246. var layout = __webpack_require__(21);
  4247. /**
  4248. * @alias module:echarts/model/Component
  4249. * @constructor
  4250. * @param {Object} option
  4251. * @param {module:echarts/model/Model} parentModel
  4252. * @param {module:echarts/model/Model} ecModel
  4253. */
  4254. var ComponentModel = Model.extend({
  4255. type: 'component',
  4256. /**
  4257. * @readOnly
  4258. * @type {string}
  4259. */
  4260. id: '',
  4261. /**
  4262. * @readOnly
  4263. */
  4264. name: '',
  4265. /**
  4266. * @readOnly
  4267. * @type {string}
  4268. */
  4269. mainType: '',
  4270. /**
  4271. * @readOnly
  4272. * @type {string}
  4273. */
  4274. subType: '',
  4275. /**
  4276. * @readOnly
  4277. * @type {number}
  4278. */
  4279. componentIndex: 0,
  4280. /**
  4281. * @type {Object}
  4282. * @protected
  4283. */
  4284. defaultOption: null,
  4285. /**
  4286. * @type {module:echarts/model/Global}
  4287. * @readOnly
  4288. */
  4289. ecModel: null,
  4290. /**
  4291. * key: componentType
  4292. * value: Component model list, can not be null.
  4293. * @type {Object.<string, Array.<module:echarts/model/Model>>}
  4294. * @readOnly
  4295. */
  4296. dependentModels: [],
  4297. /**
  4298. * @type {string}
  4299. * @readOnly
  4300. */
  4301. uid: null,
  4302. /**
  4303. * Support merge layout params.
  4304. * Only support 'box' now (left/right/top/bottom/width/height).
  4305. * @type {string|Object} Object can be {ignoreSize: true}
  4306. * @readOnly
  4307. */
  4308. layoutMode: null,
  4309. init: function (option, parentModel, ecModel, extraOpt) {
  4310. this.mergeDefaultAndTheme(this.option, this.ecModel);
  4311. },
  4312. mergeDefaultAndTheme: function (option, ecModel) {
  4313. var layoutMode = this.layoutMode;
  4314. var inputPositionParams = layoutMode
  4315. ? layout.getLayoutParams(option) : {};
  4316. var themeModel = ecModel.getTheme();
  4317. zrUtil.merge(option, themeModel.get(this.mainType));
  4318. zrUtil.merge(option, this.getDefaultOption());
  4319. if (layoutMode) {
  4320. layout.mergeLayoutParam(option, inputPositionParams, layoutMode);
  4321. }
  4322. },
  4323. mergeOption: function (option) {
  4324. zrUtil.merge(this.option, option, true);
  4325. var layoutMode = this.layoutMode;
  4326. if (layoutMode) {
  4327. layout.mergeLayoutParam(this.option, option, layoutMode);
  4328. }
  4329. },
  4330. // Hooker after init or mergeOption
  4331. optionUpdated: function (ecModel) {},
  4332. getDefaultOption: function () {
  4333. if (!this.hasOwnProperty('__defaultOption')) {
  4334. var optList = [];
  4335. var Class = this.constructor;
  4336. while (Class) {
  4337. var opt = Class.prototype.defaultOption;
  4338. opt && optList.push(opt);
  4339. Class = Class.superClass;
  4340. }
  4341. var defaultOption = {};
  4342. for (var i = optList.length - 1; i >= 0; i--) {
  4343. defaultOption = zrUtil.merge(defaultOption, optList[i], true);
  4344. }
  4345. this.__defaultOption = defaultOption;
  4346. }
  4347. return this.__defaultOption;
  4348. }
  4349. });
  4350. // Reset ComponentModel.extend, add preConstruct.
  4351. clazzUtil.enableClassExtend(
  4352. ComponentModel,
  4353. function (option, parentModel, ecModel, extraOpt) {
  4354. // Set dependentModels, componentIndex, name, id, mainType, subType.
  4355. zrUtil.extend(this, extraOpt);
  4356. this.uid = componentUtil.getUID('componentModel');
  4357. // this.setReadOnly([
  4358. // 'type', 'id', 'uid', 'name', 'mainType', 'subType',
  4359. // 'dependentModels', 'componentIndex'
  4360. // ]);
  4361. }
  4362. );
  4363. // Add capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on.
  4364. clazzUtil.enableClassManagement(
  4365. ComponentModel, {registerWhenExtend: true}
  4366. );
  4367. componentUtil.enableSubTypeDefaulter(ComponentModel);
  4368. // Add capability of ComponentModel.topologicalTravel.
  4369. componentUtil.enableTopologicalTravel(ComponentModel, getDependencies);
  4370. function getDependencies(componentType) {
  4371. var deps = [];
  4372. zrUtil.each(ComponentModel.getClassesByMainType(componentType), function (Clazz) {
  4373. arrayPush.apply(deps, Clazz.prototype.dependencies || []);
  4374. });
  4375. // Ensure main type
  4376. return zrUtil.map(deps, function (type) {
  4377. return clazzUtil.parseClassType(type).main;
  4378. });
  4379. }
  4380. zrUtil.mixin(ComponentModel, __webpack_require__(22));
  4381. module.exports = ComponentModel;
  4382. /***/ },
  4383. /* 20 */
  4384. /***/ function(module, exports, __webpack_require__) {
  4385. var zrUtil = __webpack_require__(3);
  4386. var clazz = __webpack_require__(9);
  4387. var parseClassType = clazz.parseClassType;
  4388. var base = 0;
  4389. var componentUtil = {};
  4390. var DELIMITER = '_';
  4391. /**
  4392. * @public
  4393. * @param {string} type
  4394. * @return {string}
  4395. */
  4396. componentUtil.getUID = function (type) {
  4397. // Considering the case of crossing js context,
  4398. // use Math.random to make id as unique as possible.
  4399. return [(type || ''), base++, Math.random()].join(DELIMITER);
  4400. };
  4401. /**
  4402. * @inner
  4403. */
  4404. componentUtil.enableSubTypeDefaulter = function (entity) {
  4405. var subTypeDefaulters = {};
  4406. entity.registerSubTypeDefaulter = function (componentType, defaulter) {
  4407. componentType = parseClassType(componentType);
  4408. subTypeDefaulters[componentType.main] = defaulter;
  4409. };
  4410. entity.determineSubType = function (componentType, option) {
  4411. var type = option.type;
  4412. if (!type) {
  4413. var componentTypeMain = parseClassType(componentType).main;
  4414. if (entity.hasSubTypes(componentType) && subTypeDefaulters[componentTypeMain]) {
  4415. type = subTypeDefaulters[componentTypeMain](option);
  4416. }
  4417. }
  4418. return type;
  4419. };
  4420. return entity;
  4421. };
  4422. /**
  4423. * Topological travel on Activity Network (Activity On Vertices).
  4424. * Dependencies is defined in Model.prototype.dependencies, like ['xAxis', 'yAxis'].
  4425. *
  4426. * If 'xAxis' or 'yAxis' is absent in componentTypeList, just ignore it in topology.
  4427. *
  4428. * If there is circle dependencey, Error will be thrown.
  4429. *
  4430. */
  4431. componentUtil.enableTopologicalTravel = function (entity, dependencyGetter) {
  4432. /**
  4433. * @public
  4434. * @param {Array.<string>} targetNameList Target Component type list.
  4435. * Can be ['aa', 'bb', 'aa.xx']
  4436. * @param {Array.<string>} fullNameList By which we can build dependency graph.
  4437. * @param {Function} callback Params: componentType, dependencies.
  4438. * @param {Object} context Scope of callback.
  4439. */
  4440. entity.topologicalTravel = function (targetNameList, fullNameList, callback, context) {
  4441. if (!targetNameList.length) {
  4442. return;
  4443. }
  4444. var result = makeDepndencyGraph(fullNameList);
  4445. var graph = result.graph;
  4446. var stack = result.noEntryList;
  4447. var targetNameSet = {};
  4448. zrUtil.each(targetNameList, function (name) {
  4449. targetNameSet[name] = true;
  4450. });
  4451. while (stack.length) {
  4452. var currComponentType = stack.pop();
  4453. var currVertex = graph[currComponentType];
  4454. var isInTargetNameSet = !!targetNameSet[currComponentType];
  4455. if (isInTargetNameSet) {
  4456. callback.call(context, currComponentType, currVertex.originalDeps.slice());
  4457. delete targetNameSet[currComponentType];
  4458. }
  4459. zrUtil.each(
  4460. currVertex.successor,
  4461. isInTargetNameSet ? removeEdgeAndAdd : removeEdge
  4462. );
  4463. }
  4464. zrUtil.each(targetNameSet, function () {
  4465. throw new Error('Circle dependency may exists');
  4466. });
  4467. function removeEdge(succComponentType) {
  4468. graph[succComponentType].entryCount--;
  4469. if (graph[succComponentType].entryCount === 0) {
  4470. stack.push(succComponentType);
  4471. }
  4472. }
  4473. // Consider this case: legend depends on series, and we call
  4474. // chart.setOption({series: [...]}), where only series is in option.
  4475. // If we do not have 'removeEdgeAndAdd', legendModel.mergeOption will
  4476. // not be called, but only sereis.mergeOption is called. Thus legend
  4477. // have no chance to update its local record about series (like which
  4478. // name of series is available in legend).
  4479. function removeEdgeAndAdd(succComponentType) {
  4480. targetNameSet[succComponentType] = true;
  4481. removeEdge(succComponentType);
  4482. }
  4483. };
  4484. /**
  4485. * DepndencyGraph: {Object}
  4486. * key: conponentType,
  4487. * value: {
  4488. * successor: [conponentTypes...],
  4489. * originalDeps: [conponentTypes...],
  4490. * entryCount: {number}
  4491. * }
  4492. */
  4493. function makeDepndencyGraph(fullNameList) {
  4494. var graph = {};
  4495. var noEntryList = [];
  4496. zrUtil.each(fullNameList, function (name) {
  4497. var thisItem = createDependencyGraphItem(graph, name);
  4498. var originalDeps = thisItem.originalDeps = dependencyGetter(name);
  4499. var availableDeps = getAvailableDependencies(originalDeps, fullNameList);
  4500. thisItem.entryCount = availableDeps.length;
  4501. if (thisItem.entryCount === 0) {
  4502. noEntryList.push(name);
  4503. }
  4504. zrUtil.each(availableDeps, function (dependentName) {
  4505. if (zrUtil.indexOf(thisItem.predecessor, dependentName) < 0) {
  4506. thisItem.predecessor.push(dependentName);
  4507. }
  4508. var thatItem = createDependencyGraphItem(graph, dependentName);
  4509. if (zrUtil.indexOf(thatItem.successor, dependentName) < 0) {
  4510. thatItem.successor.push(name);
  4511. }
  4512. });
  4513. });
  4514. return {graph: graph, noEntryList: noEntryList};
  4515. }
  4516. function createDependencyGraphItem(graph, name) {
  4517. if (!graph[name]) {
  4518. graph[name] = {predecessor: [], successor: []};
  4519. }
  4520. return graph[name];
  4521. }
  4522. function getAvailableDependencies(originalDeps, fullNameList) {
  4523. var availableDeps = [];
  4524. zrUtil.each(originalDeps, function (dep) {
  4525. zrUtil.indexOf(fullNameList, dep) >= 0 && availableDeps.push(dep);
  4526. });
  4527. return availableDeps;
  4528. }
  4529. };
  4530. module.exports = componentUtil;
  4531. /***/ },
  4532. /* 21 */
  4533. /***/ function(module, exports, __webpack_require__) {
  4534. 'use strict';
  4535. // Layout helpers for each component positioning
  4536. var zrUtil = __webpack_require__(3);
  4537. var BoundingRect = __webpack_require__(15);
  4538. var numberUtil = __webpack_require__(7);
  4539. var formatUtil = __webpack_require__(6);
  4540. var parsePercent = numberUtil.parsePercent;
  4541. var each = zrUtil.each;
  4542. var layout = {};
  4543. var LOCATION_PARAMS = ['left', 'right', 'top', 'bottom', 'width', 'height'];
  4544. function boxLayout(orient, group, gap, maxWidth, maxHeight) {
  4545. var x = 0;
  4546. var y = 0;
  4547. if (maxWidth == null) {
  4548. maxWidth = Infinity;
  4549. }
  4550. if (maxHeight == null) {
  4551. maxHeight = Infinity;
  4552. }
  4553. var currentLineMaxSize = 0;
  4554. group.eachChild(function (child, idx) {
  4555. var position = child.position;
  4556. var rect = child.getBoundingRect();
  4557. var nextChild = group.childAt(idx + 1);
  4558. var nextChildRect = nextChild && nextChild.getBoundingRect();
  4559. var nextX;
  4560. var nextY;
  4561. if (orient === 'horizontal') {
  4562. var moveX = rect.width + (nextChildRect ? (-nextChildRect.x + rect.x) : 0);
  4563. nextX = x + moveX;
  4564. // Wrap when width exceeds maxWidth or meet a `newline` group
  4565. if (nextX > maxWidth || child.newline) {
  4566. x = 0;
  4567. nextX = moveX;
  4568. y += currentLineMaxSize + gap;
  4569. currentLineMaxSize = rect.height;
  4570. }
  4571. else {
  4572. currentLineMaxSize = Math.max(currentLineMaxSize, rect.height);
  4573. }
  4574. }
  4575. else {
  4576. var moveY = rect.height + (nextChildRect ? (-nextChildRect.y + rect.y) : 0);
  4577. nextY = y + moveY;
  4578. // Wrap when width exceeds maxHeight or meet a `newline` group
  4579. if (nextY > maxHeight || child.newline) {
  4580. x += currentLineMaxSize + gap;
  4581. y = 0;
  4582. nextY = moveY;
  4583. currentLineMaxSize = rect.width;
  4584. }
  4585. else {
  4586. currentLineMaxSize = Math.max(currentLineMaxSize, rect.width);
  4587. }
  4588. }
  4589. if (child.newline) {
  4590. return;
  4591. }
  4592. position[0] = x;
  4593. position[1] = y;
  4594. orient === 'horizontal'
  4595. ? (x = nextX + gap)
  4596. : (y = nextY + gap);
  4597. });
  4598. }
  4599. /**
  4600. * VBox or HBox layouting
  4601. * @param {string} orient
  4602. * @param {module:zrender/container/Group} group
  4603. * @param {number} gap
  4604. * @param {number} [width=Infinity]
  4605. * @param {number} [height=Infinity]
  4606. */
  4607. layout.box = boxLayout;
  4608. /**
  4609. * VBox layouting
  4610. * @param {module:zrender/container/Group} group
  4611. * @param {number} gap
  4612. * @param {number} [width=Infinity]
  4613. * @param {number} [height=Infinity]
  4614. */
  4615. layout.vbox = zrUtil.curry(boxLayout, 'vertical');
  4616. /**
  4617. * HBox layouting
  4618. * @param {module:zrender/container/Group} group
  4619. * @param {number} gap
  4620. * @param {number} [width=Infinity]
  4621. * @param {number} [height=Infinity]
  4622. */
  4623. layout.hbox = zrUtil.curry(boxLayout, 'horizontal');
  4624. /**
  4625. * If x or x2 is not specified or 'center' 'left' 'right',
  4626. * the width would be as long as possible.
  4627. * If y or y2 is not specified or 'middle' 'top' 'bottom',
  4628. * the height would be as long as possible.
  4629. *
  4630. * @param {Object} positionInfo
  4631. * @param {number|string} [positionInfo.x]
  4632. * @param {number|string} [positionInfo.y]
  4633. * @param {number|string} [positionInfo.x2]
  4634. * @param {number|string} [positionInfo.y2]
  4635. * @param {Object} containerRect
  4636. * @param {string|number} margin
  4637. * @return {Object} {width, height}
  4638. */
  4639. layout.getAvailableSize = function (positionInfo, containerRect, margin) {
  4640. var containerWidth = containerRect.width;
  4641. var containerHeight = containerRect.height;
  4642. var x = parsePercent(positionInfo.x, containerWidth);
  4643. var y = parsePercent(positionInfo.y, containerHeight);
  4644. var x2 = parsePercent(positionInfo.x2, containerWidth);
  4645. var y2 = parsePercent(positionInfo.y2, containerHeight);
  4646. (isNaN(x) || isNaN(parseFloat(positionInfo.x))) && (x = 0);
  4647. (isNaN(x2) || isNaN(parseFloat(positionInfo.x2))) && (x2 = containerWidth);
  4648. (isNaN(y) || isNaN(parseFloat(positionInfo.y))) && (y = 0);
  4649. (isNaN(y2) || isNaN(parseFloat(positionInfo.y2))) && (y2 = containerHeight);
  4650. margin = formatUtil.normalizeCssArray(margin || 0);
  4651. return {
  4652. width: Math.max(x2 - x - margin[1] - margin[3], 0),
  4653. height: Math.max(y2 - y - margin[0] - margin[2], 0)
  4654. };
  4655. };
  4656. /**
  4657. * Parse position info.
  4658. *
  4659. * @param {Object} positionInfo
  4660. * @param {number|string} [positionInfo.left]
  4661. * @param {number|string} [positionInfo.top]
  4662. * @param {number|string} [positionInfo.right]
  4663. * @param {number|string} [positionInfo.bottom]
  4664. * @param {number|string} [positionInfo.width]
  4665. * @param {number|string} [positionInfo.height]
  4666. * @param {number|string} [positionInfo.aspect] Aspect is width / height
  4667. * @param {Object} containerRect
  4668. * @param {string|number} [margin]
  4669. *
  4670. * @return {module:zrender/core/BoundingRect}
  4671. */
  4672. layout.getLayoutRect = function (
  4673. positionInfo, containerRect, margin
  4674. ) {
  4675. margin = formatUtil.normalizeCssArray(margin || 0);
  4676. var containerWidth = containerRect.width;
  4677. var containerHeight = containerRect.height;
  4678. var left = parsePercent(positionInfo.left, containerWidth);
  4679. var top = parsePercent(positionInfo.top, containerHeight);
  4680. var right = parsePercent(positionInfo.right, containerWidth);
  4681. var bottom = parsePercent(positionInfo.bottom, containerHeight);
  4682. var width = parsePercent(positionInfo.width, containerWidth);
  4683. var height = parsePercent(positionInfo.height, containerHeight);
  4684. var verticalMargin = margin[2] + margin[0];
  4685. var horizontalMargin = margin[1] + margin[3];
  4686. var aspect = positionInfo.aspect;
  4687. // If width is not specified, calculate width from left and right
  4688. if (isNaN(width)) {
  4689. width = containerWidth - right - horizontalMargin - left;
  4690. }
  4691. if (isNaN(height)) {
  4692. height = containerHeight - bottom - verticalMargin - top;
  4693. }
  4694. // If width and height are not given
  4695. // 1. Graph should not exceeds the container
  4696. // 2. Aspect must be keeped
  4697. // 3. Graph should take the space as more as possible
  4698. if (isNaN(width) && isNaN(height)) {
  4699. if (aspect > containerWidth / containerHeight) {
  4700. width = containerWidth * 0.8;
  4701. }
  4702. else {
  4703. height = containerHeight * 0.8;
  4704. }
  4705. }
  4706. if (aspect != null) {
  4707. // Calculate width or height with given aspect
  4708. if (isNaN(width)) {
  4709. width = aspect * height;
  4710. }
  4711. if (isNaN(height)) {
  4712. height = width / aspect;
  4713. }
  4714. }
  4715. // If left is not specified, calculate left from right and width
  4716. if (isNaN(left)) {
  4717. left = containerWidth - right - width - horizontalMargin;
  4718. }
  4719. if (isNaN(top)) {
  4720. top = containerHeight - bottom - height - verticalMargin;
  4721. }
  4722. // Align left and top
  4723. switch (positionInfo.left || positionInfo.right) {
  4724. case 'center':
  4725. left = containerWidth / 2 - width / 2 - margin[3];
  4726. break;
  4727. case 'right':
  4728. left = containerWidth - width - horizontalMargin;
  4729. break;
  4730. }
  4731. switch (positionInfo.top || positionInfo.bottom) {
  4732. case 'middle':
  4733. case 'center':
  4734. top = containerHeight / 2 - height / 2 - margin[0];
  4735. break;
  4736. case 'bottom':
  4737. top = containerHeight - height - verticalMargin;
  4738. break;
  4739. }
  4740. // If something is wrong and left, top, width, height are calculated as NaN
  4741. left = left || 0;
  4742. top = top || 0;
  4743. if (isNaN(width)) {
  4744. // Width may be NaN if only one value is given except width
  4745. width = containerWidth - left - (right || 0);
  4746. }
  4747. if (isNaN(height)) {
  4748. // Height may be NaN if only one value is given except height
  4749. height = containerHeight - top - (bottom || 0);
  4750. }
  4751. var rect = new BoundingRect(left + margin[3], top + margin[0], width, height);
  4752. rect.margin = margin;
  4753. return rect;
  4754. };
  4755. /**
  4756. * Position group of component in viewport
  4757. * Group position is specified by either
  4758. * {left, top}, {right, bottom}
  4759. * If all properties exists, right and bottom will be igonred.
  4760. *
  4761. * @param {module:zrender/container/Group} group
  4762. * @param {Object} positionInfo
  4763. * @param {number|string} [positionInfo.left]
  4764. * @param {number|string} [positionInfo.top]
  4765. * @param {number|string} [positionInfo.right]
  4766. * @param {number|string} [positionInfo.bottom]
  4767. * @param {Object} containerRect
  4768. * @param {string|number} margin
  4769. */
  4770. layout.positionGroup = function (
  4771. group, positionInfo, containerRect, margin
  4772. ) {
  4773. var groupRect = group.getBoundingRect();
  4774. positionInfo = zrUtil.extend(zrUtil.clone(positionInfo), {
  4775. width: groupRect.width,
  4776. height: groupRect.height
  4777. });
  4778. positionInfo = layout.getLayoutRect(
  4779. positionInfo, containerRect, margin
  4780. );
  4781. group.position = [
  4782. positionInfo.x - groupRect.x,
  4783. positionInfo.y - groupRect.y
  4784. ];
  4785. };
  4786. /**
  4787. * Consider Case:
  4788. * When defulat option has {left: 0, width: 100}, and we set {right: 0}
  4789. * through setOption or media query, using normal zrUtil.merge will cause
  4790. * {right: 0} does not take effect.
  4791. *
  4792. * @example
  4793. * ComponentModel.extend({
  4794. * init: function () {
  4795. * ...
  4796. * var inputPositionParams = layout.getLayoutParams(option);
  4797. * this.mergeOption(inputPositionParams);
  4798. * },
  4799. * mergeOption: function (newOption) {
  4800. * newOption && zrUtil.merge(thisOption, newOption, true);
  4801. * layout.mergeLayoutParam(thisOption, newOption);
  4802. * }
  4803. * });
  4804. *
  4805. * @param {Object} targetOption
  4806. * @param {Object} newOption
  4807. * @param {Object|string} [opt]
  4808. * @param {boolean} [opt.ignoreSize=false] Some component must has width and height.
  4809. */
  4810. layout.mergeLayoutParam = function (targetOption, newOption, opt) {
  4811. !zrUtil.isObject(opt) && (opt = {});
  4812. var hNames = ['width', 'left', 'right']; // Order by priority.
  4813. var vNames = ['height', 'top', 'bottom']; // Order by priority.
  4814. var hResult = merge(hNames);
  4815. var vResult = merge(vNames);
  4816. copy(hNames, targetOption, hResult);
  4817. copy(vNames, targetOption, vResult);
  4818. function merge(names) {
  4819. var newParams = {};
  4820. var newValueCount = 0;
  4821. var merged = {};
  4822. var mergedValueCount = 0;
  4823. var enoughParamNumber = opt.ignoreSize ? 1 : 2;
  4824. each(names, function (name) {
  4825. merged[name] = targetOption[name];
  4826. });
  4827. each(names, function (name) {
  4828. // Consider case: newOption.width is null, which is
  4829. // set by user for removing width setting.
  4830. hasProp(newOption, name) && (newParams[name] = merged[name] = newOption[name]);
  4831. hasValue(newParams, name) && newValueCount++;
  4832. hasValue(merged, name) && mergedValueCount++;
  4833. });
  4834. // Case: newOption: {width: ..., right: ...},
  4835. // or targetOption: {right: ...} and newOption: {width: ...},
  4836. // There is no conflict when merged only has params count
  4837. // little than enoughParamNumber.
  4838. if (mergedValueCount === enoughParamNumber || !newValueCount) {
  4839. return merged;
  4840. }
  4841. // Case: newOption: {width: ..., right: ...},
  4842. // Than we can make sure user only want those two, and ignore
  4843. // all origin params in targetOption.
  4844. else if (newValueCount >= enoughParamNumber) {
  4845. return newParams;
  4846. }
  4847. else {
  4848. // Chose another param from targetOption by priority.
  4849. // When 'ignoreSize', enoughParamNumber is 1 and those will not happen.
  4850. for (var i = 0; i < names.length; i++) {
  4851. var name = names[i];
  4852. if (!hasProp(newParams, name) && hasProp(targetOption, name)) {
  4853. newParams[name] = targetOption[name];
  4854. break;
  4855. }
  4856. }
  4857. return newParams;
  4858. }
  4859. }
  4860. function hasProp(obj, name) {
  4861. return obj.hasOwnProperty(name);
  4862. }
  4863. function hasValue(obj, name) {
  4864. return obj[name] != null && obj[name] !== 'auto';
  4865. }
  4866. function copy(names, target, source) {
  4867. each(names, function (name) {
  4868. target[name] = source[name];
  4869. });
  4870. }
  4871. };
  4872. /**
  4873. * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object.
  4874. * @param {Object} source
  4875. * @return {Object} Result contains those props.
  4876. */
  4877. layout.getLayoutParams = function (source) {
  4878. return layout.copyLayoutParams({}, source);
  4879. };
  4880. /**
  4881. * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object.
  4882. * @param {Object} source
  4883. * @return {Object} Result contains those props.
  4884. */
  4885. layout.copyLayoutParams = function (target, source) {
  4886. source && target && each(LOCATION_PARAMS, function (name) {
  4887. source.hasOwnProperty(name) && (target[name] = source[name]);
  4888. });
  4889. return target;
  4890. };
  4891. module.exports = layout;
  4892. /***/ },
  4893. /* 22 */
  4894. /***/ function(module, exports) {
  4895. module.exports = {
  4896. getBoxLayoutParams: function () {
  4897. return {
  4898. left: this.get('left'),
  4899. top: this.get('top'),
  4900. right: this.get('right'),
  4901. bottom: this.get('bottom'),
  4902. width: this.get('width'),
  4903. height: this.get('height')
  4904. };
  4905. }
  4906. };
  4907. /***/ },
  4908. /* 23 */
  4909. /***/ function(module, exports) {
  4910. var platform = '';
  4911. // Navigator not exists in node
  4912. if (typeof navigator !== 'undefined') {
  4913. platform = navigator.platform || '';
  4914. }
  4915. module.exports = {
  4916. // 全图默认背景
  4917. // backgroundColor: 'rgba(0,0,0,0)',
  4918. // https://dribbble.com/shots/1065960-Infographic-Pie-chart-visualization
  4919. // color: ['#5793f3', '#d14a61', '#fd9c35', '#675bba', '#fec42c', '#dd4444', '#d4df5a', '#cd4870'],
  4920. // 浅色
  4921. // color: ['#bcd3bb', '#e88f70', '#edc1a5', '#9dc5c8', '#e1e8c8', '#7b7c68', '#e5b5b5', '#f0b489', '#928ea8', '#bda29a'],
  4922. // color: ['#cc5664', '#9bd6ec', '#ea946e', '#8acaaa', '#f1ec64', '#ee8686', '#a48dc1', '#5da6bc', '#b9dcae'],
  4923. // 深色
  4924. color: ['#c23531','#2f4554', '#61a0a8', '#d48265', '#91c7ae','#749f83', '#ca8622', '#bda29a','#6e7074', '#546570', '#c4ccd3'],
  4925. // 默认需要 Grid 配置项
  4926. grid: {},
  4927. // 主题,主题
  4928. textStyle: {
  4929. // color: '#000',
  4930. // decoration: 'none',
  4931. // PENDING
  4932. fontFamily: platform.match(/^Win/) ? 'Microsoft YaHei' : 'sans-serif',
  4933. // fontFamily: 'Arial, Verdana, sans-serif',
  4934. fontSize: 12,
  4935. fontStyle: 'normal',
  4936. fontWeight: 'normal'
  4937. },
  4938. // 主题,默认标志图形类型列表
  4939. // symbolList: [
  4940. // 'circle', 'rectangle', 'triangle', 'diamond',
  4941. // 'emptyCircle', 'emptyRectangle', 'emptyTriangle', 'emptyDiamond'
  4942. // ],
  4943. animation: true, // 过渡动画是否开启
  4944. animationThreshold: 2000, // 动画元素阀值,产生的图形原素超过2000不出动画
  4945. animationDuration: 1000, // 过渡动画参数:进入
  4946. animationDurationUpdate: 300, // 过渡动画参数:更新
  4947. animationEasing: 'exponentialOut', //BounceOut
  4948. animationEasingUpdate: 'cubicOut'
  4949. };
  4950. /***/ },
  4951. /* 24 */
  4952. /***/ function(module, exports, __webpack_require__) {
  4953. 'use strict';
  4954. var zrUtil = __webpack_require__(3);
  4955. var echartsAPIList = [
  4956. 'getDom', 'getZr', 'getWidth', 'getHeight', 'dispatchAction',
  4957. 'on', 'off', 'getDataURL', 'getConnectedDataURL', 'getModel', 'getOption'
  4958. ];
  4959. function ExtensionAPI(chartInstance) {
  4960. zrUtil.each(echartsAPIList, function (name) {
  4961. this[name] = zrUtil.bind(chartInstance[name], chartInstance);
  4962. }, this);
  4963. }
  4964. module.exports = ExtensionAPI;
  4965. /***/ },
  4966. /* 25 */
  4967. /***/ function(module, exports) {
  4968. 'use strict';
  4969. // var zrUtil = require('zrender/lib/core/util');
  4970. var coordinateSystemCreators = {};
  4971. function CoordinateSystemManager() {
  4972. this._coordinateSystems = [];
  4973. }
  4974. CoordinateSystemManager.prototype = {
  4975. constructor: CoordinateSystemManager,
  4976. create: function (ecModel, api) {
  4977. var coordinateSystems = [];
  4978. for (var type in coordinateSystemCreators) {
  4979. var list = coordinateSystemCreators[type].create(ecModel, api);
  4980. list && (coordinateSystems = coordinateSystems.concat(list));
  4981. }
  4982. this._coordinateSystems = coordinateSystems;
  4983. },
  4984. update: function (ecModel, api) {
  4985. var coordinateSystems = this._coordinateSystems;
  4986. for (var i = 0; i < coordinateSystems.length; i++) {
  4987. // FIXME MUST have
  4988. coordinateSystems[i].update && coordinateSystems[i].update(ecModel, api);
  4989. }
  4990. }
  4991. };
  4992. CoordinateSystemManager.register = function (type, coordinateSystemCreator) {
  4993. coordinateSystemCreators[type] = coordinateSystemCreator;
  4994. };
  4995. CoordinateSystemManager.get = function (type) {
  4996. return coordinateSystemCreators[type];
  4997. };
  4998. module.exports = CoordinateSystemManager;
  4999. /***/ },
  5000. /* 26 */
  5001. /***/ function(module, exports, __webpack_require__) {
  5002. /**
  5003. * ECharts option manager
  5004. *
  5005. * @module {echarts/model/OptionManager}
  5006. */
  5007. var zrUtil = __webpack_require__(3);
  5008. var modelUtil = __webpack_require__(5);
  5009. var ComponentModel = __webpack_require__(19);
  5010. var each = zrUtil.each;
  5011. var clone = zrUtil.clone;
  5012. var map = zrUtil.map;
  5013. var merge = zrUtil.merge;
  5014. var QUERY_REG = /^(min|max)?(.+)$/;
  5015. /**
  5016. * TERM EXPLANATIONS:
  5017. *
  5018. * [option]:
  5019. *
  5020. * An object that contains definitions of components. For example:
  5021. * var option = {
  5022. * title: {...},
  5023. * legend: {...},
  5024. * visualMap: {...},
  5025. * series: [
  5026. * {data: [...]},
  5027. * {data: [...]},
  5028. * ...
  5029. * ]
  5030. * };
  5031. *
  5032. * [rawOption]:
  5033. *
  5034. * An object input to echarts.setOption. 'rawOption' may be an
  5035. * 'option', or may be an object contains multi-options. For example:
  5036. * var option = {
  5037. * baseOption: {
  5038. * title: {...},
  5039. * legend: {...},
  5040. * series: [
  5041. * {data: [...]},
  5042. * {data: [...]},
  5043. * ...
  5044. * ]
  5045. * },
  5046. * timeline: {...},
  5047. * options: [
  5048. * {title: {...}, series: {data: [...]}},
  5049. * {title: {...}, series: {data: [...]}},
  5050. * ...
  5051. * ],
  5052. * media: [
  5053. * {
  5054. * query: {maxWidth: 320},
  5055. * option: {series: {x: 20}, visualMap: {show: false}}
  5056. * },
  5057. * {
  5058. * query: {minWidth: 320, maxWidth: 720},
  5059. * option: {series: {x: 500}, visualMap: {show: true}}
  5060. * },
  5061. * {
  5062. * option: {series: {x: 1200}, visualMap: {show: true}}
  5063. * }
  5064. * ]
  5065. * };
  5066. *
  5067. * @alias module:echarts/model/OptionManager
  5068. * @param {module:echarts/ExtensionAPI} api
  5069. */
  5070. function OptionManager(api) {
  5071. /**
  5072. * @private
  5073. * @type {module:echarts/ExtensionAPI}
  5074. */
  5075. this._api = api;
  5076. /**
  5077. * @private
  5078. * @type {Array.<number>}
  5079. */
  5080. this._timelineOptions = [];
  5081. /**
  5082. * @private
  5083. * @type {Array.<Object>}
  5084. */
  5085. this._mediaList = [];
  5086. /**
  5087. * @private
  5088. * @type {Object}
  5089. */
  5090. this._mediaDefault;
  5091. /**
  5092. * -1, means default.
  5093. * empty means no media.
  5094. * @private
  5095. * @type {Array.<number>}
  5096. */
  5097. this._currentMediaIndices = [];
  5098. /**
  5099. * @private
  5100. * @type {Object}
  5101. */
  5102. this._optionBackup;
  5103. /**
  5104. * @private
  5105. * @type {Object}
  5106. */
  5107. this._newBaseOption;
  5108. }
  5109. // timeline.notMerge is not supported in ec3. Firstly there is rearly
  5110. // case that notMerge is needed. Secondly supporting 'notMerge' requires
  5111. // rawOption cloned and backuped when timeline changed, which does no
  5112. // good to performance. What's more, that both timeline and setOption
  5113. // method supply 'notMerge' brings complex and some problems.
  5114. // Consider this case:
  5115. // (step1) chart.setOption({timeline: {notMerge: false}, ...}, false);
  5116. // (step2) chart.setOption({timeline: {notMerge: true}, ...}, false);
  5117. OptionManager.prototype = {
  5118. constructor: OptionManager,
  5119. /**
  5120. * @public
  5121. * @param {Object} rawOption Raw option.
  5122. * @param {module:echarts/model/Global} ecModel
  5123. * @param {Array.<Function>} optionPreprocessorFuncs
  5124. * @return {Object} Init option
  5125. */
  5126. setOption: function (rawOption, optionPreprocessorFuncs) {
  5127. rawOption = clone(rawOption, true);
  5128. // FIXME
  5129. // 如果 timeline options 或者 media 中设置了某个属性,而baseOption中没有设置,则进行警告。
  5130. var oldOptionBackup = this._optionBackup;
  5131. var newParsedOption = parseRawOption.call(
  5132. this, rawOption, optionPreprocessorFuncs
  5133. );
  5134. this._newBaseOption = newParsedOption.baseOption;
  5135. // For setOption at second time (using merge mode);
  5136. if (oldOptionBackup) {
  5137. // Only baseOption can be merged.
  5138. mergeOption(oldOptionBackup.baseOption, newParsedOption.baseOption);
  5139. // For simplicity, timeline options and media options do not support merge,
  5140. // that is, if you `setOption` twice and both has timeline options, the latter
  5141. // timeline opitons will not be merged to the formers, but just substitude them.
  5142. if (newParsedOption.timelineOptions.length) {
  5143. oldOptionBackup.timelineOptions = newParsedOption.timelineOptions;
  5144. }
  5145. if (newParsedOption.mediaList.length) {
  5146. oldOptionBackup.mediaList = newParsedOption.mediaList;
  5147. }
  5148. if (newParsedOption.mediaDefault) {
  5149. oldOptionBackup.mediaDefault = newParsedOption.mediaDefault;
  5150. }
  5151. }
  5152. else {
  5153. this._optionBackup = newParsedOption;
  5154. }
  5155. },
  5156. /**
  5157. * @param {boolean} isRecreate
  5158. * @return {Object}
  5159. */
  5160. mountOption: function (isRecreate) {
  5161. var optionBackup = this._optionBackup;
  5162. // TODO
  5163. // 如果没有reset功能则不clone。
  5164. this._timelineOptions = map(optionBackup.timelineOptions, clone);
  5165. this._mediaList = map(optionBackup.mediaList, clone);
  5166. this._mediaDefault = clone(optionBackup.mediaDefault);
  5167. this._currentMediaIndices = [];
  5168. return clone(isRecreate
  5169. // this._optionBackup.baseOption, which is created at the first `setOption`
  5170. // called, and is merged into every new option by inner method `mergeOption`
  5171. // each time `setOption` called, can be only used in `isRecreate`, because
  5172. // its reliability is under suspicion. In other cases option merge is
  5173. // proformed by `model.mergeOption`.
  5174. ? optionBackup.baseOption : this._newBaseOption
  5175. );
  5176. },
  5177. /**
  5178. * @param {module:echarts/model/Global} ecModel
  5179. * @return {Object}
  5180. */
  5181. getTimelineOption: function (ecModel) {
  5182. var option;
  5183. var timelineOptions = this._timelineOptions;
  5184. if (timelineOptions.length) {
  5185. // getTimelineOption can only be called after ecModel inited,
  5186. // so we can get currentIndex from timelineModel.
  5187. var timelineModel = ecModel.getComponent('timeline');
  5188. if (timelineModel) {
  5189. option = clone(
  5190. timelineOptions[timelineModel.getCurrentIndex()],
  5191. true
  5192. );
  5193. }
  5194. }
  5195. return option;
  5196. },
  5197. /**
  5198. * @param {module:echarts/model/Global} ecModel
  5199. * @return {Array.<Object>}
  5200. */
  5201. getMediaOption: function (ecModel) {
  5202. var ecWidth = this._api.getWidth();
  5203. var ecHeight = this._api.getHeight();
  5204. var mediaList = this._mediaList;
  5205. var mediaDefault = this._mediaDefault;
  5206. var indices = [];
  5207. var result = [];
  5208. // No media defined.
  5209. if (!mediaList.length && !mediaDefault) {
  5210. return result;
  5211. }
  5212. // Multi media may be applied, the latter defined media has higher priority.
  5213. for (var i = 0, len = mediaList.length; i < len; i++) {
  5214. if (applyMediaQuery(mediaList[i].query, ecWidth, ecHeight)) {
  5215. indices.push(i);
  5216. }
  5217. }
  5218. // FIXME
  5219. // 是否mediaDefault应该强制用户设置,否则可能修改不能回归。
  5220. if (!indices.length && mediaDefault) {
  5221. indices = [-1];
  5222. }
  5223. if (indices.length && !indicesEquals(indices, this._currentMediaIndices)) {
  5224. result = map(indices, function (index) {
  5225. return clone(
  5226. index === -1 ? mediaDefault.option : mediaList[index].option
  5227. );
  5228. });
  5229. }
  5230. // Otherwise return nothing.
  5231. this._currentMediaIndices = indices;
  5232. return result;
  5233. }
  5234. };
  5235. function parseRawOption(rawOption, optionPreprocessorFuncs) {
  5236. var timelineOptions = [];
  5237. var mediaList = [];
  5238. var mediaDefault;
  5239. var baseOption;
  5240. // Compatible with ec2.
  5241. var timelineOpt = rawOption.timeline;
  5242. if (rawOption.baseOption) {
  5243. baseOption = rawOption.baseOption;
  5244. }
  5245. // For timeline
  5246. if (timelineOpt || rawOption.options) {
  5247. baseOption = baseOption || {};
  5248. timelineOptions = (rawOption.options || []).slice();
  5249. }
  5250. // For media query
  5251. if (rawOption.media) {
  5252. baseOption = baseOption || {};
  5253. var media = rawOption.media;
  5254. each(media, function (singleMedia) {
  5255. if (singleMedia && singleMedia.option) {
  5256. if (singleMedia.query) {
  5257. mediaList.push(singleMedia);
  5258. }
  5259. else if (!mediaDefault) {
  5260. // Use the first media default.
  5261. mediaDefault = singleMedia;
  5262. }
  5263. }
  5264. });
  5265. }
  5266. // For normal option
  5267. if (!baseOption) {
  5268. baseOption = rawOption;
  5269. }
  5270. // Set timelineOpt to baseOption in ec3,
  5271. // which is convenient for merge option.
  5272. if (!baseOption.timeline) {
  5273. baseOption.timeline = timelineOpt;
  5274. }
  5275. // Preprocess.
  5276. each([baseOption].concat(timelineOptions)
  5277. .concat(zrUtil.map(mediaList, function (media) {
  5278. return media.option;
  5279. })),
  5280. function (option) {
  5281. each(optionPreprocessorFuncs, function (preProcess) {
  5282. preProcess(option);
  5283. });
  5284. }
  5285. );
  5286. return {
  5287. baseOption: baseOption,
  5288. timelineOptions: timelineOptions,
  5289. mediaDefault: mediaDefault,
  5290. mediaList: mediaList
  5291. };
  5292. }
  5293. /**
  5294. * @see <http://www.w3.org/TR/css3-mediaqueries/#media1>
  5295. * Support: width, height, aspectRatio
  5296. * Can use max or min as prefix.
  5297. */
  5298. function applyMediaQuery(query, ecWidth, ecHeight) {
  5299. var realMap = {
  5300. width: ecWidth,
  5301. height: ecHeight,
  5302. aspectratio: ecWidth / ecHeight // lowser case for convenientce.
  5303. };
  5304. var applicatable = true;
  5305. zrUtil.each(query, function (value, attr) {
  5306. var matched = attr.match(QUERY_REG);
  5307. if (!matched || !matched[1] || !matched[2]) {
  5308. return;
  5309. }
  5310. var operator = matched[1];
  5311. var realAttr = matched[2].toLowerCase();
  5312. if (!compare(realMap[realAttr], value, operator)) {
  5313. applicatable = false;
  5314. }
  5315. });
  5316. return applicatable;
  5317. }
  5318. function compare(real, expect, operator) {
  5319. if (operator === 'min') {
  5320. return real >= expect;
  5321. }
  5322. else if (operator === 'max') {
  5323. return real <= expect;
  5324. }
  5325. else { // Equals
  5326. return real === expect;
  5327. }
  5328. }
  5329. function indicesEquals(indices1, indices2) {
  5330. // indices is always order by asc and has only finite number.
  5331. return indices1.join(',') === indices2.join(',');
  5332. }
  5333. /**
  5334. * Consider case:
  5335. * `chart.setOption(opt1);`
  5336. * Then user do some interaction like dataZoom, dataView changing.
  5337. * `chart.setOption(opt2);`
  5338. * Then user press 'reset button' in toolbox.
  5339. *
  5340. * After doing that all of the interaction effects should be reset, the
  5341. * chart should be the same as the result of invoke
  5342. * `chart.setOption(opt1); chart.setOption(opt2);`.
  5343. *
  5344. * Although it is not able ensure that
  5345. * `chart.setOption(opt1); chart.setOption(opt2);` is equivalents to
  5346. * `chart.setOption(merge(opt1, opt2));` exactly,
  5347. * this might be the only simple way to implement that feature.
  5348. *
  5349. * MEMO: We've considered some other approaches:
  5350. * 1. Each model handle its self restoration but not uniform treatment.
  5351. * (Too complex in logic and error-prone)
  5352. * 2. Use a shadow ecModel. (Performace expensive)
  5353. */
  5354. function mergeOption(oldOption, newOption) {
  5355. newOption = newOption || {};
  5356. each(newOption, function (newCptOpt, mainType) {
  5357. if (newCptOpt == null) {
  5358. return;
  5359. }
  5360. var oldCptOpt = oldOption[mainType];
  5361. if (!ComponentModel.hasClass(mainType)) {
  5362. oldOption[mainType] = merge(oldCptOpt, newCptOpt, true);
  5363. }
  5364. else {
  5365. newCptOpt = modelUtil.normalizeToArray(newCptOpt);
  5366. oldCptOpt = modelUtil.normalizeToArray(oldCptOpt);
  5367. var mapResult = modelUtil.mappingToExists(oldCptOpt, newCptOpt);
  5368. oldOption[mainType] = map(mapResult, function (item) {
  5369. return (item.option && item.exist)
  5370. ? merge(item.exist, item.option, true)
  5371. : (item.exist || item.option);
  5372. });
  5373. }
  5374. });
  5375. }
  5376. module.exports = OptionManager;
  5377. /***/ },
  5378. /* 27 */
  5379. /***/ function(module, exports, __webpack_require__) {
  5380. 'use strict';
  5381. var zrUtil = __webpack_require__(3);
  5382. var formatUtil = __webpack_require__(6);
  5383. var modelUtil = __webpack_require__(5);
  5384. var ComponentModel = __webpack_require__(19);
  5385. var encodeHTML = formatUtil.encodeHTML;
  5386. var addCommas = formatUtil.addCommas;
  5387. var SeriesModel = ComponentModel.extend({
  5388. type: 'series.__base__',
  5389. /**
  5390. * @readOnly
  5391. */
  5392. seriesIndex: 0,
  5393. // coodinateSystem will be injected in the echarts/CoordinateSystem
  5394. coordinateSystem: null,
  5395. /**
  5396. * @type {Object}
  5397. * @protected
  5398. */
  5399. defaultOption: null,
  5400. /**
  5401. * Data provided for legend
  5402. * @type {Function}
  5403. */
  5404. // PENDING
  5405. legendDataProvider: null,
  5406. init: function (option, parentModel, ecModel, extraOpt) {
  5407. /**
  5408. * @type {number}
  5409. * @readOnly
  5410. */
  5411. this.seriesIndex = this.componentIndex;
  5412. this.mergeDefaultAndTheme(option, ecModel);
  5413. /**
  5414. * @type {module:echarts/data/List|module:echarts/data/Tree|module:echarts/data/Graph}
  5415. * @private
  5416. */
  5417. this._dataBeforeProcessed = this.getInitialData(option, ecModel);
  5418. // If we reverse the order (make this._data firstly, and then make
  5419. // this._dataBeforeProcessed by cloneShallow), cloneShallow will
  5420. // cause this._data.graph.data !== this._data when using
  5421. // module:echarts/data/Graph or module:echarts/data/Tree.
  5422. // See module:echarts/data/helper/linkList
  5423. this._data = this._dataBeforeProcessed.cloneShallow();
  5424. },
  5425. /**
  5426. * Util for merge default and theme to option
  5427. * @param {Object} option
  5428. * @param {module:echarts/model/Global} ecModel
  5429. */
  5430. mergeDefaultAndTheme: function (option, ecModel) {
  5431. zrUtil.merge(
  5432. option,
  5433. ecModel.getTheme().get(this.subType)
  5434. );
  5435. zrUtil.merge(option, this.getDefaultOption());
  5436. // Default label emphasis `position` and `show`
  5437. // FIXME Set label in mergeOption
  5438. modelUtil.defaultEmphasis(option.label, modelUtil.LABEL_OPTIONS);
  5439. this.fillDataTextStyle(option.data);
  5440. },
  5441. mergeOption: function (newSeriesOption, ecModel) {
  5442. newSeriesOption = zrUtil.merge(this.option, newSeriesOption, true);
  5443. this.fillDataTextStyle(newSeriesOption.data);
  5444. var data = this.getInitialData(newSeriesOption, ecModel);
  5445. // TODO Merge data?
  5446. if (data) {
  5447. this._data = data;
  5448. this._dataBeforeProcessed = data.cloneShallow();
  5449. }
  5450. },
  5451. fillDataTextStyle: function (data) {
  5452. // Default data label emphasis `position` and `show`
  5453. // FIXME Tree structure data ?
  5454. // FIXME Performance ?
  5455. if (data) {
  5456. for (var i = 0; i < data.length; i++) {
  5457. if (data[i] && data[i].label) {
  5458. modelUtil.defaultEmphasis(data[i].label, modelUtil.LABEL_OPTIONS);
  5459. }
  5460. }
  5461. }
  5462. },
  5463. /**
  5464. * Init a data structure from data related option in series
  5465. * Must be overwritten
  5466. */
  5467. getInitialData: function () {},
  5468. /**
  5469. * @param {string} [dataType]
  5470. * @return {module:echarts/data/List}
  5471. */
  5472. getData: function (dataType) {
  5473. return dataType == null ? this._data : this._data.getLinkedData(dataType);
  5474. },
  5475. /**
  5476. * @param {module:echarts/data/List} data
  5477. */
  5478. setData: function (data) {
  5479. this._data = data;
  5480. },
  5481. /**
  5482. * Get data before processed
  5483. * @return {module:echarts/data/List}
  5484. */
  5485. getRawData: function () {
  5486. return this._dataBeforeProcessed;
  5487. },
  5488. /**
  5489. * Coord dimension to data dimension.
  5490. *
  5491. * By default the result is the same as dimensions of series data.
  5492. * But in some series data dimensions are different from coord dimensions (i.e.
  5493. * candlestick and boxplot). Override this method to handle those cases.
  5494. *
  5495. * Coord dimension to data dimension can be one-to-many
  5496. *
  5497. * @param {string} coordDim
  5498. * @return {Array.<string>} dimensions on the axis.
  5499. */
  5500. coordDimToDataDim: function (coordDim) {
  5501. return [coordDim];
  5502. },
  5503. /**
  5504. * Convert data dimension to coord dimension.
  5505. *
  5506. * @param {string|number} dataDim
  5507. * @return {string}
  5508. */
  5509. dataDimToCoordDim: function (dataDim) {
  5510. return dataDim;
  5511. },
  5512. /**
  5513. * Get base axis if has coordinate system and has axis.
  5514. * By default use coordSys.getBaseAxis();
  5515. * Can be overrided for some chart.
  5516. * @return {type} description
  5517. */
  5518. getBaseAxis: function () {
  5519. var coordSys = this.coordinateSystem;
  5520. return coordSys && coordSys.getBaseAxis && coordSys.getBaseAxis();
  5521. },
  5522. // FIXME
  5523. /**
  5524. * Default tooltip formatter
  5525. *
  5526. * @param {number} dataIndex
  5527. * @param {boolean} [multipleSeries=false]
  5528. * @param {number} [dataType]
  5529. */
  5530. formatTooltip: function (dataIndex, multipleSeries, dataType) {
  5531. var data = this._data;
  5532. var value = this.getRawValue(dataIndex);
  5533. var formattedValue = zrUtil.isArray(value)
  5534. ? zrUtil.map(value, addCommas).join(', ') : addCommas(value);
  5535. var name = data.getName(dataIndex);
  5536. var color = data.getItemVisual(dataIndex, 'color');
  5537. var colorEl = '<span style="display:inline-block;margin-right:5px;'
  5538. + 'border-radius:10px;width:9px;height:9px;background-color:' + color + '"></span>';
  5539. var seriesName = this.name;
  5540. // FIXME
  5541. if (seriesName === '\0-') {
  5542. // Not show '-'
  5543. seriesName = '';
  5544. }
  5545. return !multipleSeries
  5546. ? ((seriesName && encodeHTML(seriesName) + '<br />') + colorEl
  5547. + (name
  5548. ? encodeHTML(name) + ' : ' + formattedValue
  5549. : formattedValue)
  5550. )
  5551. : (colorEl + encodeHTML(this.name) + ' : ' + formattedValue);
  5552. },
  5553. restoreData: function () {
  5554. this._data = this._dataBeforeProcessed.cloneShallow();
  5555. },
  5556. getAxisTooltipDataIndex: null
  5557. });
  5558. zrUtil.mixin(SeriesModel, modelUtil.dataFormatMixin);
  5559. module.exports = SeriesModel;
  5560. /***/ },
  5561. /* 28 */
  5562. /***/ function(module, exports, __webpack_require__) {
  5563. var Group = __webpack_require__(29);
  5564. var componentUtil = __webpack_require__(20);
  5565. var clazzUtil = __webpack_require__(9);
  5566. var Component = function () {
  5567. /**
  5568. * @type {module:zrender/container/Group}
  5569. * @readOnly
  5570. */
  5571. this.group = new Group();
  5572. /**
  5573. * @type {string}
  5574. * @readOnly
  5575. */
  5576. this.uid = componentUtil.getUID('viewComponent');
  5577. };
  5578. Component.prototype = {
  5579. constructor: Component,
  5580. init: function (ecModel, api) {},
  5581. render: function (componentModel, ecModel, api, payload) {},
  5582. dispose: function () {}
  5583. };
  5584. var componentProto = Component.prototype;
  5585. componentProto.updateView
  5586. = componentProto.updateLayout
  5587. = componentProto.updateVisual
  5588. = function (seriesModel, ecModel, api, payload) {
  5589. // Do nothing;
  5590. };
  5591. // Enable Component.extend.
  5592. clazzUtil.enableClassExtend(Component);
  5593. // Enable capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on.
  5594. clazzUtil.enableClassManagement(Component, {registerWhenExtend: true});
  5595. module.exports = Component;
  5596. /***/ },
  5597. /* 29 */
  5598. /***/ function(module, exports, __webpack_require__) {
  5599. /**
  5600. * Group是一个容器,可以插入子节点,Group的变换也会被应用到子节点上
  5601. * @module zrender/graphic/Group
  5602. * @example
  5603. * var Group = require('zrender/lib/container/Group');
  5604. * var Circle = require('zrender/lib/graphic/shape/Circle');
  5605. * var g = new Group();
  5606. * g.position[0] = 100;
  5607. * g.position[1] = 100;
  5608. * g.add(new Circle({
  5609. * style: {
  5610. * x: 100,
  5611. * y: 100,
  5612. * r: 20,
  5613. * }
  5614. * }));
  5615. * zr.add(g);
  5616. */
  5617. var zrUtil = __webpack_require__(3);
  5618. var Element = __webpack_require__(30);
  5619. var BoundingRect = __webpack_require__(15);
  5620. /**
  5621. * @alias module:zrender/graphic/Group
  5622. * @constructor
  5623. * @extends module:zrender/mixin/Transformable
  5624. * @extends module:zrender/mixin/Eventful
  5625. */
  5626. var Group = function (opts) {
  5627. opts = opts || {};
  5628. Element.call(this, opts);
  5629. for (var key in opts) {
  5630. this[key] = opts[key];
  5631. }
  5632. this._children = [];
  5633. this.__storage = null;
  5634. this.__dirty = true;
  5635. };
  5636. Group.prototype = {
  5637. constructor: Group,
  5638. /**
  5639. * @type {string}
  5640. */
  5641. type: 'group',
  5642. /**
  5643. * 所有子孙元素是否响应鼠标事件
  5644. * @name module:/zrender/container/Group#silent
  5645. * @type {boolean}
  5646. * @default false
  5647. */
  5648. silent: false,
  5649. /**
  5650. * @return {Array.<module:zrender/Element>}
  5651. */
  5652. children: function () {
  5653. return this._children.slice();
  5654. },
  5655. /**
  5656. * 获取指定 index 的儿子节点
  5657. * @param {number} idx
  5658. * @return {module:zrender/Element}
  5659. */
  5660. childAt: function (idx) {
  5661. return this._children[idx];
  5662. },
  5663. /**
  5664. * 获取指定名字的儿子节点
  5665. * @param {string} name
  5666. * @return {module:zrender/Element}
  5667. */
  5668. childOfName: function (name) {
  5669. var children = this._children;
  5670. for (var i = 0; i < children.length; i++) {
  5671. if (children[i].name === name) {
  5672. return children[i];
  5673. }
  5674. }
  5675. },
  5676. /**
  5677. * @return {number}
  5678. */
  5679. childCount: function () {
  5680. return this._children.length;
  5681. },
  5682. /**
  5683. * 添加子节点到最后
  5684. * @param {module:zrender/Element} child
  5685. */
  5686. add: function (child) {
  5687. if (child && child !== this && child.parent !== this) {
  5688. this._children.push(child);
  5689. this._doAdd(child);
  5690. }
  5691. return this;
  5692. },
  5693. /**
  5694. * 添加子节点在 nextSibling 之前
  5695. * @param {module:zrender/Element} child
  5696. * @param {module:zrender/Element} nextSibling
  5697. */
  5698. addBefore: function (child, nextSibling) {
  5699. if (child && child !== this && child.parent !== this
  5700. && nextSibling && nextSibling.parent === this) {
  5701. var children = this._children;
  5702. var idx = children.indexOf(nextSibling);
  5703. if (idx >= 0) {
  5704. children.splice(idx, 0, child);
  5705. this._doAdd(child);
  5706. }
  5707. }
  5708. return this;
  5709. },
  5710. _doAdd: function (child) {
  5711. if (child.parent) {
  5712. child.parent.remove(child);
  5713. }
  5714. child.parent = this;
  5715. var storage = this.__storage;
  5716. var zr = this.__zr;
  5717. if (storage && storage !== child.__storage) {
  5718. storage.addToMap(child);
  5719. if (child instanceof Group) {
  5720. child.addChildrenToStorage(storage);
  5721. }
  5722. }
  5723. zr && zr.refresh();
  5724. },
  5725. /**
  5726. * 移除子节点
  5727. * @param {module:zrender/Element} child
  5728. */
  5729. remove: function (child) {
  5730. var zr = this.__zr;
  5731. var storage = this.__storage;
  5732. var children = this._children;
  5733. var idx = zrUtil.indexOf(children, child);
  5734. if (idx < 0) {
  5735. return this;
  5736. }
  5737. children.splice(idx, 1);
  5738. child.parent = null;
  5739. if (storage) {
  5740. storage.delFromMap(child.id);
  5741. if (child instanceof Group) {
  5742. child.delChildrenFromStorage(storage);
  5743. }
  5744. }
  5745. zr && zr.refresh();
  5746. return this;
  5747. },
  5748. /**
  5749. * 移除所有子节点
  5750. */
  5751. removeAll: function () {
  5752. var children = this._children;
  5753. var storage = this.__storage;
  5754. var child;
  5755. var i;
  5756. for (i = 0; i < children.length; i++) {
  5757. child = children[i];
  5758. if (storage) {
  5759. storage.delFromMap(child.id);
  5760. if (child instanceof Group) {
  5761. child.delChildrenFromStorage(storage);
  5762. }
  5763. }
  5764. child.parent = null;
  5765. }
  5766. children.length = 0;
  5767. return this;
  5768. },
  5769. /**
  5770. * 遍历所有子节点
  5771. * @param {Function} cb
  5772. * @param {} context
  5773. */
  5774. eachChild: function (cb, context) {
  5775. var children = this._children;
  5776. for (var i = 0; i < children.length; i++) {
  5777. var child = children[i];
  5778. cb.call(context, child, i);
  5779. }
  5780. return this;
  5781. },
  5782. /**
  5783. * 深度优先遍历所有子孙节点
  5784. * @param {Function} cb
  5785. * @param {} context
  5786. */
  5787. traverse: function (cb, context) {
  5788. for (var i = 0; i < this._children.length; i++) {
  5789. var child = this._children[i];
  5790. cb.call(context, child);
  5791. if (child.type === 'group') {
  5792. child.traverse(cb, context);
  5793. }
  5794. }
  5795. return this;
  5796. },
  5797. addChildrenToStorage: function (storage) {
  5798. for (var i = 0; i < this._children.length; i++) {
  5799. var child = this._children[i];
  5800. storage.addToMap(child);
  5801. if (child instanceof Group) {
  5802. child.addChildrenToStorage(storage);
  5803. }
  5804. }
  5805. },
  5806. delChildrenFromStorage: function (storage) {
  5807. for (var i = 0; i < this._children.length; i++) {
  5808. var child = this._children[i];
  5809. storage.delFromMap(child.id);
  5810. if (child instanceof Group) {
  5811. child.delChildrenFromStorage(storage);
  5812. }
  5813. }
  5814. },
  5815. dirty: function () {
  5816. this.__dirty = true;
  5817. this.__zr && this.__zr.refresh();
  5818. return this;
  5819. },
  5820. /**
  5821. * @return {module:zrender/core/BoundingRect}
  5822. */
  5823. getBoundingRect: function (includeChildren) {
  5824. // TODO Caching
  5825. // TODO Transform
  5826. var rect = null;
  5827. var tmpRect = new BoundingRect(0, 0, 0, 0);
  5828. var children = includeChildren || this._children;
  5829. var tmpMat = [];
  5830. for (var i = 0; i < children.length; i++) {
  5831. var child = children[i];
  5832. if (child.ignore || child.invisible) {
  5833. continue;
  5834. }
  5835. var childRect = child.getBoundingRect();
  5836. var transform = child.getLocalTransform(tmpMat);
  5837. if (transform) {
  5838. tmpRect.copy(childRect);
  5839. tmpRect.applyTransform(transform);
  5840. rect = rect || tmpRect.clone();
  5841. rect.union(tmpRect);
  5842. }
  5843. else {
  5844. rect = rect || childRect.clone();
  5845. rect.union(childRect);
  5846. }
  5847. }
  5848. return rect || tmpRect;
  5849. }
  5850. };
  5851. zrUtil.inherits(Group, Element);
  5852. module.exports = Group;
  5853. /***/ },
  5854. /* 30 */
  5855. /***/ function(module, exports, __webpack_require__) {
  5856. 'use strict';
  5857. /**
  5858. * @module zrender/Element
  5859. */
  5860. var guid = __webpack_require__(31);
  5861. var Eventful = __webpack_require__(32);
  5862. var Transformable = __webpack_require__(33);
  5863. var Animatable = __webpack_require__(34);
  5864. var zrUtil = __webpack_require__(3);
  5865. /**
  5866. * @alias module:zrender/Element
  5867. * @constructor
  5868. * @extends {module:zrender/mixin/Animatable}
  5869. * @extends {module:zrender/mixin/Transformable}
  5870. * @extends {module:zrender/mixin/Eventful}
  5871. */
  5872. var Element = function (opts) {
  5873. Transformable.call(this, opts);
  5874. Eventful.call(this, opts);
  5875. Animatable.call(this, opts);
  5876. /**
  5877. * 画布元素ID
  5878. * @type {string}
  5879. */
  5880. this.id = opts.id || guid();
  5881. };
  5882. Element.prototype = {
  5883. /**
  5884. * 元素类型
  5885. * Element type
  5886. * @type {string}
  5887. */
  5888. type: 'element',
  5889. /**
  5890. * 元素名字
  5891. * Element name
  5892. * @type {string}
  5893. */
  5894. name: '',
  5895. /**
  5896. * ZRender 实例对象,会在 element 添加到 zrender 实例中后自动赋值
  5897. * ZRender instance will be assigned when element is associated with zrender
  5898. * @name module:/zrender/Element#__zr
  5899. * @type {module:zrender/ZRender}
  5900. */
  5901. __zr: null,
  5902. /**
  5903. * 图形是否忽略,为true时忽略图形的绘制以及事件触发
  5904. * If ignore drawing and events of the element object
  5905. * @name module:/zrender/Element#ignore
  5906. * @type {boolean}
  5907. * @default false
  5908. */
  5909. ignore: false,
  5910. /**
  5911. * 用于裁剪的路径(shape),所有 Group 内的路径在绘制时都会被这个路径裁剪
  5912. * 该路径会继承被裁减对象的变换
  5913. * @type {module:zrender/graphic/Path}
  5914. * @see http://www.w3.org/TR/2dcontext/#clipping-region
  5915. * @readOnly
  5916. */
  5917. clipPath: null,
  5918. /**
  5919. * Drift element
  5920. * @param {number} dx dx on the global space
  5921. * @param {number} dy dy on the global space
  5922. */
  5923. drift: function (dx, dy) {
  5924. switch (this.draggable) {
  5925. case 'horizontal':
  5926. dy = 0;
  5927. break;
  5928. case 'vertical':
  5929. dx = 0;
  5930. break;
  5931. }
  5932. var m = this.transform;
  5933. if (!m) {
  5934. m = this.transform = [1, 0, 0, 1, 0, 0];
  5935. }
  5936. m[4] += dx;
  5937. m[5] += dy;
  5938. this.decomposeTransform();
  5939. this.dirty();
  5940. },
  5941. /**
  5942. * Hook before update
  5943. */
  5944. beforeUpdate: function () {},
  5945. /**
  5946. * Hook after update
  5947. */
  5948. afterUpdate: function () {},
  5949. /**
  5950. * Update each frame
  5951. */
  5952. update: function () {
  5953. this.updateTransform();
  5954. },
  5955. /**
  5956. * @param {Function} cb
  5957. * @param {} context
  5958. */
  5959. traverse: function (cb, context) {},
  5960. /**
  5961. * @protected
  5962. */
  5963. attrKV: function (key, value) {
  5964. if (key === 'position' || key === 'scale' || key === 'origin') {
  5965. // Copy the array
  5966. if (value) {
  5967. var target = this[key];
  5968. if (!target) {
  5969. target = this[key] = [];
  5970. }
  5971. target[0] = value[0];
  5972. target[1] = value[1];
  5973. }
  5974. }
  5975. else {
  5976. this[key] = value;
  5977. }
  5978. },
  5979. /**
  5980. * Hide the element
  5981. */
  5982. hide: function () {
  5983. this.ignore = true;
  5984. this.__zr && this.__zr.refresh();
  5985. },
  5986. /**
  5987. * Show the element
  5988. */
  5989. show: function () {
  5990. this.ignore = false;
  5991. this.__zr && this.__zr.refresh();
  5992. },
  5993. /**
  5994. * @param {string|Object} key
  5995. * @param {*} value
  5996. */
  5997. attr: function (key, value) {
  5998. if (typeof key === 'string') {
  5999. this.attrKV(key, value);
  6000. }
  6001. else if (zrUtil.isObject(key)) {
  6002. for (var name in key) {
  6003. if (key.hasOwnProperty(name)) {
  6004. this.attrKV(name, key[name]);
  6005. }
  6006. }
  6007. }
  6008. this.dirty();
  6009. return this;
  6010. },
  6011. /**
  6012. * @param {module:zrender/graphic/Path} clipPath
  6013. */
  6014. setClipPath: function (clipPath) {
  6015. var zr = this.__zr;
  6016. if (zr) {
  6017. clipPath.addSelfToZr(zr);
  6018. }
  6019. // Remove previous clip path
  6020. if (this.clipPath && this.clipPath !== clipPath) {
  6021. this.removeClipPath();
  6022. }
  6023. this.clipPath = clipPath;
  6024. clipPath.__zr = zr;
  6025. clipPath.__clipTarget = this;
  6026. this.dirty();
  6027. },
  6028. /**
  6029. */
  6030. removeClipPath: function () {
  6031. var clipPath = this.clipPath;
  6032. if (clipPath) {
  6033. if (clipPath.__zr) {
  6034. clipPath.removeSelfFromZr(clipPath.__zr);
  6035. }
  6036. clipPath.__zr = null;
  6037. clipPath.__clipTarget = null;
  6038. this.clipPath = null;
  6039. this.dirty();
  6040. }
  6041. },
  6042. /**
  6043. * Add self from zrender instance.
  6044. * Not recursively because it will be invoked when element added to storage.
  6045. * @param {module:zrender/ZRender} zr
  6046. */
  6047. addSelfToZr: function (zr) {
  6048. this.__zr = zr;
  6049. // 添加动画
  6050. var animators = this.animators;
  6051. if (animators) {
  6052. for (var i = 0; i < animators.length; i++) {
  6053. zr.animation.addAnimator(animators[i]);
  6054. }
  6055. }
  6056. if (this.clipPath) {
  6057. this.clipPath.addSelfToZr(zr);
  6058. }
  6059. },
  6060. /**
  6061. * Remove self from zrender instance.
  6062. * Not recursively because it will be invoked when element added to storage.
  6063. * @param {module:zrender/ZRender} zr
  6064. */
  6065. removeSelfFromZr: function (zr) {
  6066. this.__zr = null;
  6067. // 移除动画
  6068. var animators = this.animators;
  6069. if (animators) {
  6070. for (var i = 0; i < animators.length; i++) {
  6071. zr.animation.removeAnimator(animators[i]);
  6072. }
  6073. }
  6074. if (this.clipPath) {
  6075. this.clipPath.removeSelfFromZr(zr);
  6076. }
  6077. }
  6078. };
  6079. zrUtil.mixin(Element, Animatable);
  6080. zrUtil.mixin(Element, Transformable);
  6081. zrUtil.mixin(Element, Eventful);
  6082. module.exports = Element;
  6083. /***/ },
  6084. /* 31 */
  6085. /***/ function(module, exports) {
  6086. /**
  6087. * zrender: 生成唯一id
  6088. *
  6089. * @author errorrik (errorrik@gmail.com)
  6090. */
  6091. var idStart = 0x0907;
  6092. module.exports = function () {
  6093. return 'zr_' + (idStart++);
  6094. };
  6095. /***/ },
  6096. /* 32 */
  6097. /***/ function(module, exports, __webpack_require__) {
  6098. /**
  6099. * 事件扩展
  6100. * @module zrender/mixin/Eventful
  6101. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  6102. * pissang (https://www.github.com/pissang)
  6103. */
  6104. var arrySlice = Array.prototype.slice;
  6105. var zrUtil = __webpack_require__(3);
  6106. var indexOf = zrUtil.indexOf;
  6107. /**
  6108. * 事件分发器
  6109. * @alias module:zrender/mixin/Eventful
  6110. * @constructor
  6111. */
  6112. var Eventful = function () {
  6113. this._$handlers = {};
  6114. };
  6115. Eventful.prototype = {
  6116. constructor: Eventful,
  6117. /**
  6118. * 单次触发绑定,trigger后销毁
  6119. *
  6120. * @param {string} event 事件名
  6121. * @param {Function} handler 响应函数
  6122. * @param {Object} context
  6123. */
  6124. one: function (event, handler, context) {
  6125. var _h = this._$handlers;
  6126. if (!handler || !event) {
  6127. return this;
  6128. }
  6129. if (!_h[event]) {
  6130. _h[event] = [];
  6131. }
  6132. if (indexOf(_h[event], event) >= 0) {
  6133. return this;
  6134. }
  6135. _h[event].push({
  6136. h: handler,
  6137. one: true,
  6138. ctx: context || this
  6139. });
  6140. return this;
  6141. },
  6142. /**
  6143. * 绑定事件
  6144. * @param {string} event 事件名
  6145. * @param {Function} handler 事件处理函数
  6146. * @param {Object} [context]
  6147. */
  6148. on: function (event, handler, context) {
  6149. var _h = this._$handlers;
  6150. if (!handler || !event) {
  6151. return this;
  6152. }
  6153. if (!_h[event]) {
  6154. _h[event] = [];
  6155. }
  6156. _h[event].push({
  6157. h: handler,
  6158. one: false,
  6159. ctx: context || this
  6160. });
  6161. return this;
  6162. },
  6163. /**
  6164. * 是否绑定了事件
  6165. * @param {string} event
  6166. * @return {boolean}
  6167. */
  6168. isSilent: function (event) {
  6169. var _h = this._$handlers;
  6170. return _h[event] && _h[event].length;
  6171. },
  6172. /**
  6173. * 解绑事件
  6174. * @param {string} event 事件名
  6175. * @param {Function} [handler] 事件处理函数
  6176. */
  6177. off: function (event, handler) {
  6178. var _h = this._$handlers;
  6179. if (!event) {
  6180. this._$handlers = {};
  6181. return this;
  6182. }
  6183. if (handler) {
  6184. if (_h[event]) {
  6185. var newList = [];
  6186. for (var i = 0, l = _h[event].length; i < l; i++) {
  6187. if (_h[event][i]['h'] != handler) {
  6188. newList.push(_h[event][i]);
  6189. }
  6190. }
  6191. _h[event] = newList;
  6192. }
  6193. if (_h[event] && _h[event].length === 0) {
  6194. delete _h[event];
  6195. }
  6196. }
  6197. else {
  6198. delete _h[event];
  6199. }
  6200. return this;
  6201. },
  6202. /**
  6203. * 事件分发
  6204. *
  6205. * @param {string} type 事件类型
  6206. */
  6207. trigger: function (type) {
  6208. if (this._$handlers[type]) {
  6209. var args = arguments;
  6210. var argLen = args.length;
  6211. if (argLen > 3) {
  6212. args = arrySlice.call(args, 1);
  6213. }
  6214. var _h = this._$handlers[type];
  6215. var len = _h.length;
  6216. for (var i = 0; i < len;) {
  6217. // Optimize advise from backbone
  6218. switch (argLen) {
  6219. case 1:
  6220. _h[i]['h'].call(_h[i]['ctx']);
  6221. break;
  6222. case 2:
  6223. _h[i]['h'].call(_h[i]['ctx'], args[1]);
  6224. break;
  6225. case 3:
  6226. _h[i]['h'].call(_h[i]['ctx'], args[1], args[2]);
  6227. break;
  6228. default:
  6229. // have more than 2 given arguments
  6230. _h[i]['h'].apply(_h[i]['ctx'], args);
  6231. break;
  6232. }
  6233. if (_h[i]['one']) {
  6234. _h.splice(i, 1);
  6235. len--;
  6236. }
  6237. else {
  6238. i++;
  6239. }
  6240. }
  6241. }
  6242. return this;
  6243. },
  6244. /**
  6245. * 带有context的事件分发, 最后一个参数是事件回调的context
  6246. * @param {string} type 事件类型
  6247. */
  6248. triggerWithContext: function (type) {
  6249. if (this._$handlers[type]) {
  6250. var args = arguments;
  6251. var argLen = args.length;
  6252. if (argLen > 4) {
  6253. args = arrySlice.call(args, 1, args.length - 1);
  6254. }
  6255. var ctx = args[args.length - 1];
  6256. var _h = this._$handlers[type];
  6257. var len = _h.length;
  6258. for (var i = 0; i < len;) {
  6259. // Optimize advise from backbone
  6260. switch (argLen) {
  6261. case 1:
  6262. _h[i]['h'].call(ctx);
  6263. break;
  6264. case 2:
  6265. _h[i]['h'].call(ctx, args[1]);
  6266. break;
  6267. case 3:
  6268. _h[i]['h'].call(ctx, args[1], args[2]);
  6269. break;
  6270. default:
  6271. // have more than 2 given arguments
  6272. _h[i]['h'].apply(ctx, args);
  6273. break;
  6274. }
  6275. if (_h[i]['one']) {
  6276. _h.splice(i, 1);
  6277. len--;
  6278. }
  6279. else {
  6280. i++;
  6281. }
  6282. }
  6283. }
  6284. return this;
  6285. }
  6286. };
  6287. // 对象可以通过 onxxxx 绑定事件
  6288. /**
  6289. * @event module:zrender/mixin/Eventful#onclick
  6290. * @type {Function}
  6291. * @default null
  6292. */
  6293. /**
  6294. * @event module:zrender/mixin/Eventful#onmouseover
  6295. * @type {Function}
  6296. * @default null
  6297. */
  6298. /**
  6299. * @event module:zrender/mixin/Eventful#onmouseout
  6300. * @type {Function}
  6301. * @default null
  6302. */
  6303. /**
  6304. * @event module:zrender/mixin/Eventful#onmousemove
  6305. * @type {Function}
  6306. * @default null
  6307. */
  6308. /**
  6309. * @event module:zrender/mixin/Eventful#onmousewheel
  6310. * @type {Function}
  6311. * @default null
  6312. */
  6313. /**
  6314. * @event module:zrender/mixin/Eventful#onmousedown
  6315. * @type {Function}
  6316. * @default null
  6317. */
  6318. /**
  6319. * @event module:zrender/mixin/Eventful#onmouseup
  6320. * @type {Function}
  6321. * @default null
  6322. */
  6323. /**
  6324. * @event module:zrender/mixin/Eventful#ondragstart
  6325. * @type {Function}
  6326. * @default null
  6327. */
  6328. /**
  6329. * @event module:zrender/mixin/Eventful#ondragend
  6330. * @type {Function}
  6331. * @default null
  6332. */
  6333. /**
  6334. * @event module:zrender/mixin/Eventful#ondragenter
  6335. * @type {Function}
  6336. * @default null
  6337. */
  6338. /**
  6339. * @event module:zrender/mixin/Eventful#ondragleave
  6340. * @type {Function}
  6341. * @default null
  6342. */
  6343. /**
  6344. * @event module:zrender/mixin/Eventful#ondragover
  6345. * @type {Function}
  6346. * @default null
  6347. */
  6348. /**
  6349. * @event module:zrender/mixin/Eventful#ondrop
  6350. * @type {Function}
  6351. * @default null
  6352. */
  6353. module.exports = Eventful;
  6354. /***/ },
  6355. /* 33 */
  6356. /***/ function(module, exports, __webpack_require__) {
  6357. 'use strict';
  6358. /**
  6359. * 提供变换扩展
  6360. * @module zrender/mixin/Transformable
  6361. * @author pissang (https://www.github.com/pissang)
  6362. */
  6363. var matrix = __webpack_require__(17);
  6364. var vector = __webpack_require__(16);
  6365. var mIdentity = matrix.identity;
  6366. var EPSILON = 5e-5;
  6367. function isNotAroundZero(val) {
  6368. return val > EPSILON || val < -EPSILON;
  6369. }
  6370. /**
  6371. * @alias module:zrender/mixin/Transformable
  6372. * @constructor
  6373. */
  6374. var Transformable = function (opts) {
  6375. opts = opts || {};
  6376. // If there are no given position, rotation, scale
  6377. if (!opts.position) {
  6378. /**
  6379. * 平移
  6380. * @type {Array.<number>}
  6381. * @default [0, 0]
  6382. */
  6383. this.position = [0, 0];
  6384. }
  6385. if (opts.rotation == null) {
  6386. /**
  6387. * 旋转
  6388. * @type {Array.<number>}
  6389. * @default 0
  6390. */
  6391. this.rotation = 0;
  6392. }
  6393. if (!opts.scale) {
  6394. /**
  6395. * 缩放
  6396. * @type {Array.<number>}
  6397. * @default [1, 1]
  6398. */
  6399. this.scale = [1, 1];
  6400. }
  6401. /**
  6402. * 旋转和缩放的原点
  6403. * @type {Array.<number>}
  6404. * @default null
  6405. */
  6406. this.origin = this.origin || null;
  6407. };
  6408. var transformableProto = Transformable.prototype;
  6409. transformableProto.transform = null;
  6410. /**
  6411. * 判断是否需要有坐标变换
  6412. * 如果有坐标变换, 则从position, rotation, scale以及父节点的transform计算出自身的transform矩阵
  6413. */
  6414. transformableProto.needLocalTransform = function () {
  6415. return isNotAroundZero(this.rotation)
  6416. || isNotAroundZero(this.position[0])
  6417. || isNotAroundZero(this.position[1])
  6418. || isNotAroundZero(this.scale[0] - 1)
  6419. || isNotAroundZero(this.scale[1] - 1);
  6420. };
  6421. transformableProto.updateTransform = function () {
  6422. var parent = this.parent;
  6423. var parentHasTransform = parent && parent.transform;
  6424. var needLocalTransform = this.needLocalTransform();
  6425. var m = this.transform;
  6426. if (!(needLocalTransform || parentHasTransform)) {
  6427. m && mIdentity(m);
  6428. return;
  6429. }
  6430. m = m || matrix.create();
  6431. if (needLocalTransform) {
  6432. this.getLocalTransform(m);
  6433. }
  6434. else {
  6435. mIdentity(m);
  6436. }
  6437. // 应用父节点变换
  6438. if (parentHasTransform) {
  6439. if (needLocalTransform) {
  6440. matrix.mul(m, parent.transform, m);
  6441. }
  6442. else {
  6443. matrix.copy(m, parent.transform);
  6444. }
  6445. }
  6446. // 保存这个变换矩阵
  6447. this.transform = m;
  6448. this.invTransform = this.invTransform || matrix.create();
  6449. matrix.invert(this.invTransform, m);
  6450. };
  6451. transformableProto.getLocalTransform = function (m) {
  6452. m = m || [];
  6453. mIdentity(m);
  6454. var origin = this.origin;
  6455. var scale = this.scale;
  6456. var rotation = this.rotation;
  6457. var position = this.position;
  6458. if (origin) {
  6459. // Translate to origin
  6460. m[4] -= origin[0];
  6461. m[5] -= origin[1];
  6462. }
  6463. matrix.scale(m, m, scale);
  6464. if (rotation) {
  6465. matrix.rotate(m, m, rotation);
  6466. }
  6467. if (origin) {
  6468. // Translate back from origin
  6469. m[4] += origin[0];
  6470. m[5] += origin[1];
  6471. }
  6472. m[4] += position[0];
  6473. m[5] += position[1];
  6474. return m;
  6475. };
  6476. /**
  6477. * 将自己的transform应用到context上
  6478. * @param {Context2D} ctx
  6479. */
  6480. transformableProto.setTransform = function (ctx) {
  6481. var m = this.transform;
  6482. if (m) {
  6483. ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
  6484. }
  6485. };
  6486. var tmpTransform = [];
  6487. /**
  6488. * 分解`transform`矩阵到`position`, `rotation`, `scale`
  6489. */
  6490. transformableProto.decomposeTransform = function () {
  6491. if (!this.transform) {
  6492. return;
  6493. }
  6494. var parent = this.parent;
  6495. var m = this.transform;
  6496. if (parent && parent.transform) {
  6497. // Get local transform and decompose them to position, scale, rotation
  6498. matrix.mul(tmpTransform, parent.invTransform, m);
  6499. m = tmpTransform;
  6500. }
  6501. var sx = m[0] * m[0] + m[1] * m[1];
  6502. var sy = m[2] * m[2] + m[3] * m[3];
  6503. var position = this.position;
  6504. var scale = this.scale;
  6505. if (isNotAroundZero(sx - 1)) {
  6506. sx = Math.sqrt(sx);
  6507. }
  6508. if (isNotAroundZero(sy - 1)) {
  6509. sy = Math.sqrt(sy);
  6510. }
  6511. if (m[0] < 0) {
  6512. sx = -sx;
  6513. }
  6514. if (m[3] < 0) {
  6515. sy = -sy;
  6516. }
  6517. position[0] = m[4];
  6518. position[1] = m[5];
  6519. scale[0] = sx;
  6520. scale[1] = sy;
  6521. this.rotation = Math.atan2(-m[1] / sy, m[0] / sx);
  6522. };
  6523. /**
  6524. * Get global scale
  6525. * @return {Array.<number>}
  6526. */
  6527. transformableProto.getGlobalScale = function () {
  6528. var m = this.transform;
  6529. if (!m) {
  6530. return [1, 1];
  6531. }
  6532. var sx = Math.sqrt(m[0] * m[0] + m[1] * m[1]);
  6533. var sy = Math.sqrt(m[2] * m[2] + m[3] * m[3]);
  6534. if (m[0] < 0) {
  6535. sx = -sx;
  6536. }
  6537. if (m[3] < 0) {
  6538. sy = -sy;
  6539. }
  6540. return [sx, sy];
  6541. };
  6542. /**
  6543. * 变换坐标位置到 shape 的局部坐标空间
  6544. * @method
  6545. * @param {number} x
  6546. * @param {number} y
  6547. * @return {Array.<number>}
  6548. */
  6549. transformableProto.transformCoordToLocal = function (x, y) {
  6550. var v2 = [x, y];
  6551. var invTransform = this.invTransform;
  6552. if (invTransform) {
  6553. vector.applyTransform(v2, v2, invTransform);
  6554. }
  6555. return v2;
  6556. };
  6557. /**
  6558. * 变换局部坐标位置到全局坐标空间
  6559. * @method
  6560. * @param {number} x
  6561. * @param {number} y
  6562. * @return {Array.<number>}
  6563. */
  6564. transformableProto.transformCoordToGlobal = function (x, y) {
  6565. var v2 = [x, y];
  6566. var transform = this.transform;
  6567. if (transform) {
  6568. vector.applyTransform(v2, v2, transform);
  6569. }
  6570. return v2;
  6571. };
  6572. module.exports = Transformable;
  6573. /***/ },
  6574. /* 34 */
  6575. /***/ function(module, exports, __webpack_require__) {
  6576. 'use strict';
  6577. /**
  6578. * @module zrender/mixin/Animatable
  6579. */
  6580. var Animator = __webpack_require__(35);
  6581. var util = __webpack_require__(3);
  6582. var isString = util.isString;
  6583. var isFunction = util.isFunction;
  6584. var isObject = util.isObject;
  6585. var log = __webpack_require__(39);
  6586. /**
  6587. * @alias modue:zrender/mixin/Animatable
  6588. * @constructor
  6589. */
  6590. var Animatable = function () {
  6591. /**
  6592. * @type {Array.<module:zrender/animation/Animator>}
  6593. * @readOnly
  6594. */
  6595. this.animators = [];
  6596. };
  6597. Animatable.prototype = {
  6598. constructor: Animatable,
  6599. /**
  6600. * 动画
  6601. *
  6602. * @param {string} path 需要添加动画的属性获取路径,可以通过a.b.c来获取深层的属性
  6603. * @param {boolean} [loop] 动画是否循环
  6604. * @return {module:zrender/animation/Animator}
  6605. * @example:
  6606. * el.animate('style', false)
  6607. * .when(1000, {x: 10} )
  6608. * .done(function(){ // Animation done })
  6609. * .start()
  6610. */
  6611. animate: function (path, loop) {
  6612. var target;
  6613. var animatingShape = false;
  6614. var el = this;
  6615. var zr = this.__zr;
  6616. if (path) {
  6617. var pathSplitted = path.split('.');
  6618. var prop = el;
  6619. // If animating shape
  6620. animatingShape = pathSplitted[0] === 'shape';
  6621. for (var i = 0, l = pathSplitted.length; i < l; i++) {
  6622. if (!prop) {
  6623. continue;
  6624. }
  6625. prop = prop[pathSplitted[i]];
  6626. }
  6627. if (prop) {
  6628. target = prop;
  6629. }
  6630. }
  6631. else {
  6632. target = el;
  6633. }
  6634. if (!target) {
  6635. log(
  6636. 'Property "'
  6637. + path
  6638. + '" is not existed in element '
  6639. + el.id
  6640. );
  6641. return;
  6642. }
  6643. var animators = el.animators;
  6644. var animator = new Animator(target, loop);
  6645. animator.during(function (target) {
  6646. el.dirty(animatingShape);
  6647. })
  6648. .done(function () {
  6649. // FIXME Animator will not be removed if use `Animator#stop` to stop animation
  6650. animators.splice(util.indexOf(animators, animator), 1);
  6651. });
  6652. animators.push(animator);
  6653. // If animate after added to the zrender
  6654. if (zr) {
  6655. zr.animation.addAnimator(animator);
  6656. }
  6657. return animator;
  6658. },
  6659. /**
  6660. * 停止动画
  6661. * @param {boolean} forwardToLast If move to last frame before stop
  6662. */
  6663. stopAnimation: function (forwardToLast) {
  6664. var animators = this.animators;
  6665. var len = animators.length;
  6666. for (var i = 0; i < len; i++) {
  6667. animators[i].stop(forwardToLast);
  6668. }
  6669. animators.length = 0;
  6670. return this;
  6671. },
  6672. /**
  6673. * @param {Object} target
  6674. * @param {number} [time=500] Time in ms
  6675. * @param {string} [easing='linear']
  6676. * @param {number} [delay=0]
  6677. * @param {Function} [callback]
  6678. *
  6679. * @example
  6680. * // Animate position
  6681. * el.animateTo({
  6682. * position: [10, 10]
  6683. * }, function () { // done })
  6684. *
  6685. * // Animate shape, style and position in 100ms, delayed 100ms, with cubicOut easing
  6686. * el.animateTo({
  6687. * shape: {
  6688. * width: 500
  6689. * },
  6690. * style: {
  6691. * fill: 'red'
  6692. * }
  6693. * position: [10, 10]
  6694. * }, 100, 100, 'cubicOut', function () { // done })
  6695. */
  6696. // TODO Return animation key
  6697. animateTo: function (target, time, delay, easing, callback) {
  6698. // animateTo(target, time, easing, callback);
  6699. if (isString(delay)) {
  6700. callback = easing;
  6701. easing = delay;
  6702. delay = 0;
  6703. }
  6704. // animateTo(target, time, delay, callback);
  6705. else if (isFunction(easing)) {
  6706. callback = easing;
  6707. easing = 'linear';
  6708. delay = 0;
  6709. }
  6710. // animateTo(target, time, callback);
  6711. else if (isFunction(delay)) {
  6712. callback = delay;
  6713. delay = 0;
  6714. }
  6715. // animateTo(target, callback)
  6716. else if (isFunction(time)) {
  6717. callback = time;
  6718. time = 500;
  6719. }
  6720. // animateTo(target)
  6721. else if (!time) {
  6722. time = 500;
  6723. }
  6724. // Stop all previous animations
  6725. this.stopAnimation();
  6726. this._animateToShallow('', this, target, time, delay, easing, callback);
  6727. // Animators may be removed immediately after start
  6728. // if there is nothing to animate
  6729. var animators = this.animators.slice();
  6730. var count = animators.length;
  6731. function done() {
  6732. count--;
  6733. if (!count) {
  6734. callback && callback();
  6735. }
  6736. }
  6737. // No animators. This should be checked before animators[i].start(),
  6738. // because 'done' may be executed immediately if no need to animate.
  6739. if (!count) {
  6740. callback && callback();
  6741. }
  6742. // Start after all animators created
  6743. // Incase any animator is done immediately when all animation properties are not changed
  6744. for (var i = 0; i < animators.length; i++) {
  6745. animators[i]
  6746. .done(done)
  6747. .start(easing);
  6748. }
  6749. },
  6750. /**
  6751. * @private
  6752. * @param {string} path=''
  6753. * @param {Object} source=this
  6754. * @param {Object} target
  6755. * @param {number} [time=500]
  6756. * @param {number} [delay=0]
  6757. *
  6758. * @example
  6759. * // Animate position
  6760. * el._animateToShallow({
  6761. * position: [10, 10]
  6762. * })
  6763. *
  6764. * // Animate shape, style and position in 100ms, delayed 100ms
  6765. * el._animateToShallow({
  6766. * shape: {
  6767. * width: 500
  6768. * },
  6769. * style: {
  6770. * fill: 'red'
  6771. * }
  6772. * position: [10, 10]
  6773. * }, 100, 100)
  6774. */
  6775. _animateToShallow: function (path, source, target, time, delay) {
  6776. var objShallow = {};
  6777. var propertyCount = 0;
  6778. for (var name in target) {
  6779. if (source[name] != null) {
  6780. if (isObject(target[name]) && !util.isArrayLike(target[name])) {
  6781. this._animateToShallow(
  6782. path ? path + '.' + name : name,
  6783. source[name],
  6784. target[name],
  6785. time,
  6786. delay
  6787. );
  6788. }
  6789. else {
  6790. objShallow[name] = target[name];
  6791. propertyCount++;
  6792. }
  6793. }
  6794. else if (target[name] != null) {
  6795. // Attr directly if not has property
  6796. // FIXME, if some property not needed for element ?
  6797. if (!path) {
  6798. this.attr(name, target[name]);
  6799. }
  6800. else { // Shape or style
  6801. var props = {};
  6802. props[path] = {};
  6803. props[path][name] = target[name];
  6804. this.attr(props);
  6805. }
  6806. }
  6807. }
  6808. if (propertyCount > 0) {
  6809. this.animate(path, false)
  6810. .when(time == null ? 500 : time, objShallow)
  6811. .delay(delay || 0);
  6812. }
  6813. return this;
  6814. }
  6815. };
  6816. module.exports = Animatable;
  6817. /***/ },
  6818. /* 35 */
  6819. /***/ function(module, exports, __webpack_require__) {
  6820. /**
  6821. * @module echarts/animation/Animator
  6822. */
  6823. var Clip = __webpack_require__(36);
  6824. var color = __webpack_require__(38);
  6825. var util = __webpack_require__(3);
  6826. var isArrayLike = util.isArrayLike;
  6827. var arraySlice = Array.prototype.slice;
  6828. function defaultGetter(target, key) {
  6829. return target[key];
  6830. }
  6831. function defaultSetter(target, key, value) {
  6832. target[key] = value;
  6833. }
  6834. /**
  6835. * @param {number} p0
  6836. * @param {number} p1
  6837. * @param {number} percent
  6838. * @return {number}
  6839. */
  6840. function interpolateNumber(p0, p1, percent) {
  6841. return (p1 - p0) * percent + p0;
  6842. }
  6843. /**
  6844. * @param {string} p0
  6845. * @param {string} p1
  6846. * @param {number} percent
  6847. * @return {string}
  6848. */
  6849. function interpolateString(p0, p1, percent) {
  6850. return percent > 0.5 ? p1 : p0;
  6851. }
  6852. /**
  6853. * @param {Array} p0
  6854. * @param {Array} p1
  6855. * @param {number} percent
  6856. * @param {Array} out
  6857. * @param {number} arrDim
  6858. */
  6859. function interpolateArray(p0, p1, percent, out, arrDim) {
  6860. var len = p0.length;
  6861. if (arrDim == 1) {
  6862. for (var i = 0; i < len; i++) {
  6863. out[i] = interpolateNumber(p0[i], p1[i], percent);
  6864. }
  6865. }
  6866. else {
  6867. var len2 = p0[0].length;
  6868. for (var i = 0; i < len; i++) {
  6869. for (var j = 0; j < len2; j++) {
  6870. out[i][j] = interpolateNumber(
  6871. p0[i][j], p1[i][j], percent
  6872. );
  6873. }
  6874. }
  6875. }
  6876. }
  6877. // arr0 is source array, arr1 is target array.
  6878. // Do some preprocess to avoid error happened when interpolating from arr0 to arr1
  6879. function fillArr(arr0, arr1, arrDim) {
  6880. var arr0Len = arr0.length;
  6881. var arr1Len = arr1.length;
  6882. if (arr0Len !== arr1Len) {
  6883. // FIXME Not work for TypedArray
  6884. var isPreviousLarger = arr0Len > arr1Len;
  6885. if (isPreviousLarger) {
  6886. // Cut the previous
  6887. arr0.length = arr1Len;
  6888. }
  6889. else {
  6890. // Fill the previous
  6891. for (var i = arr0Len; i < arr1Len; i++) {
  6892. arr0.push(
  6893. arrDim === 1 ? arr1[i] : arraySlice.call(arr1[i])
  6894. );
  6895. }
  6896. }
  6897. }
  6898. // Handling NaN value
  6899. var len2 = arr0[0] && arr0[0].length;
  6900. for (var i = 0; i < arr0.length; i++) {
  6901. if (arrDim === 1) {
  6902. if (isNaN(arr0[i])) {
  6903. arr0[i] = arr1[i];
  6904. }
  6905. }
  6906. else {
  6907. for (var j = 0; j < len2; j++) {
  6908. if (isNaN(arr0[i][j])) {
  6909. arr0[i][j] = arr1[i][j];
  6910. }
  6911. }
  6912. }
  6913. }
  6914. }
  6915. /**
  6916. * @param {Array} arr0
  6917. * @param {Array} arr1
  6918. * @param {number} arrDim
  6919. * @return {boolean}
  6920. */
  6921. function isArraySame(arr0, arr1, arrDim) {
  6922. if (arr0 === arr1) {
  6923. return true;
  6924. }
  6925. var len = arr0.length;
  6926. if (len !== arr1.length) {
  6927. return false;
  6928. }
  6929. if (arrDim === 1) {
  6930. for (var i = 0; i < len; i++) {
  6931. if (arr0[i] !== arr1[i]) {
  6932. return false;
  6933. }
  6934. }
  6935. }
  6936. else {
  6937. var len2 = arr0[0].length;
  6938. for (var i = 0; i < len; i++) {
  6939. for (var j = 0; j < len2; j++) {
  6940. if (arr0[i][j] !== arr1[i][j]) {
  6941. return false;
  6942. }
  6943. }
  6944. }
  6945. }
  6946. return true;
  6947. }
  6948. /**
  6949. * Catmull Rom interpolate array
  6950. * @param {Array} p0
  6951. * @param {Array} p1
  6952. * @param {Array} p2
  6953. * @param {Array} p3
  6954. * @param {number} t
  6955. * @param {number} t2
  6956. * @param {number} t3
  6957. * @param {Array} out
  6958. * @param {number} arrDim
  6959. */
  6960. function catmullRomInterpolateArray(
  6961. p0, p1, p2, p3, t, t2, t3, out, arrDim
  6962. ) {
  6963. var len = p0.length;
  6964. if (arrDim == 1) {
  6965. for (var i = 0; i < len; i++) {
  6966. out[i] = catmullRomInterpolate(
  6967. p0[i], p1[i], p2[i], p3[i], t, t2, t3
  6968. );
  6969. }
  6970. }
  6971. else {
  6972. var len2 = p0[0].length;
  6973. for (var i = 0; i < len; i++) {
  6974. for (var j = 0; j < len2; j++) {
  6975. out[i][j] = catmullRomInterpolate(
  6976. p0[i][j], p1[i][j], p2[i][j], p3[i][j],
  6977. t, t2, t3
  6978. );
  6979. }
  6980. }
  6981. }
  6982. }
  6983. /**
  6984. * Catmull Rom interpolate number
  6985. * @param {number} p0
  6986. * @param {number} p1
  6987. * @param {number} p2
  6988. * @param {number} p3
  6989. * @param {number} t
  6990. * @param {number} t2
  6991. * @param {number} t3
  6992. * @return {number}
  6993. */
  6994. function catmullRomInterpolate(p0, p1, p2, p3, t, t2, t3) {
  6995. var v0 = (p2 - p0) * 0.5;
  6996. var v1 = (p3 - p1) * 0.5;
  6997. return (2 * (p1 - p2) + v0 + v1) * t3
  6998. + (-3 * (p1 - p2) - 2 * v0 - v1) * t2
  6999. + v0 * t + p1;
  7000. }
  7001. function cloneValue(value) {
  7002. if (isArrayLike(value)) {
  7003. var len = value.length;
  7004. if (isArrayLike(value[0])) {
  7005. var ret = [];
  7006. for (var i = 0; i < len; i++) {
  7007. ret.push(arraySlice.call(value[i]));
  7008. }
  7009. return ret;
  7010. }
  7011. return arraySlice.call(value);
  7012. }
  7013. return value;
  7014. }
  7015. function rgba2String(rgba) {
  7016. rgba[0] = Math.floor(rgba[0]);
  7017. rgba[1] = Math.floor(rgba[1]);
  7018. rgba[2] = Math.floor(rgba[2]);
  7019. return 'rgba(' + rgba.join(',') + ')';
  7020. }
  7021. function createTrackClip (animator, easing, oneTrackDone, keyframes, propName) {
  7022. var getter = animator._getter;
  7023. var setter = animator._setter;
  7024. var useSpline = easing === 'spline';
  7025. var trackLen = keyframes.length;
  7026. if (!trackLen) {
  7027. return;
  7028. }
  7029. // Guess data type
  7030. var firstVal = keyframes[0].value;
  7031. var isValueArray = isArrayLike(firstVal);
  7032. var isValueColor = false;
  7033. var isValueString = false;
  7034. // For vertices morphing
  7035. var arrDim = (
  7036. isValueArray
  7037. && isArrayLike(firstVal[0])
  7038. )
  7039. ? 2 : 1;
  7040. var trackMaxTime;
  7041. // Sort keyframe as ascending
  7042. keyframes.sort(function(a, b) {
  7043. return a.time - b.time;
  7044. });
  7045. trackMaxTime = keyframes[trackLen - 1].time;
  7046. // Percents of each keyframe
  7047. var kfPercents = [];
  7048. // Value of each keyframe
  7049. var kfValues = [];
  7050. var prevValue = keyframes[0].value;
  7051. var isAllValueEqual = true;
  7052. for (var i = 0; i < trackLen; i++) {
  7053. kfPercents.push(keyframes[i].time / trackMaxTime);
  7054. // Assume value is a color when it is a string
  7055. var value = keyframes[i].value;
  7056. // Check if value is equal, deep check if value is array
  7057. if (!((isValueArray && isArraySame(value, prevValue, arrDim))
  7058. || (!isValueArray && value === prevValue))) {
  7059. isAllValueEqual = false;
  7060. }
  7061. prevValue = value;
  7062. // Try converting a string to a color array
  7063. if (typeof value == 'string') {
  7064. var colorArray = color.parse(value);
  7065. if (colorArray) {
  7066. value = colorArray;
  7067. isValueColor = true;
  7068. }
  7069. else {
  7070. isValueString = true;
  7071. }
  7072. }
  7073. kfValues.push(value);
  7074. }
  7075. if (isAllValueEqual) {
  7076. return;
  7077. }
  7078. var lastValue = kfValues[trackLen - 1];
  7079. // Polyfill array and NaN value
  7080. for (var i = 0; i < trackLen - 1; i++) {
  7081. if (isValueArray) {
  7082. fillArr(kfValues[i], lastValue, arrDim);
  7083. }
  7084. else {
  7085. if (isNaN(kfValues[i]) && !isNaN(lastValue) && !isValueString && !isValueColor) {
  7086. kfValues[i] = lastValue;
  7087. }
  7088. }
  7089. }
  7090. isValueArray && fillArr(getter(animator._target, propName), lastValue, arrDim);
  7091. // Cache the key of last frame to speed up when
  7092. // animation playback is sequency
  7093. var lastFrame = 0;
  7094. var lastFramePercent = 0;
  7095. var start;
  7096. var w;
  7097. var p0;
  7098. var p1;
  7099. var p2;
  7100. var p3;
  7101. if (isValueColor) {
  7102. var rgba = [0, 0, 0, 0];
  7103. }
  7104. var onframe = function (target, percent) {
  7105. // Find the range keyframes
  7106. // kf1-----kf2---------current--------kf3
  7107. // find kf2 and kf3 and do interpolation
  7108. var frame;
  7109. if (percent < lastFramePercent) {
  7110. // Start from next key
  7111. start = Math.min(lastFrame + 1, trackLen - 1);
  7112. for (frame = start; frame >= 0; frame--) {
  7113. if (kfPercents[frame] <= percent) {
  7114. break;
  7115. }
  7116. }
  7117. frame = Math.min(frame, trackLen - 2);
  7118. }
  7119. else {
  7120. for (frame = lastFrame; frame < trackLen; frame++) {
  7121. if (kfPercents[frame] > percent) {
  7122. break;
  7123. }
  7124. }
  7125. frame = Math.min(frame - 1, trackLen - 2);
  7126. }
  7127. lastFrame = frame;
  7128. lastFramePercent = percent;
  7129. var range = (kfPercents[frame + 1] - kfPercents[frame]);
  7130. if (range === 0) {
  7131. return;
  7132. }
  7133. else {
  7134. w = (percent - kfPercents[frame]) / range;
  7135. }
  7136. if (useSpline) {
  7137. p1 = kfValues[frame];
  7138. p0 = kfValues[frame === 0 ? frame : frame - 1];
  7139. p2 = kfValues[frame > trackLen - 2 ? trackLen - 1 : frame + 1];
  7140. p3 = kfValues[frame > trackLen - 3 ? trackLen - 1 : frame + 2];
  7141. if (isValueArray) {
  7142. catmullRomInterpolateArray(
  7143. p0, p1, p2, p3, w, w * w, w * w * w,
  7144. getter(target, propName),
  7145. arrDim
  7146. );
  7147. }
  7148. else {
  7149. var value;
  7150. if (isValueColor) {
  7151. value = catmullRomInterpolateArray(
  7152. p0, p1, p2, p3, w, w * w, w * w * w,
  7153. rgba, 1
  7154. );
  7155. value = rgba2String(rgba);
  7156. }
  7157. else if (isValueString) {
  7158. // String is step(0.5)
  7159. return interpolateString(p1, p2, w);
  7160. }
  7161. else {
  7162. value = catmullRomInterpolate(
  7163. p0, p1, p2, p3, w, w * w, w * w * w
  7164. );
  7165. }
  7166. setter(
  7167. target,
  7168. propName,
  7169. value
  7170. );
  7171. }
  7172. }
  7173. else {
  7174. if (isValueArray) {
  7175. interpolateArray(
  7176. kfValues[frame], kfValues[frame + 1], w,
  7177. getter(target, propName),
  7178. arrDim
  7179. );
  7180. }
  7181. else {
  7182. var value;
  7183. if (isValueColor) {
  7184. interpolateArray(
  7185. kfValues[frame], kfValues[frame + 1], w,
  7186. rgba, 1
  7187. );
  7188. value = rgba2String(rgba);
  7189. }
  7190. else if (isValueString) {
  7191. // String is step(0.5)
  7192. return interpolateString(kfValues[frame], kfValues[frame + 1], w);
  7193. }
  7194. else {
  7195. value = interpolateNumber(kfValues[frame], kfValues[frame + 1], w);
  7196. }
  7197. setter(
  7198. target,
  7199. propName,
  7200. value
  7201. );
  7202. }
  7203. }
  7204. };
  7205. var clip = new Clip({
  7206. target: animator._target,
  7207. life: trackMaxTime,
  7208. loop: animator._loop,
  7209. delay: animator._delay,
  7210. onframe: onframe,
  7211. ondestroy: oneTrackDone
  7212. });
  7213. if (easing && easing !== 'spline') {
  7214. clip.easing = easing;
  7215. }
  7216. return clip;
  7217. }
  7218. /**
  7219. * @alias module:zrender/animation/Animator
  7220. * @constructor
  7221. * @param {Object} target
  7222. * @param {boolean} loop
  7223. * @param {Function} getter
  7224. * @param {Function} setter
  7225. */
  7226. var Animator = function(target, loop, getter, setter) {
  7227. this._tracks = {};
  7228. this._target = target;
  7229. this._loop = loop || false;
  7230. this._getter = getter || defaultGetter;
  7231. this._setter = setter || defaultSetter;
  7232. this._clipCount = 0;
  7233. this._delay = 0;
  7234. this._doneList = [];
  7235. this._onframeList = [];
  7236. this._clipList = [];
  7237. };
  7238. Animator.prototype = {
  7239. /**
  7240. * 设置动画关键帧
  7241. * @param {number} time 关键帧时间,单位是ms
  7242. * @param {Object} props 关键帧的属性值,key-value表示
  7243. * @return {module:zrender/animation/Animator}
  7244. */
  7245. when: function(time /* ms */, props) {
  7246. var tracks = this._tracks;
  7247. for (var propName in props) {
  7248. if (!tracks[propName]) {
  7249. tracks[propName] = [];
  7250. // Invalid value
  7251. var value = this._getter(this._target, propName);
  7252. if (value == null) {
  7253. // zrLog('Invalid property ' + propName);
  7254. continue;
  7255. }
  7256. // If time is 0
  7257. // Then props is given initialize value
  7258. // Else
  7259. // Initialize value from current prop value
  7260. if (time !== 0) {
  7261. tracks[propName].push({
  7262. time: 0,
  7263. value: cloneValue(value)
  7264. });
  7265. }
  7266. }
  7267. tracks[propName].push({
  7268. time: time,
  7269. value: props[propName]
  7270. });
  7271. }
  7272. return this;
  7273. },
  7274. /**
  7275. * 添加动画每一帧的回调函数
  7276. * @param {Function} callback
  7277. * @return {module:zrender/animation/Animator}
  7278. */
  7279. during: function (callback) {
  7280. this._onframeList.push(callback);
  7281. return this;
  7282. },
  7283. _doneCallback: function () {
  7284. // Clear all tracks
  7285. this._tracks = {};
  7286. // Clear all clips
  7287. this._clipList.length = 0;
  7288. var doneList = this._doneList;
  7289. var len = doneList.length;
  7290. for (var i = 0; i < len; i++) {
  7291. doneList[i].call(this);
  7292. }
  7293. },
  7294. /**
  7295. * 开始执行动画
  7296. * @param {string|Function} easing
  7297. * 动画缓动函数,详见{@link module:zrender/animation/easing}
  7298. * @return {module:zrender/animation/Animator}
  7299. */
  7300. start: function (easing) {
  7301. var self = this;
  7302. var clipCount = 0;
  7303. var oneTrackDone = function() {
  7304. clipCount--;
  7305. if (!clipCount) {
  7306. self._doneCallback();
  7307. }
  7308. };
  7309. var lastClip;
  7310. for (var propName in this._tracks) {
  7311. var clip = createTrackClip(
  7312. this, easing, oneTrackDone,
  7313. this._tracks[propName], propName
  7314. );
  7315. if (clip) {
  7316. this._clipList.push(clip);
  7317. clipCount++;
  7318. // If start after added to animation
  7319. if (this.animation) {
  7320. this.animation.addClip(clip);
  7321. }
  7322. lastClip = clip;
  7323. }
  7324. }
  7325. // Add during callback on the last clip
  7326. if (lastClip) {
  7327. var oldOnFrame = lastClip.onframe;
  7328. lastClip.onframe = function (target, percent) {
  7329. oldOnFrame(target, percent);
  7330. for (var i = 0; i < self._onframeList.length; i++) {
  7331. self._onframeList[i](target, percent);
  7332. }
  7333. };
  7334. }
  7335. if (!clipCount) {
  7336. this._doneCallback();
  7337. }
  7338. return this;
  7339. },
  7340. /**
  7341. * 停止动画
  7342. * @param {boolean} forwardToLast If move to last frame before stop
  7343. */
  7344. stop: function (forwardToLast) {
  7345. var clipList = this._clipList;
  7346. var animation = this.animation;
  7347. for (var i = 0; i < clipList.length; i++) {
  7348. var clip = clipList[i];
  7349. if (forwardToLast) {
  7350. // Move to last frame before stop
  7351. clip.onframe(this._target, 1);
  7352. }
  7353. animation && animation.removeClip(clip);
  7354. }
  7355. clipList.length = 0;
  7356. },
  7357. /**
  7358. * 设置动画延迟开始的时间
  7359. * @param {number} time 单位ms
  7360. * @return {module:zrender/animation/Animator}
  7361. */
  7362. delay: function (time) {
  7363. this._delay = time;
  7364. return this;
  7365. },
  7366. /**
  7367. * 添加动画结束的回调
  7368. * @param {Function} cb
  7369. * @return {module:zrender/animation/Animator}
  7370. */
  7371. done: function(cb) {
  7372. if (cb) {
  7373. this._doneList.push(cb);
  7374. }
  7375. return this;
  7376. },
  7377. /**
  7378. * @return {Array.<module:zrender/animation/Clip>}
  7379. */
  7380. getClips: function () {
  7381. return this._clipList;
  7382. }
  7383. };
  7384. module.exports = Animator;
  7385. /***/ },
  7386. /* 36 */
  7387. /***/ function(module, exports, __webpack_require__) {
  7388. /**
  7389. * 动画主控制器
  7390. * @config target 动画对象,可以是数组,如果是数组的话会批量分发onframe等事件
  7391. * @config life(1000) 动画时长
  7392. * @config delay(0) 动画延迟时间
  7393. * @config loop(true)
  7394. * @config gap(0) 循环的间隔时间
  7395. * @config onframe
  7396. * @config easing(optional)
  7397. * @config ondestroy(optional)
  7398. * @config onrestart(optional)
  7399. *
  7400. * TODO pause
  7401. */
  7402. var easingFuncs = __webpack_require__(37);
  7403. function Clip(options) {
  7404. this._target = options.target;
  7405. // 生命周期
  7406. this._life = options.life || 1000;
  7407. // 延时
  7408. this._delay = options.delay || 0;
  7409. // 开始时间
  7410. // this._startTime = new Date().getTime() + this._delay;// 单位毫秒
  7411. this._initialized = false;
  7412. // 是否循环
  7413. this.loop = options.loop == null ? false : options.loop;
  7414. this.gap = options.gap || 0;
  7415. this.easing = options.easing || 'Linear';
  7416. this.onframe = options.onframe;
  7417. this.ondestroy = options.ondestroy;
  7418. this.onrestart = options.onrestart;
  7419. }
  7420. Clip.prototype = {
  7421. constructor: Clip,
  7422. step: function (time) {
  7423. // Set startTime on first step, or _startTime may has milleseconds different between clips
  7424. // PENDING
  7425. if (!this._initialized) {
  7426. this._startTime = new Date().getTime() + this._delay;
  7427. this._initialized = true;
  7428. }
  7429. var percent = (time - this._startTime) / this._life;
  7430. // 还没开始
  7431. if (percent < 0) {
  7432. return;
  7433. }
  7434. percent = Math.min(percent, 1);
  7435. var easing = this.easing;
  7436. var easingFunc = typeof easing == 'string' ? easingFuncs[easing] : easing;
  7437. var schedule = typeof easingFunc === 'function'
  7438. ? easingFunc(percent)
  7439. : percent;
  7440. this.fire('frame', schedule);
  7441. // 结束
  7442. if (percent == 1) {
  7443. if (this.loop) {
  7444. this.restart();
  7445. // 重新开始周期
  7446. // 抛出而不是直接调用事件直到 stage.update 后再统一调用这些事件
  7447. return 'restart';
  7448. }
  7449. // 动画完成将这个控制器标识为待删除
  7450. // 在Animation.update中进行批量删除
  7451. this._needsRemove = true;
  7452. return 'destroy';
  7453. }
  7454. return null;
  7455. },
  7456. restart: function() {
  7457. var time = new Date().getTime();
  7458. var remainder = (time - this._startTime) % this._life;
  7459. this._startTime = new Date().getTime() - remainder + this.gap;
  7460. this._needsRemove = false;
  7461. },
  7462. fire: function(eventType, arg) {
  7463. eventType = 'on' + eventType;
  7464. if (this[eventType]) {
  7465. this[eventType](this._target, arg);
  7466. }
  7467. }
  7468. };
  7469. module.exports = Clip;
  7470. /***/ },
  7471. /* 37 */
  7472. /***/ function(module, exports) {
  7473. /**
  7474. * 缓动代码来自 https://github.com/sole/tween.js/blob/master/src/Tween.js
  7475. * @see http://sole.github.io/tween.js/examples/03_graphs.html
  7476. * @exports zrender/animation/easing
  7477. */
  7478. var easing = {
  7479. /**
  7480. * @param {number} k
  7481. * @return {number}
  7482. */
  7483. linear: function (k) {
  7484. return k;
  7485. },
  7486. /**
  7487. * @param {number} k
  7488. * @return {number}
  7489. */
  7490. quadraticIn: function (k) {
  7491. return k * k;
  7492. },
  7493. /**
  7494. * @param {number} k
  7495. * @return {number}
  7496. */
  7497. quadraticOut: function (k) {
  7498. return k * (2 - k);
  7499. },
  7500. /**
  7501. * @param {number} k
  7502. * @return {number}
  7503. */
  7504. quadraticInOut: function (k) {
  7505. if ((k *= 2) < 1) {
  7506. return 0.5 * k * k;
  7507. }
  7508. return -0.5 * (--k * (k - 2) - 1);
  7509. },
  7510. // 三次方的缓动(t^3)
  7511. /**
  7512. * @param {number} k
  7513. * @return {number}
  7514. */
  7515. cubicIn: function (k) {
  7516. return k * k * k;
  7517. },
  7518. /**
  7519. * @param {number} k
  7520. * @return {number}
  7521. */
  7522. cubicOut: function (k) {
  7523. return --k * k * k + 1;
  7524. },
  7525. /**
  7526. * @param {number} k
  7527. * @return {number}
  7528. */
  7529. cubicInOut: function (k) {
  7530. if ((k *= 2) < 1) {
  7531. return 0.5 * k * k * k;
  7532. }
  7533. return 0.5 * ((k -= 2) * k * k + 2);
  7534. },
  7535. // 四次方的缓动(t^4)
  7536. /**
  7537. * @param {number} k
  7538. * @return {number}
  7539. */
  7540. quarticIn: function (k) {
  7541. return k * k * k * k;
  7542. },
  7543. /**
  7544. * @param {number} k
  7545. * @return {number}
  7546. */
  7547. quarticOut: function (k) {
  7548. return 1 - (--k * k * k * k);
  7549. },
  7550. /**
  7551. * @param {number} k
  7552. * @return {number}
  7553. */
  7554. quarticInOut: function (k) {
  7555. if ((k *= 2) < 1) {
  7556. return 0.5 * k * k * k * k;
  7557. }
  7558. return -0.5 * ((k -= 2) * k * k * k - 2);
  7559. },
  7560. // 五次方的缓动(t^5)
  7561. /**
  7562. * @param {number} k
  7563. * @return {number}
  7564. */
  7565. quinticIn: function (k) {
  7566. return k * k * k * k * k;
  7567. },
  7568. /**
  7569. * @param {number} k
  7570. * @return {number}
  7571. */
  7572. quinticOut: function (k) {
  7573. return --k * k * k * k * k + 1;
  7574. },
  7575. /**
  7576. * @param {number} k
  7577. * @return {number}
  7578. */
  7579. quinticInOut: function (k) {
  7580. if ((k *= 2) < 1) {
  7581. return 0.5 * k * k * k * k * k;
  7582. }
  7583. return 0.5 * ((k -= 2) * k * k * k * k + 2);
  7584. },
  7585. // 正弦曲线的缓动(sin(t))
  7586. /**
  7587. * @param {number} k
  7588. * @return {number}
  7589. */
  7590. sinusoidalIn: function (k) {
  7591. return 1 - Math.cos(k * Math.PI / 2);
  7592. },
  7593. /**
  7594. * @param {number} k
  7595. * @return {number}
  7596. */
  7597. sinusoidalOut: function (k) {
  7598. return Math.sin(k * Math.PI / 2);
  7599. },
  7600. /**
  7601. * @param {number} k
  7602. * @return {number}
  7603. */
  7604. sinusoidalInOut: function (k) {
  7605. return 0.5 * (1 - Math.cos(Math.PI * k));
  7606. },
  7607. // 指数曲线的缓动(2^t)
  7608. /**
  7609. * @param {number} k
  7610. * @return {number}
  7611. */
  7612. exponentialIn: function (k) {
  7613. return k === 0 ? 0 : Math.pow(1024, k - 1);
  7614. },
  7615. /**
  7616. * @param {number} k
  7617. * @return {number}
  7618. */
  7619. exponentialOut: function (k) {
  7620. return k === 1 ? 1 : 1 - Math.pow(2, -10 * k);
  7621. },
  7622. /**
  7623. * @param {number} k
  7624. * @return {number}
  7625. */
  7626. exponentialInOut: function (k) {
  7627. if (k === 0) {
  7628. return 0;
  7629. }
  7630. if (k === 1) {
  7631. return 1;
  7632. }
  7633. if ((k *= 2) < 1) {
  7634. return 0.5 * Math.pow(1024, k - 1);
  7635. }
  7636. return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2);
  7637. },
  7638. // 圆形曲线的缓动(sqrt(1-t^2))
  7639. /**
  7640. * @param {number} k
  7641. * @return {number}
  7642. */
  7643. circularIn: function (k) {
  7644. return 1 - Math.sqrt(1 - k * k);
  7645. },
  7646. /**
  7647. * @param {number} k
  7648. * @return {number}
  7649. */
  7650. circularOut: function (k) {
  7651. return Math.sqrt(1 - (--k * k));
  7652. },
  7653. /**
  7654. * @param {number} k
  7655. * @return {number}
  7656. */
  7657. circularInOut: function (k) {
  7658. if ((k *= 2) < 1) {
  7659. return -0.5 * (Math.sqrt(1 - k * k) - 1);
  7660. }
  7661. return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1);
  7662. },
  7663. // 创建类似于弹簧在停止前来回振荡的动画
  7664. /**
  7665. * @param {number} k
  7666. * @return {number}
  7667. */
  7668. elasticIn: function (k) {
  7669. var s;
  7670. var a = 0.1;
  7671. var p = 0.4;
  7672. if (k === 0) {
  7673. return 0;
  7674. }
  7675. if (k === 1) {
  7676. return 1;
  7677. }
  7678. if (!a || a < 1) {
  7679. a = 1; s = p / 4;
  7680. }
  7681. else {
  7682. s = p * Math.asin(1 / a) / (2 * Math.PI);
  7683. }
  7684. return -(a * Math.pow(2, 10 * (k -= 1)) *
  7685. Math.sin((k - s) * (2 * Math.PI) / p));
  7686. },
  7687. /**
  7688. * @param {number} k
  7689. * @return {number}
  7690. */
  7691. elasticOut: function (k) {
  7692. var s;
  7693. var a = 0.1;
  7694. var p = 0.4;
  7695. if (k === 0) {
  7696. return 0;
  7697. }
  7698. if (k === 1) {
  7699. return 1;
  7700. }
  7701. if (!a || a < 1) {
  7702. a = 1; s = p / 4;
  7703. }
  7704. else {
  7705. s = p * Math.asin(1 / a) / (2 * Math.PI);
  7706. }
  7707. return (a * Math.pow(2, -10 * k) *
  7708. Math.sin((k - s) * (2 * Math.PI) / p) + 1);
  7709. },
  7710. /**
  7711. * @param {number} k
  7712. * @return {number}
  7713. */
  7714. elasticInOut: function (k) {
  7715. var s;
  7716. var a = 0.1;
  7717. var p = 0.4;
  7718. if (k === 0) {
  7719. return 0;
  7720. }
  7721. if (k === 1) {
  7722. return 1;
  7723. }
  7724. if (!a || a < 1) {
  7725. a = 1; s = p / 4;
  7726. }
  7727. else {
  7728. s = p * Math.asin(1 / a) / (2 * Math.PI);
  7729. }
  7730. if ((k *= 2) < 1) {
  7731. return -0.5 * (a * Math.pow(2, 10 * (k -= 1))
  7732. * Math.sin((k - s) * (2 * Math.PI) / p));
  7733. }
  7734. return a * Math.pow(2, -10 * (k -= 1))
  7735. * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1;
  7736. },
  7737. // 在某一动画开始沿指示的路径进行动画处理前稍稍收回该动画的移动
  7738. /**
  7739. * @param {number} k
  7740. * @return {number}
  7741. */
  7742. backIn: function (k) {
  7743. var s = 1.70158;
  7744. return k * k * ((s + 1) * k - s);
  7745. },
  7746. /**
  7747. * @param {number} k
  7748. * @return {number}
  7749. */
  7750. backOut: function (k) {
  7751. var s = 1.70158;
  7752. return --k * k * ((s + 1) * k + s) + 1;
  7753. },
  7754. /**
  7755. * @param {number} k
  7756. * @return {number}
  7757. */
  7758. backInOut: function (k) {
  7759. var s = 1.70158 * 1.525;
  7760. if ((k *= 2) < 1) {
  7761. return 0.5 * (k * k * ((s + 1) * k - s));
  7762. }
  7763. return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
  7764. },
  7765. // 创建弹跳效果
  7766. /**
  7767. * @param {number} k
  7768. * @return {number}
  7769. */
  7770. bounceIn: function (k) {
  7771. return 1 - easing.bounceOut(1 - k);
  7772. },
  7773. /**
  7774. * @param {number} k
  7775. * @return {number}
  7776. */
  7777. bounceOut: function (k) {
  7778. if (k < (1 / 2.75)) {
  7779. return 7.5625 * k * k;
  7780. }
  7781. else if (k < (2 / 2.75)) {
  7782. return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75;
  7783. }
  7784. else if (k < (2.5 / 2.75)) {
  7785. return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375;
  7786. }
  7787. else {
  7788. return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375;
  7789. }
  7790. },
  7791. /**
  7792. * @param {number} k
  7793. * @return {number}
  7794. */
  7795. bounceInOut: function (k) {
  7796. if (k < 0.5) {
  7797. return easing.bounceIn(k * 2) * 0.5;
  7798. }
  7799. return easing.bounceOut(k * 2 - 1) * 0.5 + 0.5;
  7800. }
  7801. };
  7802. module.exports = easing;
  7803. /***/ },
  7804. /* 38 */
  7805. /***/ function(module, exports) {
  7806. /**
  7807. * @module zrender/tool/color
  7808. */
  7809. var kCSSColorTable = {
  7810. 'transparent': [0,0,0,0], 'aliceblue': [240,248,255,1],
  7811. 'antiquewhite': [250,235,215,1], 'aqua': [0,255,255,1],
  7812. 'aquamarine': [127,255,212,1], 'azure': [240,255,255,1],
  7813. 'beige': [245,245,220,1], 'bisque': [255,228,196,1],
  7814. 'black': [0,0,0,1], 'blanchedalmond': [255,235,205,1],
  7815. 'blue': [0,0,255,1], 'blueviolet': [138,43,226,1],
  7816. 'brown': [165,42,42,1], 'burlywood': [222,184,135,1],
  7817. 'cadetblue': [95,158,160,1], 'chartreuse': [127,255,0,1],
  7818. 'chocolate': [210,105,30,1], 'coral': [255,127,80,1],
  7819. 'cornflowerblue': [100,149,237,1], 'cornsilk': [255,248,220,1],
  7820. 'crimson': [220,20,60,1], 'cyan': [0,255,255,1],
  7821. 'darkblue': [0,0,139,1], 'darkcyan': [0,139,139,1],
  7822. 'darkgoldenrod': [184,134,11,1], 'darkgray': [169,169,169,1],
  7823. 'darkgreen': [0,100,0,1], 'darkgrey': [169,169,169,1],
  7824. 'darkkhaki': [189,183,107,1], 'darkmagenta': [139,0,139,1],
  7825. 'darkolivegreen': [85,107,47,1], 'darkorange': [255,140,0,1],
  7826. 'darkorchid': [153,50,204,1], 'darkred': [139,0,0,1],
  7827. 'darksalmon': [233,150,122,1], 'darkseagreen': [143,188,143,1],
  7828. 'darkslateblue': [72,61,139,1], 'darkslategray': [47,79,79,1],
  7829. 'darkslategrey': [47,79,79,1], 'darkturquoise': [0,206,209,1],
  7830. 'darkviolet': [148,0,211,1], 'deeppink': [255,20,147,1],
  7831. 'deepskyblue': [0,191,255,1], 'dimgray': [105,105,105,1],
  7832. 'dimgrey': [105,105,105,1], 'dodgerblue': [30,144,255,1],
  7833. 'firebrick': [178,34,34,1], 'floralwhite': [255,250,240,1],
  7834. 'forestgreen': [34,139,34,1], 'fuchsia': [255,0,255,1],
  7835. 'gainsboro': [220,220,220,1], 'ghostwhite': [248,248,255,1],
  7836. 'gold': [255,215,0,1], 'goldenrod': [218,165,32,1],
  7837. 'gray': [128,128,128,1], 'green': [0,128,0,1],
  7838. 'greenyellow': [173,255,47,1], 'grey': [128,128,128,1],
  7839. 'honeydew': [240,255,240,1], 'hotpink': [255,105,180,1],
  7840. 'indianred': [205,92,92,1], 'indigo': [75,0,130,1],
  7841. 'ivory': [255,255,240,1], 'khaki': [240,230,140,1],
  7842. 'lavender': [230,230,250,1], 'lavenderblush': [255,240,245,1],
  7843. 'lawngreen': [124,252,0,1], 'lemonchiffon': [255,250,205,1],
  7844. 'lightblue': [173,216,230,1], 'lightcoral': [240,128,128,1],
  7845. 'lightcyan': [224,255,255,1], 'lightgoldenrodyellow': [250,250,210,1],
  7846. 'lightgray': [211,211,211,1], 'lightgreen': [144,238,144,1],
  7847. 'lightgrey': [211,211,211,1], 'lightpink': [255,182,193,1],
  7848. 'lightsalmon': [255,160,122,1], 'lightseagreen': [32,178,170,1],
  7849. 'lightskyblue': [135,206,250,1], 'lightslategray': [119,136,153,1],
  7850. 'lightslategrey': [119,136,153,1], 'lightsteelblue': [176,196,222,1],
  7851. 'lightyellow': [255,255,224,1], 'lime': [0,255,0,1],
  7852. 'limegreen': [50,205,50,1], 'linen': [250,240,230,1],
  7853. 'magenta': [255,0,255,1], 'maroon': [128,0,0,1],
  7854. 'mediumaquamarine': [102,205,170,1], 'mediumblue': [0,0,205,1],
  7855. 'mediumorchid': [186,85,211,1], 'mediumpurple': [147,112,219,1],
  7856. 'mediumseagreen': [60,179,113,1], 'mediumslateblue': [123,104,238,1],
  7857. 'mediumspringgreen': [0,250,154,1], 'mediumturquoise': [72,209,204,1],
  7858. 'mediumvioletred': [199,21,133,1], 'midnightblue': [25,25,112,1],
  7859. 'mintcream': [245,255,250,1], 'mistyrose': [255,228,225,1],
  7860. 'moccasin': [255,228,181,1], 'navajowhite': [255,222,173,1],
  7861. 'navy': [0,0,128,1], 'oldlace': [253,245,230,1],
  7862. 'olive': [128,128,0,1], 'olivedrab': [107,142,35,1],
  7863. 'orange': [255,165,0,1], 'orangered': [255,69,0,1],
  7864. 'orchid': [218,112,214,1], 'palegoldenrod': [238,232,170,1],
  7865. 'palegreen': [152,251,152,1], 'paleturquoise': [175,238,238,1],
  7866. 'palevioletred': [219,112,147,1], 'papayawhip': [255,239,213,1],
  7867. 'peachpuff': [255,218,185,1], 'peru': [205,133,63,1],
  7868. 'pink': [255,192,203,1], 'plum': [221,160,221,1],
  7869. 'powderblue': [176,224,230,1], 'purple': [128,0,128,1],
  7870. 'red': [255,0,0,1], 'rosybrown': [188,143,143,1],
  7871. 'royalblue': [65,105,225,1], 'saddlebrown': [139,69,19,1],
  7872. 'salmon': [250,128,114,1], 'sandybrown': [244,164,96,1],
  7873. 'seagreen': [46,139,87,1], 'seashell': [255,245,238,1],
  7874. 'sienna': [160,82,45,1], 'silver': [192,192,192,1],
  7875. 'skyblue': [135,206,235,1], 'slateblue': [106,90,205,1],
  7876. 'slategray': [112,128,144,1], 'slategrey': [112,128,144,1],
  7877. 'snow': [255,250,250,1], 'springgreen': [0,255,127,1],
  7878. 'steelblue': [70,130,180,1], 'tan': [210,180,140,1],
  7879. 'teal': [0,128,128,1], 'thistle': [216,191,216,1],
  7880. 'tomato': [255,99,71,1], 'turquoise': [64,224,208,1],
  7881. 'violet': [238,130,238,1], 'wheat': [245,222,179,1],
  7882. 'white': [255,255,255,1], 'whitesmoke': [245,245,245,1],
  7883. 'yellow': [255,255,0,1], 'yellowgreen': [154,205,50,1]
  7884. };
  7885. function clampCssByte(i) { // Clamp to integer 0 .. 255.
  7886. i = Math.round(i); // Seems to be what Chrome does (vs truncation).
  7887. return i < 0 ? 0 : i > 255 ? 255 : i;
  7888. }
  7889. function clampCssAngle(i) { // Clamp to integer 0 .. 360.
  7890. i = Math.round(i); // Seems to be what Chrome does (vs truncation).
  7891. return i < 0 ? 0 : i > 360 ? 360 : i;
  7892. }
  7893. function clampCssFloat(f) { // Clamp to float 0.0 .. 1.0.
  7894. return f < 0 ? 0 : f > 1 ? 1 : f;
  7895. }
  7896. function parseCssInt(str) { // int or percentage.
  7897. if (str.length && str.charAt(str.length - 1) === '%') {
  7898. return clampCssByte(parseFloat(str) / 100 * 255);
  7899. }
  7900. return clampCssByte(parseInt(str, 10));
  7901. }
  7902. function parseCssFloat(str) { // float or percentage.
  7903. if (str.length && str.charAt(str.length - 1) === '%') {
  7904. return clampCssFloat(parseFloat(str) / 100);
  7905. }
  7906. return clampCssFloat(parseFloat(str));
  7907. }
  7908. function cssHueToRgb(m1, m2, h) {
  7909. if (h < 0) {
  7910. h += 1;
  7911. }
  7912. else if (h > 1) {
  7913. h -= 1;
  7914. }
  7915. if (h * 6 < 1) {
  7916. return m1 + (m2 - m1) * h * 6;
  7917. }
  7918. if (h * 2 < 1) {
  7919. return m2;
  7920. }
  7921. if (h * 3 < 2) {
  7922. return m1 + (m2 - m1) * (2/3 - h) * 6;
  7923. }
  7924. return m1;
  7925. }
  7926. function lerp(a, b, p) {
  7927. return a + (b - a) * p;
  7928. }
  7929. /**
  7930. * @param {string} colorStr
  7931. * @return {Array.<number>}
  7932. * @memberOf module:zrender/util/color
  7933. */
  7934. function parse(colorStr) {
  7935. if (!colorStr) {
  7936. return;
  7937. }
  7938. // colorStr may be not string
  7939. colorStr = colorStr + '';
  7940. // Remove all whitespace, not compliant, but should just be more accepting.
  7941. var str = colorStr.replace(/ /g, '').toLowerCase();
  7942. // Color keywords (and transparent) lookup.
  7943. if (str in kCSSColorTable) {
  7944. return kCSSColorTable[str].slice(); // dup.
  7945. }
  7946. // #abc and #abc123 syntax.
  7947. if (str.charAt(0) === '#') {
  7948. if (str.length === 4) {
  7949. var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing.
  7950. if (!(iv >= 0 && iv <= 0xfff)) {
  7951. return; // Covers NaN.
  7952. }
  7953. return [
  7954. ((iv & 0xf00) >> 4) | ((iv & 0xf00) >> 8),
  7955. (iv & 0xf0) | ((iv & 0xf0) >> 4),
  7956. (iv & 0xf) | ((iv & 0xf) << 4),
  7957. 1
  7958. ];
  7959. }
  7960. else if (str.length === 7) {
  7961. var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing.
  7962. if (!(iv >= 0 && iv <= 0xffffff)) {
  7963. return; // Covers NaN.
  7964. }
  7965. return [
  7966. (iv & 0xff0000) >> 16,
  7967. (iv & 0xff00) >> 8,
  7968. iv & 0xff,
  7969. 1
  7970. ];
  7971. }
  7972. return;
  7973. }
  7974. var op = str.indexOf('('), ep = str.indexOf(')');
  7975. if (op !== -1 && ep + 1 === str.length) {
  7976. var fname = str.substr(0, op);
  7977. var params = str.substr(op + 1, ep - (op + 1)).split(',');
  7978. var alpha = 1; // To allow case fallthrough.
  7979. switch (fname) {
  7980. case 'rgba':
  7981. if (params.length !== 4) {
  7982. return;
  7983. }
  7984. alpha = parseCssFloat(params.pop()); // jshint ignore:line
  7985. // Fall through.
  7986. case 'rgb':
  7987. if (params.length !== 3) {
  7988. return;
  7989. }
  7990. return [
  7991. parseCssInt(params[0]),
  7992. parseCssInt(params[1]),
  7993. parseCssInt(params[2]),
  7994. alpha
  7995. ];
  7996. case 'hsla':
  7997. if (params.length !== 4) {
  7998. return;
  7999. }
  8000. params[3] = parseCssFloat(params[3]);
  8001. return hsla2rgba(params);
  8002. case 'hsl':
  8003. if (params.length !== 3) {
  8004. return;
  8005. }
  8006. return hsla2rgba(params);
  8007. default:
  8008. return;
  8009. }
  8010. }
  8011. return;
  8012. }
  8013. /**
  8014. * @param {Array.<number>} hsla
  8015. * @return {Array.<number>} rgba
  8016. */
  8017. function hsla2rgba(hsla) {
  8018. var h = (((parseFloat(hsla[0]) % 360) + 360) % 360) / 360; // 0 .. 1
  8019. // NOTE(deanm): According to the CSS spec s/l should only be
  8020. // percentages, but we don't bother and let float or percentage.
  8021. var s = parseCssFloat(hsla[1]);
  8022. var l = parseCssFloat(hsla[2]);
  8023. var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
  8024. var m1 = l * 2 - m2;
  8025. var rgba = [
  8026. clampCssByte(cssHueToRgb(m1, m2, h + 1 / 3) * 255),
  8027. clampCssByte(cssHueToRgb(m1, m2, h) * 255),
  8028. clampCssByte(cssHueToRgb(m1, m2, h - 1 / 3) * 255)
  8029. ];
  8030. if (hsla.length === 4) {
  8031. rgba[3] = hsla[3];
  8032. }
  8033. return rgba;
  8034. }
  8035. /**
  8036. * @param {Array.<number>} rgba
  8037. * @return {Array.<number>} hsla
  8038. */
  8039. function rgba2hsla(rgba) {
  8040. if (!rgba) {
  8041. return;
  8042. }
  8043. // RGB from 0 to 255
  8044. var R = rgba[0] / 255;
  8045. var G = rgba[1] / 255;
  8046. var B = rgba[2] / 255;
  8047. var vMin = Math.min(R, G, B); // Min. value of RGB
  8048. var vMax = Math.max(R, G, B); // Max. value of RGB
  8049. var delta = vMax - vMin; // Delta RGB value
  8050. var L = (vMax + vMin) / 2;
  8051. var H;
  8052. var S;
  8053. // HSL results from 0 to 1
  8054. if (delta === 0) {
  8055. H = 0;
  8056. S = 0;
  8057. }
  8058. else {
  8059. if (L < 0.5) {
  8060. S = delta / (vMax + vMin);
  8061. }
  8062. else {
  8063. S = delta / (2 - vMax - vMin);
  8064. }
  8065. var deltaR = (((vMax - R) / 6) + (delta / 2)) / delta;
  8066. var deltaG = (((vMax - G) / 6) + (delta / 2)) / delta;
  8067. var deltaB = (((vMax - B) / 6) + (delta / 2)) / delta;
  8068. if (R === vMax) {
  8069. H = deltaB - deltaG;
  8070. }
  8071. else if (G === vMax) {
  8072. H = (1 / 3) + deltaR - deltaB;
  8073. }
  8074. else if (B === vMax) {
  8075. H = (2 / 3) + deltaG - deltaR;
  8076. }
  8077. if (H < 0) {
  8078. H += 1;
  8079. }
  8080. if (H > 1) {
  8081. H -= 1;
  8082. }
  8083. }
  8084. var hsla = [H * 360, S, L];
  8085. if (rgba[3] != null) {
  8086. hsla.push(rgba[3]);
  8087. }
  8088. return hsla;
  8089. }
  8090. /**
  8091. * @param {string} color
  8092. * @param {number} level
  8093. * @return {string}
  8094. * @memberOf module:zrender/util/color
  8095. */
  8096. function lift(color, level) {
  8097. var colorArr = parse(color);
  8098. if (colorArr) {
  8099. for (var i = 0; i < 3; i++) {
  8100. if (level < 0) {
  8101. colorArr[i] = colorArr[i] * (1 - level) | 0;
  8102. }
  8103. else {
  8104. colorArr[i] = ((255 - colorArr[i]) * level + colorArr[i]) | 0;
  8105. }
  8106. }
  8107. return stringify(colorArr, colorArr.length === 4 ? 'rgba' : 'rgb');
  8108. }
  8109. }
  8110. /**
  8111. * @param {string} color
  8112. * @return {string}
  8113. * @memberOf module:zrender/util/color
  8114. */
  8115. function toHex(color, level) {
  8116. var colorArr = parse(color);
  8117. if (colorArr) {
  8118. return ((1 << 24) + (colorArr[0] << 16) + (colorArr[1] << 8) + (+colorArr[2])).toString(16).slice(1);
  8119. }
  8120. }
  8121. /**
  8122. * Map value to color. Faster than mapToColor methods because color is represented by rgba array
  8123. * @param {number} normalizedValue A float between 0 and 1.
  8124. * @param {Array.<Array.<number>>} colors List of rgba color array
  8125. * @param {Array.<number>} [out] Mapped gba color array
  8126. * @return {Array.<number>}
  8127. */
  8128. function fastMapToColor(normalizedValue, colors, out) {
  8129. if (!(colors && colors.length)
  8130. || !(normalizedValue >= 0 && normalizedValue <= 1)
  8131. ) {
  8132. return;
  8133. }
  8134. out = out || [0, 0, 0, 0];
  8135. var value = normalizedValue * (colors.length - 1);
  8136. var leftIndex = Math.floor(value);
  8137. var rightIndex = Math.ceil(value);
  8138. var leftColor = colors[leftIndex];
  8139. var rightColor = colors[rightIndex];
  8140. var dv = value - leftIndex;
  8141. out[0] = clampCssByte(lerp(leftColor[0], rightColor[0], dv));
  8142. out[1] = clampCssByte(lerp(leftColor[1], rightColor[1], dv));
  8143. out[2] = clampCssByte(lerp(leftColor[2], rightColor[2], dv));
  8144. out[3] = clampCssByte(lerp(leftColor[3], rightColor[3], dv));
  8145. return out;
  8146. }
  8147. /**
  8148. * @param {number} normalizedValue A float between 0 and 1.
  8149. * @param {Array.<string>} colors Color list.
  8150. * @param {boolean=} fullOutput Default false.
  8151. * @return {(string|Object)} Result color. If fullOutput,
  8152. * return {color: ..., leftIndex: ..., rightIndex: ..., value: ...},
  8153. * @memberOf module:zrender/util/color
  8154. */
  8155. function mapToColor(normalizedValue, colors, fullOutput) {
  8156. if (!(colors && colors.length)
  8157. || !(normalizedValue >= 0 && normalizedValue <= 1)
  8158. ) {
  8159. return;
  8160. }
  8161. var value = normalizedValue * (colors.length - 1);
  8162. var leftIndex = Math.floor(value);
  8163. var rightIndex = Math.ceil(value);
  8164. var leftColor = parse(colors[leftIndex]);
  8165. var rightColor = parse(colors[rightIndex]);
  8166. var dv = value - leftIndex;
  8167. var color = stringify(
  8168. [
  8169. clampCssByte(lerp(leftColor[0], rightColor[0], dv)),
  8170. clampCssByte(lerp(leftColor[1], rightColor[1], dv)),
  8171. clampCssByte(lerp(leftColor[2], rightColor[2], dv)),
  8172. clampCssFloat(lerp(leftColor[3], rightColor[3], dv))
  8173. ],
  8174. 'rgba'
  8175. );
  8176. return fullOutput
  8177. ? {
  8178. color: color,
  8179. leftIndex: leftIndex,
  8180. rightIndex: rightIndex,
  8181. value: value
  8182. }
  8183. : color;
  8184. }
  8185. /**
  8186. * @param {string} color
  8187. * @param {number=} h 0 ~ 360, ignore when null.
  8188. * @param {number=} s 0 ~ 1, ignore when null.
  8189. * @param {number=} l 0 ~ 1, ignore when null.
  8190. * @return {string} Color string in rgba format.
  8191. * @memberOf module:zrender/util/color
  8192. */
  8193. function modifyHSL(color, h, s, l) {
  8194. color = parse(color);
  8195. if (color) {
  8196. color = rgba2hsla(color);
  8197. h != null && (color[0] = clampCssAngle(h));
  8198. s != null && (color[1] = parseCssFloat(s));
  8199. l != null && (color[2] = parseCssFloat(l));
  8200. return stringify(hsla2rgba(color), 'rgba');
  8201. }
  8202. }
  8203. /**
  8204. * @param {string} color
  8205. * @param {number=} alpha 0 ~ 1
  8206. * @return {string} Color string in rgba format.
  8207. * @memberOf module:zrender/util/color
  8208. */
  8209. function modifyAlpha(color, alpha) {
  8210. color = parse(color);
  8211. if (color && alpha != null) {
  8212. color[3] = clampCssFloat(alpha);
  8213. return stringify(color, 'rgba');
  8214. }
  8215. }
  8216. /**
  8217. * @param {Array.<string>} colors Color list.
  8218. * @param {string} type 'rgba', 'hsva', ...
  8219. * @return {string} Result color.
  8220. */
  8221. function stringify(arrColor, type) {
  8222. if (type === 'rgb' || type === 'hsv' || type === 'hsl') {
  8223. arrColor = arrColor.slice(0, 3);
  8224. }
  8225. return type + '(' + arrColor.join(',') + ')';
  8226. }
  8227. module.exports = {
  8228. parse: parse,
  8229. lift: lift,
  8230. toHex: toHex,
  8231. fastMapToColor: fastMapToColor,
  8232. mapToColor: mapToColor,
  8233. modifyHSL: modifyHSL,
  8234. modifyAlpha: modifyAlpha,
  8235. stringify: stringify
  8236. };
  8237. /***/ },
  8238. /* 39 */
  8239. /***/ function(module, exports, __webpack_require__) {
  8240. var config = __webpack_require__(40);
  8241. /**
  8242. * @exports zrender/tool/log
  8243. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  8244. */
  8245. module.exports = function() {
  8246. if (config.debugMode === 0) {
  8247. return;
  8248. }
  8249. else if (config.debugMode == 1) {
  8250. for (var k in arguments) {
  8251. throw new Error(arguments[k]);
  8252. }
  8253. }
  8254. else if (config.debugMode > 1) {
  8255. for (var k in arguments) {
  8256. console.log(arguments[k]);
  8257. }
  8258. }
  8259. };
  8260. /* for debug
  8261. return function(mes) {
  8262. document.getElementById('wrong-message').innerHTML =
  8263. mes + ' ' + (new Date() - 0)
  8264. + '<br/>'
  8265. + document.getElementById('wrong-message').innerHTML;
  8266. };
  8267. */
  8268. /***/ },
  8269. /* 40 */
  8270. /***/ function(module, exports) {
  8271. var dpr = 1;
  8272. // If in browser environment
  8273. if (typeof window !== 'undefined') {
  8274. dpr = Math.max(window.devicePixelRatio || 1, 1);
  8275. }
  8276. /**
  8277. * config默认配置项
  8278. * @exports zrender/config
  8279. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  8280. */
  8281. var config = {
  8282. /**
  8283. * debug日志选项:catchBrushException为true下有效
  8284. * 0 : 不生成debug数据,发布用
  8285. * 1 : 异常抛出,调试用
  8286. * 2 : 控制台输出,调试用
  8287. */
  8288. debugMode: 0,
  8289. // retina 屏幕优化
  8290. devicePixelRatio: dpr
  8291. };
  8292. module.exports = config;
  8293. /***/ },
  8294. /* 41 */
  8295. /***/ function(module, exports, __webpack_require__) {
  8296. var Group = __webpack_require__(29);
  8297. var componentUtil = __webpack_require__(20);
  8298. var clazzUtil = __webpack_require__(9);
  8299. function Chart() {
  8300. /**
  8301. * @type {module:zrender/container/Group}
  8302. * @readOnly
  8303. */
  8304. this.group = new Group();
  8305. /**
  8306. * @type {string}
  8307. * @readOnly
  8308. */
  8309. this.uid = componentUtil.getUID('viewChart');
  8310. }
  8311. Chart.prototype = {
  8312. type: 'chart',
  8313. /**
  8314. * Init the chart
  8315. * @param {module:echarts/model/Global} ecModel
  8316. * @param {module:echarts/ExtensionAPI} api
  8317. */
  8318. init: function (ecModel, api) {},
  8319. /**
  8320. * Render the chart
  8321. * @param {module:echarts/model/Series} seriesModel
  8322. * @param {module:echarts/model/Global} ecModel
  8323. * @param {module:echarts/ExtensionAPI} api
  8324. * @param {Object} payload
  8325. */
  8326. render: function (seriesModel, ecModel, api, payload) {},
  8327. /**
  8328. * Highlight series or specified data item
  8329. * @param {module:echarts/model/Series} seriesModel
  8330. * @param {module:echarts/model/Global} ecModel
  8331. * @param {module:echarts/ExtensionAPI} api
  8332. * @param {Object} payload
  8333. */
  8334. highlight: function (seriesModel, ecModel, api, payload) {
  8335. toggleHighlight(seriesModel.getData(), payload, 'emphasis');
  8336. },
  8337. /**
  8338. * Downplay series or specified data item
  8339. * @param {module:echarts/model/Series} seriesModel
  8340. * @param {module:echarts/model/Global} ecModel
  8341. * @param {module:echarts/ExtensionAPI} api
  8342. * @param {Object} payload
  8343. */
  8344. downplay: function (seriesModel, ecModel, api, payload) {
  8345. toggleHighlight(seriesModel.getData(), payload, 'normal');
  8346. },
  8347. /**
  8348. * Remove self
  8349. * @param {module:echarts/model/Global} ecModel
  8350. * @param {module:echarts/ExtensionAPI} api
  8351. */
  8352. remove: function (ecModel, api) {
  8353. this.group.removeAll();
  8354. },
  8355. /**
  8356. * Dispose self
  8357. * @param {module:echarts/model/Global} ecModel
  8358. * @param {module:echarts/ExtensionAPI} api
  8359. */
  8360. dispose: function () {}
  8361. };
  8362. var chartProto = Chart.prototype;
  8363. chartProto.updateView
  8364. = chartProto.updateLayout
  8365. = chartProto.updateVisual
  8366. = function (seriesModel, ecModel, api, payload) {
  8367. this.render(seriesModel, ecModel, api, payload);
  8368. };
  8369. /**
  8370. * Set state of single element
  8371. * @param {module:zrender/Element} el
  8372. * @param {string} state
  8373. */
  8374. function elSetState(el, state) {
  8375. if (el) {
  8376. el.trigger(state);
  8377. if (el.type === 'group') {
  8378. for (var i = 0; i < el.childCount(); i++) {
  8379. elSetState(el.childAt(i), state);
  8380. }
  8381. }
  8382. }
  8383. }
  8384. /**
  8385. * @param {module:echarts/data/List} data
  8386. * @param {Object} payload
  8387. * @param {string} state 'normal'|'emphasis'
  8388. * @inner
  8389. */
  8390. function toggleHighlight(data, payload, state) {
  8391. if (payload.dataIndex != null) {
  8392. var el = data.getItemGraphicEl(payload.dataIndex);
  8393. elSetState(el, state);
  8394. }
  8395. else if (payload.name) {
  8396. var dataIndex = data.indexOfName(payload.name);
  8397. var el = data.getItemGraphicEl(dataIndex);
  8398. elSetState(el, state);
  8399. }
  8400. else {
  8401. data.eachItemGraphicEl(function (el) {
  8402. elSetState(el, state);
  8403. });
  8404. }
  8405. }
  8406. // Enable Chart.extend.
  8407. clazzUtil.enableClassExtend(Chart);
  8408. // Add capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on.
  8409. clazzUtil.enableClassManagement(Chart, {registerWhenExtend: true});
  8410. module.exports = Chart;
  8411. /***/ },
  8412. /* 42 */
  8413. /***/ function(module, exports, __webpack_require__) {
  8414. 'use strict';
  8415. var zrUtil = __webpack_require__(3);
  8416. var pathTool = __webpack_require__(43);
  8417. var round = Math.round;
  8418. var Path = __webpack_require__(44);
  8419. var colorTool = __webpack_require__(38);
  8420. var matrix = __webpack_require__(17);
  8421. var vector = __webpack_require__(16);
  8422. var Gradient = __webpack_require__(4);
  8423. var graphic = {};
  8424. graphic.Group = __webpack_require__(29);
  8425. graphic.Image = __webpack_require__(59);
  8426. graphic.Text = __webpack_require__(62);
  8427. graphic.Circle = __webpack_require__(63);
  8428. graphic.Sector = __webpack_require__(64);
  8429. graphic.Ring = __webpack_require__(65);
  8430. graphic.Polygon = __webpack_require__(66);
  8431. graphic.Polyline = __webpack_require__(70);
  8432. graphic.Rect = __webpack_require__(71);
  8433. graphic.Line = __webpack_require__(72);
  8434. graphic.BezierCurve = __webpack_require__(73);
  8435. graphic.Arc = __webpack_require__(74);
  8436. graphic.CompoundPath = __webpack_require__(75);
  8437. graphic.LinearGradient = __webpack_require__(76);
  8438. graphic.RadialGradient = __webpack_require__(77);
  8439. graphic.BoundingRect = __webpack_require__(15);
  8440. /**
  8441. * Extend shape with parameters
  8442. */
  8443. graphic.extendShape = function (opts) {
  8444. return Path.extend(opts);
  8445. };
  8446. /**
  8447. * Extend path
  8448. */
  8449. graphic.extendPath = function (pathData, opts) {
  8450. return pathTool.extendFromString(pathData, opts);
  8451. };
  8452. /**
  8453. * Create a path element from path data string
  8454. * @param {string} pathData
  8455. * @param {Object} opts
  8456. * @param {module:zrender/core/BoundingRect} rect
  8457. * @param {string} [layout=cover] 'center' or 'cover'
  8458. */
  8459. graphic.makePath = function (pathData, opts, rect, layout) {
  8460. var path = pathTool.createFromString(pathData, opts);
  8461. var boundingRect = path.getBoundingRect();
  8462. if (rect) {
  8463. var aspect = boundingRect.width / boundingRect.height;
  8464. if (layout === 'center') {
  8465. // Set rect to center, keep width / height ratio.
  8466. var width = rect.height * aspect;
  8467. var height;
  8468. if (width <= rect.width) {
  8469. height = rect.height;
  8470. }
  8471. else {
  8472. width = rect.width;
  8473. height = width / aspect;
  8474. }
  8475. var cx = rect.x + rect.width / 2;
  8476. var cy = rect.y + rect.height / 2;
  8477. rect.x = cx - width / 2;
  8478. rect.y = cy - height / 2;
  8479. rect.width = width;
  8480. rect.height = height;
  8481. }
  8482. this.resizePath(path, rect);
  8483. }
  8484. return path;
  8485. };
  8486. graphic.mergePath = pathTool.mergePath,
  8487. /**
  8488. * Resize a path to fit the rect
  8489. * @param {module:zrender/graphic/Path} path
  8490. * @param {Object} rect
  8491. */
  8492. graphic.resizePath = function (path, rect) {
  8493. if (!path.applyTransform) {
  8494. return;
  8495. }
  8496. var pathRect = path.getBoundingRect();
  8497. var m = pathRect.calculateTransform(rect);
  8498. path.applyTransform(m);
  8499. };
  8500. /**
  8501. * Sub pixel optimize line for canvas
  8502. *
  8503. * @param {Object} param
  8504. * @param {Object} [param.shape]
  8505. * @param {number} [param.shape.x1]
  8506. * @param {number} [param.shape.y1]
  8507. * @param {number} [param.shape.x2]
  8508. * @param {number} [param.shape.y2]
  8509. * @param {Object} [param.style]
  8510. * @param {number} [param.style.lineWidth]
  8511. * @return {Object} Modified param
  8512. */
  8513. graphic.subPixelOptimizeLine = function (param) {
  8514. var subPixelOptimize = graphic.subPixelOptimize;
  8515. var shape = param.shape;
  8516. var lineWidth = param.style.lineWidth;
  8517. if (round(shape.x1 * 2) === round(shape.x2 * 2)) {
  8518. shape.x1 = shape.x2 = subPixelOptimize(shape.x1, lineWidth, true);
  8519. }
  8520. if (round(shape.y1 * 2) === round(shape.y2 * 2)) {
  8521. shape.y1 = shape.y2 = subPixelOptimize(shape.y1, lineWidth, true);
  8522. }
  8523. return param;
  8524. };
  8525. /**
  8526. * Sub pixel optimize rect for canvas
  8527. *
  8528. * @param {Object} param
  8529. * @param {Object} [param.shape]
  8530. * @param {number} [param.shape.x]
  8531. * @param {number} [param.shape.y]
  8532. * @param {number} [param.shape.width]
  8533. * @param {number} [param.shape.height]
  8534. * @param {Object} [param.style]
  8535. * @param {number} [param.style.lineWidth]
  8536. * @return {Object} Modified param
  8537. */
  8538. graphic.subPixelOptimizeRect = function (param) {
  8539. var subPixelOptimize = graphic.subPixelOptimize;
  8540. var shape = param.shape;
  8541. var lineWidth = param.style.lineWidth;
  8542. var originX = shape.x;
  8543. var originY = shape.y;
  8544. var originWidth = shape.width;
  8545. var originHeight = shape.height;
  8546. shape.x = subPixelOptimize(shape.x, lineWidth, true);
  8547. shape.y = subPixelOptimize(shape.y, lineWidth, true);
  8548. shape.width = Math.max(
  8549. subPixelOptimize(originX + originWidth, lineWidth, false) - shape.x,
  8550. originWidth === 0 ? 0 : 1
  8551. );
  8552. shape.height = Math.max(
  8553. subPixelOptimize(originY + originHeight, lineWidth, false) - shape.y,
  8554. originHeight === 0 ? 0 : 1
  8555. );
  8556. return param;
  8557. };
  8558. /**
  8559. * Sub pixel optimize for canvas
  8560. *
  8561. * @param {number} position Coordinate, such as x, y
  8562. * @param {number} lineWidth Should be nonnegative integer.
  8563. * @param {boolean=} positiveOrNegative Default false (negative).
  8564. * @return {number} Optimized position.
  8565. */
  8566. graphic.subPixelOptimize = function (position, lineWidth, positiveOrNegative) {
  8567. // Assure that (position + lineWidth / 2) is near integer edge,
  8568. // otherwise line will be fuzzy in canvas.
  8569. var doubledPosition = round(position * 2);
  8570. return (doubledPosition + round(lineWidth)) % 2 === 0
  8571. ? doubledPosition / 2
  8572. : (doubledPosition + (positiveOrNegative ? 1 : -1)) / 2;
  8573. };
  8574. function hasFillOrStroke(fillOrStroke) {
  8575. return fillOrStroke != null && fillOrStroke != 'none';
  8576. }
  8577. function liftColor(color) {
  8578. return color instanceof Gradient ? color : colorTool.lift(color, -0.1);
  8579. }
  8580. /**
  8581. * @private
  8582. */
  8583. function cacheElementStl(el) {
  8584. if (el.__hoverStlDirty) {
  8585. var stroke = el.style.stroke;
  8586. var fill = el.style.fill;
  8587. // Create hoverStyle on mouseover
  8588. var hoverStyle = el.__hoverStl;
  8589. hoverStyle.fill = hoverStyle.fill
  8590. || (hasFillOrStroke(fill) ? liftColor(fill) : null);
  8591. hoverStyle.stroke = hoverStyle.stroke
  8592. || (hasFillOrStroke(stroke) ? liftColor(stroke) : null);
  8593. var normalStyle = {};
  8594. for (var name in hoverStyle) {
  8595. if (hoverStyle.hasOwnProperty(name)) {
  8596. normalStyle[name] = el.style[name];
  8597. }
  8598. }
  8599. el.__normalStl = normalStyle;
  8600. el.__hoverStlDirty = false;
  8601. }
  8602. }
  8603. /**
  8604. * @private
  8605. */
  8606. function doSingleEnterHover(el) {
  8607. if (el.__isHover) {
  8608. return;
  8609. }
  8610. cacheElementStl(el);
  8611. el.setStyle(el.__hoverStl);
  8612. el.z2 += 1;
  8613. el.__isHover = true;
  8614. }
  8615. /**
  8616. * @inner
  8617. */
  8618. function doSingleLeaveHover(el) {
  8619. if (!el.__isHover) {
  8620. return;
  8621. }
  8622. var normalStl = el.__normalStl;
  8623. normalStl && el.setStyle(normalStl);
  8624. el.z2 -= 1;
  8625. el.__isHover = false;
  8626. }
  8627. /**
  8628. * @inner
  8629. */
  8630. function doEnterHover(el) {
  8631. el.type === 'group'
  8632. ? el.traverse(function (child) {
  8633. if (child.type !== 'group') {
  8634. doSingleEnterHover(child);
  8635. }
  8636. })
  8637. : doSingleEnterHover(el);
  8638. }
  8639. function doLeaveHover(el) {
  8640. el.type === 'group'
  8641. ? el.traverse(function (child) {
  8642. if (child.type !== 'group') {
  8643. doSingleLeaveHover(child);
  8644. }
  8645. })
  8646. : doSingleLeaveHover(el);
  8647. }
  8648. /**
  8649. * @inner
  8650. */
  8651. function setElementHoverStl(el, hoverStl) {
  8652. // If element has sepcified hoverStyle, then use it instead of given hoverStyle
  8653. // Often used when item group has a label element and it's hoverStyle is different
  8654. el.__hoverStl = el.hoverStyle || hoverStl || {};
  8655. el.__hoverStlDirty = true;
  8656. if (el.__isHover) {
  8657. cacheElementStl(el);
  8658. }
  8659. }
  8660. /**
  8661. * @inner
  8662. */
  8663. function onElementMouseOver() {
  8664. // Only if element is not in emphasis status
  8665. !this.__isEmphasis && doEnterHover(this);
  8666. }
  8667. /**
  8668. * @inner
  8669. */
  8670. function onElementMouseOut() {
  8671. // Only if element is not in emphasis status
  8672. !this.__isEmphasis && doLeaveHover(this);
  8673. }
  8674. /**
  8675. * @inner
  8676. */
  8677. function enterEmphasis() {
  8678. this.__isEmphasis = true;
  8679. doEnterHover(this);
  8680. }
  8681. /**
  8682. * @inner
  8683. */
  8684. function leaveEmphasis() {
  8685. this.__isEmphasis = false;
  8686. doLeaveHover(this);
  8687. }
  8688. /**
  8689. * Set hover style of element
  8690. * @param {module:zrender/Element} el
  8691. * @param {Object} [hoverStyle]
  8692. */
  8693. graphic.setHoverStyle = function (el, hoverStyle) {
  8694. el.type === 'group'
  8695. ? el.traverse(function (child) {
  8696. if (child.type !== 'group') {
  8697. setElementHoverStl(child, hoverStyle);
  8698. }
  8699. })
  8700. : setElementHoverStl(el, hoverStyle);
  8701. // Remove previous bound handlers
  8702. el.on('mouseover', onElementMouseOver)
  8703. .on('mouseout', onElementMouseOut);
  8704. // Emphasis, normal can be triggered manually
  8705. el.on('emphasis', enterEmphasis)
  8706. .on('normal', leaveEmphasis);
  8707. };
  8708. /**
  8709. * Set text option in the style
  8710. * @param {Object} textStyle
  8711. * @param {module:echarts/model/Model} labelModel
  8712. * @param {string} color
  8713. */
  8714. graphic.setText = function (textStyle, labelModel, color) {
  8715. var labelPosition = labelModel.getShallow('position') || 'inside';
  8716. var labelColor = labelPosition.indexOf('inside') >= 0 ? 'white' : color;
  8717. var textStyleModel = labelModel.getModel('textStyle');
  8718. zrUtil.extend(textStyle, {
  8719. textDistance: labelModel.getShallow('distance') || 5,
  8720. textFont: textStyleModel.getFont(),
  8721. textPosition: labelPosition,
  8722. textFill: textStyleModel.getTextColor() || labelColor
  8723. });
  8724. };
  8725. function animateOrSetProps(isUpdate, el, props, animatableModel, dataIndex, cb) {
  8726. if (typeof dataIndex === 'function') {
  8727. cb = dataIndex;
  8728. dataIndex = null;
  8729. }
  8730. var postfix = isUpdate ? 'Update' : '';
  8731. var duration = animatableModel
  8732. && animatableModel.getShallow('animationDuration' + postfix);
  8733. var animationEasing = animatableModel
  8734. && animatableModel.getShallow('animationEasing' + postfix);
  8735. var animationDelay = animatableModel
  8736. && animatableModel.getShallow('animationDelay' + postfix);
  8737. if (typeof animationDelay === 'function') {
  8738. animationDelay = animationDelay(dataIndex);
  8739. }
  8740. animatableModel && animatableModel.getShallow('animation')
  8741. ? el.animateTo(props, duration, animationDelay || 0, animationEasing, cb)
  8742. : (el.attr(props), cb && cb());
  8743. }
  8744. /**
  8745. * Update graphic element properties with or without animation according to the configuration in series
  8746. * @param {module:zrender/Element} el
  8747. * @param {Object} props
  8748. * @param {module:echarts/model/Model} [animatableModel]
  8749. * @param {number} [dataIndex]
  8750. * @param {Function} [cb]
  8751. * @example
  8752. * graphic.updateProps(el, {
  8753. * position: [100, 100]
  8754. * }, seriesModel, dataIndex, function () { console.log('Animation done!'); });
  8755. * // Or
  8756. * graphic.updateProps(el, {
  8757. * position: [100, 100]
  8758. * }, seriesModel, function () { console.log('Animation done!'); });
  8759. */
  8760. graphic.updateProps = zrUtil.curry(animateOrSetProps, true);
  8761. /**
  8762. * Init graphic element properties with or without animation according to the configuration in series
  8763. * @param {module:zrender/Element} el
  8764. * @param {Object} props
  8765. * @param {module:echarts/model/Model} [animatableModel]
  8766. * @param {Function} cb
  8767. */
  8768. graphic.initProps = zrUtil.curry(animateOrSetProps, false);
  8769. /**
  8770. * Get transform matrix of target (param target),
  8771. * in coordinate of its ancestor (param ancestor)
  8772. *
  8773. * @param {module:zrender/mixin/Transformable} target
  8774. * @param {module:zrender/mixin/Transformable} [ancestor]
  8775. */
  8776. graphic.getTransform = function (target, ancestor) {
  8777. var mat = matrix.identity([]);
  8778. while (target && target !== ancestor) {
  8779. matrix.mul(mat, target.getLocalTransform(), mat);
  8780. target = target.parent;
  8781. }
  8782. return mat;
  8783. };
  8784. /**
  8785. * Apply transform to an vertex.
  8786. * @param {Array.<number>} vertex [x, y]
  8787. * @param {Array.<number>} transform Transform matrix: like [1, 0, 0, 1, 0, 0]
  8788. * @param {boolean=} invert Whether use invert matrix.
  8789. * @return {Array.<number>} [x, y]
  8790. */
  8791. graphic.applyTransform = function (vertex, transform, invert) {
  8792. if (invert) {
  8793. transform = matrix.invert([], transform);
  8794. }
  8795. return vector.applyTransform([], vertex, transform);
  8796. };
  8797. /**
  8798. * @param {string} direction 'left' 'right' 'top' 'bottom'
  8799. * @param {Array.<number>} transform Transform matrix: like [1, 0, 0, 1, 0, 0]
  8800. * @param {boolean=} invert Whether use invert matrix.
  8801. * @return {string} Transformed direction. 'left' 'right' 'top' 'bottom'
  8802. */
  8803. graphic.transformDirection = function (direction, transform, invert) {
  8804. // Pick a base, ensure that transform result will not be (0, 0).
  8805. var hBase = (transform[4] === 0 || transform[5] === 0 || transform[0] === 0)
  8806. ? 1 : Math.abs(2 * transform[4] / transform[0]);
  8807. var vBase = (transform[4] === 0 || transform[5] === 0 || transform[2] === 0)
  8808. ? 1 : Math.abs(2 * transform[4] / transform[2]);
  8809. var vertex = [
  8810. direction === 'left' ? -hBase : direction === 'right' ? hBase : 0,
  8811. direction === 'top' ? -vBase : direction === 'bottom' ? vBase : 0
  8812. ];
  8813. vertex = graphic.applyTransform(vertex, transform, invert);
  8814. return Math.abs(vertex[0]) > Math.abs(vertex[1])
  8815. ? (vertex[0] > 0 ? 'right' : 'left')
  8816. : (vertex[1] > 0 ? 'bottom' : 'top');
  8817. };
  8818. module.exports = graphic;
  8819. /***/ },
  8820. /* 43 */
  8821. /***/ function(module, exports, __webpack_require__) {
  8822. var Path = __webpack_require__(44);
  8823. var PathProxy = __webpack_require__(48);
  8824. var transformPath = __webpack_require__(58);
  8825. var matrix = __webpack_require__(17);
  8826. // command chars
  8827. var cc = [
  8828. 'm', 'M', 'l', 'L', 'v', 'V', 'h', 'H', 'z', 'Z',
  8829. 'c', 'C', 'q', 'Q', 't', 'T', 's', 'S', 'a', 'A'
  8830. ];
  8831. var mathSqrt = Math.sqrt;
  8832. var mathSin = Math.sin;
  8833. var mathCos = Math.cos;
  8834. var PI = Math.PI;
  8835. var vMag = function(v) {
  8836. return Math.sqrt(v[0] * v[0] + v[1] * v[1]);
  8837. };
  8838. var vRatio = function(u, v) {
  8839. return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v));
  8840. };
  8841. var vAngle = function(u, v) {
  8842. return (u[0] * v[1] < u[1] * v[0] ? -1 : 1)
  8843. * Math.acos(vRatio(u, v));
  8844. };
  8845. function processArc(x1, y1, x2, y2, fa, fs, rx, ry, psiDeg, cmd, path) {
  8846. var psi = psiDeg * (PI / 180.0);
  8847. var xp = mathCos(psi) * (x1 - x2) / 2.0
  8848. + mathSin(psi) * (y1 - y2) / 2.0;
  8849. var yp = -1 * mathSin(psi) * (x1 - x2) / 2.0
  8850. + mathCos(psi) * (y1 - y2) / 2.0;
  8851. var lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry);
  8852. if (lambda > 1) {
  8853. rx *= mathSqrt(lambda);
  8854. ry *= mathSqrt(lambda);
  8855. }
  8856. var f = (fa === fs ? -1 : 1)
  8857. * mathSqrt((((rx * rx) * (ry * ry))
  8858. - ((rx * rx) * (yp * yp))
  8859. - ((ry * ry) * (xp * xp))) / ((rx * rx) * (yp * yp)
  8860. + (ry * ry) * (xp * xp))
  8861. ) || 0;
  8862. var cxp = f * rx * yp / ry;
  8863. var cyp = f * -ry * xp / rx;
  8864. var cx = (x1 + x2) / 2.0
  8865. + mathCos(psi) * cxp
  8866. - mathSin(psi) * cyp;
  8867. var cy = (y1 + y2) / 2.0
  8868. + mathSin(psi) * cxp
  8869. + mathCos(psi) * cyp;
  8870. var theta = vAngle([ 1, 0 ], [ (xp - cxp) / rx, (yp - cyp) / ry ]);
  8871. var u = [ (xp - cxp) / rx, (yp - cyp) / ry ];
  8872. var v = [ (-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry ];
  8873. var dTheta = vAngle(u, v);
  8874. if (vRatio(u, v) <= -1) {
  8875. dTheta = PI;
  8876. }
  8877. if (vRatio(u, v) >= 1) {
  8878. dTheta = 0;
  8879. }
  8880. if (fs === 0 && dTheta > 0) {
  8881. dTheta = dTheta - 2 * PI;
  8882. }
  8883. if (fs === 1 && dTheta < 0) {
  8884. dTheta = dTheta + 2 * PI;
  8885. }
  8886. path.addData(cmd, cx, cy, rx, ry, theta, dTheta, psi, fs);
  8887. }
  8888. function createPathProxyFromString(data) {
  8889. if (!data) {
  8890. return [];
  8891. }
  8892. // command string
  8893. var cs = data.replace(/-/g, ' -')
  8894. .replace(/ /g, ' ')
  8895. .replace(/ /g, ',')
  8896. .replace(/,,/g, ',');
  8897. var n;
  8898. // create pipes so that we can split the data
  8899. for (n = 0; n < cc.length; n++) {
  8900. cs = cs.replace(new RegExp(cc[n], 'g'), '|' + cc[n]);
  8901. }
  8902. // create array
  8903. var arr = cs.split('|');
  8904. // init context point
  8905. var cpx = 0;
  8906. var cpy = 0;
  8907. var path = new PathProxy();
  8908. var CMD = PathProxy.CMD;
  8909. var prevCmd;
  8910. for (n = 1; n < arr.length; n++) {
  8911. var str = arr[n];
  8912. var c = str.charAt(0);
  8913. var off = 0;
  8914. var p = str.slice(1).replace(/e,-/g, 'e-').split(',');
  8915. var cmd;
  8916. if (p.length > 0 && p[0] === '') {
  8917. p.shift();
  8918. }
  8919. for (var i = 0; i < p.length; i++) {
  8920. p[i] = parseFloat(p[i]);
  8921. }
  8922. while (off < p.length && !isNaN(p[off])) {
  8923. if (isNaN(p[0])) {
  8924. break;
  8925. }
  8926. var ctlPtx;
  8927. var ctlPty;
  8928. var rx;
  8929. var ry;
  8930. var psi;
  8931. var fa;
  8932. var fs;
  8933. var x1 = cpx;
  8934. var y1 = cpy;
  8935. // convert l, H, h, V, and v to L
  8936. switch (c) {
  8937. case 'l':
  8938. cpx += p[off++];
  8939. cpy += p[off++];
  8940. cmd = CMD.L;
  8941. path.addData(cmd, cpx, cpy);
  8942. break;
  8943. case 'L':
  8944. cpx = p[off++];
  8945. cpy = p[off++];
  8946. cmd = CMD.L;
  8947. path.addData(cmd, cpx, cpy);
  8948. break;
  8949. case 'm':
  8950. cpx += p[off++];
  8951. cpy += p[off++];
  8952. cmd = CMD.M;
  8953. path.addData(cmd, cpx, cpy);
  8954. c = 'l';
  8955. break;
  8956. case 'M':
  8957. cpx = p[off++];
  8958. cpy = p[off++];
  8959. cmd = CMD.M;
  8960. path.addData(cmd, cpx, cpy);
  8961. c = 'L';
  8962. break;
  8963. case 'h':
  8964. cpx += p[off++];
  8965. cmd = CMD.L;
  8966. path.addData(cmd, cpx, cpy);
  8967. break;
  8968. case 'H':
  8969. cpx = p[off++];
  8970. cmd = CMD.L;
  8971. path.addData(cmd, cpx, cpy);
  8972. break;
  8973. case 'v':
  8974. cpy += p[off++];
  8975. cmd = CMD.L;
  8976. path.addData(cmd, cpx, cpy);
  8977. break;
  8978. case 'V':
  8979. cpy = p[off++];
  8980. cmd = CMD.L;
  8981. path.addData(cmd, cpx, cpy);
  8982. break;
  8983. case 'C':
  8984. cmd = CMD.C;
  8985. path.addData(
  8986. cmd, p[off++], p[off++], p[off++], p[off++], p[off++], p[off++]
  8987. );
  8988. cpx = p[off - 2];
  8989. cpy = p[off - 1];
  8990. break;
  8991. case 'c':
  8992. cmd = CMD.C;
  8993. path.addData(
  8994. cmd,
  8995. p[off++] + cpx, p[off++] + cpy,
  8996. p[off++] + cpx, p[off++] + cpy,
  8997. p[off++] + cpx, p[off++] + cpy
  8998. );
  8999. cpx += p[off - 2];
  9000. cpy += p[off - 1];
  9001. break;
  9002. case 'S':
  9003. ctlPtx = cpx;
  9004. ctlPty = cpy;
  9005. var len = path.len();
  9006. var pathData = path.data;
  9007. if (prevCmd === CMD.C) {
  9008. ctlPtx += cpx - pathData[len - 4];
  9009. ctlPty += cpy - pathData[len - 3];
  9010. }
  9011. cmd = CMD.C;
  9012. x1 = p[off++];
  9013. y1 = p[off++];
  9014. cpx = p[off++];
  9015. cpy = p[off++];
  9016. path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy);
  9017. break;
  9018. case 's':
  9019. ctlPtx = cpx;
  9020. ctlPty = cpy;
  9021. var len = path.len();
  9022. var pathData = path.data;
  9023. if (prevCmd === CMD.C) {
  9024. ctlPtx += cpx - pathData[len - 4];
  9025. ctlPty += cpy - pathData[len - 3];
  9026. }
  9027. cmd = CMD.C;
  9028. x1 = cpx + p[off++];
  9029. y1 = cpy + p[off++];
  9030. cpx += p[off++];
  9031. cpy += p[off++];
  9032. path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy);
  9033. break;
  9034. case 'Q':
  9035. x1 = p[off++];
  9036. y1 = p[off++];
  9037. cpx = p[off++];
  9038. cpy = p[off++];
  9039. cmd = CMD.Q;
  9040. path.addData(cmd, x1, y1, cpx, cpy);
  9041. break;
  9042. case 'q':
  9043. x1 = p[off++] + cpx;
  9044. y1 = p[off++] + cpy;
  9045. cpx += p[off++];
  9046. cpy += p[off++];
  9047. cmd = CMD.Q;
  9048. path.addData(cmd, x1, y1, cpx, cpy);
  9049. break;
  9050. case 'T':
  9051. ctlPtx = cpx;
  9052. ctlPty = cpy;
  9053. var len = path.len();
  9054. var pathData = path.data;
  9055. if (prevCmd === CMD.Q) {
  9056. ctlPtx += cpx - pathData[len - 4];
  9057. ctlPty += cpy - pathData[len - 3];
  9058. }
  9059. cpx = p[off++];
  9060. cpy = p[off++];
  9061. cmd = CMD.Q;
  9062. path.addData(cmd, ctlPtx, ctlPty, cpx, cpy);
  9063. break;
  9064. case 't':
  9065. ctlPtx = cpx;
  9066. ctlPty = cpy;
  9067. var len = path.len();
  9068. var pathData = path.data;
  9069. if (prevCmd === CMD.Q) {
  9070. ctlPtx += cpx - pathData[len - 4];
  9071. ctlPty += cpy - pathData[len - 3];
  9072. }
  9073. cpx += p[off++];
  9074. cpy += p[off++];
  9075. cmd = CMD.Q;
  9076. path.addData(cmd, ctlPtx, ctlPty, cpx, cpy);
  9077. break;
  9078. case 'A':
  9079. rx = p[off++];
  9080. ry = p[off++];
  9081. psi = p[off++];
  9082. fa = p[off++];
  9083. fs = p[off++];
  9084. x1 = cpx, y1 = cpy;
  9085. cpx = p[off++];
  9086. cpy = p[off++];
  9087. cmd = CMD.A;
  9088. processArc(
  9089. x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path
  9090. );
  9091. break;
  9092. case 'a':
  9093. rx = p[off++];
  9094. ry = p[off++];
  9095. psi = p[off++];
  9096. fa = p[off++];
  9097. fs = p[off++];
  9098. x1 = cpx, y1 = cpy;
  9099. cpx += p[off++];
  9100. cpy += p[off++];
  9101. cmd = CMD.A;
  9102. processArc(
  9103. x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path
  9104. );
  9105. break;
  9106. }
  9107. }
  9108. if (c === 'z' || c === 'Z') {
  9109. cmd = CMD.Z;
  9110. path.addData(cmd);
  9111. }
  9112. prevCmd = cmd;
  9113. }
  9114. path.toStatic();
  9115. return path;
  9116. }
  9117. // TODO Optimize double memory cost problem
  9118. function createPathOptions(str, opts) {
  9119. var pathProxy = createPathProxyFromString(str);
  9120. var transform;
  9121. opts = opts || {};
  9122. opts.buildPath = function (path) {
  9123. path.setData(pathProxy.data);
  9124. transform && transformPath(path, transform);
  9125. // Svg and vml renderer don't have context
  9126. var ctx = path.getContext();
  9127. if (ctx) {
  9128. path.rebuildPath(ctx);
  9129. }
  9130. };
  9131. opts.applyTransform = function (m) {
  9132. if (!transform) {
  9133. transform = matrix.create();
  9134. }
  9135. matrix.mul(transform, m, transform);
  9136. };
  9137. return opts;
  9138. }
  9139. module.exports = {
  9140. /**
  9141. * Create a Path object from path string data
  9142. * http://www.w3.org/TR/SVG/paths.html#PathData
  9143. * @param {Object} opts Other options
  9144. */
  9145. createFromString: function (str, opts) {
  9146. return new Path(createPathOptions(str, opts));
  9147. },
  9148. /**
  9149. * Create a Path class from path string data
  9150. * @param {string} str
  9151. * @param {Object} opts Other options
  9152. */
  9153. extendFromString: function (str, opts) {
  9154. return Path.extend(createPathOptions(str, opts));
  9155. },
  9156. /**
  9157. * Merge multiple paths
  9158. */
  9159. // TODO Apply transform
  9160. // TODO stroke dash
  9161. // TODO Optimize double memory cost problem
  9162. mergePath: function (pathEls, opts) {
  9163. var pathList = [];
  9164. var len = pathEls.length;
  9165. var pathEl;
  9166. var i;
  9167. for (i = 0; i < len; i++) {
  9168. pathEl = pathEls[i];
  9169. if (pathEl.__dirty) {
  9170. pathEl.buildPath(pathEl.path, pathEl.shape);
  9171. }
  9172. pathList.push(pathEl.path);
  9173. }
  9174. var pathBundle = new Path(opts);
  9175. pathBundle.buildPath = function (path) {
  9176. path.appendPath(pathList);
  9177. // Svg and vml renderer don't have context
  9178. var ctx = path.getContext();
  9179. if (ctx) {
  9180. path.rebuildPath(ctx);
  9181. }
  9182. };
  9183. return pathBundle;
  9184. }
  9185. };
  9186. /***/ },
  9187. /* 44 */
  9188. /***/ function(module, exports, __webpack_require__) {
  9189. /**
  9190. * Path element
  9191. * @module zrender/graphic/Path
  9192. */
  9193. var Displayable = __webpack_require__(45);
  9194. var zrUtil = __webpack_require__(3);
  9195. var PathProxy = __webpack_require__(48);
  9196. var pathContain = __webpack_require__(51);
  9197. var Gradient = __webpack_require__(4);
  9198. function pathHasFill(style) {
  9199. var fill = style.fill;
  9200. return fill != null && fill !== 'none';
  9201. }
  9202. function pathHasStroke(style) {
  9203. var stroke = style.stroke;
  9204. return stroke != null && stroke !== 'none' && style.lineWidth > 0;
  9205. }
  9206. var abs = Math.abs;
  9207. /**
  9208. * @alias module:zrender/graphic/Path
  9209. * @extends module:zrender/graphic/Displayable
  9210. * @constructor
  9211. * @param {Object} opts
  9212. */
  9213. function Path(opts) {
  9214. Displayable.call(this, opts);
  9215. /**
  9216. * @type {module:zrender/core/PathProxy}
  9217. * @readOnly
  9218. */
  9219. this.path = new PathProxy();
  9220. }
  9221. Path.prototype = {
  9222. constructor: Path,
  9223. type: 'path',
  9224. __dirtyPath: true,
  9225. strokeContainThreshold: 5,
  9226. brush: function (ctx) {
  9227. ctx.save();
  9228. var style = this.style;
  9229. var path = this.path;
  9230. var hasStroke = pathHasStroke(style);
  9231. var hasFill = pathHasFill(style);
  9232. var hasFillGradient = hasFill && !!(style.fill.colorStops);
  9233. var hasStrokeGradient = hasStroke && !!(style.stroke.colorStops);
  9234. style.bind(ctx, this);
  9235. this.setTransform(ctx);
  9236. if (this.__dirtyPath) {
  9237. var rect = this.getBoundingRect();
  9238. // Update gradient because bounding rect may changed
  9239. if (hasFillGradient) {
  9240. this._fillGradient = style.getGradient(ctx, style.fill, rect);
  9241. }
  9242. if (hasStrokeGradient) {
  9243. this._strokeGradient = style.getGradient(ctx, style.stroke, rect);
  9244. }
  9245. }
  9246. // Use the gradient
  9247. if (hasFillGradient) {
  9248. ctx.fillStyle = this._fillGradient;
  9249. }
  9250. if (hasStrokeGradient) {
  9251. ctx.strokeStyle = this._strokeGradient;
  9252. }
  9253. var lineDash = style.lineDash;
  9254. var lineDashOffset = style.lineDashOffset;
  9255. var ctxLineDash = !!ctx.setLineDash;
  9256. // Update path sx, sy
  9257. var scale = this.getGlobalScale();
  9258. path.setScale(scale[0], scale[1]);
  9259. // Proxy context
  9260. // Rebuild path in following 2 cases
  9261. // 1. Path is dirty
  9262. // 2. Path needs javascript implemented lineDash stroking.
  9263. // In this case, lineDash information will not be saved in PathProxy
  9264. if (this.__dirtyPath || (
  9265. lineDash && !ctxLineDash && hasStroke
  9266. )) {
  9267. path = this.path.beginPath(ctx);
  9268. // Setting line dash before build path
  9269. if (lineDash && !ctxLineDash) {
  9270. path.setLineDash(lineDash);
  9271. path.setLineDashOffset(lineDashOffset);
  9272. }
  9273. this.buildPath(path, this.shape);
  9274. // Clear path dirty flag
  9275. this.__dirtyPath = false;
  9276. }
  9277. else {
  9278. // Replay path building
  9279. ctx.beginPath();
  9280. this.path.rebuildPath(ctx);
  9281. }
  9282. hasFill && path.fill(ctx);
  9283. if (lineDash && ctxLineDash) {
  9284. ctx.setLineDash(lineDash);
  9285. ctx.lineDashOffset = lineDashOffset;
  9286. }
  9287. hasStroke && path.stroke(ctx);
  9288. // Draw rect text
  9289. if (style.text != null) {
  9290. // var rect = this.getBoundingRect();
  9291. this.drawRectText(ctx, this.getBoundingRect());
  9292. }
  9293. ctx.restore();
  9294. },
  9295. buildPath: function (ctx, shapeCfg) {},
  9296. getBoundingRect: function () {
  9297. var rect = this._rect;
  9298. var style = this.style;
  9299. var needsUpdateRect = !rect;
  9300. if (needsUpdateRect) {
  9301. var path = this.path;
  9302. if (this.__dirtyPath) {
  9303. path.beginPath();
  9304. this.buildPath(path, this.shape);
  9305. }
  9306. rect = path.getBoundingRect();
  9307. }
  9308. this._rect = rect;
  9309. if (pathHasStroke(style)) {
  9310. // Needs update rect with stroke lineWidth when
  9311. // 1. Element changes scale or lineWidth
  9312. // 2. Shape is changed
  9313. var rectWithStroke = this._rectWithStroke || (this._rectWithStroke = rect.clone());
  9314. if (this.__dirty || needsUpdateRect) {
  9315. rectWithStroke.copy(rect);
  9316. // FIXME Must after updateTransform
  9317. var w = style.lineWidth;
  9318. // PENDING, Min line width is needed when line is horizontal or vertical
  9319. var lineScale = style.strokeNoScale ? this.getLineScale() : 1;
  9320. // Only add extra hover lineWidth when there are no fill
  9321. if (!pathHasFill(style)) {
  9322. w = Math.max(w, this.strokeContainThreshold);
  9323. }
  9324. // Consider line width
  9325. // Line scale can't be 0;
  9326. if (lineScale > 1e-10) {
  9327. rectWithStroke.width += w / lineScale;
  9328. rectWithStroke.height += w / lineScale;
  9329. rectWithStroke.x -= w / lineScale / 2;
  9330. rectWithStroke.y -= w / lineScale / 2;
  9331. }
  9332. }
  9333. // Return rect with stroke
  9334. return rectWithStroke;
  9335. }
  9336. return rect;
  9337. },
  9338. contain: function (x, y) {
  9339. var localPos = this.transformCoordToLocal(x, y);
  9340. var rect = this.getBoundingRect();
  9341. var style = this.style;
  9342. x = localPos[0];
  9343. y = localPos[1];
  9344. if (rect.contain(x, y)) {
  9345. var pathData = this.path.data;
  9346. if (pathHasStroke(style)) {
  9347. var lineWidth = style.lineWidth;
  9348. var lineScale = style.strokeNoScale ? this.getLineScale() : 1;
  9349. // Line scale can't be 0;
  9350. if (lineScale > 1e-10) {
  9351. // Only add extra hover lineWidth when there are no fill
  9352. if (!pathHasFill(style)) {
  9353. lineWidth = Math.max(lineWidth, this.strokeContainThreshold);
  9354. }
  9355. if (pathContain.containStroke(
  9356. pathData, lineWidth / lineScale, x, y
  9357. )) {
  9358. return true;
  9359. }
  9360. }
  9361. }
  9362. if (pathHasFill(style)) {
  9363. return pathContain.contain(pathData, x, y);
  9364. }
  9365. }
  9366. return false;
  9367. },
  9368. /**
  9369. * @param {boolean} dirtyPath
  9370. */
  9371. dirty: function (dirtyPath) {
  9372. if (arguments.length ===0) {
  9373. dirtyPath = true;
  9374. }
  9375. // Only mark dirty, not mark clean
  9376. if (dirtyPath) {
  9377. this.__dirtyPath = dirtyPath;
  9378. this._rect = null;
  9379. }
  9380. this.__dirty = true;
  9381. this.__zr && this.__zr.refresh();
  9382. // Used as a clipping path
  9383. if (this.__clipTarget) {
  9384. this.__clipTarget.dirty();
  9385. }
  9386. },
  9387. /**
  9388. * Alias for animate('shape')
  9389. * @param {boolean} loop
  9390. */
  9391. animateShape: function (loop) {
  9392. return this.animate('shape', loop);
  9393. },
  9394. // Overwrite attrKV
  9395. attrKV: function (key, value) {
  9396. // FIXME
  9397. if (key === 'shape') {
  9398. this.setShape(value);
  9399. }
  9400. else {
  9401. Displayable.prototype.attrKV.call(this, key, value);
  9402. }
  9403. },
  9404. /**
  9405. * @param {Object|string} key
  9406. * @param {*} value
  9407. */
  9408. setShape: function (key, value) {
  9409. var shape = this.shape;
  9410. // Path from string may not have shape
  9411. if (shape) {
  9412. if (zrUtil.isObject(key)) {
  9413. for (var name in key) {
  9414. shape[name] = key[name];
  9415. }
  9416. }
  9417. else {
  9418. shape[key] = value;
  9419. }
  9420. this.dirty(true);
  9421. }
  9422. return this;
  9423. },
  9424. getLineScale: function () {
  9425. var m = this.transform;
  9426. // Get the line scale.
  9427. // Determinant of `m` means how much the area is enlarged by the
  9428. // transformation. So its square root can be used as a scale factor
  9429. // for width.
  9430. return m && abs(m[0] - 1) > 1e-10 && abs(m[3] - 1) > 1e-10
  9431. ? Math.sqrt(abs(m[0] * m[3] - m[2] * m[1]))
  9432. : 1;
  9433. }
  9434. };
  9435. /**
  9436. * 扩展一个 Path element, 比如星形,圆等。
  9437. * Extend a path element
  9438. * @param {Object} props
  9439. * @param {string} props.type Path type
  9440. * @param {Function} props.init Initialize
  9441. * @param {Function} props.buildPath Overwrite buildPath method
  9442. * @param {Object} [props.style] Extended default style config
  9443. * @param {Object} [props.shape] Extended default shape config
  9444. */
  9445. Path.extend = function (defaults) {
  9446. var Sub = function (opts) {
  9447. Path.call(this, opts);
  9448. if (defaults.style) {
  9449. // Extend default style
  9450. this.style.extendFrom(defaults.style, false);
  9451. }
  9452. // Extend default shape
  9453. var defaultShape = defaults.shape;
  9454. if (defaultShape) {
  9455. this.shape = this.shape || {};
  9456. var thisShape = this.shape;
  9457. for (var name in defaultShape) {
  9458. if (
  9459. ! thisShape.hasOwnProperty(name)
  9460. && defaultShape.hasOwnProperty(name)
  9461. ) {
  9462. thisShape[name] = defaultShape[name];
  9463. }
  9464. }
  9465. }
  9466. defaults.init && defaults.init.call(this, opts);
  9467. };
  9468. zrUtil.inherits(Sub, Path);
  9469. // FIXME 不能 extend position, rotation 等引用对象
  9470. for (var name in defaults) {
  9471. // Extending prototype values and methods
  9472. if (name !== 'style' && name !== 'shape') {
  9473. Sub.prototype[name] = defaults[name];
  9474. }
  9475. }
  9476. return Sub;
  9477. };
  9478. zrUtil.inherits(Path, Displayable);
  9479. module.exports = Path;
  9480. /***/ },
  9481. /* 45 */
  9482. /***/ function(module, exports, __webpack_require__) {
  9483. /**
  9484. * 可绘制的图形基类
  9485. * Base class of all displayable graphic objects
  9486. * @module zrender/graphic/Displayable
  9487. */
  9488. var zrUtil = __webpack_require__(3);
  9489. var Style = __webpack_require__(46);
  9490. var Element = __webpack_require__(30);
  9491. var RectText = __webpack_require__(47);
  9492. // var Stateful = require('./mixin/Stateful');
  9493. /**
  9494. * @alias module:zrender/graphic/Displayable
  9495. * @extends module:zrender/Element
  9496. * @extends module:zrender/graphic/mixin/RectText
  9497. */
  9498. function Displayable(opts) {
  9499. opts = opts || {};
  9500. Element.call(this, opts);
  9501. // Extend properties
  9502. for (var name in opts) {
  9503. if (
  9504. opts.hasOwnProperty(name) &&
  9505. name !== 'style'
  9506. ) {
  9507. this[name] = opts[name];
  9508. }
  9509. }
  9510. /**
  9511. * @type {module:zrender/graphic/Style}
  9512. */
  9513. this.style = new Style(opts.style);
  9514. this._rect = null;
  9515. // Shapes for cascade clipping.
  9516. this.__clipPaths = [];
  9517. // FIXME Stateful must be mixined after style is setted
  9518. // Stateful.call(this, opts);
  9519. }
  9520. Displayable.prototype = {
  9521. constructor: Displayable,
  9522. type: 'displayable',
  9523. /**
  9524. * Displayable 是否为脏,Painter 中会根据该标记判断是否需要是否需要重新绘制
  9525. * Dirty flag. From which painter will determine if this displayable object needs brush
  9526. * @name module:zrender/graphic/Displayable#__dirty
  9527. * @type {boolean}
  9528. */
  9529. __dirty: true,
  9530. /**
  9531. * 图形是否可见,为true时不绘制图形,但是仍能触发鼠标事件
  9532. * If ignore drawing of the displayable object. Mouse event will still be triggered
  9533. * @name module:/zrender/graphic/Displayable#invisible
  9534. * @type {boolean}
  9535. * @default false
  9536. */
  9537. invisible: false,
  9538. /**
  9539. * @name module:/zrender/graphic/Displayable#z
  9540. * @type {number}
  9541. * @default 0
  9542. */
  9543. z: 0,
  9544. /**
  9545. * @name module:/zrender/graphic/Displayable#z
  9546. * @type {number}
  9547. * @default 0
  9548. */
  9549. z2: 0,
  9550. /**
  9551. * z层level,决定绘画在哪层canvas中
  9552. * @name module:/zrender/graphic/Displayable#zlevel
  9553. * @type {number}
  9554. * @default 0
  9555. */
  9556. zlevel: 0,
  9557. /**
  9558. * 是否可拖拽
  9559. * @name module:/zrender/graphic/Displayable#draggable
  9560. * @type {boolean}
  9561. * @default false
  9562. */
  9563. draggable: false,
  9564. /**
  9565. * 是否正在拖拽
  9566. * @name module:/zrender/graphic/Displayable#draggable
  9567. * @type {boolean}
  9568. * @default false
  9569. */
  9570. dragging: false,
  9571. /**
  9572. * 是否相应鼠标事件
  9573. * @name module:/zrender/graphic/Displayable#silent
  9574. * @type {boolean}
  9575. * @default false
  9576. */
  9577. silent: false,
  9578. /**
  9579. * If enable culling
  9580. * @type {boolean}
  9581. * @default false
  9582. */
  9583. culling: false,
  9584. /**
  9585. * Mouse cursor when hovered
  9586. * @name module:/zrender/graphic/Displayable#cursor
  9587. * @type {string}
  9588. */
  9589. cursor: 'pointer',
  9590. /**
  9591. * If hover area is bounding rect
  9592. * @name module:/zrender/graphic/Displayable#rectHover
  9593. * @type {string}
  9594. */
  9595. rectHover: false,
  9596. beforeBrush: function (ctx) {},
  9597. afterBrush: function (ctx) {},
  9598. /**
  9599. * 图形绘制方法
  9600. * @param {Canvas2DRenderingContext} ctx
  9601. */
  9602. // Interface
  9603. brush: function (ctx) {},
  9604. /**
  9605. * 获取最小包围盒
  9606. * @return {module:zrender/core/BoundingRect}
  9607. */
  9608. // Interface
  9609. getBoundingRect: function () {},
  9610. /**
  9611. * 判断坐标 x, y 是否在图形上
  9612. * If displayable element contain coord x, y
  9613. * @param {number} x
  9614. * @param {number} y
  9615. * @return {boolean}
  9616. */
  9617. contain: function (x, y) {
  9618. return this.rectContain(x, y);
  9619. },
  9620. /**
  9621. * @param {Function} cb
  9622. * @param {} context
  9623. */
  9624. traverse: function (cb, context) {
  9625. cb.call(context, this);
  9626. },
  9627. /**
  9628. * 判断坐标 x, y 是否在图形的包围盒上
  9629. * If bounding rect of element contain coord x, y
  9630. * @param {number} x
  9631. * @param {number} y
  9632. * @return {boolean}
  9633. */
  9634. rectContain: function (x, y) {
  9635. var coord = this.transformCoordToLocal(x, y);
  9636. var rect = this.getBoundingRect();
  9637. return rect.contain(coord[0], coord[1]);
  9638. },
  9639. /**
  9640. * 标记图形元素为脏,并且在下一帧重绘
  9641. * Mark displayable element dirty and refresh next frame
  9642. */
  9643. dirty: function () {
  9644. this.__dirty = true;
  9645. this._rect = null;
  9646. this.__zr && this.__zr.refresh();
  9647. },
  9648. /**
  9649. * 图形是否会触发事件
  9650. * If displayable object binded any event
  9651. * @return {boolean}
  9652. */
  9653. // TODO, 通过 bind 绑定的事件
  9654. // isSilent: function () {
  9655. // return !(
  9656. // this.hoverable || this.draggable
  9657. // || this.onmousemove || this.onmouseover || this.onmouseout
  9658. // || this.onmousedown || this.onmouseup || this.onclick
  9659. // || this.ondragenter || this.ondragover || this.ondragleave
  9660. // || this.ondrop
  9661. // );
  9662. // },
  9663. /**
  9664. * Alias for animate('style')
  9665. * @param {boolean} loop
  9666. */
  9667. animateStyle: function (loop) {
  9668. return this.animate('style', loop);
  9669. },
  9670. attrKV: function (key, value) {
  9671. if (key !== 'style') {
  9672. Element.prototype.attrKV.call(this, key, value);
  9673. }
  9674. else {
  9675. this.style.set(value);
  9676. }
  9677. },
  9678. /**
  9679. * @param {Object|string} key
  9680. * @param {*} value
  9681. */
  9682. setStyle: function (key, value) {
  9683. this.style.set(key, value);
  9684. this.dirty(false);
  9685. return this;
  9686. },
  9687. /**
  9688. * Use given style object
  9689. * @param {Object} obj
  9690. */
  9691. useStyle: function (obj) {
  9692. this.style = new Style(obj);
  9693. this.dirty(false);
  9694. return this;
  9695. }
  9696. };
  9697. zrUtil.inherits(Displayable, Element);
  9698. zrUtil.mixin(Displayable, RectText);
  9699. // zrUtil.mixin(Displayable, Stateful);
  9700. module.exports = Displayable;
  9701. /***/ },
  9702. /* 46 */
  9703. /***/ function(module, exports) {
  9704. /**
  9705. * @module zrender/graphic/Style
  9706. */
  9707. var STYLE_LIST_COMMON = [
  9708. 'lineCap', 'lineJoin', 'miterLimit',
  9709. 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY', 'shadowColor'
  9710. ];
  9711. var Style = function (opts) {
  9712. this.extendFrom(opts);
  9713. };
  9714. Style.prototype = {
  9715. constructor: Style,
  9716. /**
  9717. * @type {string}
  9718. */
  9719. fill: '#000000',
  9720. /**
  9721. * @type {string}
  9722. */
  9723. stroke: null,
  9724. /**
  9725. * @type {number}
  9726. */
  9727. opacity: 1,
  9728. /**
  9729. * @type {Array.<number>}
  9730. */
  9731. lineDash: null,
  9732. /**
  9733. * @type {number}
  9734. */
  9735. lineDashOffset: 0,
  9736. /**
  9737. * @type {number}
  9738. */
  9739. shadowBlur: 0,
  9740. /**
  9741. * @type {number}
  9742. */
  9743. shadowOffsetX: 0,
  9744. /**
  9745. * @type {number}
  9746. */
  9747. shadowOffsetY: 0,
  9748. /**
  9749. * @type {number}
  9750. */
  9751. lineWidth: 1,
  9752. /**
  9753. * If stroke ignore scale
  9754. * @type {Boolean}
  9755. */
  9756. strokeNoScale: false,
  9757. // Bounding rect text configuration
  9758. // Not affected by element transform
  9759. /**
  9760. * @type {string}
  9761. */
  9762. text: null,
  9763. /**
  9764. * @type {string}
  9765. */
  9766. textFill: '#000',
  9767. /**
  9768. * @type {string}
  9769. */
  9770. textStroke: null,
  9771. /**
  9772. * 'inside', 'left', 'right', 'top', 'bottom'
  9773. * [x, y]
  9774. * @type {string|Array.<number>}
  9775. * @default 'inside'
  9776. */
  9777. textPosition: 'inside',
  9778. /**
  9779. * @type {string}
  9780. */
  9781. textBaseline: null,
  9782. /**
  9783. * @type {string}
  9784. */
  9785. textAlign: null,
  9786. /**
  9787. * @type {string}
  9788. */
  9789. textVerticalAlign: null,
  9790. /**
  9791. * @type {number}
  9792. */
  9793. textDistance: 5,
  9794. /**
  9795. * @type {number}
  9796. */
  9797. textShadowBlur: 0,
  9798. /**
  9799. * @type {number}
  9800. */
  9801. textShadowOffsetX: 0,
  9802. /**
  9803. * @type {number}
  9804. */
  9805. textShadowOffsetY: 0,
  9806. /**
  9807. * @param {CanvasRenderingContext2D} ctx
  9808. */
  9809. bind: function (ctx, el) {
  9810. var fill = this.fill;
  9811. var stroke = this.stroke;
  9812. for (var i = 0; i < STYLE_LIST_COMMON.length; i++) {
  9813. var styleName = STYLE_LIST_COMMON[i];
  9814. if (this[styleName] != null) {
  9815. ctx[styleName] = this[styleName];
  9816. }
  9817. }
  9818. if (stroke != null) {
  9819. var lineWidth = this.lineWidth;
  9820. ctx.lineWidth = lineWidth / (
  9821. (this.strokeNoScale && el && el.getLineScale) ? el.getLineScale() : 1
  9822. );
  9823. }
  9824. // Gradient will be created and set in Path#brush. So ignore it here
  9825. if (fill != null && fill !== 'none' && !fill.colorStops) {
  9826. ctx.fillStyle = fill;
  9827. }
  9828. if (stroke != null && stroke !== 'none' && !stroke.colorStops) {
  9829. // Use canvas gradient if has
  9830. ctx.strokeStyle = stroke;
  9831. }
  9832. this.opacity != null && (ctx.globalAlpha = this.opacity);
  9833. },
  9834. /**
  9835. * Extend from other style
  9836. * @param {zrender/graphic/Style} otherStyle
  9837. * @param {boolean} overwrite
  9838. */
  9839. extendFrom: function (otherStyle, overwrite) {
  9840. if (otherStyle) {
  9841. var target = this;
  9842. for (var name in otherStyle) {
  9843. if (otherStyle.hasOwnProperty(name)
  9844. && (overwrite || ! target.hasOwnProperty(name))
  9845. ) {
  9846. target[name] = otherStyle[name];
  9847. }
  9848. }
  9849. }
  9850. },
  9851. /**
  9852. * Batch setting style with a given object
  9853. * @param {Object|string} obj
  9854. * @param {*} [obj]
  9855. */
  9856. set: function (obj, value) {
  9857. if (typeof obj === 'string') {
  9858. this[obj] = value;
  9859. }
  9860. else {
  9861. this.extendFrom(obj, true);
  9862. }
  9863. },
  9864. /**
  9865. * Clone
  9866. * @return {zrender/graphic/Style} [description]
  9867. */
  9868. clone: function () {
  9869. var newStyle = new this.constructor();
  9870. newStyle.extendFrom(this, true);
  9871. return newStyle;
  9872. },
  9873. createLinearGradient: function (ctx, obj, rect) {
  9874. // var size =
  9875. var x = obj.x * rect.width + rect.x;
  9876. var x2 = obj.x2 * rect.width + rect.x;
  9877. var y = obj.y * rect.height + rect.y;
  9878. var y2 = obj.y2 * rect.height + rect.y;
  9879. var canvasGradient = ctx.createLinearGradient(x, y, x2, y2);
  9880. return canvasGradient;
  9881. },
  9882. createRadialGradient: function (ctx, obj, rect) {
  9883. var width = rect.width;
  9884. var height = rect.height;
  9885. var min = Math.min(width, height);
  9886. var x = obj.x * width + rect.x;
  9887. var y = obj.y * height + rect.y;
  9888. var r = obj.r * min;
  9889. var canvasGradient = ctx.createRadialGradient(x, y, 0, x, y, r);
  9890. return canvasGradient;
  9891. },
  9892. getGradient: function (ctx, obj, rect) {
  9893. var method = obj.type === 'radial' ? 'createRadialGradient' : 'createLinearGradient';
  9894. var canvasGradient = this[method](ctx, obj, rect);
  9895. var colorStops = obj.colorStops;
  9896. for (var i = 0; i < colorStops.length; i++) {
  9897. canvasGradient.addColorStop(
  9898. colorStops[i].offset, colorStops[i].color
  9899. );
  9900. }
  9901. return canvasGradient;
  9902. }
  9903. };
  9904. var styleProto = Style.prototype;
  9905. var name;
  9906. var i;
  9907. for (i = 0; i < STYLE_LIST_COMMON.length; i++) {
  9908. name = STYLE_LIST_COMMON[i];
  9909. if (!(name in styleProto)) {
  9910. styleProto[name] = null;
  9911. }
  9912. }
  9913. module.exports = Style;
  9914. /***/ },
  9915. /* 47 */
  9916. /***/ function(module, exports, __webpack_require__) {
  9917. /**
  9918. * Mixin for drawing text in a element bounding rect
  9919. * @module zrender/mixin/RectText
  9920. */
  9921. var textContain = __webpack_require__(14);
  9922. var BoundingRect = __webpack_require__(15);
  9923. var tmpRect = new BoundingRect();
  9924. var RectText = function () {};
  9925. function parsePercent(value, maxValue) {
  9926. if (typeof value === 'string') {
  9927. if (value.lastIndexOf('%') >= 0) {
  9928. return parseFloat(value) / 100 * maxValue;
  9929. }
  9930. return parseFloat(value);
  9931. }
  9932. return value;
  9933. }
  9934. function setTransform(ctx, m) {
  9935. ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
  9936. }
  9937. RectText.prototype = {
  9938. constructor: RectText,
  9939. /**
  9940. * Draw text in a rect with specified position.
  9941. * @param {CanvasRenderingContext} ctx
  9942. * @param {Object} rect Displayable rect
  9943. * @return {Object} textRect Alternative precalculated text bounding rect
  9944. */
  9945. drawRectText: function (ctx, rect, textRect) {
  9946. var style = this.style;
  9947. var text = style.text;
  9948. // Convert to string
  9949. text != null && (text += '');
  9950. if (!text) {
  9951. return;
  9952. }
  9953. var x;
  9954. var y;
  9955. var textPosition = style.textPosition;
  9956. var distance = style.textDistance;
  9957. var align = style.textAlign;
  9958. var font = style.textFont || style.font;
  9959. var baseline = style.textBaseline;
  9960. var verticalAlign = style.textVerticalAlign;
  9961. textRect = textRect || textContain.getBoundingRect(text, font, align, baseline);
  9962. // Transform rect to view space
  9963. var transform = this.transform;
  9964. var invTransform = this.invTransform;
  9965. if (transform) {
  9966. tmpRect.copy(rect);
  9967. tmpRect.applyTransform(transform);
  9968. rect = tmpRect;
  9969. // Transform back
  9970. setTransform(ctx, invTransform);
  9971. }
  9972. // Text position represented by coord
  9973. if (textPosition instanceof Array) {
  9974. // Percent
  9975. x = rect.x + parsePercent(textPosition[0], rect.width);
  9976. y = rect.y + parsePercent(textPosition[1], rect.height);
  9977. align = align || 'left';
  9978. baseline = baseline || 'top';
  9979. if (verticalAlign) {
  9980. switch (verticalAlign) {
  9981. case 'middle':
  9982. y -= textRect.height / 2 - textRect.lineHeight / 2;
  9983. break;
  9984. case 'bottom':
  9985. y -= textRect.height - textRect.lineHeight / 2;
  9986. break;
  9987. default:
  9988. y += textRect.lineHeight / 2;
  9989. }
  9990. // Force bseline to be middle
  9991. baseline = 'middle';
  9992. }
  9993. }
  9994. else {
  9995. var res = textContain.adjustTextPositionOnRect(
  9996. textPosition, rect, textRect, distance
  9997. );
  9998. x = res.x;
  9999. y = res.y;
  10000. // Default align and baseline when has textPosition
  10001. align = align || res.textAlign;
  10002. baseline = baseline || res.textBaseline;
  10003. }
  10004. ctx.textAlign = align;
  10005. ctx.textBaseline = baseline;
  10006. var textFill = style.textFill;
  10007. var textStroke = style.textStroke;
  10008. textFill && (ctx.fillStyle = textFill);
  10009. textStroke && (ctx.strokeStyle = textStroke);
  10010. ctx.font = font;
  10011. // Text shadow
  10012. ctx.shadowColor = style.textShadowColor;
  10013. ctx.shadowBlur = style.textShadowBlur;
  10014. ctx.shadowOffsetX = style.textShadowOffsetX;
  10015. ctx.shadowOffsetY = style.textShadowOffsetY;
  10016. var textLines = text.split('\n');
  10017. for (var i = 0; i < textLines.length; i++) {
  10018. textFill && ctx.fillText(textLines[i], x, y);
  10019. textStroke && ctx.strokeText(textLines[i], x, y);
  10020. y += textRect.lineHeight;
  10021. }
  10022. // Transform again
  10023. transform && setTransform(ctx, transform);
  10024. }
  10025. };
  10026. module.exports = RectText;
  10027. /***/ },
  10028. /* 48 */
  10029. /***/ function(module, exports, __webpack_require__) {
  10030. 'use strict';
  10031. /**
  10032. * Path 代理,可以在`buildPath`中用于替代`ctx`, 会保存每个path操作的命令到pathCommands属性中
  10033. * 可以用于 isInsidePath 判断以及获取boundingRect
  10034. *
  10035. * @module zrender/core/PathProxy
  10036. * @author Yi Shen (http://www.github.com/pissang)
  10037. */
  10038. // TODO getTotalLength, getPointAtLength
  10039. var curve = __webpack_require__(49);
  10040. var vec2 = __webpack_require__(16);
  10041. var bbox = __webpack_require__(50);
  10042. var BoundingRect = __webpack_require__(15);
  10043. var dpr = __webpack_require__(40).devicePixelRatio;
  10044. var CMD = {
  10045. M: 1,
  10046. L: 2,
  10047. C: 3,
  10048. Q: 4,
  10049. A: 5,
  10050. Z: 6,
  10051. // Rect
  10052. R: 7
  10053. };
  10054. var min = [];
  10055. var max = [];
  10056. var min2 = [];
  10057. var max2 = [];
  10058. var mathMin = Math.min;
  10059. var mathMax = Math.max;
  10060. var mathCos = Math.cos;
  10061. var mathSin = Math.sin;
  10062. var mathSqrt = Math.sqrt;
  10063. var mathAbs = Math.abs;
  10064. var hasTypedArray = typeof Float32Array != 'undefined';
  10065. /**
  10066. * @alias module:zrender/core/PathProxy
  10067. * @constructor
  10068. */
  10069. var PathProxy = function () {
  10070. /**
  10071. * Path data. Stored as flat array
  10072. * @type {Array.<Object>}
  10073. */
  10074. this.data = [];
  10075. this._len = 0;
  10076. this._ctx = null;
  10077. this._xi = 0;
  10078. this._yi = 0;
  10079. this._x0 = 0;
  10080. this._y0 = 0;
  10081. // Unit x, Unit y. Provide for avoiding drawing that too short line segment
  10082. this._ux = 0;
  10083. this._uy = 0;
  10084. };
  10085. /**
  10086. * 快速计算Path包围盒(并不是最小包围盒)
  10087. * @return {Object}
  10088. */
  10089. PathProxy.prototype = {
  10090. constructor: PathProxy,
  10091. _lineDash: null,
  10092. _dashOffset: 0,
  10093. _dashIdx: 0,
  10094. _dashSum: 0,
  10095. /**
  10096. * @readOnly
  10097. */
  10098. setScale: function (sx, sy) {
  10099. this._ux = mathAbs(1 / dpr / sx) || 0;
  10100. this._uy = mathAbs(1 / dpr / sy) || 0;
  10101. },
  10102. getContext: function () {
  10103. return this._ctx;
  10104. },
  10105. /**
  10106. * @param {CanvasRenderingContext2D} ctx
  10107. * @return {module:zrender/core/PathProxy}
  10108. */
  10109. beginPath: function (ctx) {
  10110. this._ctx = ctx;
  10111. ctx && ctx.beginPath();
  10112. // Reset
  10113. this._len = 0;
  10114. if (this._lineDash) {
  10115. this._lineDash = null;
  10116. this._dashOffset = 0;
  10117. }
  10118. return this;
  10119. },
  10120. /**
  10121. * @param {number} x
  10122. * @param {number} y
  10123. * @return {module:zrender/core/PathProxy}
  10124. */
  10125. moveTo: function (x, y) {
  10126. this.addData(CMD.M, x, y);
  10127. this._ctx && this._ctx.moveTo(x, y);
  10128. // x0, y0, xi, yi 是记录在 _dashedXXXXTo 方法中使用
  10129. // xi, yi 记录当前点, x0, y0 在 closePath 的时候回到起始点。
  10130. // 有可能在 beginPath 之后直接调用 lineTo,这时候 x0, y0 需要
  10131. // 在 lineTo 方法中记录,这里先不考虑这种情况,dashed line 也只在 IE10- 中不支持
  10132. this._x0 = x;
  10133. this._y0 = y;
  10134. this._xi = x;
  10135. this._yi = y;
  10136. return this;
  10137. },
  10138. /**
  10139. * @param {number} x
  10140. * @param {number} y
  10141. * @return {module:zrender/core/PathProxy}
  10142. */
  10143. lineTo: function (x, y) {
  10144. var exceedUnit = mathAbs(x - this._xi) > this._ux
  10145. || mathAbs(y - this._yi) > this._uy
  10146. // Force draw the first segment
  10147. || this._len === 0;
  10148. this.addData(CMD.L, x, y);
  10149. if (this._ctx && exceedUnit) {
  10150. this._needsDash() ? this._dashedLineTo(x, y)
  10151. : this._ctx.lineTo(x, y);
  10152. }
  10153. if (exceedUnit) {
  10154. this._xi = x;
  10155. this._yi = y;
  10156. }
  10157. return this;
  10158. },
  10159. /**
  10160. * @param {number} x1
  10161. * @param {number} y1
  10162. * @param {number} x2
  10163. * @param {number} y2
  10164. * @param {number} x3
  10165. * @param {number} y3
  10166. * @return {module:zrender/core/PathProxy}
  10167. */
  10168. bezierCurveTo: function (x1, y1, x2, y2, x3, y3) {
  10169. this.addData(CMD.C, x1, y1, x2, y2, x3, y3);
  10170. if (this._ctx) {
  10171. this._needsDash() ? this._dashedBezierTo(x1, y1, x2, y2, x3, y3)
  10172. : this._ctx.bezierCurveTo(x1, y1, x2, y2, x3, y3);
  10173. }
  10174. this._xi = x3;
  10175. this._yi = y3;
  10176. return this;
  10177. },
  10178. /**
  10179. * @param {number} x1
  10180. * @param {number} y1
  10181. * @param {number} x2
  10182. * @param {number} y2
  10183. * @return {module:zrender/core/PathProxy}
  10184. */
  10185. quadraticCurveTo: function (x1, y1, x2, y2) {
  10186. this.addData(CMD.Q, x1, y1, x2, y2);
  10187. if (this._ctx) {
  10188. this._needsDash() ? this._dashedQuadraticTo(x1, y1, x2, y2)
  10189. : this._ctx.quadraticCurveTo(x1, y1, x2, y2);
  10190. }
  10191. this._xi = x2;
  10192. this._yi = y2;
  10193. return this;
  10194. },
  10195. /**
  10196. * @param {number} cx
  10197. * @param {number} cy
  10198. * @param {number} r
  10199. * @param {number} startAngle
  10200. * @param {number} endAngle
  10201. * @param {boolean} anticlockwise
  10202. * @return {module:zrender/core/PathProxy}
  10203. */
  10204. arc: function (cx, cy, r, startAngle, endAngle, anticlockwise) {
  10205. this.addData(
  10206. CMD.A, cx, cy, r, r, startAngle, endAngle - startAngle, 0, anticlockwise ? 0 : 1
  10207. );
  10208. this._ctx && this._ctx.arc(cx, cy, r, startAngle, endAngle, anticlockwise);
  10209. this._xi = mathCos(endAngle) * r + cx;
  10210. this._xi = mathSin(endAngle) * r + cx;
  10211. return this;
  10212. },
  10213. // TODO
  10214. arcTo: function (x1, y1, x2, y2, radius) {
  10215. if (this._ctx) {
  10216. this._ctx.arcTo(x1, y1, x2, y2, radius);
  10217. }
  10218. return this;
  10219. },
  10220. // TODO
  10221. rect: function (x, y, w, h) {
  10222. this._ctx && this._ctx.rect(x, y, w, h);
  10223. this.addData(CMD.R, x, y, w, h);
  10224. return this;
  10225. },
  10226. /**
  10227. * @return {module:zrender/core/PathProxy}
  10228. */
  10229. closePath: function () {
  10230. this.addData(CMD.Z);
  10231. var ctx = this._ctx;
  10232. var x0 = this._x0;
  10233. var y0 = this._y0;
  10234. if (ctx) {
  10235. this._needsDash() && this._dashedLineTo(x0, y0);
  10236. ctx.closePath();
  10237. }
  10238. this._xi = x0;
  10239. this._yi = y0;
  10240. return this;
  10241. },
  10242. /**
  10243. * Context 从外部传入,因为有可能是 rebuildPath 完之后再 fill。
  10244. * stroke 同样
  10245. * @param {CanvasRenderingContext2D} ctx
  10246. * @return {module:zrender/core/PathProxy}
  10247. */
  10248. fill: function (ctx) {
  10249. ctx && ctx.fill();
  10250. this.toStatic();
  10251. },
  10252. /**
  10253. * @param {CanvasRenderingContext2D} ctx
  10254. * @return {module:zrender/core/PathProxy}
  10255. */
  10256. stroke: function (ctx) {
  10257. ctx && ctx.stroke();
  10258. this.toStatic();
  10259. },
  10260. /**
  10261. * 必须在其它绘制命令前调用
  10262. * Must be invoked before all other path drawing methods
  10263. * @return {module:zrender/core/PathProxy}
  10264. */
  10265. setLineDash: function (lineDash) {
  10266. if (lineDash instanceof Array) {
  10267. this._lineDash = lineDash;
  10268. this._dashIdx = 0;
  10269. var lineDashSum = 0;
  10270. for (var i = 0; i < lineDash.length; i++) {
  10271. lineDashSum += lineDash[i];
  10272. }
  10273. this._dashSum = lineDashSum;
  10274. }
  10275. return this;
  10276. },
  10277. /**
  10278. * 必须在其它绘制命令前调用
  10279. * Must be invoked before all other path drawing methods
  10280. * @return {module:zrender/core/PathProxy}
  10281. */
  10282. setLineDashOffset: function (offset) {
  10283. this._dashOffset = offset;
  10284. return this;
  10285. },
  10286. /**
  10287. *
  10288. * @return {boolean}
  10289. */
  10290. len: function () {
  10291. return this._len;
  10292. },
  10293. /**
  10294. * 直接设置 Path 数据
  10295. */
  10296. setData: function (data) {
  10297. var len = data.length;
  10298. if (! (this.data && this.data.length == len) && hasTypedArray) {
  10299. this.data = new Float32Array(len);
  10300. }
  10301. for (var i = 0; i < len; i++) {
  10302. this.data[i] = data[i];
  10303. }
  10304. this._len = len;
  10305. },
  10306. /**
  10307. * 添加子路径
  10308. * @param {module:zrender/core/PathProxy|Array.<module:zrender/core/PathProxy>} path
  10309. */
  10310. appendPath: function (path) {
  10311. if (!(path instanceof Array)) {
  10312. path = [path];
  10313. }
  10314. var len = path.length;
  10315. var appendSize = 0;
  10316. var offset = this._len;
  10317. for (var i = 0; i < len; i++) {
  10318. appendSize += path[i].len();
  10319. }
  10320. if (hasTypedArray && (this.data instanceof Float32Array)) {
  10321. this.data = new Float32Array(offset + appendSize);
  10322. }
  10323. for (var i = 0; i < len; i++) {
  10324. var appendPathData = path[i].data;
  10325. for (var k = 0; k < appendPathData.length; k++) {
  10326. this.data[offset++] = appendPathData[k];
  10327. }
  10328. }
  10329. this._len = offset;
  10330. },
  10331. /**
  10332. * 填充 Path 数据。
  10333. * 尽量复用而不申明新的数组。大部分图形重绘的指令数据长度都是不变的。
  10334. */
  10335. addData: function (cmd) {
  10336. var data = this.data;
  10337. if (this._len + arguments.length > data.length) {
  10338. // 因为之前的数组已经转换成静态的 Float32Array
  10339. // 所以不够用时需要扩展一个新的动态数组
  10340. this._expandData();
  10341. data = this.data;
  10342. }
  10343. for (var i = 0; i < arguments.length; i++) {
  10344. data[this._len++] = arguments[i];
  10345. }
  10346. this._prevCmd = cmd;
  10347. },
  10348. _expandData: function () {
  10349. // Only if data is Float32Array
  10350. if (!(this.data instanceof Array)) {
  10351. var newData = [];
  10352. for (var i = 0; i < this._len; i++) {
  10353. newData[i] = this.data[i];
  10354. }
  10355. this.data = newData;
  10356. }
  10357. },
  10358. /**
  10359. * If needs js implemented dashed line
  10360. * @return {boolean}
  10361. * @private
  10362. */
  10363. _needsDash: function () {
  10364. return this._lineDash;
  10365. },
  10366. _dashedLineTo: function (x1, y1) {
  10367. var dashSum = this._dashSum;
  10368. var offset = this._dashOffset;
  10369. var lineDash = this._lineDash;
  10370. var ctx = this._ctx;
  10371. var x0 = this._xi;
  10372. var y0 = this._yi;
  10373. var dx = x1 - x0;
  10374. var dy = y1 - y0;
  10375. var dist = mathSqrt(dx * dx + dy * dy);
  10376. var x = x0;
  10377. var y = y0;
  10378. var dash;
  10379. var nDash = lineDash.length;
  10380. var idx;
  10381. dx /= dist;
  10382. dy /= dist;
  10383. if (offset < 0) {
  10384. // Convert to positive offset
  10385. offset = dashSum + offset;
  10386. }
  10387. offset %= dashSum;
  10388. x -= offset * dx;
  10389. y -= offset * dy;
  10390. while ((dx >= 0 && x <= x1) || (dx < 0 && x > x1)) {
  10391. idx = this._dashIdx;
  10392. dash = lineDash[idx];
  10393. x += dx * dash;
  10394. y += dy * dash;
  10395. this._dashIdx = (idx + 1) % nDash;
  10396. // Skip positive offset
  10397. if ((dx > 0 && x < x0) || (dx < 0 && x > x0)) {
  10398. continue;
  10399. }
  10400. ctx[idx % 2 ? 'moveTo' : 'lineTo'](
  10401. dx >= 0 ? mathMin(x, x1) : mathMax(x, x1),
  10402. dy >= 0 ? mathMin(y, y1) : mathMax(y, y1)
  10403. );
  10404. }
  10405. // Offset for next lineTo
  10406. dx = x - x1;
  10407. dy = y - y1;
  10408. this._dashOffset = -mathSqrt(dx * dx + dy * dy);
  10409. },
  10410. // Not accurate dashed line to
  10411. _dashedBezierTo: function (x1, y1, x2, y2, x3, y3) {
  10412. var dashSum = this._dashSum;
  10413. var offset = this._dashOffset;
  10414. var lineDash = this._lineDash;
  10415. var ctx = this._ctx;
  10416. var x0 = this._xi;
  10417. var y0 = this._yi;
  10418. var t;
  10419. var dx;
  10420. var dy;
  10421. var cubicAt = curve.cubicAt;
  10422. var bezierLen = 0;
  10423. var idx = this._dashIdx;
  10424. var nDash = lineDash.length;
  10425. var x;
  10426. var y;
  10427. var tmpLen = 0;
  10428. if (offset < 0) {
  10429. // Convert to positive offset
  10430. offset = dashSum + offset;
  10431. }
  10432. offset %= dashSum;
  10433. // Bezier approx length
  10434. for (t = 0; t < 1; t += 0.1) {
  10435. dx = cubicAt(x0, x1, x2, x3, t + 0.1)
  10436. - cubicAt(x0, x1, x2, x3, t);
  10437. dy = cubicAt(y0, y1, y2, y3, t + 0.1)
  10438. - cubicAt(y0, y1, y2, y3, t);
  10439. bezierLen += mathSqrt(dx * dx + dy * dy);
  10440. }
  10441. // Find idx after add offset
  10442. for (; idx < nDash; idx++) {
  10443. tmpLen += lineDash[idx];
  10444. if (tmpLen > offset) {
  10445. break;
  10446. }
  10447. }
  10448. t = (tmpLen - offset) / bezierLen;
  10449. while (t <= 1) {
  10450. x = cubicAt(x0, x1, x2, x3, t);
  10451. y = cubicAt(y0, y1, y2, y3, t);
  10452. // Use line to approximate dashed bezier
  10453. // Bad result if dash is long
  10454. idx % 2 ? ctx.moveTo(x, y)
  10455. : ctx.lineTo(x, y);
  10456. t += lineDash[idx] / bezierLen;
  10457. idx = (idx + 1) % nDash;
  10458. }
  10459. // Finish the last segment and calculate the new offset
  10460. (idx % 2 !== 0) && ctx.lineTo(x3, y3);
  10461. dx = x3 - x;
  10462. dy = y3 - y;
  10463. this._dashOffset = -mathSqrt(dx * dx + dy * dy);
  10464. },
  10465. _dashedQuadraticTo: function (x1, y1, x2, y2) {
  10466. // Convert quadratic to cubic using degree elevation
  10467. var x3 = x2;
  10468. var y3 = y2;
  10469. x2 = (x2 + 2 * x1) / 3;
  10470. y2 = (y2 + 2 * y1) / 3;
  10471. x1 = (this._xi + 2 * x1) / 3;
  10472. y1 = (this._yi + 2 * y1) / 3;
  10473. this._dashedBezierTo(x1, y1, x2, y2, x3, y3);
  10474. },
  10475. /**
  10476. * 转成静态的 Float32Array 减少堆内存占用
  10477. * Convert dynamic array to static Float32Array
  10478. */
  10479. toStatic: function () {
  10480. var data = this.data;
  10481. if (data instanceof Array) {
  10482. data.length = this._len;
  10483. if (hasTypedArray) {
  10484. this.data = new Float32Array(data);
  10485. }
  10486. }
  10487. },
  10488. /**
  10489. * @return {module:zrender/core/BoundingRect}
  10490. */
  10491. getBoundingRect: function () {
  10492. min[0] = min[1] = min2[0] = min2[1] = Number.MAX_VALUE;
  10493. max[0] = max[1] = max2[0] = max2[1] = -Number.MAX_VALUE;
  10494. var data = this.data;
  10495. var xi = 0;
  10496. var yi = 0;
  10497. var x0 = 0;
  10498. var y0 = 0;
  10499. for (var i = 0; i < data.length;) {
  10500. var cmd = data[i++];
  10501. if (i == 1) {
  10502. // 如果第一个命令是 L, C, Q
  10503. // 则 previous point 同绘制命令的第一个 point
  10504. //
  10505. // 第一个命令为 Arc 的情况下会在后面特殊处理
  10506. xi = data[i];
  10507. yi = data[i + 1];
  10508. x0 = xi;
  10509. y0 = yi;
  10510. }
  10511. switch (cmd) {
  10512. case CMD.M:
  10513. // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点
  10514. // 在 closePath 的时候使用
  10515. x0 = data[i++];
  10516. y0 = data[i++];
  10517. xi = x0;
  10518. yi = y0;
  10519. min2[0] = x0;
  10520. min2[1] = y0;
  10521. max2[0] = x0;
  10522. max2[1] = y0;
  10523. break;
  10524. case CMD.L:
  10525. bbox.fromLine(xi, yi, data[i], data[i + 1], min2, max2);
  10526. xi = data[i++];
  10527. yi = data[i++];
  10528. break;
  10529. case CMD.C:
  10530. bbox.fromCubic(
  10531. xi, yi, data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1],
  10532. min2, max2
  10533. );
  10534. xi = data[i++];
  10535. yi = data[i++];
  10536. break;
  10537. case CMD.Q:
  10538. bbox.fromQuadratic(
  10539. xi, yi, data[i++], data[i++], data[i], data[i + 1],
  10540. min2, max2
  10541. );
  10542. xi = data[i++];
  10543. yi = data[i++];
  10544. break;
  10545. case CMD.A:
  10546. // TODO Arc 判断的开销比较大
  10547. var cx = data[i++];
  10548. var cy = data[i++];
  10549. var rx = data[i++];
  10550. var ry = data[i++];
  10551. var startAngle = data[i++];
  10552. var endAngle = data[i++] + startAngle;
  10553. // TODO Arc 旋转
  10554. var psi = data[i++];
  10555. var anticlockwise = 1 - data[i++];
  10556. if (i == 1) {
  10557. // 直接使用 arc 命令
  10558. // 第一个命令起点还未定义
  10559. x0 = mathCos(startAngle) * rx + cx;
  10560. y0 = mathSin(startAngle) * ry + cy;
  10561. }
  10562. bbox.fromArc(
  10563. cx, cy, rx, ry, startAngle, endAngle,
  10564. anticlockwise, min2, max2
  10565. );
  10566. xi = mathCos(endAngle) * rx + cx;
  10567. yi = mathSin(endAngle) * ry + cy;
  10568. break;
  10569. case CMD.R:
  10570. x0 = xi = data[i++];
  10571. y0 = yi = data[i++];
  10572. var width = data[i++];
  10573. var height = data[i++];
  10574. // Use fromLine
  10575. bbox.fromLine(x0, y0, x0 + width, y0 + height, min2, max2);
  10576. break;
  10577. case CMD.Z:
  10578. xi = x0;
  10579. yi = y0;
  10580. break;
  10581. }
  10582. // Union
  10583. vec2.min(min, min, min2);
  10584. vec2.max(max, max, max2);
  10585. }
  10586. // No data
  10587. if (i === 0) {
  10588. min[0] = min[1] = max[0] = max[1] = 0;
  10589. }
  10590. return new BoundingRect(
  10591. min[0], min[1], max[0] - min[0], max[1] - min[1]
  10592. );
  10593. },
  10594. /**
  10595. * Rebuild path from current data
  10596. * Rebuild path will not consider javascript implemented line dash.
  10597. * @param {CanvasRenderingContext} ctx
  10598. */
  10599. rebuildPath: function (ctx) {
  10600. var d = this.data;
  10601. var x0, y0;
  10602. var xi, yi;
  10603. var x, y;
  10604. var ux = this._ux;
  10605. var uy = this._uy;
  10606. var len = this._len;
  10607. for (var i = 0; i < len;) {
  10608. var cmd = d[i++];
  10609. if (i == 1) {
  10610. // 如果第一个命令是 L, C, Q
  10611. // 则 previous point 同绘制命令的第一个 point
  10612. //
  10613. // 第一个命令为 Arc 的情况下会在后面特殊处理
  10614. xi = d[i];
  10615. yi = d[i + 1];
  10616. x0 = xi;
  10617. y0 = yi;
  10618. }
  10619. switch (cmd) {
  10620. case CMD.M:
  10621. x0 = xi = d[i++];
  10622. y0 = yi = d[i++];
  10623. ctx.moveTo(xi, yi);
  10624. break;
  10625. case CMD.L:
  10626. x = d[i++];
  10627. y = d[i++];
  10628. // Not draw too small seg between
  10629. if (mathAbs(x - xi) > ux || mathAbs(y - yi) > uy || i === len - 1) {
  10630. ctx.lineTo(x, y);
  10631. xi = x;
  10632. yi = y;
  10633. }
  10634. break;
  10635. case CMD.C:
  10636. ctx.bezierCurveTo(
  10637. d[i++], d[i++], d[i++], d[i++], d[i++], d[i++]
  10638. );
  10639. xi = d[i - 2];
  10640. yi = d[i - 1];
  10641. break;
  10642. case CMD.Q:
  10643. ctx.quadraticCurveTo(d[i++], d[i++], d[i++], d[i++]);
  10644. xi = d[i - 2];
  10645. yi = d[i - 1];
  10646. break;
  10647. case CMD.A:
  10648. var cx = d[i++];
  10649. var cy = d[i++];
  10650. var rx = d[i++];
  10651. var ry = d[i++];
  10652. var theta = d[i++];
  10653. var dTheta = d[i++];
  10654. var psi = d[i++];
  10655. var fs = d[i++];
  10656. var r = (rx > ry) ? rx : ry;
  10657. var scaleX = (rx > ry) ? 1 : rx / ry;
  10658. var scaleY = (rx > ry) ? ry / rx : 1;
  10659. var isEllipse = Math.abs(rx - ry) > 1e-3;
  10660. var endAngle = theta + dTheta;
  10661. if (isEllipse) {
  10662. ctx.translate(cx, cy);
  10663. ctx.rotate(psi);
  10664. ctx.scale(scaleX, scaleY);
  10665. ctx.arc(0, 0, r, theta, endAngle, 1 - fs);
  10666. ctx.scale(1 / scaleX, 1 / scaleY);
  10667. ctx.rotate(-psi);
  10668. ctx.translate(-cx, -cy);
  10669. }
  10670. else {
  10671. ctx.arc(cx, cy, r, theta, endAngle, 1 - fs);
  10672. }
  10673. if (i == 1) {
  10674. // 直接使用 arc 命令
  10675. // 第一个命令起点还未定义
  10676. x0 = mathCos(theta) * rx + cx;
  10677. y0 = mathSin(theta) * ry + cy;
  10678. }
  10679. xi = mathCos(endAngle) * rx + cx;
  10680. yi = mathSin(endAngle) * ry + cy;
  10681. break;
  10682. case CMD.R:
  10683. x0 = xi = d[i];
  10684. y0 = yi = d[i + 1];
  10685. ctx.rect(d[i++], d[i++], d[i++], d[i++]);
  10686. break;
  10687. case CMD.Z:
  10688. ctx.closePath();
  10689. xi = x0;
  10690. yi = y0;
  10691. }
  10692. }
  10693. }
  10694. };
  10695. PathProxy.CMD = CMD;
  10696. module.exports = PathProxy;
  10697. /***/ },
  10698. /* 49 */
  10699. /***/ function(module, exports, __webpack_require__) {
  10700. 'use strict';
  10701. /**
  10702. * 曲线辅助模块
  10703. * @module zrender/core/curve
  10704. * @author pissang(https://www.github.com/pissang)
  10705. */
  10706. var vec2 = __webpack_require__(16);
  10707. var v2Create = vec2.create;
  10708. var v2DistSquare = vec2.distSquare;
  10709. var mathPow = Math.pow;
  10710. var mathSqrt = Math.sqrt;
  10711. var EPSILON = 1e-8;
  10712. var EPSILON_NUMERIC = 1e-4;
  10713. var THREE_SQRT = mathSqrt(3);
  10714. var ONE_THIRD = 1 / 3;
  10715. // 临时变量
  10716. var _v0 = v2Create();
  10717. var _v1 = v2Create();
  10718. var _v2 = v2Create();
  10719. // var _v3 = vec2.create();
  10720. function isAroundZero(val) {
  10721. return val > -EPSILON && val < EPSILON;
  10722. }
  10723. function isNotAroundZero(val) {
  10724. return val > EPSILON || val < -EPSILON;
  10725. }
  10726. /**
  10727. * 计算三次贝塞尔值
  10728. * @memberOf module:zrender/core/curve
  10729. * @param {number} p0
  10730. * @param {number} p1
  10731. * @param {number} p2
  10732. * @param {number} p3
  10733. * @param {number} t
  10734. * @return {number}
  10735. */
  10736. function cubicAt(p0, p1, p2, p3, t) {
  10737. var onet = 1 - t;
  10738. return onet * onet * (onet * p0 + 3 * t * p1)
  10739. + t * t * (t * p3 + 3 * onet * p2);
  10740. }
  10741. /**
  10742. * 计算三次贝塞尔导数值
  10743. * @memberOf module:zrender/core/curve
  10744. * @param {number} p0
  10745. * @param {number} p1
  10746. * @param {number} p2
  10747. * @param {number} p3
  10748. * @param {number} t
  10749. * @return {number}
  10750. */
  10751. function cubicDerivativeAt(p0, p1, p2, p3, t) {
  10752. var onet = 1 - t;
  10753. return 3 * (
  10754. ((p1 - p0) * onet + 2 * (p2 - p1) * t) * onet
  10755. + (p3 - p2) * t * t
  10756. );
  10757. }
  10758. /**
  10759. * 计算三次贝塞尔方程根,使用盛金公式
  10760. * @memberOf module:zrender/core/curve
  10761. * @param {number} p0
  10762. * @param {number} p1
  10763. * @param {number} p2
  10764. * @param {number} p3
  10765. * @param {number} val
  10766. * @param {Array.<number>} roots
  10767. * @return {number} 有效根数目
  10768. */
  10769. function cubicRootAt(p0, p1, p2, p3, val, roots) {
  10770. // Evaluate roots of cubic functions
  10771. var a = p3 + 3 * (p1 - p2) - p0;
  10772. var b = 3 * (p2 - p1 * 2 + p0);
  10773. var c = 3 * (p1 - p0);
  10774. var d = p0 - val;
  10775. var A = b * b - 3 * a * c;
  10776. var B = b * c - 9 * a * d;
  10777. var C = c * c - 3 * b * d;
  10778. var n = 0;
  10779. if (isAroundZero(A) && isAroundZero(B)) {
  10780. if (isAroundZero(b)) {
  10781. roots[0] = 0;
  10782. }
  10783. else {
  10784. var t1 = -c / b; //t1, t2, t3, b is not zero
  10785. if (t1 >= 0 && t1 <= 1) {
  10786. roots[n++] = t1;
  10787. }
  10788. }
  10789. }
  10790. else {
  10791. var disc = B * B - 4 * A * C;
  10792. if (isAroundZero(disc)) {
  10793. var K = B / A;
  10794. var t1 = -b / a + K; // t1, a is not zero
  10795. var t2 = -K / 2; // t2, t3
  10796. if (t1 >= 0 && t1 <= 1) {
  10797. roots[n++] = t1;
  10798. }
  10799. if (t2 >= 0 && t2 <= 1) {
  10800. roots[n++] = t2;
  10801. }
  10802. }
  10803. else if (disc > 0) {
  10804. var discSqrt = mathSqrt(disc);
  10805. var Y1 = A * b + 1.5 * a * (-B + discSqrt);
  10806. var Y2 = A * b + 1.5 * a * (-B - discSqrt);
  10807. if (Y1 < 0) {
  10808. Y1 = -mathPow(-Y1, ONE_THIRD);
  10809. }
  10810. else {
  10811. Y1 = mathPow(Y1, ONE_THIRD);
  10812. }
  10813. if (Y2 < 0) {
  10814. Y2 = -mathPow(-Y2, ONE_THIRD);
  10815. }
  10816. else {
  10817. Y2 = mathPow(Y2, ONE_THIRD);
  10818. }
  10819. var t1 = (-b - (Y1 + Y2)) / (3 * a);
  10820. if (t1 >= 0 && t1 <= 1) {
  10821. roots[n++] = t1;
  10822. }
  10823. }
  10824. else {
  10825. var T = (2 * A * b - 3 * a * B) / (2 * mathSqrt(A * A * A));
  10826. var theta = Math.acos(T) / 3;
  10827. var ASqrt = mathSqrt(A);
  10828. var tmp = Math.cos(theta);
  10829. var t1 = (-b - 2 * ASqrt * tmp) / (3 * a);
  10830. var t2 = (-b + ASqrt * (tmp + THREE_SQRT * Math.sin(theta))) / (3 * a);
  10831. var t3 = (-b + ASqrt * (tmp - THREE_SQRT * Math.sin(theta))) / (3 * a);
  10832. if (t1 >= 0 && t1 <= 1) {
  10833. roots[n++] = t1;
  10834. }
  10835. if (t2 >= 0 && t2 <= 1) {
  10836. roots[n++] = t2;
  10837. }
  10838. if (t3 >= 0 && t3 <= 1) {
  10839. roots[n++] = t3;
  10840. }
  10841. }
  10842. }
  10843. return n;
  10844. }
  10845. /**
  10846. * 计算三次贝塞尔方程极限值的位置
  10847. * @memberOf module:zrender/core/curve
  10848. * @param {number} p0
  10849. * @param {number} p1
  10850. * @param {number} p2
  10851. * @param {number} p3
  10852. * @param {Array.<number>} extrema
  10853. * @return {number} 有效数目
  10854. */
  10855. function cubicExtrema(p0, p1, p2, p3, extrema) {
  10856. var b = 6 * p2 - 12 * p1 + 6 * p0;
  10857. var a = 9 * p1 + 3 * p3 - 3 * p0 - 9 * p2;
  10858. var c = 3 * p1 - 3 * p0;
  10859. var n = 0;
  10860. if (isAroundZero(a)) {
  10861. if (isNotAroundZero(b)) {
  10862. var t1 = -c / b;
  10863. if (t1 >= 0 && t1 <=1) {
  10864. extrema[n++] = t1;
  10865. }
  10866. }
  10867. }
  10868. else {
  10869. var disc = b * b - 4 * a * c;
  10870. if (isAroundZero(disc)) {
  10871. extrema[0] = -b / (2 * a);
  10872. }
  10873. else if (disc > 0) {
  10874. var discSqrt = mathSqrt(disc);
  10875. var t1 = (-b + discSqrt) / (2 * a);
  10876. var t2 = (-b - discSqrt) / (2 * a);
  10877. if (t1 >= 0 && t1 <= 1) {
  10878. extrema[n++] = t1;
  10879. }
  10880. if (t2 >= 0 && t2 <= 1) {
  10881. extrema[n++] = t2;
  10882. }
  10883. }
  10884. }
  10885. return n;
  10886. }
  10887. /**
  10888. * 细分三次贝塞尔曲线
  10889. * @memberOf module:zrender/core/curve
  10890. * @param {number} p0
  10891. * @param {number} p1
  10892. * @param {number} p2
  10893. * @param {number} p3
  10894. * @param {number} t
  10895. * @param {Array.<number>} out
  10896. */
  10897. function cubicSubdivide(p0, p1, p2, p3, t, out) {
  10898. var p01 = (p1 - p0) * t + p0;
  10899. var p12 = (p2 - p1) * t + p1;
  10900. var p23 = (p3 - p2) * t + p2;
  10901. var p012 = (p12 - p01) * t + p01;
  10902. var p123 = (p23 - p12) * t + p12;
  10903. var p0123 = (p123 - p012) * t + p012;
  10904. // Seg0
  10905. out[0] = p0;
  10906. out[1] = p01;
  10907. out[2] = p012;
  10908. out[3] = p0123;
  10909. // Seg1
  10910. out[4] = p0123;
  10911. out[5] = p123;
  10912. out[6] = p23;
  10913. out[7] = p3;
  10914. }
  10915. /**
  10916. * 投射点到三次贝塞尔曲线上,返回投射距离。
  10917. * 投射点有可能会有一个或者多个,这里只返回其中距离最短的一个。
  10918. * @param {number} x0
  10919. * @param {number} y0
  10920. * @param {number} x1
  10921. * @param {number} y1
  10922. * @param {number} x2
  10923. * @param {number} y2
  10924. * @param {number} x3
  10925. * @param {number} y3
  10926. * @param {number} x
  10927. * @param {number} y
  10928. * @param {Array.<number>} [out] 投射点
  10929. * @return {number}
  10930. */
  10931. function cubicProjectPoint(
  10932. x0, y0, x1, y1, x2, y2, x3, y3,
  10933. x, y, out
  10934. ) {
  10935. // http://pomax.github.io/bezierinfo/#projections
  10936. var t;
  10937. var interval = 0.005;
  10938. var d = Infinity;
  10939. var prev;
  10940. var next;
  10941. var d1;
  10942. var d2;
  10943. _v0[0] = x;
  10944. _v0[1] = y;
  10945. // 先粗略估计一下可能的最小距离的 t 值
  10946. // PENDING
  10947. for (var _t = 0; _t < 1; _t += 0.05) {
  10948. _v1[0] = cubicAt(x0, x1, x2, x3, _t);
  10949. _v1[1] = cubicAt(y0, y1, y2, y3, _t);
  10950. d1 = v2DistSquare(_v0, _v1);
  10951. if (d1 < d) {
  10952. t = _t;
  10953. d = d1;
  10954. }
  10955. }
  10956. d = Infinity;
  10957. // At most 32 iteration
  10958. for (var i = 0; i < 32; i++) {
  10959. if (interval < EPSILON_NUMERIC) {
  10960. break;
  10961. }
  10962. prev = t - interval;
  10963. next = t + interval;
  10964. // t - interval
  10965. _v1[0] = cubicAt(x0, x1, x2, x3, prev);
  10966. _v1[1] = cubicAt(y0, y1, y2, y3, prev);
  10967. d1 = v2DistSquare(_v1, _v0);
  10968. if (prev >= 0 && d1 < d) {
  10969. t = prev;
  10970. d = d1;
  10971. }
  10972. else {
  10973. // t + interval
  10974. _v2[0] = cubicAt(x0, x1, x2, x3, next);
  10975. _v2[1] = cubicAt(y0, y1, y2, y3, next);
  10976. d2 = v2DistSquare(_v2, _v0);
  10977. if (next <= 1 && d2 < d) {
  10978. t = next;
  10979. d = d2;
  10980. }
  10981. else {
  10982. interval *= 0.5;
  10983. }
  10984. }
  10985. }
  10986. // t
  10987. if (out) {
  10988. out[0] = cubicAt(x0, x1, x2, x3, t);
  10989. out[1] = cubicAt(y0, y1, y2, y3, t);
  10990. }
  10991. // console.log(interval, i);
  10992. return mathSqrt(d);
  10993. }
  10994. /**
  10995. * 计算二次方贝塞尔值
  10996. * @param {number} p0
  10997. * @param {number} p1
  10998. * @param {number} p2
  10999. * @param {number} t
  11000. * @return {number}
  11001. */
  11002. function quadraticAt(p0, p1, p2, t) {
  11003. var onet = 1 - t;
  11004. return onet * (onet * p0 + 2 * t * p1) + t * t * p2;
  11005. }
  11006. /**
  11007. * 计算二次方贝塞尔导数值
  11008. * @param {number} p0
  11009. * @param {number} p1
  11010. * @param {number} p2
  11011. * @param {number} t
  11012. * @return {number}
  11013. */
  11014. function quadraticDerivativeAt(p0, p1, p2, t) {
  11015. return 2 * ((1 - t) * (p1 - p0) + t * (p2 - p1));
  11016. }
  11017. /**
  11018. * 计算二次方贝塞尔方程根
  11019. * @param {number} p0
  11020. * @param {number} p1
  11021. * @param {number} p2
  11022. * @param {number} t
  11023. * @param {Array.<number>} roots
  11024. * @return {number} 有效根数目
  11025. */
  11026. function quadraticRootAt(p0, p1, p2, val, roots) {
  11027. var a = p0 - 2 * p1 + p2;
  11028. var b = 2 * (p1 - p0);
  11029. var c = p0 - val;
  11030. var n = 0;
  11031. if (isAroundZero(a)) {
  11032. if (isNotAroundZero(b)) {
  11033. var t1 = -c / b;
  11034. if (t1 >= 0 && t1 <= 1) {
  11035. roots[n++] = t1;
  11036. }
  11037. }
  11038. }
  11039. else {
  11040. var disc = b * b - 4 * a * c;
  11041. if (isAroundZero(disc)) {
  11042. var t1 = -b / (2 * a);
  11043. if (t1 >= 0 && t1 <= 1) {
  11044. roots[n++] = t1;
  11045. }
  11046. }
  11047. else if (disc > 0) {
  11048. var discSqrt = mathSqrt(disc);
  11049. var t1 = (-b + discSqrt) / (2 * a);
  11050. var t2 = (-b - discSqrt) / (2 * a);
  11051. if (t1 >= 0 && t1 <= 1) {
  11052. roots[n++] = t1;
  11053. }
  11054. if (t2 >= 0 && t2 <= 1) {
  11055. roots[n++] = t2;
  11056. }
  11057. }
  11058. }
  11059. return n;
  11060. }
  11061. /**
  11062. * 计算二次贝塞尔方程极限值
  11063. * @memberOf module:zrender/core/curve
  11064. * @param {number} p0
  11065. * @param {number} p1
  11066. * @param {number} p2
  11067. * @return {number}
  11068. */
  11069. function quadraticExtremum(p0, p1, p2) {
  11070. var divider = p0 + p2 - 2 * p1;
  11071. if (divider === 0) {
  11072. // p1 is center of p0 and p2
  11073. return 0.5;
  11074. }
  11075. else {
  11076. return (p0 - p1) / divider;
  11077. }
  11078. }
  11079. /**
  11080. * 细分二次贝塞尔曲线
  11081. * @memberOf module:zrender/core/curve
  11082. * @param {number} p0
  11083. * @param {number} p1
  11084. * @param {number} p2
  11085. * @param {number} t
  11086. * @param {Array.<number>} out
  11087. */
  11088. function quadraticSubdivide(p0, p1, p2, t, out) {
  11089. var p01 = (p1 - p0) * t + p0;
  11090. var p12 = (p2 - p1) * t + p1;
  11091. var p012 = (p12 - p01) * t + p01;
  11092. // Seg0
  11093. out[0] = p0;
  11094. out[1] = p01;
  11095. out[2] = p012;
  11096. // Seg1
  11097. out[3] = p012;
  11098. out[4] = p12;
  11099. out[5] = p2;
  11100. }
  11101. /**
  11102. * 投射点到二次贝塞尔曲线上,返回投射距离。
  11103. * 投射点有可能会有一个或者多个,这里只返回其中距离最短的一个。
  11104. * @param {number} x0
  11105. * @param {number} y0
  11106. * @param {number} x1
  11107. * @param {number} y1
  11108. * @param {number} x2
  11109. * @param {number} y2
  11110. * @param {number} x
  11111. * @param {number} y
  11112. * @param {Array.<number>} out 投射点
  11113. * @return {number}
  11114. */
  11115. function quadraticProjectPoint(
  11116. x0, y0, x1, y1, x2, y2,
  11117. x, y, out
  11118. ) {
  11119. // http://pomax.github.io/bezierinfo/#projections
  11120. var t;
  11121. var interval = 0.005;
  11122. var d = Infinity;
  11123. _v0[0] = x;
  11124. _v0[1] = y;
  11125. // 先粗略估计一下可能的最小距离的 t 值
  11126. // PENDING
  11127. for (var _t = 0; _t < 1; _t += 0.05) {
  11128. _v1[0] = quadraticAt(x0, x1, x2, _t);
  11129. _v1[1] = quadraticAt(y0, y1, y2, _t);
  11130. var d1 = v2DistSquare(_v0, _v1);
  11131. if (d1 < d) {
  11132. t = _t;
  11133. d = d1;
  11134. }
  11135. }
  11136. d = Infinity;
  11137. // At most 32 iteration
  11138. for (var i = 0; i < 32; i++) {
  11139. if (interval < EPSILON_NUMERIC) {
  11140. break;
  11141. }
  11142. var prev = t - interval;
  11143. var next = t + interval;
  11144. // t - interval
  11145. _v1[0] = quadraticAt(x0, x1, x2, prev);
  11146. _v1[1] = quadraticAt(y0, y1, y2, prev);
  11147. var d1 = v2DistSquare(_v1, _v0);
  11148. if (prev >= 0 && d1 < d) {
  11149. t = prev;
  11150. d = d1;
  11151. }
  11152. else {
  11153. // t + interval
  11154. _v2[0] = quadraticAt(x0, x1, x2, next);
  11155. _v2[1] = quadraticAt(y0, y1, y2, next);
  11156. var d2 = v2DistSquare(_v2, _v0);
  11157. if (next <= 1 && d2 < d) {
  11158. t = next;
  11159. d = d2;
  11160. }
  11161. else {
  11162. interval *= 0.5;
  11163. }
  11164. }
  11165. }
  11166. // t
  11167. if (out) {
  11168. out[0] = quadraticAt(x0, x1, x2, t);
  11169. out[1] = quadraticAt(y0, y1, y2, t);
  11170. }
  11171. // console.log(interval, i);
  11172. return mathSqrt(d);
  11173. }
  11174. module.exports = {
  11175. cubicAt: cubicAt,
  11176. cubicDerivativeAt: cubicDerivativeAt,
  11177. cubicRootAt: cubicRootAt,
  11178. cubicExtrema: cubicExtrema,
  11179. cubicSubdivide: cubicSubdivide,
  11180. cubicProjectPoint: cubicProjectPoint,
  11181. quadraticAt: quadraticAt,
  11182. quadraticDerivativeAt: quadraticDerivativeAt,
  11183. quadraticRootAt: quadraticRootAt,
  11184. quadraticExtremum: quadraticExtremum,
  11185. quadraticSubdivide: quadraticSubdivide,
  11186. quadraticProjectPoint: quadraticProjectPoint
  11187. };
  11188. /***/ },
  11189. /* 50 */
  11190. /***/ function(module, exports, __webpack_require__) {
  11191. /**
  11192. * @author Yi Shen(https://github.com/pissang)
  11193. */
  11194. var vec2 = __webpack_require__(16);
  11195. var curve = __webpack_require__(49);
  11196. var bbox = {};
  11197. var mathMin = Math.min;
  11198. var mathMax = Math.max;
  11199. var mathSin = Math.sin;
  11200. var mathCos = Math.cos;
  11201. var start = vec2.create();
  11202. var end = vec2.create();
  11203. var extremity = vec2.create();
  11204. var PI2 = Math.PI * 2;
  11205. /**
  11206. * 从顶点数组中计算出最小包围盒,写入`min`和`max`中
  11207. * @module zrender/core/bbox
  11208. * @param {Array<Object>} points 顶点数组
  11209. * @param {number} min
  11210. * @param {number} max
  11211. */
  11212. bbox.fromPoints = function(points, min, max) {
  11213. if (points.length === 0) {
  11214. return;
  11215. }
  11216. var p = points[0];
  11217. var left = p[0];
  11218. var right = p[0];
  11219. var top = p[1];
  11220. var bottom = p[1];
  11221. var i;
  11222. for (i = 1; i < points.length; i++) {
  11223. p = points[i];
  11224. left = mathMin(left, p[0]);
  11225. right = mathMax(right, p[0]);
  11226. top = mathMin(top, p[1]);
  11227. bottom = mathMax(bottom, p[1]);
  11228. }
  11229. min[0] = left;
  11230. min[1] = top;
  11231. max[0] = right;
  11232. max[1] = bottom;
  11233. };
  11234. /**
  11235. * @memberOf module:zrender/core/bbox
  11236. * @param {number} x0
  11237. * @param {number} y0
  11238. * @param {number} x1
  11239. * @param {number} y1
  11240. * @param {Array.<number>} min
  11241. * @param {Array.<number>} max
  11242. */
  11243. bbox.fromLine = function (x0, y0, x1, y1, min, max) {
  11244. min[0] = mathMin(x0, x1);
  11245. min[1] = mathMin(y0, y1);
  11246. max[0] = mathMax(x0, x1);
  11247. max[1] = mathMax(y0, y1);
  11248. };
  11249. var xDim = [];
  11250. var yDim = [];
  11251. /**
  11252. * 从三阶贝塞尔曲线(p0, p1, p2, p3)中计算出最小包围盒,写入`min`和`max`中
  11253. * @memberOf module:zrender/core/bbox
  11254. * @param {number} x0
  11255. * @param {number} y0
  11256. * @param {number} x1
  11257. * @param {number} y1
  11258. * @param {number} x2
  11259. * @param {number} y2
  11260. * @param {number} x3
  11261. * @param {number} y3
  11262. * @param {Array.<number>} min
  11263. * @param {Array.<number>} max
  11264. */
  11265. bbox.fromCubic = function(
  11266. x0, y0, x1, y1, x2, y2, x3, y3, min, max
  11267. ) {
  11268. var cubicExtrema = curve.cubicExtrema;
  11269. var cubicAt = curve.cubicAt;
  11270. var i;
  11271. var n = cubicExtrema(x0, x1, x2, x3, xDim);
  11272. min[0] = Infinity;
  11273. min[1] = Infinity;
  11274. max[0] = -Infinity;
  11275. max[1] = -Infinity;
  11276. for (i = 0; i < n; i++) {
  11277. var x = cubicAt(x0, x1, x2, x3, xDim[i]);
  11278. min[0] = mathMin(x, min[0]);
  11279. max[0] = mathMax(x, max[0]);
  11280. }
  11281. n = cubicExtrema(y0, y1, y2, y3, yDim);
  11282. for (i = 0; i < n; i++) {
  11283. var y = cubicAt(y0, y1, y2, y3, yDim[i]);
  11284. min[1] = mathMin(y, min[1]);
  11285. max[1] = mathMax(y, max[1]);
  11286. }
  11287. min[0] = mathMin(x0, min[0]);
  11288. max[0] = mathMax(x0, max[0]);
  11289. min[0] = mathMin(x3, min[0]);
  11290. max[0] = mathMax(x3, max[0]);
  11291. min[1] = mathMin(y0, min[1]);
  11292. max[1] = mathMax(y0, max[1]);
  11293. min[1] = mathMin(y3, min[1]);
  11294. max[1] = mathMax(y3, max[1]);
  11295. };
  11296. /**
  11297. * 从二阶贝塞尔曲线(p0, p1, p2)中计算出最小包围盒,写入`min`和`max`中
  11298. * @memberOf module:zrender/core/bbox
  11299. * @param {number} x0
  11300. * @param {number} y0
  11301. * @param {number} x1
  11302. * @param {number} y1
  11303. * @param {number} x2
  11304. * @param {number} y2
  11305. * @param {Array.<number>} min
  11306. * @param {Array.<number>} max
  11307. */
  11308. bbox.fromQuadratic = function(x0, y0, x1, y1, x2, y2, min, max) {
  11309. var quadraticExtremum = curve.quadraticExtremum;
  11310. var quadraticAt = curve.quadraticAt;
  11311. // Find extremities, where derivative in x dim or y dim is zero
  11312. var tx =
  11313. mathMax(
  11314. mathMin(quadraticExtremum(x0, x1, x2), 1), 0
  11315. );
  11316. var ty =
  11317. mathMax(
  11318. mathMin(quadraticExtremum(y0, y1, y2), 1), 0
  11319. );
  11320. var x = quadraticAt(x0, x1, x2, tx);
  11321. var y = quadraticAt(y0, y1, y2, ty);
  11322. min[0] = mathMin(x0, x2, x);
  11323. min[1] = mathMin(y0, y2, y);
  11324. max[0] = mathMax(x0, x2, x);
  11325. max[1] = mathMax(y0, y2, y);
  11326. };
  11327. /**
  11328. * 从圆弧中计算出最小包围盒,写入`min`和`max`中
  11329. * @method
  11330. * @memberOf module:zrender/core/bbox
  11331. * @param {number} x
  11332. * @param {number} y
  11333. * @param {number} rx
  11334. * @param {number} ry
  11335. * @param {number} startAngle
  11336. * @param {number} endAngle
  11337. * @param {number} anticlockwise
  11338. * @param {Array.<number>} min
  11339. * @param {Array.<number>} max
  11340. */
  11341. bbox.fromArc = function (
  11342. x, y, rx, ry, startAngle, endAngle, anticlockwise, min, max
  11343. ) {
  11344. var vec2Min = vec2.min;
  11345. var vec2Max = vec2.max;
  11346. var diff = Math.abs(startAngle - endAngle);
  11347. if (diff % PI2 < 1e-4 && diff > 1e-4) {
  11348. // Is a circle
  11349. min[0] = x - rx;
  11350. min[1] = y - ry;
  11351. max[0] = x + rx;
  11352. max[1] = y + ry;
  11353. return;
  11354. }
  11355. start[0] = mathCos(startAngle) * rx + x;
  11356. start[1] = mathSin(startAngle) * ry + y;
  11357. end[0] = mathCos(endAngle) * rx + x;
  11358. end[1] = mathSin(endAngle) * ry + y;
  11359. vec2Min(min, start, end);
  11360. vec2Max(max, start, end);
  11361. // Thresh to [0, Math.PI * 2]
  11362. startAngle = startAngle % (PI2);
  11363. if (startAngle < 0) {
  11364. startAngle = startAngle + PI2;
  11365. }
  11366. endAngle = endAngle % (PI2);
  11367. if (endAngle < 0) {
  11368. endAngle = endAngle + PI2;
  11369. }
  11370. if (startAngle > endAngle && !anticlockwise) {
  11371. endAngle += PI2;
  11372. }
  11373. else if (startAngle < endAngle && anticlockwise) {
  11374. startAngle += PI2;
  11375. }
  11376. if (anticlockwise) {
  11377. var tmp = endAngle;
  11378. endAngle = startAngle;
  11379. startAngle = tmp;
  11380. }
  11381. // var number = 0;
  11382. // var step = (anticlockwise ? -Math.PI : Math.PI) / 2;
  11383. for (var angle = 0; angle < endAngle; angle += Math.PI / 2) {
  11384. if (angle > startAngle) {
  11385. extremity[0] = mathCos(angle) * rx + x;
  11386. extremity[1] = mathSin(angle) * ry + y;
  11387. vec2Min(min, extremity, min);
  11388. vec2Max(max, extremity, max);
  11389. }
  11390. }
  11391. };
  11392. module.exports = bbox;
  11393. /***/ },
  11394. /* 51 */
  11395. /***/ function(module, exports, __webpack_require__) {
  11396. 'use strict';
  11397. var CMD = __webpack_require__(48).CMD;
  11398. var line = __webpack_require__(52);
  11399. var cubic = __webpack_require__(53);
  11400. var quadratic = __webpack_require__(54);
  11401. var arc = __webpack_require__(55);
  11402. var normalizeRadian = __webpack_require__(56).normalizeRadian;
  11403. var curve = __webpack_require__(49);
  11404. var windingLine = __webpack_require__(57);
  11405. var containStroke = line.containStroke;
  11406. var PI2 = Math.PI * 2;
  11407. var EPSILON = 1e-4;
  11408. function isAroundEqual(a, b) {
  11409. return Math.abs(a - b) < EPSILON;
  11410. }
  11411. // 临时数组
  11412. var roots = [-1, -1, -1];
  11413. var extrema = [-1, -1];
  11414. function swapExtrema() {
  11415. var tmp = extrema[0];
  11416. extrema[0] = extrema[1];
  11417. extrema[1] = tmp;
  11418. }
  11419. function windingCubic(x0, y0, x1, y1, x2, y2, x3, y3, x, y) {
  11420. // Quick reject
  11421. if (
  11422. (y > y0 && y > y1 && y > y2 && y > y3)
  11423. || (y < y0 && y < y1 && y < y2 && y < y3)
  11424. ) {
  11425. return 0;
  11426. }
  11427. var nRoots = curve.cubicRootAt(y0, y1, y2, y3, y, roots);
  11428. if (nRoots === 0) {
  11429. return 0;
  11430. }
  11431. else {
  11432. var w = 0;
  11433. var nExtrema = -1;
  11434. var y0_, y1_;
  11435. for (var i = 0; i < nRoots; i++) {
  11436. var t = roots[i];
  11437. var x_ = curve.cubicAt(x0, x1, x2, x3, t);
  11438. if (x_ < x) { // Quick reject
  11439. continue;
  11440. }
  11441. if (nExtrema < 0) {
  11442. nExtrema = curve.cubicExtrema(y0, y1, y2, y3, extrema);
  11443. if (extrema[1] < extrema[0] && nExtrema > 1) {
  11444. swapExtrema();
  11445. }
  11446. y0_ = curve.cubicAt(y0, y1, y2, y3, extrema[0]);
  11447. if (nExtrema > 1) {
  11448. y1_ = curve.cubicAt(y0, y1, y2, y3, extrema[1]);
  11449. }
  11450. }
  11451. if (nExtrema == 2) {
  11452. // 分成三段单调函数
  11453. if (t < extrema[0]) {
  11454. w += y0_ < y0 ? 1 : -1;
  11455. }
  11456. else if (t < extrema[1]) {
  11457. w += y1_ < y0_ ? 1 : -1;
  11458. }
  11459. else {
  11460. w += y3 < y1_ ? 1 : -1;
  11461. }
  11462. }
  11463. else {
  11464. // 分成两段单调函数
  11465. if (t < extrema[0]) {
  11466. w += y0_ < y0 ? 1 : -1;
  11467. }
  11468. else {
  11469. w += y3 < y0_ ? 1 : -1;
  11470. }
  11471. }
  11472. }
  11473. return w;
  11474. }
  11475. }
  11476. function windingQuadratic(x0, y0, x1, y1, x2, y2, x, y) {
  11477. // Quick reject
  11478. if (
  11479. (y > y0 && y > y1 && y > y2)
  11480. || (y < y0 && y < y1 && y < y2)
  11481. ) {
  11482. return 0;
  11483. }
  11484. var nRoots = curve.quadraticRootAt(y0, y1, y2, y, roots);
  11485. if (nRoots === 0) {
  11486. return 0;
  11487. }
  11488. else {
  11489. var t = curve.quadraticExtremum(y0, y1, y2);
  11490. if (t >= 0 && t <= 1) {
  11491. var w = 0;
  11492. var y_ = curve.quadraticAt(y0, y1, y2, t);
  11493. for (var i = 0; i < nRoots; i++) {
  11494. var x_ = curve.quadraticAt(x0, x1, x2, roots[i]);
  11495. if (x_ < x) { // Quick reject
  11496. continue;
  11497. }
  11498. if (roots[i] < t) {
  11499. w += y_ < y0 ? 1 : -1;
  11500. }
  11501. else {
  11502. w += y2 < y_ ? 1 : -1;
  11503. }
  11504. }
  11505. return w;
  11506. }
  11507. else {
  11508. var x_ = curve.quadraticAt(x0, x1, x2, roots[0]);
  11509. if (x_ < x) { // Quick reject
  11510. return 0;
  11511. }
  11512. return y2 < y0 ? 1 : -1;
  11513. }
  11514. }
  11515. }
  11516. // TODO
  11517. // Arc 旋转
  11518. function windingArc(
  11519. cx, cy, r, startAngle, endAngle, anticlockwise, x, y
  11520. ) {
  11521. y -= cy;
  11522. if (y > r || y < -r) {
  11523. return 0;
  11524. }
  11525. var tmp = Math.sqrt(r * r - y * y);
  11526. roots[0] = -tmp;
  11527. roots[1] = tmp;
  11528. var diff = Math.abs(startAngle - endAngle);
  11529. if (diff < 1e-4) {
  11530. return 0;
  11531. }
  11532. if (diff % PI2 < 1e-4) {
  11533. // Is a circle
  11534. startAngle = 0;
  11535. endAngle = PI2;
  11536. var dir = anticlockwise ? 1 : -1;
  11537. if (x >= roots[0] + cx && x <= roots[1] + cx) {
  11538. return dir;
  11539. } else {
  11540. return 0;
  11541. }
  11542. }
  11543. if (anticlockwise) {
  11544. var tmp = startAngle;
  11545. startAngle = normalizeRadian(endAngle);
  11546. endAngle = normalizeRadian(tmp);
  11547. }
  11548. else {
  11549. startAngle = normalizeRadian(startAngle);
  11550. endAngle = normalizeRadian(endAngle);
  11551. }
  11552. if (startAngle > endAngle) {
  11553. endAngle += PI2;
  11554. }
  11555. var w = 0;
  11556. for (var i = 0; i < 2; i++) {
  11557. var x_ = roots[i];
  11558. if (x_ + cx > x) {
  11559. var angle = Math.atan2(y, x_);
  11560. var dir = anticlockwise ? 1 : -1;
  11561. if (angle < 0) {
  11562. angle = PI2 + angle;
  11563. }
  11564. if (
  11565. (angle >= startAngle && angle <= endAngle)
  11566. || (angle + PI2 >= startAngle && angle + PI2 <= endAngle)
  11567. ) {
  11568. if (angle > Math.PI / 2 && angle < Math.PI * 1.5) {
  11569. dir = -dir;
  11570. }
  11571. w += dir;
  11572. }
  11573. }
  11574. }
  11575. return w;
  11576. }
  11577. function containPath(data, lineWidth, isStroke, x, y) {
  11578. var w = 0;
  11579. var xi = 0;
  11580. var yi = 0;
  11581. var x0 = 0;
  11582. var y0 = 0;
  11583. for (var i = 0; i < data.length;) {
  11584. var cmd = data[i++];
  11585. // Begin a new subpath
  11586. if (cmd === CMD.M && i > 1) {
  11587. // Close previous subpath
  11588. if (!isStroke) {
  11589. w += windingLine(xi, yi, x0, y0, x, y);
  11590. }
  11591. // 如果被任何一个 subpath 包含
  11592. if (w !== 0) {
  11593. return true;
  11594. }
  11595. }
  11596. if (i == 1) {
  11597. // 如果第一个命令是 L, C, Q
  11598. // 则 previous point 同绘制命令的第一个 point
  11599. //
  11600. // 第一个命令为 Arc 的情况下会在后面特殊处理
  11601. xi = data[i];
  11602. yi = data[i + 1];
  11603. x0 = xi;
  11604. y0 = yi;
  11605. }
  11606. switch (cmd) {
  11607. case CMD.M:
  11608. // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点
  11609. // 在 closePath 的时候使用
  11610. x0 = data[i++];
  11611. y0 = data[i++];
  11612. xi = x0;
  11613. yi = y0;
  11614. break;
  11615. case CMD.L:
  11616. if (isStroke) {
  11617. if (containStroke(xi, yi, data[i], data[i + 1], lineWidth, x, y)) {
  11618. return true;
  11619. }
  11620. }
  11621. else {
  11622. // NOTE 在第一个命令为 L, C, Q 的时候会计算出 NaN
  11623. w += windingLine(xi, yi, data[i], data[i + 1], x, y) || 0;
  11624. }
  11625. xi = data[i++];
  11626. yi = data[i++];
  11627. break;
  11628. case CMD.C:
  11629. if (isStroke) {
  11630. if (cubic.containStroke(xi, yi,
  11631. data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1],
  11632. lineWidth, x, y
  11633. )) {
  11634. return true;
  11635. }
  11636. }
  11637. else {
  11638. w += windingCubic(
  11639. xi, yi,
  11640. data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1],
  11641. x, y
  11642. ) || 0;
  11643. }
  11644. xi = data[i++];
  11645. yi = data[i++];
  11646. break;
  11647. case CMD.Q:
  11648. if (isStroke) {
  11649. if (quadratic.containStroke(xi, yi,
  11650. data[i++], data[i++], data[i], data[i + 1],
  11651. lineWidth, x, y
  11652. )) {
  11653. return true;
  11654. }
  11655. }
  11656. else {
  11657. w += windingQuadratic(
  11658. xi, yi,
  11659. data[i++], data[i++], data[i], data[i + 1],
  11660. x, y
  11661. ) || 0;
  11662. }
  11663. xi = data[i++];
  11664. yi = data[i++];
  11665. break;
  11666. case CMD.A:
  11667. // TODO Arc 判断的开销比较大
  11668. var cx = data[i++];
  11669. var cy = data[i++];
  11670. var rx = data[i++];
  11671. var ry = data[i++];
  11672. var theta = data[i++];
  11673. var dTheta = data[i++];
  11674. // TODO Arc 旋转
  11675. var psi = data[i++];
  11676. var anticlockwise = 1 - data[i++];
  11677. var x1 = Math.cos(theta) * rx + cx;
  11678. var y1 = Math.sin(theta) * ry + cy;
  11679. // 不是直接使用 arc 命令
  11680. if (i > 1) {
  11681. w += windingLine(xi, yi, x1, y1, x, y);
  11682. }
  11683. else {
  11684. // 第一个命令起点还未定义
  11685. x0 = x1;
  11686. y0 = y1;
  11687. }
  11688. // zr 使用scale来模拟椭圆, 这里也对x做一定的缩放
  11689. var _x = (x - cx) * ry / rx + cx;
  11690. if (isStroke) {
  11691. if (arc.containStroke(
  11692. cx, cy, ry, theta, theta + dTheta, anticlockwise,
  11693. lineWidth, _x, y
  11694. )) {
  11695. return true;
  11696. }
  11697. }
  11698. else {
  11699. w += windingArc(
  11700. cx, cy, ry, theta, theta + dTheta, anticlockwise,
  11701. _x, y
  11702. );
  11703. }
  11704. xi = Math.cos(theta + dTheta) * rx + cx;
  11705. yi = Math.sin(theta + dTheta) * ry + cy;
  11706. break;
  11707. case CMD.R:
  11708. x0 = xi = data[i++];
  11709. y0 = yi = data[i++];
  11710. var width = data[i++];
  11711. var height = data[i++];
  11712. var x1 = x0 + width;
  11713. var y1 = y0 + height;
  11714. if (isStroke) {
  11715. if (containStroke(x0, y0, x1, y0, lineWidth, x, y)
  11716. || containStroke(x1, y0, x1, y1, lineWidth, x, y)
  11717. || containStroke(x1, y1, x0, y1, lineWidth, x, y)
  11718. || containStroke(x0, y1, x1, y1, lineWidth, x, y)
  11719. ) {
  11720. return true;
  11721. }
  11722. }
  11723. else {
  11724. // FIXME Clockwise ?
  11725. w += windingLine(x1, y0, x1, y1, x, y);
  11726. w += windingLine(x0, y1, x0, y0, x, y);
  11727. }
  11728. break;
  11729. case CMD.Z:
  11730. if (isStroke) {
  11731. if (containStroke(
  11732. xi, yi, x0, y0, lineWidth, x, y
  11733. )) {
  11734. return true;
  11735. }
  11736. }
  11737. else {
  11738. // Close a subpath
  11739. w += windingLine(xi, yi, x0, y0, x, y);
  11740. // 如果被任何一个 subpath 包含
  11741. if (w !== 0) {
  11742. return true;
  11743. }
  11744. }
  11745. xi = x0;
  11746. yi = y0;
  11747. break;
  11748. }
  11749. }
  11750. if (!isStroke && !isAroundEqual(yi, y0)) {
  11751. w += windingLine(xi, yi, x0, y0, x, y) || 0;
  11752. }
  11753. return w !== 0;
  11754. }
  11755. module.exports = {
  11756. contain: function (pathData, x, y) {
  11757. return containPath(pathData, 0, false, x, y);
  11758. },
  11759. containStroke: function (pathData, lineWidth, x, y) {
  11760. return containPath(pathData, lineWidth, true, x, y);
  11761. }
  11762. };
  11763. /***/ },
  11764. /* 52 */
  11765. /***/ function(module, exports) {
  11766. module.exports = {
  11767. /**
  11768. * 线段包含判断
  11769. * @param {number} x0
  11770. * @param {number} y0
  11771. * @param {number} x1
  11772. * @param {number} y1
  11773. * @param {number} lineWidth
  11774. * @param {number} x
  11775. * @param {number} y
  11776. * @return {boolean}
  11777. */
  11778. containStroke: function (x0, y0, x1, y1, lineWidth, x, y) {
  11779. if (lineWidth === 0) {
  11780. return false;
  11781. }
  11782. var _l = lineWidth;
  11783. var _a = 0;
  11784. var _b = x0;
  11785. // Quick reject
  11786. if (
  11787. (y > y0 + _l && y > y1 + _l)
  11788. || (y < y0 - _l && y < y1 - _l)
  11789. || (x > x0 + _l && x > x1 + _l)
  11790. || (x < x0 - _l && x < x1 - _l)
  11791. ) {
  11792. return false;
  11793. }
  11794. if (x0 !== x1) {
  11795. _a = (y0 - y1) / (x0 - x1);
  11796. _b = (x0 * y1 - x1 * y0) / (x0 - x1) ;
  11797. }
  11798. else {
  11799. return Math.abs(x - x0) <= _l / 2;
  11800. }
  11801. var tmp = _a * x - y + _b;
  11802. var _s = tmp * tmp / (_a * _a + 1);
  11803. return _s <= _l / 2 * _l / 2;
  11804. }
  11805. };
  11806. /***/ },
  11807. /* 53 */
  11808. /***/ function(module, exports, __webpack_require__) {
  11809. var curve = __webpack_require__(49);
  11810. module.exports = {
  11811. /**
  11812. * 三次贝塞尔曲线描边包含判断
  11813. * @param {number} x0
  11814. * @param {number} y0
  11815. * @param {number} x1
  11816. * @param {number} y1
  11817. * @param {number} x2
  11818. * @param {number} y2
  11819. * @param {number} x3
  11820. * @param {number} y3
  11821. * @param {number} lineWidth
  11822. * @param {number} x
  11823. * @param {number} y
  11824. * @return {boolean}
  11825. */
  11826. containStroke: function(x0, y0, x1, y1, x2, y2, x3, y3, lineWidth, x, y) {
  11827. if (lineWidth === 0) {
  11828. return false;
  11829. }
  11830. var _l = lineWidth;
  11831. // Quick reject
  11832. if (
  11833. (y > y0 + _l && y > y1 + _l && y > y2 + _l && y > y3 + _l)
  11834. || (y < y0 - _l && y < y1 - _l && y < y2 - _l && y < y3 - _l)
  11835. || (x > x0 + _l && x > x1 + _l && x > x2 + _l && x > x3 + _l)
  11836. || (x < x0 - _l && x < x1 - _l && x < x2 - _l && x < x3 - _l)
  11837. ) {
  11838. return false;
  11839. }
  11840. var d = curve.cubicProjectPoint(
  11841. x0, y0, x1, y1, x2, y2, x3, y3,
  11842. x, y, null
  11843. );
  11844. return d <= _l / 2;
  11845. }
  11846. };
  11847. /***/ },
  11848. /* 54 */
  11849. /***/ function(module, exports, __webpack_require__) {
  11850. var curve = __webpack_require__(49);
  11851. module.exports = {
  11852. /**
  11853. * 二次贝塞尔曲线描边包含判断
  11854. * @param {number} x0
  11855. * @param {number} y0
  11856. * @param {number} x1
  11857. * @param {number} y1
  11858. * @param {number} x2
  11859. * @param {number} y2
  11860. * @param {number} lineWidth
  11861. * @param {number} x
  11862. * @param {number} y
  11863. * @return {boolean}
  11864. */
  11865. containStroke: function (x0, y0, x1, y1, x2, y2, lineWidth, x, y) {
  11866. if (lineWidth === 0) {
  11867. return false;
  11868. }
  11869. var _l = lineWidth;
  11870. // Quick reject
  11871. if (
  11872. (y > y0 + _l && y > y1 + _l && y > y2 + _l)
  11873. || (y < y0 - _l && y < y1 - _l && y < y2 - _l)
  11874. || (x > x0 + _l && x > x1 + _l && x > x2 + _l)
  11875. || (x < x0 - _l && x < x1 - _l && x < x2 - _l)
  11876. ) {
  11877. return false;
  11878. }
  11879. var d = curve.quadraticProjectPoint(
  11880. x0, y0, x1, y1, x2, y2,
  11881. x, y, null
  11882. );
  11883. return d <= _l / 2;
  11884. }
  11885. };
  11886. /***/ },
  11887. /* 55 */
  11888. /***/ function(module, exports, __webpack_require__) {
  11889. var normalizeRadian = __webpack_require__(56).normalizeRadian;
  11890. var PI2 = Math.PI * 2;
  11891. module.exports = {
  11892. /**
  11893. * 圆弧描边包含判断
  11894. * @param {number} cx
  11895. * @param {number} cy
  11896. * @param {number} r
  11897. * @param {number} startAngle
  11898. * @param {number} endAngle
  11899. * @param {boolean} anticlockwise
  11900. * @param {number} lineWidth
  11901. * @param {number} x
  11902. * @param {number} y
  11903. * @return {Boolean}
  11904. */
  11905. containStroke: function (
  11906. cx, cy, r, startAngle, endAngle, anticlockwise,
  11907. lineWidth, x, y
  11908. ) {
  11909. if (lineWidth === 0) {
  11910. return false;
  11911. }
  11912. var _l = lineWidth;
  11913. x -= cx;
  11914. y -= cy;
  11915. var d = Math.sqrt(x * x + y * y);
  11916. if ((d - _l > r) || (d + _l < r)) {
  11917. return false;
  11918. }
  11919. if (Math.abs(startAngle - endAngle) % PI2 < 1e-4) {
  11920. // Is a circle
  11921. return true;
  11922. }
  11923. if (anticlockwise) {
  11924. var tmp = startAngle;
  11925. startAngle = normalizeRadian(endAngle);
  11926. endAngle = normalizeRadian(tmp);
  11927. } else {
  11928. startAngle = normalizeRadian(startAngle);
  11929. endAngle = normalizeRadian(endAngle);
  11930. }
  11931. if (startAngle > endAngle) {
  11932. endAngle += PI2;
  11933. }
  11934. var angle = Math.atan2(y, x);
  11935. if (angle < 0) {
  11936. angle += PI2;
  11937. }
  11938. return (angle >= startAngle && angle <= endAngle)
  11939. || (angle + PI2 >= startAngle && angle + PI2 <= endAngle);
  11940. }
  11941. };
  11942. /***/ },
  11943. /* 56 */
  11944. /***/ function(module, exports) {
  11945. var PI2 = Math.PI * 2;
  11946. module.exports = {
  11947. normalizeRadian: function(angle) {
  11948. angle %= PI2;
  11949. if (angle < 0) {
  11950. angle += PI2;
  11951. }
  11952. return angle;
  11953. }
  11954. };
  11955. /***/ },
  11956. /* 57 */
  11957. /***/ function(module, exports) {
  11958. module.exports = function windingLine(x0, y0, x1, y1, x, y) {
  11959. if ((y > y0 && y > y1) || (y < y0 && y < y1)) {
  11960. return 0;
  11961. }
  11962. if (y1 === y0) {
  11963. return 0;
  11964. }
  11965. var dir = y1 < y0 ? 1 : -1;
  11966. var t = (y - y0) / (y1 - y0);
  11967. var x_ = t * (x1 - x0) + x0;
  11968. return x_ > x ? dir : 0;
  11969. };
  11970. /***/ },
  11971. /* 58 */
  11972. /***/ function(module, exports, __webpack_require__) {
  11973. var CMD = __webpack_require__(48).CMD;
  11974. var vec2 = __webpack_require__(16);
  11975. var v2ApplyTransform = vec2.applyTransform;
  11976. var points = [[], [], []];
  11977. var mathSqrt = Math.sqrt;
  11978. var mathAtan2 = Math.atan2;
  11979. function transformPath(path, m) {
  11980. var data = path.data;
  11981. var cmd;
  11982. var nPoint;
  11983. var i;
  11984. var j;
  11985. var k;
  11986. var p;
  11987. var M = CMD.M;
  11988. var C = CMD.C;
  11989. var L = CMD.L;
  11990. var R = CMD.R;
  11991. var A = CMD.A;
  11992. var Q = CMD.Q;
  11993. for (i = 0, j = 0; i < data.length;) {
  11994. cmd = data[i++];
  11995. j = i;
  11996. nPoint = 0;
  11997. switch (cmd) {
  11998. case M:
  11999. nPoint = 1;
  12000. break;
  12001. case L:
  12002. nPoint = 1;
  12003. break;
  12004. case C:
  12005. nPoint = 3;
  12006. break;
  12007. case Q:
  12008. nPoint = 2;
  12009. break;
  12010. case A:
  12011. var x = m[4];
  12012. var y = m[5];
  12013. var sx = mathSqrt(m[0] * m[0] + m[1] * m[1]);
  12014. var sy = mathSqrt(m[2] * m[2] + m[3] * m[3]);
  12015. var angle = mathAtan2(-m[1] / sy, m[0] / sx);
  12016. // cx
  12017. data[i++] += x;
  12018. // cy
  12019. data[i++] += y;
  12020. // Scale rx and ry
  12021. // FIXME Assume psi is 0 here
  12022. data[i++] *= sx;
  12023. data[i++] *= sy;
  12024. // Start angle
  12025. data[i++] += angle;
  12026. // end angle
  12027. data[i++] += angle;
  12028. // FIXME psi
  12029. i += 2;
  12030. j = i;
  12031. break;
  12032. case R:
  12033. // x0, y0
  12034. p[0] = data[i++];
  12035. p[1] = data[i++];
  12036. v2ApplyTransform(p, p, m);
  12037. data[j++] = p[0];
  12038. data[j++] = p[1];
  12039. // x1, y1
  12040. p[0] += data[i++];
  12041. p[1] += data[i++];
  12042. v2ApplyTransform(p, p, m);
  12043. data[j++] = p[0];
  12044. data[j++] = p[1];
  12045. }
  12046. for (k = 0; k < nPoint; k++) {
  12047. var p = points[k];
  12048. p[0] = data[i++];
  12049. p[1] = data[i++];
  12050. v2ApplyTransform(p, p, m);
  12051. // Write back
  12052. data[j++] = p[0];
  12053. data[j++] = p[1];
  12054. }
  12055. }
  12056. }
  12057. module.exports = transformPath;
  12058. /***/ },
  12059. /* 59 */
  12060. /***/ function(module, exports, __webpack_require__) {
  12061. /**
  12062. * Image element
  12063. * @module zrender/graphic/Image
  12064. */
  12065. var Displayable = __webpack_require__(45);
  12066. var BoundingRect = __webpack_require__(15);
  12067. var zrUtil = __webpack_require__(3);
  12068. var roundRectHelper = __webpack_require__(60);
  12069. var LRU = __webpack_require__(61);
  12070. var globalImageCache = new LRU(50);
  12071. /**
  12072. * @alias zrender/graphic/Image
  12073. * @extends module:zrender/graphic/Displayable
  12074. * @constructor
  12075. * @param {Object} opts
  12076. */
  12077. function ZImage(opts) {
  12078. Displayable.call(this, opts);
  12079. }
  12080. ZImage.prototype = {
  12081. constructor: ZImage,
  12082. type: 'image',
  12083. brush: function (ctx) {
  12084. var style = this.style;
  12085. var src = style.image;
  12086. var image;
  12087. // style.image is a url string
  12088. if (typeof src === 'string') {
  12089. image = this._image;
  12090. }
  12091. // style.image is an HTMLImageElement or HTMLCanvasElement or Canvas
  12092. else {
  12093. image = src;
  12094. }
  12095. // FIXME Case create many images with src
  12096. if (!image && src) {
  12097. // Try get from global image cache
  12098. var cachedImgObj = globalImageCache.get(src);
  12099. if (!cachedImgObj) {
  12100. // Create a new image
  12101. image = new Image();
  12102. image.onload = function () {
  12103. image.onload = null;
  12104. for (var i = 0; i < cachedImgObj.pending.length; i++) {
  12105. cachedImgObj.pending[i].dirty();
  12106. }
  12107. };
  12108. cachedImgObj = {
  12109. image: image,
  12110. pending: [this]
  12111. };
  12112. image.src = src;
  12113. globalImageCache.put(src, cachedImgObj);
  12114. this._image = image;
  12115. return;
  12116. }
  12117. else {
  12118. image = cachedImgObj.image;
  12119. this._image = image;
  12120. // Image is not complete finish, add to pending list
  12121. if (!image.width || !image.height) {
  12122. cachedImgObj.pending.push(this);
  12123. return;
  12124. }
  12125. }
  12126. }
  12127. if (image) {
  12128. // 图片已经加载完成
  12129. // if (image.nodeName.toUpperCase() == 'IMG') {
  12130. // if (!image.complete) {
  12131. // return;
  12132. // }
  12133. // }
  12134. // Else is canvas
  12135. var width = style.width || image.width;
  12136. var height = style.height || image.height;
  12137. var x = style.x || 0;
  12138. var y = style.y || 0;
  12139. // 图片加载失败
  12140. if (!image.width || !image.height) {
  12141. return;
  12142. }
  12143. ctx.save();
  12144. style.bind(ctx);
  12145. // 设置transform
  12146. this.setTransform(ctx);
  12147. if (style.r) {
  12148. // Border radius clipping
  12149. // FIXME
  12150. ctx.beginPath();
  12151. roundRectHelper.buildPath(ctx, style);
  12152. ctx.clip();
  12153. }
  12154. if (style.sWidth && style.sHeight) {
  12155. var sx = style.sx || 0;
  12156. var sy = style.sy || 0;
  12157. ctx.drawImage(
  12158. image,
  12159. sx, sy, style.sWidth, style.sHeight,
  12160. x, y, width, height
  12161. );
  12162. }
  12163. else if (style.sx && style.sy) {
  12164. var sx = style.sx;
  12165. var sy = style.sy;
  12166. var sWidth = width - sx;
  12167. var sHeight = height - sy;
  12168. ctx.drawImage(
  12169. image,
  12170. sx, sy, sWidth, sHeight,
  12171. x, y, width, height
  12172. );
  12173. }
  12174. else {
  12175. ctx.drawImage(image, x, y, width, height);
  12176. }
  12177. // 如果没设置宽和高的话自动根据图片宽高设置
  12178. if (style.width == null) {
  12179. style.width = width;
  12180. }
  12181. if (style.height == null) {
  12182. style.height = height;
  12183. }
  12184. // Draw rect text
  12185. if (style.text != null) {
  12186. this.drawRectText(ctx, this.getBoundingRect());
  12187. }
  12188. ctx.restore();
  12189. }
  12190. },
  12191. getBoundingRect: function () {
  12192. var style = this.style;
  12193. if (! this._rect) {
  12194. this._rect = new BoundingRect(
  12195. style.x || 0, style.y || 0, style.width || 0, style.height || 0
  12196. );
  12197. }
  12198. return this._rect;
  12199. }
  12200. };
  12201. zrUtil.inherits(ZImage, Displayable);
  12202. module.exports = ZImage;
  12203. /***/ },
  12204. /* 60 */
  12205. /***/ function(module, exports) {
  12206. module.exports = {
  12207. buildPath: function (ctx, shape) {
  12208. var x = shape.x;
  12209. var y = shape.y;
  12210. var width = shape.width;
  12211. var height = shape.height;
  12212. var r = shape.r;
  12213. var r1;
  12214. var r2;
  12215. var r3;
  12216. var r4;
  12217. // Convert width and height to positive for better borderRadius
  12218. if (width < 0) {
  12219. x = x + width;
  12220. width = -width;
  12221. }
  12222. if (height < 0) {
  12223. y = y + height;
  12224. height = -height;
  12225. }
  12226. if (typeof r === 'number') {
  12227. r1 = r2 = r3 = r4 = r;
  12228. }
  12229. else if (r instanceof Array) {
  12230. if (r.length === 1) {
  12231. r1 = r2 = r3 = r4 = r[0];
  12232. }
  12233. else if (r.length === 2) {
  12234. r1 = r3 = r[0];
  12235. r2 = r4 = r[1];
  12236. }
  12237. else if (r.length === 3) {
  12238. r1 = r[0];
  12239. r2 = r4 = r[1];
  12240. r3 = r[2];
  12241. }
  12242. else {
  12243. r1 = r[0];
  12244. r2 = r[1];
  12245. r3 = r[2];
  12246. r4 = r[3];
  12247. }
  12248. }
  12249. else {
  12250. r1 = r2 = r3 = r4 = 0;
  12251. }
  12252. var total;
  12253. if (r1 + r2 > width) {
  12254. total = r1 + r2;
  12255. r1 *= width / total;
  12256. r2 *= width / total;
  12257. }
  12258. if (r3 + r4 > width) {
  12259. total = r3 + r4;
  12260. r3 *= width / total;
  12261. r4 *= width / total;
  12262. }
  12263. if (r2 + r3 > height) {
  12264. total = r2 + r3;
  12265. r2 *= height / total;
  12266. r3 *= height / total;
  12267. }
  12268. if (r1 + r4 > height) {
  12269. total = r1 + r4;
  12270. r1 *= height / total;
  12271. r4 *= height / total;
  12272. }
  12273. ctx.moveTo(x + r1, y);
  12274. ctx.lineTo(x + width - r2, y);
  12275. r2 !== 0 && ctx.quadraticCurveTo(
  12276. x + width, y, x + width, y + r2
  12277. );
  12278. ctx.lineTo(x + width, y + height - r3);
  12279. r3 !== 0 && ctx.quadraticCurveTo(
  12280. x + width, y + height, x + width - r3, y + height
  12281. );
  12282. ctx.lineTo(x + r4, y + height);
  12283. r4 !== 0 && ctx.quadraticCurveTo(
  12284. x, y + height, x, y + height - r4
  12285. );
  12286. ctx.lineTo(x, y + r1);
  12287. r1 !== 0 && ctx.quadraticCurveTo(x, y, x + r1, y);
  12288. }
  12289. };
  12290. /***/ },
  12291. /* 61 */
  12292. /***/ function(module, exports) {
  12293. // Simple LRU cache use doubly linked list
  12294. // @module zrender/core/LRU
  12295. /**
  12296. * Simple double linked list. Compared with array, it has O(1) remove operation.
  12297. * @constructor
  12298. */
  12299. var LinkedList = function() {
  12300. /**
  12301. * @type {module:zrender/core/LRU~Entry}
  12302. */
  12303. this.head = null;
  12304. /**
  12305. * @type {module:zrender/core/LRU~Entry}
  12306. */
  12307. this.tail = null;
  12308. this._len = 0;
  12309. };
  12310. var linkedListProto = LinkedList.prototype;
  12311. /**
  12312. * Insert a new value at the tail
  12313. * @param {} val
  12314. * @return {module:zrender/core/LRU~Entry}
  12315. */
  12316. linkedListProto.insert = function(val) {
  12317. var entry = new Entry(val);
  12318. this.insertEntry(entry);
  12319. return entry;
  12320. };
  12321. /**
  12322. * Insert an entry at the tail
  12323. * @param {module:zrender/core/LRU~Entry} entry
  12324. */
  12325. linkedListProto.insertEntry = function(entry) {
  12326. if (!this.head) {
  12327. this.head = this.tail = entry;
  12328. }
  12329. else {
  12330. this.tail.next = entry;
  12331. entry.prev = this.tail;
  12332. this.tail = entry;
  12333. }
  12334. this._len++;
  12335. };
  12336. /**
  12337. * Remove entry.
  12338. * @param {module:zrender/core/LRU~Entry} entry
  12339. */
  12340. linkedListProto.remove = function(entry) {
  12341. var prev = entry.prev;
  12342. var next = entry.next;
  12343. if (prev) {
  12344. prev.next = next;
  12345. }
  12346. else {
  12347. // Is head
  12348. this.head = next;
  12349. }
  12350. if (next) {
  12351. next.prev = prev;
  12352. }
  12353. else {
  12354. // Is tail
  12355. this.tail = prev;
  12356. }
  12357. entry.next = entry.prev = null;
  12358. this._len--;
  12359. };
  12360. /**
  12361. * @return {number}
  12362. */
  12363. linkedListProto.len = function() {
  12364. return this._len;
  12365. };
  12366. /**
  12367. * @constructor
  12368. * @param {} val
  12369. */
  12370. var Entry = function(val) {
  12371. /**
  12372. * @type {}
  12373. */
  12374. this.value = val;
  12375. /**
  12376. * @type {module:zrender/core/LRU~Entry}
  12377. */
  12378. this.next;
  12379. /**
  12380. * @type {module:zrender/core/LRU~Entry}
  12381. */
  12382. this.prev;
  12383. };
  12384. /**
  12385. * LRU Cache
  12386. * @constructor
  12387. * @alias module:zrender/core/LRU
  12388. */
  12389. var LRU = function(maxSize) {
  12390. this._list = new LinkedList();
  12391. this._map = {};
  12392. this._maxSize = maxSize || 10;
  12393. };
  12394. var LRUProto = LRU.prototype;
  12395. /**
  12396. * @param {string} key
  12397. * @param {} value
  12398. */
  12399. LRUProto.put = function(key, value) {
  12400. var list = this._list;
  12401. var map = this._map;
  12402. if (map[key] == null) {
  12403. var len = list.len();
  12404. if (len >= this._maxSize && len > 0) {
  12405. // Remove the least recently used
  12406. var leastUsedEntry = list.head;
  12407. list.remove(leastUsedEntry);
  12408. delete map[leastUsedEntry.key];
  12409. }
  12410. var entry = list.insert(value);
  12411. entry.key = key;
  12412. map[key] = entry;
  12413. }
  12414. };
  12415. /**
  12416. * @param {string} key
  12417. * @return {}
  12418. */
  12419. LRUProto.get = function(key) {
  12420. var entry = this._map[key];
  12421. var list = this._list;
  12422. if (entry != null) {
  12423. // Put the latest used entry in the tail
  12424. if (entry !== list.tail) {
  12425. list.remove(entry);
  12426. list.insertEntry(entry);
  12427. }
  12428. return entry.value;
  12429. }
  12430. };
  12431. /**
  12432. * Clear the cache
  12433. */
  12434. LRUProto.clear = function() {
  12435. this._list.clear();
  12436. this._map = {};
  12437. };
  12438. module.exports = LRU;
  12439. /***/ },
  12440. /* 62 */
  12441. /***/ function(module, exports, __webpack_require__) {
  12442. /**
  12443. * Text element
  12444. * @module zrender/graphic/Text
  12445. *
  12446. * TODO Wrapping
  12447. *
  12448. * Text not support gradient
  12449. */
  12450. var Displayable = __webpack_require__(45);
  12451. var zrUtil = __webpack_require__(3);
  12452. var textContain = __webpack_require__(14);
  12453. /**
  12454. * @alias zrender/graphic/Text
  12455. * @extends module:zrender/graphic/Displayable
  12456. * @constructor
  12457. * @param {Object} opts
  12458. */
  12459. var Text = function (opts) {
  12460. Displayable.call(this, opts);
  12461. };
  12462. Text.prototype = {
  12463. constructor: Text,
  12464. type: 'text',
  12465. brush: function (ctx) {
  12466. var style = this.style;
  12467. var x = style.x || 0;
  12468. var y = style.y || 0;
  12469. // Convert to string
  12470. var text = style.text;
  12471. var textFill = style.fill;
  12472. var textStroke = style.stroke;
  12473. // Convert to string
  12474. text != null && (text += '');
  12475. if (text) {
  12476. ctx.save();
  12477. this.style.bind(ctx);
  12478. this.setTransform(ctx);
  12479. textFill && (ctx.fillStyle = textFill);
  12480. textStroke && (ctx.strokeStyle = textStroke);
  12481. ctx.font = style.textFont || style.font;
  12482. ctx.textAlign = style.textAlign;
  12483. if (style.textVerticalAlign) {
  12484. var rect = textContain.getBoundingRect(
  12485. text, ctx.font, style.textAlign, 'top'
  12486. );
  12487. // Ignore textBaseline
  12488. ctx.textBaseline = 'middle';
  12489. switch (style.textVerticalAlign) {
  12490. case 'middle':
  12491. y -= rect.height / 2 - rect.lineHeight / 2;
  12492. break;
  12493. case 'bottom':
  12494. y -= rect.height - rect.lineHeight / 2;
  12495. break;
  12496. default:
  12497. y += rect.lineHeight / 2;
  12498. }
  12499. }
  12500. else {
  12501. ctx.textBaseline = style.textBaseline;
  12502. }
  12503. var lineHeight = textContain.measureText('国', ctx.font).width;
  12504. var textLines = text.split('\n');
  12505. for (var i = 0; i < textLines.length; i++) {
  12506. textFill && ctx.fillText(textLines[i], x, y);
  12507. textStroke && ctx.strokeText(textLines[i], x, y);
  12508. y += lineHeight;
  12509. }
  12510. ctx.restore();
  12511. }
  12512. },
  12513. getBoundingRect: function () {
  12514. if (!this._rect) {
  12515. var style = this.style;
  12516. var textVerticalAlign = style.textVerticalAlign;
  12517. var rect = textContain.getBoundingRect(
  12518. style.text + '', style.textFont || style.font, style.textAlign,
  12519. textVerticalAlign ? 'top' : style.textBaseline
  12520. );
  12521. switch (textVerticalAlign) {
  12522. case 'middle':
  12523. rect.y -= rect.height / 2;
  12524. break;
  12525. case 'bottom':
  12526. rect.y -= rect.height;
  12527. break;
  12528. }
  12529. rect.x += style.x || 0;
  12530. rect.y += style.y || 0;
  12531. this._rect = rect;
  12532. }
  12533. return this._rect;
  12534. }
  12535. };
  12536. zrUtil.inherits(Text, Displayable);
  12537. module.exports = Text;
  12538. /***/ },
  12539. /* 63 */
  12540. /***/ function(module, exports, __webpack_require__) {
  12541. 'use strict';
  12542. /**
  12543. * 圆形
  12544. * @module zrender/shape/Circle
  12545. */
  12546. module.exports = __webpack_require__(44).extend({
  12547. type: 'circle',
  12548. shape: {
  12549. cx: 0,
  12550. cy: 0,
  12551. r: 0
  12552. },
  12553. buildPath : function (ctx, shape) {
  12554. // Better stroking in ShapeBundle
  12555. ctx.moveTo(shape.cx + shape.r, shape.cy);
  12556. ctx.arc(shape.cx, shape.cy, shape.r, 0, Math.PI * 2, true);
  12557. return;
  12558. }
  12559. });
  12560. /***/ },
  12561. /* 64 */
  12562. /***/ function(module, exports, __webpack_require__) {
  12563. /**
  12564. * 扇形
  12565. * @module zrender/graphic/shape/Sector
  12566. */
  12567. // FIXME clockwise seems wrong
  12568. module.exports = __webpack_require__(44).extend({
  12569. type: 'sector',
  12570. shape: {
  12571. cx: 0,
  12572. cy: 0,
  12573. r0: 0,
  12574. r: 0,
  12575. startAngle: 0,
  12576. endAngle: Math.PI * 2,
  12577. clockwise: true
  12578. },
  12579. buildPath: function (ctx, shape) {
  12580. var x = shape.cx;
  12581. var y = shape.cy;
  12582. var r0 = Math.max(shape.r0 || 0, 0);
  12583. var r = Math.max(shape.r, 0);
  12584. var startAngle = shape.startAngle;
  12585. var endAngle = shape.endAngle;
  12586. var clockwise = shape.clockwise;
  12587. var unitX = Math.cos(startAngle);
  12588. var unitY = Math.sin(startAngle);
  12589. ctx.moveTo(unitX * r0 + x, unitY * r0 + y);
  12590. ctx.lineTo(unitX * r + x, unitY * r + y);
  12591. ctx.arc(x, y, r, startAngle, endAngle, !clockwise);
  12592. ctx.lineTo(
  12593. Math.cos(endAngle) * r0 + x,
  12594. Math.sin(endAngle) * r0 + y
  12595. );
  12596. if (r0 !== 0) {
  12597. ctx.arc(x, y, r0, endAngle, startAngle, clockwise);
  12598. }
  12599. ctx.closePath();
  12600. }
  12601. });
  12602. /***/ },
  12603. /* 65 */
  12604. /***/ function(module, exports, __webpack_require__) {
  12605. /**
  12606. * 圆环
  12607. * @module zrender/graphic/shape/Ring
  12608. */
  12609. module.exports = __webpack_require__(44).extend({
  12610. type: 'ring',
  12611. shape: {
  12612. cx: 0,
  12613. cy: 0,
  12614. r: 0,
  12615. r0: 0
  12616. },
  12617. buildPath: function (ctx, shape) {
  12618. var x = shape.cx;
  12619. var y = shape.cy;
  12620. var PI2 = Math.PI * 2;
  12621. ctx.moveTo(x + shape.r, y);
  12622. ctx.arc(x, y, shape.r, 0, PI2, false);
  12623. ctx.moveTo(x + shape.r0, y);
  12624. ctx.arc(x, y, shape.r0, 0, PI2, true);
  12625. }
  12626. });
  12627. /***/ },
  12628. /* 66 */
  12629. /***/ function(module, exports, __webpack_require__) {
  12630. /**
  12631. * 多边形
  12632. * @module zrender/shape/Polygon
  12633. */
  12634. var polyHelper = __webpack_require__(67);
  12635. module.exports = __webpack_require__(44).extend({
  12636. type: 'polygon',
  12637. shape: {
  12638. points: null,
  12639. smooth: false,
  12640. smoothConstraint: null
  12641. },
  12642. buildPath: function (ctx, shape) {
  12643. polyHelper.buildPath(ctx, shape, true);
  12644. }
  12645. });
  12646. /***/ },
  12647. /* 67 */
  12648. /***/ function(module, exports, __webpack_require__) {
  12649. var smoothSpline = __webpack_require__(68);
  12650. var smoothBezier = __webpack_require__(69);
  12651. module.exports = {
  12652. buildPath: function (ctx, shape, closePath) {
  12653. var points = shape.points;
  12654. var smooth = shape.smooth;
  12655. if (points && points.length >= 2) {
  12656. if (smooth && smooth !== 'spline') {
  12657. var controlPoints = smoothBezier(
  12658. points, smooth, closePath, shape.smoothConstraint
  12659. );
  12660. ctx.moveTo(points[0][0], points[0][1]);
  12661. var len = points.length;
  12662. for (var i = 0; i < (closePath ? len : len - 1); i++) {
  12663. var cp1 = controlPoints[i * 2];
  12664. var cp2 = controlPoints[i * 2 + 1];
  12665. var p = points[(i + 1) % len];
  12666. ctx.bezierCurveTo(
  12667. cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1]
  12668. );
  12669. }
  12670. }
  12671. else {
  12672. if (smooth === 'spline') {
  12673. points = smoothSpline(points, closePath);
  12674. }
  12675. ctx.moveTo(points[0][0], points[0][1]);
  12676. for (var i = 1, l = points.length; i < l; i++) {
  12677. ctx.lineTo(points[i][0], points[i][1]);
  12678. }
  12679. }
  12680. closePath && ctx.closePath();
  12681. }
  12682. }
  12683. };
  12684. /***/ },
  12685. /* 68 */
  12686. /***/ function(module, exports, __webpack_require__) {
  12687. /**
  12688. * Catmull-Rom spline 插值折线
  12689. * @module zrender/shape/util/smoothSpline
  12690. * @author pissang (https://www.github.com/pissang)
  12691. * Kener (@Kener-林峰, kener.linfeng@gmail.com)
  12692. * errorrik (errorrik@gmail.com)
  12693. */
  12694. var vec2 = __webpack_require__(16);
  12695. /**
  12696. * @inner
  12697. */
  12698. function interpolate(p0, p1, p2, p3, t, t2, t3) {
  12699. var v0 = (p2 - p0) * 0.5;
  12700. var v1 = (p3 - p1) * 0.5;
  12701. return (2 * (p1 - p2) + v0 + v1) * t3
  12702. + (-3 * (p1 - p2) - 2 * v0 - v1) * t2
  12703. + v0 * t + p1;
  12704. }
  12705. /**
  12706. * @alias module:zrender/shape/util/smoothSpline
  12707. * @param {Array} points 线段顶点数组
  12708. * @param {boolean} isLoop
  12709. * @return {Array}
  12710. */
  12711. module.exports = function (points, isLoop) {
  12712. var len = points.length;
  12713. var ret = [];
  12714. var distance = 0;
  12715. for (var i = 1; i < len; i++) {
  12716. distance += vec2.distance(points[i - 1], points[i]);
  12717. }
  12718. var segs = distance / 2;
  12719. segs = segs < len ? len : segs;
  12720. for (var i = 0; i < segs; i++) {
  12721. var pos = i / (segs - 1) * (isLoop ? len : len - 1);
  12722. var idx = Math.floor(pos);
  12723. var w = pos - idx;
  12724. var p0;
  12725. var p1 = points[idx % len];
  12726. var p2;
  12727. var p3;
  12728. if (!isLoop) {
  12729. p0 = points[idx === 0 ? idx : idx - 1];
  12730. p2 = points[idx > len - 2 ? len - 1 : idx + 1];
  12731. p3 = points[idx > len - 3 ? len - 1 : idx + 2];
  12732. }
  12733. else {
  12734. p0 = points[(idx - 1 + len) % len];
  12735. p2 = points[(idx + 1) % len];
  12736. p3 = points[(idx + 2) % len];
  12737. }
  12738. var w2 = w * w;
  12739. var w3 = w * w2;
  12740. ret.push([
  12741. interpolate(p0[0], p1[0], p2[0], p3[0], w, w2, w3),
  12742. interpolate(p0[1], p1[1], p2[1], p3[1], w, w2, w3)
  12743. ]);
  12744. }
  12745. return ret;
  12746. };
  12747. /***/ },
  12748. /* 69 */
  12749. /***/ function(module, exports, __webpack_require__) {
  12750. /**
  12751. * 贝塞尔平滑曲线
  12752. * @module zrender/shape/util/smoothBezier
  12753. * @author pissang (https://www.github.com/pissang)
  12754. * Kener (@Kener-林峰, kener.linfeng@gmail.com)
  12755. * errorrik (errorrik@gmail.com)
  12756. */
  12757. var vec2 = __webpack_require__(16);
  12758. var v2Min = vec2.min;
  12759. var v2Max = vec2.max;
  12760. var v2Scale = vec2.scale;
  12761. var v2Distance = vec2.distance;
  12762. var v2Add = vec2.add;
  12763. /**
  12764. * 贝塞尔平滑曲线
  12765. * @alias module:zrender/shape/util/smoothBezier
  12766. * @param {Array} points 线段顶点数组
  12767. * @param {number} smooth 平滑等级, 0-1
  12768. * @param {boolean} isLoop
  12769. * @param {Array} constraint 将计算出来的控制点约束在一个包围盒内
  12770. * 比如 [[0, 0], [100, 100]], 这个包围盒会与
  12771. * 整个折线的包围盒做一个并集用来约束控制点。
  12772. * @param {Array} 计算出来的控制点数组
  12773. */
  12774. module.exports = function (points, smooth, isLoop, constraint) {
  12775. var cps = [];
  12776. var v = [];
  12777. var v1 = [];
  12778. var v2 = [];
  12779. var prevPoint;
  12780. var nextPoint;
  12781. var min, max;
  12782. if (constraint) {
  12783. min = [Infinity, Infinity];
  12784. max = [-Infinity, -Infinity];
  12785. for (var i = 0, len = points.length; i < len; i++) {
  12786. v2Min(min, min, points[i]);
  12787. v2Max(max, max, points[i]);
  12788. }
  12789. // 与指定的包围盒做并集
  12790. v2Min(min, min, constraint[0]);
  12791. v2Max(max, max, constraint[1]);
  12792. }
  12793. for (var i = 0, len = points.length; i < len; i++) {
  12794. var point = points[i];
  12795. if (isLoop) {
  12796. prevPoint = points[i ? i - 1 : len - 1];
  12797. nextPoint = points[(i + 1) % len];
  12798. }
  12799. else {
  12800. if (i === 0 || i === len - 1) {
  12801. cps.push(vec2.clone(points[i]));
  12802. continue;
  12803. }
  12804. else {
  12805. prevPoint = points[i - 1];
  12806. nextPoint = points[i + 1];
  12807. }
  12808. }
  12809. vec2.sub(v, nextPoint, prevPoint);
  12810. // use degree to scale the handle length
  12811. v2Scale(v, v, smooth);
  12812. var d0 = v2Distance(point, prevPoint);
  12813. var d1 = v2Distance(point, nextPoint);
  12814. var sum = d0 + d1;
  12815. if (sum !== 0) {
  12816. d0 /= sum;
  12817. d1 /= sum;
  12818. }
  12819. v2Scale(v1, v, -d0);
  12820. v2Scale(v2, v, d1);
  12821. var cp0 = v2Add([], point, v1);
  12822. var cp1 = v2Add([], point, v2);
  12823. if (constraint) {
  12824. v2Max(cp0, cp0, min);
  12825. v2Min(cp0, cp0, max);
  12826. v2Max(cp1, cp1, min);
  12827. v2Min(cp1, cp1, max);
  12828. }
  12829. cps.push(cp0);
  12830. cps.push(cp1);
  12831. }
  12832. if (isLoop) {
  12833. cps.push(cps.shift());
  12834. }
  12835. return cps;
  12836. };
  12837. /***/ },
  12838. /* 70 */
  12839. /***/ function(module, exports, __webpack_require__) {
  12840. /**
  12841. * @module zrender/graphic/shape/Polyline
  12842. */
  12843. var polyHelper = __webpack_require__(67);
  12844. module.exports = __webpack_require__(44).extend({
  12845. type: 'polyline',
  12846. shape: {
  12847. points: null,
  12848. smooth: false,
  12849. smoothConstraint: null
  12850. },
  12851. style: {
  12852. stroke: '#000',
  12853. fill: null
  12854. },
  12855. buildPath: function (ctx, shape) {
  12856. polyHelper.buildPath(ctx, shape, false);
  12857. }
  12858. });
  12859. /***/ },
  12860. /* 71 */
  12861. /***/ function(module, exports, __webpack_require__) {
  12862. /**
  12863. * 矩形
  12864. * @module zrender/graphic/shape/Rect
  12865. */
  12866. var roundRectHelper = __webpack_require__(60);
  12867. module.exports = __webpack_require__(44).extend({
  12868. type: 'rect',
  12869. shape: {
  12870. // 左上、右上、右下、左下角的半径依次为r1、r2、r3、r4
  12871. // r缩写为1 相当于 [1, 1, 1, 1]
  12872. // r缩写为[1] 相当于 [1, 1, 1, 1]
  12873. // r缩写为[1, 2] 相当于 [1, 2, 1, 2]
  12874. // r缩写为[1, 2, 3] 相当于 [1, 2, 3, 2]
  12875. r: 0,
  12876. x: 0,
  12877. y: 0,
  12878. width: 0,
  12879. height: 0
  12880. },
  12881. buildPath: function (ctx, shape) {
  12882. var x = shape.x;
  12883. var y = shape.y;
  12884. var width = shape.width;
  12885. var height = shape.height;
  12886. if (!shape.r) {
  12887. ctx.rect(x, y, width, height);
  12888. }
  12889. else {
  12890. roundRectHelper.buildPath(ctx, shape);
  12891. }
  12892. ctx.closePath();
  12893. return;
  12894. }
  12895. });
  12896. /***/ },
  12897. /* 72 */
  12898. /***/ function(module, exports, __webpack_require__) {
  12899. /**
  12900. * 直线
  12901. * @module zrender/graphic/shape/Line
  12902. */
  12903. module.exports = __webpack_require__(44).extend({
  12904. type: 'line',
  12905. shape: {
  12906. // Start point
  12907. x1: 0,
  12908. y1: 0,
  12909. // End point
  12910. x2: 0,
  12911. y2: 0,
  12912. percent: 1
  12913. },
  12914. style: {
  12915. stroke: '#000',
  12916. fill: null
  12917. },
  12918. buildPath: function (ctx, shape) {
  12919. var x1 = shape.x1;
  12920. var y1 = shape.y1;
  12921. var x2 = shape.x2;
  12922. var y2 = shape.y2;
  12923. var percent = shape.percent;
  12924. if (percent === 0) {
  12925. return;
  12926. }
  12927. ctx.moveTo(x1, y1);
  12928. if (percent < 1) {
  12929. x2 = x1 * (1 - percent) + x2 * percent;
  12930. y2 = y1 * (1 - percent) + y2 * percent;
  12931. }
  12932. ctx.lineTo(x2, y2);
  12933. },
  12934. /**
  12935. * Get point at percent
  12936. * @param {number} percent
  12937. * @return {Array.<number>}
  12938. */
  12939. pointAt: function (p) {
  12940. var shape = this.shape;
  12941. return [
  12942. shape.x1 * (1 - p) + shape.x2 * p,
  12943. shape.y1 * (1 - p) + shape.y2 * p
  12944. ];
  12945. }
  12946. });
  12947. /***/ },
  12948. /* 73 */
  12949. /***/ function(module, exports, __webpack_require__) {
  12950. 'use strict';
  12951. /**
  12952. * 贝塞尔曲线
  12953. * @module zrender/shape/BezierCurve
  12954. */
  12955. var curveTool = __webpack_require__(49);
  12956. var vec2 = __webpack_require__(16);
  12957. var quadraticSubdivide = curveTool.quadraticSubdivide;
  12958. var cubicSubdivide = curveTool.cubicSubdivide;
  12959. var quadraticAt = curveTool.quadraticAt;
  12960. var cubicAt = curveTool.cubicAt;
  12961. var quadraticDerivativeAt = curveTool.quadraticDerivativeAt;
  12962. var cubicDerivativeAt = curveTool.cubicDerivativeAt;
  12963. var out = [];
  12964. function someVectorAt(shape, t, isTangent) {
  12965. var cpx2 = shape.cpx2;
  12966. var cpy2 = shape.cpy2;
  12967. if (cpx2 === null || cpy2 === null) {
  12968. return [
  12969. (isTangent ? cubicDerivativeAt : cubicAt)(shape.x1, shape.cpx1, shape.cpx2, shape.x2, t),
  12970. (isTangent ? cubicDerivativeAt : cubicAt)(shape.y1, shape.cpy1, shape.cpy2, shape.y2, t)
  12971. ];
  12972. }
  12973. else {
  12974. return [
  12975. (isTangent ? quadraticDerivativeAt : quadraticAt)(shape.x1, shape.cpx1, shape.x2, t),
  12976. (isTangent ? quadraticDerivativeAt : quadraticAt)(shape.y1, shape.cpy1, shape.y2, t)
  12977. ];
  12978. }
  12979. }
  12980. module.exports = __webpack_require__(44).extend({
  12981. type: 'bezier-curve',
  12982. shape: {
  12983. x1: 0,
  12984. y1: 0,
  12985. x2: 0,
  12986. y2: 0,
  12987. cpx1: 0,
  12988. cpy1: 0,
  12989. // cpx2: 0,
  12990. // cpy2: 0
  12991. // Curve show percent, for animating
  12992. percent: 1
  12993. },
  12994. style: {
  12995. stroke: '#000',
  12996. fill: null
  12997. },
  12998. buildPath: function (ctx, shape) {
  12999. var x1 = shape.x1;
  13000. var y1 = shape.y1;
  13001. var x2 = shape.x2;
  13002. var y2 = shape.y2;
  13003. var cpx1 = shape.cpx1;
  13004. var cpy1 = shape.cpy1;
  13005. var cpx2 = shape.cpx2;
  13006. var cpy2 = shape.cpy2;
  13007. var percent = shape.percent;
  13008. if (percent === 0) {
  13009. return;
  13010. }
  13011. ctx.moveTo(x1, y1);
  13012. if (cpx2 == null || cpy2 == null) {
  13013. if (percent < 1) {
  13014. quadraticSubdivide(
  13015. x1, cpx1, x2, percent, out
  13016. );
  13017. cpx1 = out[1];
  13018. x2 = out[2];
  13019. quadraticSubdivide(
  13020. y1, cpy1, y2, percent, out
  13021. );
  13022. cpy1 = out[1];
  13023. y2 = out[2];
  13024. }
  13025. ctx.quadraticCurveTo(
  13026. cpx1, cpy1,
  13027. x2, y2
  13028. );
  13029. }
  13030. else {
  13031. if (percent < 1) {
  13032. cubicSubdivide(
  13033. x1, cpx1, cpx2, x2, percent, out
  13034. );
  13035. cpx1 = out[1];
  13036. cpx2 = out[2];
  13037. x2 = out[3];
  13038. cubicSubdivide(
  13039. y1, cpy1, cpy2, y2, percent, out
  13040. );
  13041. cpy1 = out[1];
  13042. cpy2 = out[2];
  13043. y2 = out[3];
  13044. }
  13045. ctx.bezierCurveTo(
  13046. cpx1, cpy1,
  13047. cpx2, cpy2,
  13048. x2, y2
  13049. );
  13050. }
  13051. },
  13052. /**
  13053. * Get point at percent
  13054. * @param {number} t
  13055. * @return {Array.<number>}
  13056. */
  13057. pointAt: function (t) {
  13058. return someVectorAt(this.shape, t, false);
  13059. },
  13060. /**
  13061. * Get tangent at percent
  13062. * @param {number} t
  13063. * @return {Array.<number>}
  13064. */
  13065. tangentAt: function (t) {
  13066. var p = someVectorAt(this.shape, t, true);
  13067. return vec2.normalize(p, p);
  13068. }
  13069. });
  13070. /***/ },
  13071. /* 74 */
  13072. /***/ function(module, exports, __webpack_require__) {
  13073. /**
  13074. * 圆弧
  13075. * @module zrender/graphic/shape/Arc
  13076. */
  13077. module.exports = __webpack_require__(44).extend({
  13078. type: 'arc',
  13079. shape: {
  13080. cx: 0,
  13081. cy: 0,
  13082. r: 0,
  13083. startAngle: 0,
  13084. endAngle: Math.PI * 2,
  13085. clockwise: true
  13086. },
  13087. style: {
  13088. stroke: '#000',
  13089. fill: null
  13090. },
  13091. buildPath: function (ctx, shape) {
  13092. var x = shape.cx;
  13093. var y = shape.cy;
  13094. var r = Math.max(shape.r, 0);
  13095. var startAngle = shape.startAngle;
  13096. var endAngle = shape.endAngle;
  13097. var clockwise = shape.clockwise;
  13098. var unitX = Math.cos(startAngle);
  13099. var unitY = Math.sin(startAngle);
  13100. ctx.moveTo(unitX * r + x, unitY * r + y);
  13101. ctx.arc(x, y, r, startAngle, endAngle, !clockwise);
  13102. }
  13103. });
  13104. /***/ },
  13105. /* 75 */
  13106. /***/ function(module, exports, __webpack_require__) {
  13107. // CompoundPath to improve performance
  13108. var Path = __webpack_require__(44);
  13109. module.exports = Path.extend({
  13110. type: 'compound',
  13111. shape: {
  13112. paths: null
  13113. },
  13114. _updatePathDirty: function () {
  13115. var dirtyPath = this.__dirtyPath;
  13116. var paths = this.shape.paths;
  13117. for (var i = 0; i < paths.length; i++) {
  13118. // Mark as dirty if any subpath is dirty
  13119. dirtyPath = dirtyPath || paths[i].__dirtyPath;
  13120. }
  13121. this.__dirtyPath = dirtyPath;
  13122. this.__dirty = this.__dirty || dirtyPath;
  13123. },
  13124. beforeBrush: function () {
  13125. this._updatePathDirty();
  13126. var paths = this.shape.paths || [];
  13127. var scale = this.getGlobalScale();
  13128. // Update path scale
  13129. for (var i = 0; i < paths.length; i++) {
  13130. paths[i].path.setScale(scale[0], scale[1]);
  13131. }
  13132. },
  13133. buildPath: function (ctx, shape) {
  13134. var paths = shape.paths || [];
  13135. for (var i = 0; i < paths.length; i++) {
  13136. paths[i].buildPath(ctx, paths[i].shape);
  13137. }
  13138. },
  13139. afterBrush: function () {
  13140. var paths = this.shape.paths;
  13141. for (var i = 0; i < paths.length; i++) {
  13142. paths[i].__dirtyPath = false;
  13143. }
  13144. },
  13145. getBoundingRect: function () {
  13146. this._updatePathDirty();
  13147. return Path.prototype.getBoundingRect.call(this);
  13148. }
  13149. });
  13150. /***/ },
  13151. /* 76 */
  13152. /***/ function(module, exports, __webpack_require__) {
  13153. 'use strict';
  13154. var zrUtil = __webpack_require__(3);
  13155. var Gradient = __webpack_require__(4);
  13156. /**
  13157. * x, y, x2, y2 are all percent from 0 to 1
  13158. * @param {number} [x=0]
  13159. * @param {number} [y=0]
  13160. * @param {number} [x2=1]
  13161. * @param {number} [y2=0]
  13162. * @param {Array.<Object>} colorStops
  13163. */
  13164. var LinearGradient = function (x, y, x2, y2, colorStops) {
  13165. this.x = x == null ? 0 : x;
  13166. this.y = y == null ? 0 : y;
  13167. this.x2 = x2 == null ? 1 : x2;
  13168. this.y2 = y2 == null ? 0 : y2;
  13169. Gradient.call(this, colorStops);
  13170. };
  13171. LinearGradient.prototype = {
  13172. constructor: LinearGradient,
  13173. type: 'linear'
  13174. };
  13175. zrUtil.inherits(LinearGradient, Gradient);
  13176. module.exports = LinearGradient;
  13177. /***/ },
  13178. /* 77 */
  13179. /***/ function(module, exports, __webpack_require__) {
  13180. 'use strict';
  13181. var zrUtil = __webpack_require__(3);
  13182. var Gradient = __webpack_require__(4);
  13183. /**
  13184. * x, y, r are all percent from 0 to 1
  13185. * @param {number} [x=0.5]
  13186. * @param {number} [y=0.5]
  13187. * @param {number} [r=0.5]
  13188. * @param {Array.<Object>} [colorStops]
  13189. */
  13190. var RadialGradient = function (x, y, r, colorStops) {
  13191. this.x = x == null ? 0.5 : x;
  13192. this.y = y == null ? 0.5 : y;
  13193. this.r = r == null ? 0.5 : r;
  13194. Gradient.call(this, colorStops);
  13195. };
  13196. RadialGradient.prototype = {
  13197. constructor: RadialGradient,
  13198. type: 'radial'
  13199. };
  13200. zrUtil.inherits(RadialGradient, Gradient);
  13201. module.exports = RadialGradient;
  13202. /***/ },
  13203. /* 78 */
  13204. /***/ function(module, exports, __webpack_require__) {
  13205. /*!
  13206. * ZRender, a high performance 2d drawing library.
  13207. *
  13208. * Copyright (c) 2013, Baidu Inc.
  13209. * All rights reserved.
  13210. *
  13211. * LICENSE
  13212. * https://github.com/ecomfe/zrender/blob/master/LICENSE.txt
  13213. */
  13214. // Global defines
  13215. var guid = __webpack_require__(31);
  13216. var env = __webpack_require__(79);
  13217. var Handler = __webpack_require__(80);
  13218. var Storage = __webpack_require__(84);
  13219. var Animation = __webpack_require__(85);
  13220. var useVML = !env.canvasSupported;
  13221. var painterCtors = {
  13222. canvas: __webpack_require__(86)
  13223. };
  13224. var instances = {}; // ZRender实例map索引
  13225. var zrender = {};
  13226. /**
  13227. * @type {string}
  13228. */
  13229. zrender.version = '3.1.0';
  13230. /**
  13231. * Initializing a zrender instance
  13232. * @param {HTMLElement} dom
  13233. * @param {Object} opts
  13234. * @param {string} [opts.renderer='canvas'] 'canvas' or 'svg'
  13235. * @param {number} [opts.devicePixelRatio]
  13236. * @return {module:zrender/ZRender}
  13237. */
  13238. zrender.init = function(dom, opts) {
  13239. var zr = new ZRender(guid(), dom, opts);
  13240. instances[zr.id] = zr;
  13241. return zr;
  13242. };
  13243. /**
  13244. * Dispose zrender instance
  13245. * @param {module:zrender/ZRender} zr
  13246. */
  13247. zrender.dispose = function (zr) {
  13248. if (zr) {
  13249. zr.dispose();
  13250. }
  13251. else {
  13252. for (var key in instances) {
  13253. instances[key].dispose();
  13254. }
  13255. instances = {};
  13256. }
  13257. return zrender;
  13258. };
  13259. /**
  13260. * Get zrender instance by id
  13261. * @param {string} id zrender instance id
  13262. * @return {module:zrender/ZRender}
  13263. */
  13264. zrender.getInstance = function (id) {
  13265. return instances[id];
  13266. };
  13267. zrender.registerPainter = function (name, Ctor) {
  13268. painterCtors[name] = Ctor;
  13269. };
  13270. function delInstance(id) {
  13271. delete instances[id];
  13272. }
  13273. /**
  13274. * @module zrender/ZRender
  13275. */
  13276. /**
  13277. * @constructor
  13278. * @alias module:zrender/ZRender
  13279. * @param {string} id
  13280. * @param {HTMLDomElement} dom
  13281. * @param {Object} opts
  13282. * @param {string} [opts.renderer='canvas'] 'canvas' or 'svg'
  13283. * @param {number} [opts.devicePixelRatio]
  13284. */
  13285. var ZRender = function(id, dom, opts) {
  13286. opts = opts || {};
  13287. /**
  13288. * @type {HTMLDomElement}
  13289. */
  13290. this.dom = dom;
  13291. /**
  13292. * @type {string}
  13293. */
  13294. this.id = id;
  13295. var self = this;
  13296. var storage = new Storage();
  13297. var rendererType = opts.renderer;
  13298. if (useVML) {
  13299. if (!painterCtors.vml) {
  13300. throw new Error('You need to require \'zrender/vml/vml\' to support IE8');
  13301. }
  13302. rendererType = 'vml';
  13303. }
  13304. else if (!rendererType || !painterCtors[rendererType]) {
  13305. rendererType = 'canvas';
  13306. }
  13307. var painter = new painterCtors[rendererType](dom, storage, opts);
  13308. this.storage = storage;
  13309. this.painter = painter;
  13310. if (!env.node) {
  13311. this.handler = new Handler(painter.getViewportRoot(), storage, painter);
  13312. }
  13313. /**
  13314. * @type {module:zrender/animation/Animation}
  13315. */
  13316. this.animation = new Animation({
  13317. stage: {
  13318. update: function () {
  13319. if (self._needsRefresh) {
  13320. self.refreshImmediately();
  13321. }
  13322. }
  13323. }
  13324. });
  13325. this.animation.start();
  13326. /**
  13327. * @type {boolean}
  13328. * @private
  13329. */
  13330. this._needsRefresh;
  13331. // 修改 storage.delFromMap, 每次删除元素之前删除动画
  13332. // FIXME 有点ugly
  13333. var oldDelFromMap = storage.delFromMap;
  13334. var oldAddToMap = storage.addToMap;
  13335. storage.delFromMap = function (elId) {
  13336. var el = storage.get(elId);
  13337. oldDelFromMap.call(storage, elId);
  13338. el && el.removeSelfFromZr(self);
  13339. };
  13340. storage.addToMap = function (el) {
  13341. oldAddToMap.call(storage, el);
  13342. el.addSelfToZr(self);
  13343. };
  13344. };
  13345. ZRender.prototype = {
  13346. constructor: ZRender,
  13347. /**
  13348. * 获取实例唯一标识
  13349. * @return {string}
  13350. */
  13351. getId: function () {
  13352. return this.id;
  13353. },
  13354. /**
  13355. * 添加元素
  13356. * @param {string|module:zrender/Element} el
  13357. */
  13358. add: function (el) {
  13359. this.storage.addRoot(el);
  13360. this._needsRefresh = true;
  13361. },
  13362. /**
  13363. * 删除元素
  13364. * @param {string|module:zrender/Element} el
  13365. */
  13366. remove: function (el) {
  13367. this.storage.delRoot(el);
  13368. this._needsRefresh = true;
  13369. },
  13370. /**
  13371. * Change configuration of layer
  13372. * @param {string} zLevel
  13373. * @param {Object} config
  13374. * @param {string} [config.clearColor=0] Clear color
  13375. * @param {string} [config.motionBlur=false] If enable motion blur
  13376. * @param {number} [config.lastFrameAlpha=0.7] Motion blur factor. Larger value cause longer trailer
  13377. */
  13378. configLayer: function (zLevel, config) {
  13379. this.painter.configLayer(zLevel, config);
  13380. this._needsRefresh = true;
  13381. },
  13382. /**
  13383. * Repaint the canvas immediately
  13384. */
  13385. refreshImmediately: function () {
  13386. // Clear needsRefresh ahead to avoid something wrong happens in refresh
  13387. // Or it will cause zrender refreshes again and again.
  13388. this._needsRefresh = false;
  13389. this.painter.refresh();
  13390. /**
  13391. * Avoid trigger zr.refresh in Element#beforeUpdate hook
  13392. */
  13393. this._needsRefresh = false;
  13394. },
  13395. /**
  13396. * Mark and repaint the canvas in the next frame of browser
  13397. */
  13398. refresh: function() {
  13399. this._needsRefresh = true;
  13400. },
  13401. /**
  13402. * Resize the canvas.
  13403. * Should be invoked when container size is changed
  13404. */
  13405. resize: function() {
  13406. this.painter.resize();
  13407. this.handler && this.handler.resize();
  13408. },
  13409. /**
  13410. * Stop and clear all animation immediately
  13411. */
  13412. clearAnimation: function () {
  13413. this.animation.clear();
  13414. },
  13415. /**
  13416. * Get container width
  13417. */
  13418. getWidth: function() {
  13419. return this.painter.getWidth();
  13420. },
  13421. /**
  13422. * Get container height
  13423. */
  13424. getHeight: function() {
  13425. return this.painter.getHeight();
  13426. },
  13427. /**
  13428. * Export the canvas as Base64 URL
  13429. * @param {string} type
  13430. * @param {string} [backgroundColor='#fff']
  13431. * @return {string} Base64 URL
  13432. */
  13433. // toDataURL: function(type, backgroundColor) {
  13434. // return this.painter.getRenderedCanvas({
  13435. // backgroundColor: backgroundColor
  13436. // }).toDataURL(type);
  13437. // },
  13438. /**
  13439. * Converting a path to image.
  13440. * It has much better performance of drawing image rather than drawing a vector path.
  13441. * @param {module:zrender/graphic/Path} e
  13442. * @param {number} width
  13443. * @param {number} height
  13444. */
  13445. pathToImage: function(e, width, height) {
  13446. var id = guid();
  13447. return this.painter.pathToImage(id, e, width, height);
  13448. },
  13449. /**
  13450. * Set default cursor
  13451. * @param {string} cursorStyle 例如 crosshair
  13452. */
  13453. setDefaultCursorStyle: function (cursorStyle) {
  13454. this.handler.setDefaultCursorStyle(cursorStyle);
  13455. },
  13456. /**
  13457. * Bind event
  13458. *
  13459. * @param {string} eventName Event name
  13460. * @param {Function} eventHandler Handler function
  13461. * @param {Object} [context] Context object
  13462. */
  13463. on: function(eventName, eventHandler, context) {
  13464. this.handler && this.handler.on(eventName, eventHandler, context);
  13465. },
  13466. /**
  13467. * Unbind event
  13468. * @param {string} eventName Event name
  13469. * @param {Function} [eventHandler] Handler function
  13470. */
  13471. off: function(eventName, eventHandler) {
  13472. this.handler && this.handler.off(eventName, eventHandler);
  13473. },
  13474. /**
  13475. * Trigger event manually
  13476. *
  13477. * @param {string} eventName Event name
  13478. * @param {event=} event Event object
  13479. */
  13480. trigger: function (eventName, event) {
  13481. this.handler && this.handler.trigger(eventName, event);
  13482. },
  13483. /**
  13484. * Clear all objects and the canvas.
  13485. */
  13486. clear: function () {
  13487. this.storage.delRoot();
  13488. this.painter.clear();
  13489. },
  13490. /**
  13491. * Dispose self.
  13492. */
  13493. dispose: function () {
  13494. this.animation.stop();
  13495. this.clear();
  13496. this.storage.dispose();
  13497. this.painter.dispose();
  13498. this.handler && this.handler.dispose();
  13499. this.animation =
  13500. this.storage =
  13501. this.painter =
  13502. this.handler = null;
  13503. delInstance(this.id);
  13504. }
  13505. };
  13506. module.exports = zrender;
  13507. /***/ },
  13508. /* 79 */
  13509. /***/ function(module, exports) {
  13510. /**
  13511. * echarts设备环境识别
  13512. *
  13513. * @desc echarts基于Canvas,纯Javascript图表库,提供直观,生动,可交互,可个性化定制的数据统计图表。
  13514. * @author firede[firede@firede.us]
  13515. * @desc thanks zepto.
  13516. */
  13517. var env = {};
  13518. if (typeof navigator === 'undefined') {
  13519. // In node
  13520. env = {
  13521. browser: {},
  13522. os: {},
  13523. node: true,
  13524. // Assume canvas is supported
  13525. canvasSupported: true
  13526. };
  13527. }
  13528. else {
  13529. env = detect(navigator.userAgent);
  13530. }
  13531. module.exports = env;
  13532. // Zepto.js
  13533. // (c) 2010-2013 Thomas Fuchs
  13534. // Zepto.js may be freely distributed under the MIT license.
  13535. function detect(ua) {
  13536. var os = {};
  13537. var browser = {};
  13538. var webkit = ua.match(/Web[kK]it[\/]{0,1}([\d.]+)/);
  13539. var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/);
  13540. var ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
  13541. var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
  13542. var iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/);
  13543. var webos = ua.match(/(webOS|hpwOS)[\s\/]([\d.]+)/);
  13544. var touchpad = webos && ua.match(/TouchPad/);
  13545. var kindle = ua.match(/Kindle\/([\d.]+)/);
  13546. var silk = ua.match(/Silk\/([\d._]+)/);
  13547. var blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/);
  13548. var bb10 = ua.match(/(BB10).*Version\/([\d.]+)/);
  13549. var rimtabletos = ua.match(/(RIM\sTablet\sOS)\s([\d.]+)/);
  13550. var playbook = ua.match(/PlayBook/);
  13551. var chrome = ua.match(/Chrome\/([\d.]+)/) || ua.match(/CriOS\/([\d.]+)/);
  13552. var firefox = ua.match(/Firefox\/([\d.]+)/);
  13553. var safari = webkit && ua.match(/Mobile\//) && !chrome;
  13554. var webview = ua.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/) && !chrome;
  13555. var ie = ua.match(/MSIE\s([\d.]+)/)
  13556. // IE 11 Trident/7.0; rv:11.0
  13557. || ua.match(/Trident\/.+?rv:(([\d.]+))/);
  13558. var edge = ua.match(/Edge\/([\d.]+)/); // IE 12 and 12+
  13559. // Todo: clean this up with a better OS/browser seperation:
  13560. // - discern (more) between multiple browsers on android
  13561. // - decide if kindle fire in silk mode is android or not
  13562. // - Firefox on Android doesn't specify the Android version
  13563. // - possibly devide in os, device and browser hashes
  13564. if (browser.webkit = !!webkit) browser.version = webkit[1];
  13565. if (android) os.android = true, os.version = android[2];
  13566. if (iphone && !ipod) os.ios = os.iphone = true, os.version = iphone[2].replace(/_/g, '.');
  13567. if (ipad) os.ios = os.ipad = true, os.version = ipad[2].replace(/_/g, '.');
  13568. if (ipod) os.ios = os.ipod = true, os.version = ipod[3] ? ipod[3].replace(/_/g, '.') : null;
  13569. if (webos) os.webos = true, os.version = webos[2];
  13570. if (touchpad) os.touchpad = true;
  13571. if (blackberry) os.blackberry = true, os.version = blackberry[2];
  13572. if (bb10) os.bb10 = true, os.version = bb10[2];
  13573. if (rimtabletos) os.rimtabletos = true, os.version = rimtabletos[2];
  13574. if (playbook) browser.playbook = true;
  13575. if (kindle) os.kindle = true, os.version = kindle[1];
  13576. if (silk) browser.silk = true, browser.version = silk[1];
  13577. if (!silk && os.android && ua.match(/Kindle Fire/)) browser.silk = true;
  13578. if (chrome) browser.chrome = true, browser.version = chrome[1];
  13579. if (firefox) browser.firefox = true, browser.version = firefox[1];
  13580. if (ie) browser.ie = true, browser.version = ie[1];
  13581. if (safari && (ua.match(/Safari/) || !!os.ios)) browser.safari = true;
  13582. if (webview) browser.webview = true;
  13583. if (ie) browser.ie = true, browser.version = ie[1];
  13584. if (edge) browser.edge = true, browser.version = edge[1];
  13585. os.tablet = !!(ipad || playbook || (android && !ua.match(/Mobile/)) ||
  13586. (firefox && ua.match(/Tablet/)) || (ie && !ua.match(/Phone/) && ua.match(/Touch/)));
  13587. os.phone = !!(!os.tablet && !os.ipod && (android || iphone || webos || blackberry || bb10 ||
  13588. (chrome && ua.match(/Android/)) || (chrome && ua.match(/CriOS\/([\d.]+)/)) ||
  13589. (firefox && ua.match(/Mobile/)) || (ie && ua.match(/Touch/))));
  13590. return {
  13591. browser: browser,
  13592. os: os,
  13593. node: false,
  13594. // 原生canvas支持,改极端点了
  13595. // canvasSupported : !(browser.ie && parseFloat(browser.version) < 9)
  13596. canvasSupported : document.createElement('canvas').getContext ? true : false,
  13597. // @see <http://stackoverflow.com/questions/4817029/whats-the-best-way-to-detect-a-touch-screen-device-using-javascript>
  13598. // works on most browsers
  13599. // IE10/11 does not support touch event, and MS Edge supports them but not by
  13600. // default, so we dont check navigator.maxTouchPoints for them here.
  13601. touchEventsSupported: 'ontouchstart' in window && !browser.ie && !browser.edge,
  13602. // <http://caniuse.com/#search=pointer%20event>.
  13603. pointerEventsSupported: 'onpointerdown' in window
  13604. // Firefox supports pointer but not by default,
  13605. // only MS browsers are reliable on pointer events currently.
  13606. && (browser.edge || (browser.ie && browser.version >= 10))
  13607. };
  13608. }
  13609. /***/ },
  13610. /* 80 */
  13611. /***/ function(module, exports, __webpack_require__) {
  13612. 'use strict';
  13613. /**
  13614. * Handler
  13615. * @module zrender/Handler
  13616. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  13617. * errorrik (errorrik@gmail.com)
  13618. * pissang (shenyi.914@gmail.com)
  13619. */
  13620. var env = __webpack_require__(79);
  13621. var eventTool = __webpack_require__(81);
  13622. var util = __webpack_require__(3);
  13623. var Draggable = __webpack_require__(82);
  13624. var GestureMgr = __webpack_require__(83);
  13625. var Eventful = __webpack_require__(32);
  13626. var mouseHandlerNames = [
  13627. 'click', 'dblclick', 'mousewheel', 'mouseout'
  13628. ];
  13629. !usePointerEvent() && mouseHandlerNames.push(
  13630. 'mouseup', 'mousedown', 'mousemove'
  13631. );
  13632. var touchHandlerNames = [
  13633. 'touchstart', 'touchend', 'touchmove'
  13634. ];
  13635. var pointerHandlerNames = [
  13636. 'pointerdown', 'pointerup', 'pointermove'
  13637. ];
  13638. var TOUCH_CLICK_DELAY = 300;
  13639. var addEventListener = eventTool.addEventListener;
  13640. var removeEventListener = eventTool.removeEventListener;
  13641. var normalizeEvent = eventTool.normalizeEvent;
  13642. function makeEventPacket(eveType, target, event) {
  13643. return {
  13644. type: eveType,
  13645. event: event,
  13646. target: target,
  13647. cancelBubble: false,
  13648. offsetX: event.zrX,
  13649. offsetY: event.zrY,
  13650. gestureEvent: event.gestureEvent,
  13651. pinchX: event.pinchX,
  13652. pinchY: event.pinchY,
  13653. pinchScale: event.pinchScale,
  13654. wheelDelta: event.zrDelta
  13655. };
  13656. }
  13657. var domHandlers = {
  13658. /**
  13659. * Mouse move handler
  13660. * @inner
  13661. * @param {Event} event
  13662. */
  13663. mousemove: function (event) {
  13664. event = normalizeEvent(this.root, event);
  13665. var x = event.zrX;
  13666. var y = event.zrY;
  13667. var hovered = this.findHover(x, y, null);
  13668. var lastHovered = this._hovered;
  13669. this._hovered = hovered;
  13670. this.root.style.cursor = hovered ? hovered.cursor : this._defaultCursorStyle;
  13671. // Mouse out on previous hovered element
  13672. if (lastHovered && hovered !== lastHovered && lastHovered.__zr) {
  13673. this._dispatchProxy(lastHovered, 'mouseout', event);
  13674. }
  13675. // Mouse moving on one element
  13676. this._dispatchProxy(hovered, 'mousemove', event);
  13677. // Mouse over on a new element
  13678. if (hovered && hovered !== lastHovered) {
  13679. this._dispatchProxy(hovered, 'mouseover', event);
  13680. }
  13681. },
  13682. /**
  13683. * Mouse out handler
  13684. * @inner
  13685. * @param {Event} event
  13686. */
  13687. mouseout: function (event) {
  13688. event = normalizeEvent(this.root, event);
  13689. var element = event.toElement || event.relatedTarget;
  13690. if (element != this.root) {
  13691. while (element && element.nodeType != 9) {
  13692. // 忽略包含在root中的dom引起的mouseOut
  13693. if (element === this.root) {
  13694. return;
  13695. }
  13696. element = element.parentNode;
  13697. }
  13698. }
  13699. this._dispatchProxy(this._hovered, 'mouseout', event);
  13700. this.trigger('globalout', {
  13701. event: event
  13702. });
  13703. },
  13704. /**
  13705. * Touch开始响应函数
  13706. * @inner
  13707. * @param {Event} event
  13708. */
  13709. touchstart: function (event) {
  13710. // Default mouse behaviour should not be disabled here.
  13711. // For example, page may needs to be slided.
  13712. // eventTool.stop(event);
  13713. event = normalizeEvent(this.root, event);
  13714. this._lastTouchMoment = new Date();
  13715. processGesture(this, event, 'start');
  13716. // 平板补充一次findHover
  13717. // this._mobileFindFixed(event);
  13718. // Trigger mousemove and mousedown
  13719. domHandlers.mousemove.call(this, event);
  13720. domHandlers.mousedown.call(this, event);
  13721. setTouchTimer(this);
  13722. },
  13723. /**
  13724. * Touch移动响应函数
  13725. * @inner
  13726. * @param {Event} event
  13727. */
  13728. touchmove: function (event) {
  13729. // eventTool.stop(event);// 阻止浏览器默认事件,重要
  13730. event = normalizeEvent(this.root, event);
  13731. processGesture(this, event, 'change');
  13732. // Mouse move should always be triggered no matter whether
  13733. // there is gestrue event, because mouse move and pinch may
  13734. // be used at the same time.
  13735. domHandlers.mousemove.call(this, event);
  13736. setTouchTimer(this);
  13737. },
  13738. /**
  13739. * Touch结束响应函数
  13740. * @inner
  13741. * @param {Event} event
  13742. */
  13743. touchend: function (event) {
  13744. // eventTool.stop(event);// 阻止浏览器默认事件,重要
  13745. event = normalizeEvent(this.root, event);
  13746. processGesture(this, event, 'end');
  13747. domHandlers.mouseup.call(this, event);
  13748. // click event should always be triggered no matter whether
  13749. // there is gestrue event. System click can not be prevented.
  13750. if (+new Date() - this._lastTouchMoment < TOUCH_CLICK_DELAY) {
  13751. // this._mobileFindFixed(event);
  13752. domHandlers.click.call(this, event);
  13753. }
  13754. setTouchTimer(this);
  13755. }
  13756. };
  13757. // Common handlers
  13758. util.each(['click', 'mousedown', 'mouseup', 'mousewheel', 'dblclick'], function (name) {
  13759. domHandlers[name] = function (event) {
  13760. event = normalizeEvent(this.root, event);
  13761. // Find hover again to avoid click event is dispatched manually. Or click is triggered without mouseover
  13762. var hovered = this.findHover(event.zrX, event.zrY, null);
  13763. if (name === 'mousedown') {
  13764. this._downel = hovered;
  13765. // In case click triggered before mouseup
  13766. this._upel = hovered;
  13767. }
  13768. else if (name === 'mosueup') {
  13769. this._upel = hovered;
  13770. }
  13771. else if (name === 'click') {
  13772. if (this._downel !== this._upel) {
  13773. return;
  13774. }
  13775. }
  13776. this._dispatchProxy(hovered, name, event);
  13777. };
  13778. });
  13779. // Pointer event handlers
  13780. // util.each(['pointerdown', 'pointermove', 'pointerup'], function (name) {
  13781. // domHandlers[name] = function (event) {
  13782. // var mouseName = name.replace('pointer', 'mouse');
  13783. // domHandlers[mouseName].call(this, event);
  13784. // };
  13785. // });
  13786. function processGesture(zrHandler, event, stage) {
  13787. var gestureMgr = zrHandler._gestureMgr;
  13788. stage === 'start' && gestureMgr.clear();
  13789. var gestureInfo = gestureMgr.recognize(
  13790. event,
  13791. zrHandler.findHover(event.zrX, event.zrY, null)
  13792. );
  13793. stage === 'end' && gestureMgr.clear();
  13794. if (gestureInfo) {
  13795. // eventTool.stop(event);
  13796. var type = gestureInfo.type;
  13797. event.gestureEvent = type;
  13798. zrHandler._dispatchProxy(gestureInfo.target, type, gestureInfo.event);
  13799. }
  13800. }
  13801. /**
  13802. * 为控制类实例初始化dom 事件处理函数
  13803. *
  13804. * @inner
  13805. * @param {module:zrender/Handler} instance 控制类实例
  13806. */
  13807. function initDomHandler(instance) {
  13808. var handlerNames = touchHandlerNames.concat(pointerHandlerNames);
  13809. for (var i = 0; i < handlerNames.length; i++) {
  13810. var name = handlerNames[i];
  13811. instance._handlers[name] = util.bind(domHandlers[name], instance);
  13812. }
  13813. for (var i = 0; i < mouseHandlerNames.length; i++) {
  13814. var name = mouseHandlerNames[i];
  13815. instance._handlers[name] = makeMouseHandler(domHandlers[name], instance);
  13816. }
  13817. function makeMouseHandler(fn, instance) {
  13818. return function () {
  13819. if (instance._touching) {
  13820. return;
  13821. }
  13822. return fn.apply(instance, arguments);
  13823. };
  13824. }
  13825. }
  13826. /**
  13827. * @alias module:zrender/Handler
  13828. * @constructor
  13829. * @extends module:zrender/mixin/Eventful
  13830. * @param {HTMLElement} root Main HTML element for painting.
  13831. * @param {module:zrender/Storage} storage Storage instance.
  13832. * @param {module:zrender/Painter} painter Painter instance.
  13833. */
  13834. var Handler = function(root, storage, painter) {
  13835. Eventful.call(this);
  13836. this.root = root;
  13837. this.storage = storage;
  13838. this.painter = painter;
  13839. /**
  13840. * @private
  13841. * @type {boolean}
  13842. */
  13843. this._hovered;
  13844. /**
  13845. * @private
  13846. * @type {Date}
  13847. */
  13848. this._lastTouchMoment;
  13849. /**
  13850. * @private
  13851. * @type {number}
  13852. */
  13853. this._lastX;
  13854. /**
  13855. * @private
  13856. * @type {number}
  13857. */
  13858. this._lastY;
  13859. /**
  13860. * @private
  13861. * @type {string}
  13862. */
  13863. this._defaultCursorStyle = 'default';
  13864. /**
  13865. * @private
  13866. * @type {module:zrender/core/GestureMgr}
  13867. */
  13868. this._gestureMgr = new GestureMgr();
  13869. /**
  13870. * @private
  13871. * @type {Array.<Function>}
  13872. */
  13873. this._handlers = [];
  13874. /**
  13875. * @private
  13876. * @type {boolean}
  13877. */
  13878. this._touching = false;
  13879. /**
  13880. * @private
  13881. * @type {number}
  13882. */
  13883. this._touchTimer;
  13884. initDomHandler(this);
  13885. if (usePointerEvent()) {
  13886. mountHandlers(pointerHandlerNames, this);
  13887. }
  13888. else if (useTouchEvent()) {
  13889. mountHandlers(touchHandlerNames, this);
  13890. // Handler of 'mouseout' event is needed in touch mode, which will be mounted below.
  13891. // addEventListener(root, 'mouseout', this._mouseoutHandler);
  13892. }
  13893. // Considering some devices that both enable touch and mouse event (like MS Surface
  13894. // and lenovo X240, @see #2350), we make mouse event be always listened, otherwise
  13895. // mouse event can not be handle in those devices.
  13896. mountHandlers(mouseHandlerNames, this);
  13897. Draggable.call(this);
  13898. function mountHandlers(handlerNames, instance) {
  13899. util.each(handlerNames, function (name) {
  13900. addEventListener(root, eventNameFix(name), instance._handlers[name]);
  13901. }, instance);
  13902. }
  13903. };
  13904. Handler.prototype = {
  13905. constructor: Handler,
  13906. /**
  13907. * Resize
  13908. */
  13909. resize: function (event) {
  13910. this._hovered = null;
  13911. },
  13912. /**
  13913. * Dispatch event
  13914. * @param {string} eventName
  13915. * @param {event=} eventArgs
  13916. */
  13917. dispatch: function (eventName, eventArgs) {
  13918. var handler = this._handlers[eventName];
  13919. handler && handler.call(this, eventArgs);
  13920. },
  13921. /**
  13922. * Dispose
  13923. */
  13924. dispose: function () {
  13925. var root = this.root;
  13926. var handlerNames = mouseHandlerNames.concat(touchHandlerNames);
  13927. for (var i = 0; i < handlerNames.length; i++) {
  13928. var name = handlerNames[i];
  13929. removeEventListener(root, eventNameFix(name), this._handlers[name]);
  13930. }
  13931. this.root =
  13932. this.storage =
  13933. this.painter = null;
  13934. },
  13935. /**
  13936. * 设置默认的cursor style
  13937. * @param {string} cursorStyle 例如 crosshair
  13938. */
  13939. setDefaultCursorStyle: function (cursorStyle) {
  13940. this._defaultCursorStyle = cursorStyle;
  13941. },
  13942. /**
  13943. * 事件分发代理
  13944. *
  13945. * @private
  13946. * @param {Object} targetEl 目标图形元素
  13947. * @param {string} eventName 事件名称
  13948. * @param {Object} event 事件对象
  13949. */
  13950. _dispatchProxy: function (targetEl, eventName, event) {
  13951. var eventHandler = 'on' + eventName;
  13952. var eventPacket = makeEventPacket(eventName, targetEl, event);
  13953. var el = targetEl;
  13954. while (el) {
  13955. el[eventHandler]
  13956. && (eventPacket.cancelBubble = el[eventHandler].call(el, eventPacket));
  13957. el.trigger(eventName, eventPacket);
  13958. el = el.parent;
  13959. if (eventPacket.cancelBubble) {
  13960. break;
  13961. }
  13962. }
  13963. if (!eventPacket.cancelBubble) {
  13964. // 冒泡到顶级 zrender 对象
  13965. this.trigger(eventName, eventPacket);
  13966. // 分发事件到用户自定义层
  13967. // 用户有可能在全局 click 事件中 dispose,所以需要判断下 painter 是否存在
  13968. this.painter && this.painter.eachOtherLayer(function (layer) {
  13969. if (typeof(layer[eventHandler]) == 'function') {
  13970. layer[eventHandler].call(layer, eventPacket);
  13971. }
  13972. if (layer.trigger) {
  13973. layer.trigger(eventName, eventPacket);
  13974. }
  13975. });
  13976. }
  13977. },
  13978. /**
  13979. * @private
  13980. * @param {number} x
  13981. * @param {number} y
  13982. * @param {module:zrender/graphic/Displayable} exclude
  13983. * @method
  13984. */
  13985. findHover: function(x, y, exclude) {
  13986. var list = this.storage.getDisplayList();
  13987. for (var i = list.length - 1; i >= 0 ; i--) {
  13988. if (!list[i].silent
  13989. && list[i] !== exclude
  13990. // getDisplayList may include ignored item in VML mode
  13991. && !list[i].ignore
  13992. && isHover(list[i], x, y)) {
  13993. return list[i];
  13994. }
  13995. }
  13996. }
  13997. };
  13998. function isHover(displayable, x, y) {
  13999. if (displayable[displayable.rectHover ? 'rectContain' : 'contain'](x, y)) {
  14000. var el = displayable;
  14001. while (el) {
  14002. // If ancestor is silent or clipped by ancestor
  14003. if (el.silent || (el.clipPath && !el.clipPath.contain(x, y))) {
  14004. return false;
  14005. }
  14006. el = el.parent;
  14007. }
  14008. return true;
  14009. }
  14010. return false;
  14011. }
  14012. /**
  14013. * Prevent mouse event from being dispatched after Touch Events action
  14014. * @see <https://github.com/deltakosh/handjs/blob/master/src/hand.base.js>
  14015. * 1. Mobile browsers dispatch mouse events 300ms after touchend.
  14016. * 2. Chrome for Android dispatch mousedown for long-touch about 650ms
  14017. * Result: Blocking Mouse Events for 700ms.
  14018. */
  14019. function setTouchTimer(instance) {
  14020. instance._touching = true;
  14021. clearTimeout(instance._touchTimer);
  14022. instance._touchTimer = setTimeout(function () {
  14023. instance._touching = false;
  14024. }, 700);
  14025. }
  14026. /**
  14027. * Althought MS Surface support screen touch, IE10/11 do not support
  14028. * touch event and MS Edge supported them but not by default (but chrome
  14029. * and firefox do). Thus we use Pointer event on MS browsers to handle touch.
  14030. */
  14031. function usePointerEvent() {
  14032. // TODO
  14033. // pointermove event dont trigger when using finger.
  14034. // We may figger it out latter.
  14035. return false;
  14036. // return env.pointerEventsSupported
  14037. // In no-touch device we dont use pointer evnets but just
  14038. // use mouse event for avoiding problems.
  14039. // && window.navigator.maxTouchPoints;
  14040. }
  14041. function useTouchEvent() {
  14042. return env.touchEventsSupported;
  14043. }
  14044. function eventNameFix(name) {
  14045. return (name === 'mousewheel' && env.browser.firefox) ? 'DOMMouseScroll' : name;
  14046. }
  14047. util.mixin(Handler, Eventful);
  14048. util.mixin(Handler, Draggable);
  14049. module.exports = Handler;
  14050. /***/ },
  14051. /* 81 */
  14052. /***/ function(module, exports, __webpack_require__) {
  14053. 'use strict';
  14054. /**
  14055. * 事件辅助类
  14056. * @module zrender/core/event
  14057. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  14058. */
  14059. var Eventful = __webpack_require__(32);
  14060. var isDomLevel2 = (typeof window !== 'undefined') && !!window.addEventListener;
  14061. function getBoundingClientRect(el) {
  14062. // BlackBerry 5, iOS 3 (original iPhone) don't have getBoundingRect
  14063. return el.getBoundingClientRect ? el.getBoundingClientRect() : { left: 0, top: 0};
  14064. }
  14065. /**
  14066. * 如果存在第三方嵌入的一些dom触发的事件,或touch事件,需要转换一下事件坐标
  14067. */
  14068. function normalizeEvent(el, e) {
  14069. e = e || window.event;
  14070. if (e.zrX != null) {
  14071. return e;
  14072. }
  14073. var eventType = e.type;
  14074. var isTouch = eventType && eventType.indexOf('touch') >= 0;
  14075. if (!isTouch) {
  14076. var box = getBoundingClientRect(el);
  14077. e.zrX = e.clientX - box.left;
  14078. e.zrY = e.clientY - box.top;
  14079. e.zrDelta = (e.wheelDelta) ? e.wheelDelta / 120 : -(e.detail || 0) / 3;
  14080. }
  14081. else {
  14082. var touch = eventType != 'touchend'
  14083. ? e.targetTouches[0]
  14084. : e.changedTouches[0];
  14085. if (touch) {
  14086. var rBounding = getBoundingClientRect(el);
  14087. // touch事件坐标是全屏的~
  14088. e.zrX = touch.clientX - rBounding.left;
  14089. e.zrY = touch.clientY - rBounding.top;
  14090. }
  14091. }
  14092. return e;
  14093. }
  14094. function addEventListener(el, name, handler) {
  14095. if (isDomLevel2) {
  14096. el.addEventListener(name, handler);
  14097. }
  14098. else {
  14099. el.attachEvent('on' + name, handler);
  14100. }
  14101. }
  14102. function removeEventListener(el, name, handler) {
  14103. if (isDomLevel2) {
  14104. el.removeEventListener(name, handler);
  14105. }
  14106. else {
  14107. el.detachEvent('on' + name, handler);
  14108. }
  14109. }
  14110. /**
  14111. * 停止冒泡和阻止默认行为
  14112. * @memberOf module:zrender/core/event
  14113. * @method
  14114. * @param {Event} e : event对象
  14115. */
  14116. var stop = isDomLevel2
  14117. ? function (e) {
  14118. e.preventDefault();
  14119. e.stopPropagation();
  14120. e.cancelBubble = true;
  14121. }
  14122. : function (e) {
  14123. e.returnValue = false;
  14124. e.cancelBubble = true;
  14125. };
  14126. module.exports = {
  14127. normalizeEvent: normalizeEvent,
  14128. addEventListener: addEventListener,
  14129. removeEventListener: removeEventListener,
  14130. stop: stop,
  14131. // 做向上兼容
  14132. Dispatcher: Eventful
  14133. };
  14134. /***/ },
  14135. /* 82 */
  14136. /***/ function(module, exports) {
  14137. // TODO Draggable for group
  14138. // FIXME Draggable on element which has parent rotation or scale
  14139. function Draggable() {
  14140. this.on('mousedown', this._dragStart, this);
  14141. this.on('mousemove', this._drag, this);
  14142. this.on('mouseup', this._dragEnd, this);
  14143. this.on('globalout', this._dragEnd, this);
  14144. // this._dropTarget = null;
  14145. // this._draggingTarget = null;
  14146. // this._x = 0;
  14147. // this._y = 0;
  14148. }
  14149. Draggable.prototype = {
  14150. constructor: Draggable,
  14151. _dragStart: function (e) {
  14152. var draggingTarget = e.target;
  14153. if (draggingTarget && draggingTarget.draggable) {
  14154. this._draggingTarget = draggingTarget;
  14155. draggingTarget.dragging = true;
  14156. this._x = e.offsetX;
  14157. this._y = e.offsetY;
  14158. this._dispatchProxy(draggingTarget, 'dragstart', e.event);
  14159. }
  14160. },
  14161. _drag: function (e) {
  14162. var draggingTarget = this._draggingTarget;
  14163. if (draggingTarget) {
  14164. var x = e.offsetX;
  14165. var y = e.offsetY;
  14166. var dx = x - this._x;
  14167. var dy = y - this._y;
  14168. this._x = x;
  14169. this._y = y;
  14170. draggingTarget.drift(dx, dy, e);
  14171. this._dispatchProxy(draggingTarget, 'drag', e.event);
  14172. var dropTarget = this.findHover(x, y, draggingTarget);
  14173. var lastDropTarget = this._dropTarget;
  14174. this._dropTarget = dropTarget;
  14175. if (draggingTarget !== dropTarget) {
  14176. if (lastDropTarget && dropTarget !== lastDropTarget) {
  14177. this._dispatchProxy(lastDropTarget, 'dragleave', e.event);
  14178. }
  14179. if (dropTarget && dropTarget !== lastDropTarget) {
  14180. this._dispatchProxy(dropTarget, 'dragenter', e.event);
  14181. }
  14182. }
  14183. }
  14184. },
  14185. _dragEnd: function (e) {
  14186. var draggingTarget = this._draggingTarget;
  14187. if (draggingTarget) {
  14188. draggingTarget.dragging = false;
  14189. }
  14190. this._dispatchProxy(draggingTarget, 'dragend', e.event);
  14191. if (this._dropTarget) {
  14192. this._dispatchProxy(this._dropTarget, 'drop', e.event);
  14193. }
  14194. this._draggingTarget = null;
  14195. this._dropTarget = null;
  14196. }
  14197. };
  14198. module.exports = Draggable;
  14199. /***/ },
  14200. /* 83 */
  14201. /***/ function(module, exports) {
  14202. 'use strict';
  14203. /**
  14204. * Only implements needed gestures for mobile.
  14205. */
  14206. var GestureMgr = function () {
  14207. /**
  14208. * @private
  14209. * @type {Array.<Object>}
  14210. */
  14211. this._track = [];
  14212. };
  14213. GestureMgr.prototype = {
  14214. constructor: GestureMgr,
  14215. recognize: function (event, target) {
  14216. this._doTrack(event, target);
  14217. return this._recognize(event);
  14218. },
  14219. clear: function () {
  14220. this._track.length = 0;
  14221. return this;
  14222. },
  14223. _doTrack: function (event, target) {
  14224. var touches = event.touches;
  14225. if (!touches) {
  14226. return;
  14227. }
  14228. var trackItem = {
  14229. points: [],
  14230. touches: [],
  14231. target: target,
  14232. event: event
  14233. };
  14234. for (var i = 0, len = touches.length; i < len; i++) {
  14235. var touch = touches[i];
  14236. trackItem.points.push([touch.clientX, touch.clientY]);
  14237. trackItem.touches.push(touch);
  14238. }
  14239. this._track.push(trackItem);
  14240. },
  14241. _recognize: function (event) {
  14242. for (var eventName in recognizers) {
  14243. if (recognizers.hasOwnProperty(eventName)) {
  14244. var gestureInfo = recognizers[eventName](this._track, event);
  14245. if (gestureInfo) {
  14246. return gestureInfo;
  14247. }
  14248. }
  14249. }
  14250. }
  14251. };
  14252. function dist(pointPair) {
  14253. var dx = pointPair[1][0] - pointPair[0][0];
  14254. var dy = pointPair[1][1] - pointPair[0][1];
  14255. return Math.sqrt(dx * dx + dy * dy);
  14256. }
  14257. function center(pointPair) {
  14258. return [
  14259. (pointPair[0][0] + pointPair[1][0]) / 2,
  14260. (pointPair[0][1] + pointPair[1][1]) / 2
  14261. ];
  14262. }
  14263. var recognizers = {
  14264. pinch: function (track, event) {
  14265. var trackLen = track.length;
  14266. if (!trackLen) {
  14267. return;
  14268. }
  14269. var pinchEnd = (track[trackLen - 1] || {}).points;
  14270. var pinchPre = (track[trackLen - 2] || {}).points || pinchEnd;
  14271. if (pinchPre
  14272. && pinchPre.length > 1
  14273. && pinchEnd
  14274. && pinchEnd.length > 1
  14275. ) {
  14276. var pinchScale = dist(pinchEnd) / dist(pinchPre);
  14277. !isFinite(pinchScale) && (pinchScale = 1);
  14278. event.pinchScale = pinchScale;
  14279. var pinchCenter = center(pinchEnd);
  14280. event.pinchX = pinchCenter[0];
  14281. event.pinchY = pinchCenter[1];
  14282. return {
  14283. type: 'pinch',
  14284. target: track[0].target,
  14285. event: event
  14286. };
  14287. }
  14288. }
  14289. // Only pinch currently.
  14290. };
  14291. module.exports = GestureMgr;
  14292. /***/ },
  14293. /* 84 */
  14294. /***/ function(module, exports, __webpack_require__) {
  14295. 'use strict';
  14296. /**
  14297. * Storage内容仓库模块
  14298. * @module zrender/Storage
  14299. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  14300. * @author errorrik (errorrik@gmail.com)
  14301. * @author pissang (https://github.com/pissang/)
  14302. */
  14303. var util = __webpack_require__(3);
  14304. var Group = __webpack_require__(29);
  14305. function shapeCompareFunc(a, b) {
  14306. if (a.zlevel === b.zlevel) {
  14307. if (a.z === b.z) {
  14308. if (a.z2 === b.z2) {
  14309. return a.__renderidx - b.__renderidx;
  14310. }
  14311. return a.z2 - b.z2;
  14312. }
  14313. return a.z - b.z;
  14314. }
  14315. return a.zlevel - b.zlevel;
  14316. }
  14317. /**
  14318. * 内容仓库 (M)
  14319. * @alias module:zrender/Storage
  14320. * @constructor
  14321. */
  14322. var Storage = function () {
  14323. // 所有常规形状,id索引的map
  14324. this._elements = {};
  14325. this._roots = [];
  14326. this._displayList = [];
  14327. this._displayListLen = 0;
  14328. };
  14329. Storage.prototype = {
  14330. constructor: Storage,
  14331. /**
  14332. * 返回所有图形的绘制队列
  14333. * @param {boolean} [update=false] 是否在返回前更新该数组
  14334. * @param {boolean} [includeIgnore=false] 是否包含 ignore 的数组, 在 update 为 true 的时候有效
  14335. *
  14336. * 详见{@link module:zrender/graphic/Displayable.prototype.updateDisplayList}
  14337. * @return {Array.<module:zrender/graphic/Displayable>}
  14338. */
  14339. getDisplayList: function (update, includeIgnore) {
  14340. includeIgnore = includeIgnore || false;
  14341. if (update) {
  14342. this.updateDisplayList(includeIgnore);
  14343. }
  14344. return this._displayList;
  14345. },
  14346. /**
  14347. * 更新图形的绘制队列。
  14348. * 每次绘制前都会调用,该方法会先深度优先遍历整个树,更新所有Group和Shape的变换并且把所有可见的Shape保存到数组中,
  14349. * 最后根据绘制的优先级(zlevel > z > 插入顺序)排序得到绘制队列
  14350. * @param {boolean} [includeIgnore=false] 是否包含 ignore 的数组
  14351. */
  14352. updateDisplayList: function (includeIgnore) {
  14353. this._displayListLen = 0;
  14354. var roots = this._roots;
  14355. var displayList = this._displayList;
  14356. for (var i = 0, len = roots.length; i < len; i++) {
  14357. this._updateAndAddDisplayable(roots[i], null, includeIgnore);
  14358. }
  14359. displayList.length = this._displayListLen;
  14360. for (var i = 0, len = displayList.length; i < len; i++) {
  14361. displayList[i].__renderidx = i;
  14362. }
  14363. displayList.sort(shapeCompareFunc);
  14364. },
  14365. _updateAndAddDisplayable: function (el, clipPaths, includeIgnore) {
  14366. if (el.ignore && !includeIgnore) {
  14367. return;
  14368. }
  14369. el.beforeUpdate();
  14370. el.update();
  14371. el.afterUpdate();
  14372. var clipPath = el.clipPath;
  14373. if (clipPath) {
  14374. // clipPath 的变换是基于 group 的变换
  14375. clipPath.parent = el;
  14376. clipPath.updateTransform();
  14377. // FIXME 效率影响
  14378. if (clipPaths) {
  14379. clipPaths = clipPaths.slice();
  14380. clipPaths.push(clipPath);
  14381. }
  14382. else {
  14383. clipPaths = [clipPath];
  14384. }
  14385. }
  14386. if (el.type == 'group') {
  14387. var children = el._children;
  14388. for (var i = 0; i < children.length; i++) {
  14389. var child = children[i];
  14390. // Force to mark as dirty if group is dirty
  14391. // FIXME __dirtyPath ?
  14392. child.__dirty = el.__dirty || child.__dirty;
  14393. this._updateAndAddDisplayable(child, clipPaths, includeIgnore);
  14394. }
  14395. // Mark group clean here
  14396. el.__dirty = false;
  14397. }
  14398. else {
  14399. el.__clipPaths = clipPaths;
  14400. this._displayList[this._displayListLen++] = el;
  14401. }
  14402. },
  14403. /**
  14404. * 添加图形(Shape)或者组(Group)到根节点
  14405. * @param {module:zrender/Element} el
  14406. */
  14407. addRoot: function (el) {
  14408. // Element has been added
  14409. if (this._elements[el.id]) {
  14410. return;
  14411. }
  14412. if (el instanceof Group) {
  14413. el.addChildrenToStorage(this);
  14414. }
  14415. this.addToMap(el);
  14416. this._roots.push(el);
  14417. },
  14418. /**
  14419. * 删除指定的图形(Shape)或者组(Group)
  14420. * @param {string|Array.<string>} [elId] 如果为空清空整个Storage
  14421. */
  14422. delRoot: function (elId) {
  14423. if (elId == null) {
  14424. // 不指定elId清空
  14425. for (var i = 0; i < this._roots.length; i++) {
  14426. var root = this._roots[i];
  14427. if (root instanceof Group) {
  14428. root.delChildrenFromStorage(this);
  14429. }
  14430. }
  14431. this._elements = {};
  14432. this._roots = [];
  14433. this._displayList = [];
  14434. this._displayListLen = 0;
  14435. return;
  14436. }
  14437. if (elId instanceof Array) {
  14438. for (var i = 0, l = elId.length; i < l; i++) {
  14439. this.delRoot(elId[i]);
  14440. }
  14441. return;
  14442. }
  14443. var el;
  14444. if (typeof(elId) == 'string') {
  14445. el = this._elements[elId];
  14446. }
  14447. else {
  14448. el = elId;
  14449. }
  14450. var idx = util.indexOf(this._roots, el);
  14451. if (idx >= 0) {
  14452. this.delFromMap(el.id);
  14453. this._roots.splice(idx, 1);
  14454. if (el instanceof Group) {
  14455. el.delChildrenFromStorage(this);
  14456. }
  14457. }
  14458. },
  14459. addToMap: function (el) {
  14460. if (el instanceof Group) {
  14461. el.__storage = this;
  14462. }
  14463. el.dirty();
  14464. this._elements[el.id] = el;
  14465. return this;
  14466. },
  14467. get: function (elId) {
  14468. return this._elements[elId];
  14469. },
  14470. delFromMap: function (elId) {
  14471. var elements = this._elements;
  14472. var el = elements[elId];
  14473. if (el) {
  14474. delete elements[elId];
  14475. if (el instanceof Group) {
  14476. el.__storage = null;
  14477. }
  14478. }
  14479. return this;
  14480. },
  14481. /**
  14482. * 清空并且释放Storage
  14483. */
  14484. dispose: function () {
  14485. this._elements =
  14486. this._renderList =
  14487. this._roots = null;
  14488. }
  14489. };
  14490. module.exports = Storage;
  14491. /***/ },
  14492. /* 85 */
  14493. /***/ function(module, exports, __webpack_require__) {
  14494. 'use strict';
  14495. /**
  14496. * 动画主类, 调度和管理所有动画控制器
  14497. *
  14498. * @module zrender/animation/Animation
  14499. * @author pissang(https://github.com/pissang)
  14500. */
  14501. // TODO Additive animation
  14502. // http://iosoteric.com/additive-animations-animatewithduration-in-ios-8/
  14503. // https://developer.apple.com/videos/wwdc2014/#236
  14504. var util = __webpack_require__(3);
  14505. var Dispatcher = __webpack_require__(81).Dispatcher;
  14506. var requestAnimationFrame = (typeof window !== 'undefined' &&
  14507. (window.requestAnimationFrame
  14508. || window.msRequestAnimationFrame
  14509. || window.mozRequestAnimationFrame
  14510. || window.webkitRequestAnimationFrame))
  14511. || function (func) {
  14512. setTimeout(func, 16);
  14513. };
  14514. var Animator = __webpack_require__(35);
  14515. /**
  14516. * @typedef {Object} IZRenderStage
  14517. * @property {Function} update
  14518. */
  14519. /**
  14520. * @alias module:zrender/animation/Animation
  14521. * @constructor
  14522. * @param {Object} [options]
  14523. * @param {Function} [options.onframe]
  14524. * @param {IZRenderStage} [options.stage]
  14525. * @example
  14526. * var animation = new Animation();
  14527. * var obj = {
  14528. * x: 100,
  14529. * y: 100
  14530. * };
  14531. * animation.animate(node.position)
  14532. * .when(1000, {
  14533. * x: 500,
  14534. * y: 500
  14535. * })
  14536. * .when(2000, {
  14537. * x: 100,
  14538. * y: 100
  14539. * })
  14540. * .start('spline');
  14541. */
  14542. var Animation = function (options) {
  14543. options = options || {};
  14544. this.stage = options.stage || {};
  14545. this.onframe = options.onframe || function() {};
  14546. // private properties
  14547. this._clips = [];
  14548. this._running = false;
  14549. this._time = 0;
  14550. Dispatcher.call(this);
  14551. };
  14552. Animation.prototype = {
  14553. constructor: Animation,
  14554. /**
  14555. * 添加 clip
  14556. * @param {module:zrender/animation/Clip} clip
  14557. */
  14558. addClip: function (clip) {
  14559. this._clips.push(clip);
  14560. },
  14561. /**
  14562. * 添加 animator
  14563. * @param {module:zrender/animation/Animator} animator
  14564. */
  14565. addAnimator: function (animator) {
  14566. animator.animation = this;
  14567. var clips = animator.getClips();
  14568. for (var i = 0; i < clips.length; i++) {
  14569. this.addClip(clips[i]);
  14570. }
  14571. },
  14572. /**
  14573. * 删除动画片段
  14574. * @param {module:zrender/animation/Clip} clip
  14575. */
  14576. removeClip: function(clip) {
  14577. var idx = util.indexOf(this._clips, clip);
  14578. if (idx >= 0) {
  14579. this._clips.splice(idx, 1);
  14580. }
  14581. },
  14582. /**
  14583. * 删除动画片段
  14584. * @param {module:zrender/animation/Animator} animator
  14585. */
  14586. removeAnimator: function (animator) {
  14587. var clips = animator.getClips();
  14588. for (var i = 0; i < clips.length; i++) {
  14589. this.removeClip(clips[i]);
  14590. }
  14591. animator.animation = null;
  14592. },
  14593. _update: function() {
  14594. var time = new Date().getTime();
  14595. var delta = time - this._time;
  14596. var clips = this._clips;
  14597. var len = clips.length;
  14598. var deferredEvents = [];
  14599. var deferredClips = [];
  14600. for (var i = 0; i < len; i++) {
  14601. var clip = clips[i];
  14602. var e = clip.step(time);
  14603. // Throw out the events need to be called after
  14604. // stage.update, like destroy
  14605. if (e) {
  14606. deferredEvents.push(e);
  14607. deferredClips.push(clip);
  14608. }
  14609. }
  14610. // Remove the finished clip
  14611. for (var i = 0; i < len;) {
  14612. if (clips[i]._needsRemove) {
  14613. clips[i] = clips[len - 1];
  14614. clips.pop();
  14615. len--;
  14616. }
  14617. else {
  14618. i++;
  14619. }
  14620. }
  14621. len = deferredEvents.length;
  14622. for (var i = 0; i < len; i++) {
  14623. deferredClips[i].fire(deferredEvents[i]);
  14624. }
  14625. this._time = time;
  14626. this.onframe(delta);
  14627. this.trigger('frame', delta);
  14628. if (this.stage.update) {
  14629. this.stage.update();
  14630. }
  14631. },
  14632. /**
  14633. * 开始运行动画
  14634. */
  14635. start: function () {
  14636. var self = this;
  14637. this._running = true;
  14638. function step() {
  14639. if (self._running) {
  14640. requestAnimationFrame(step);
  14641. self._update();
  14642. }
  14643. }
  14644. this._time = new Date().getTime();
  14645. requestAnimationFrame(step);
  14646. },
  14647. /**
  14648. * 停止运行动画
  14649. */
  14650. stop: function () {
  14651. this._running = false;
  14652. },
  14653. /**
  14654. * 清除所有动画片段
  14655. */
  14656. clear: function () {
  14657. this._clips = [];
  14658. },
  14659. /**
  14660. * 对一个目标创建一个animator对象,可以指定目标中的属性使用动画
  14661. * @param {Object} target
  14662. * @param {Object} options
  14663. * @param {boolean} [options.loop=false] 是否循环播放动画
  14664. * @param {Function} [options.getter=null]
  14665. * 如果指定getter函数,会通过getter函数取属性值
  14666. * @param {Function} [options.setter=null]
  14667. * 如果指定setter函数,会通过setter函数设置属性值
  14668. * @return {module:zrender/animation/Animation~Animator}
  14669. */
  14670. animate: function (target, options) {
  14671. options = options || {};
  14672. var animator = new Animator(
  14673. target,
  14674. options.loop,
  14675. options.getter,
  14676. options.setter
  14677. );
  14678. return animator;
  14679. }
  14680. };
  14681. util.mixin(Animation, Dispatcher);
  14682. module.exports = Animation;
  14683. /***/ },
  14684. /* 86 */
  14685. /***/ function(module, exports, __webpack_require__) {
  14686. 'use strict';
  14687. /**
  14688. * Default canvas painter
  14689. * @module zrender/Painter
  14690. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  14691. * errorrik (errorrik@gmail.com)
  14692. * pissang (https://www.github.com/pissang)
  14693. */
  14694. var config = __webpack_require__(40);
  14695. var util = __webpack_require__(3);
  14696. var log = __webpack_require__(39);
  14697. var BoundingRect = __webpack_require__(15);
  14698. var Layer = __webpack_require__(87);
  14699. function parseInt10(val) {
  14700. return parseInt(val, 10);
  14701. }
  14702. function isLayerValid(layer) {
  14703. if (!layer) {
  14704. return false;
  14705. }
  14706. if (layer.isBuildin) {
  14707. return true;
  14708. }
  14709. if (typeof(layer.resize) !== 'function'
  14710. || typeof(layer.refresh) !== 'function'
  14711. ) {
  14712. return false;
  14713. }
  14714. return true;
  14715. }
  14716. function preProcessLayer(layer) {
  14717. layer.__unusedCount++;
  14718. }
  14719. function postProcessLayer(layer) {
  14720. layer.__dirty = false;
  14721. if (layer.__unusedCount == 1) {
  14722. layer.clear();
  14723. }
  14724. }
  14725. var tmpRect = new BoundingRect(0, 0, 0, 0);
  14726. var viewRect = new BoundingRect(0, 0, 0, 0);
  14727. function isDisplayableCulled(el, width, height) {
  14728. tmpRect.copy(el.getBoundingRect());
  14729. if (el.transform) {
  14730. tmpRect.applyTransform(el.transform);
  14731. }
  14732. viewRect.width = width;
  14733. viewRect.height = height;
  14734. return !tmpRect.intersect(viewRect);
  14735. }
  14736. function isClipPathChanged(clipPaths, prevClipPaths) {
  14737. if (!clipPaths || !prevClipPaths || (clipPaths.length !== prevClipPaths.length)) {
  14738. return true;
  14739. }
  14740. for (var i = 0; i < clipPaths.length; i++) {
  14741. if (clipPaths[i] !== prevClipPaths[i]) {
  14742. return true;
  14743. }
  14744. }
  14745. }
  14746. function doClip(clipPaths, ctx) {
  14747. for (var i = 0; i < clipPaths.length; i++) {
  14748. var clipPath = clipPaths[i];
  14749. var m;
  14750. if (clipPath.transform) {
  14751. m = clipPath.transform;
  14752. ctx.transform(
  14753. m[0], m[1],
  14754. m[2], m[3],
  14755. m[4], m[5]
  14756. );
  14757. }
  14758. var path = clipPath.path;
  14759. path.beginPath(ctx);
  14760. clipPath.buildPath(path, clipPath.shape);
  14761. ctx.clip();
  14762. // Transform back
  14763. if (clipPath.transform) {
  14764. m = clipPath.invTransform;
  14765. ctx.transform(
  14766. m[0], m[1],
  14767. m[2], m[3],
  14768. m[4], m[5]
  14769. );
  14770. }
  14771. }
  14772. }
  14773. /**
  14774. * @alias module:zrender/Painter
  14775. * @constructor
  14776. * @param {HTMLElement} root 绘图容器
  14777. * @param {module:zrender/Storage} storage
  14778. * @param {Ojbect} opts
  14779. */
  14780. var Painter = function (root, storage, opts) {
  14781. var singleCanvas = !root.nodeName // In node ?
  14782. || root.nodeName.toUpperCase() === 'CANVAS';
  14783. opts = opts || {};
  14784. /**
  14785. * @type {number}
  14786. */
  14787. this.dpr = opts.devicePixelRatio || config.devicePixelRatio;
  14788. /**
  14789. * @type {boolean}
  14790. * @private
  14791. */
  14792. this._singleCanvas = singleCanvas;
  14793. /**
  14794. * 绘图容器
  14795. * @type {HTMLElement}
  14796. */
  14797. this.root = root;
  14798. var rootStyle = root.style;
  14799. // In node environment using node-canvas
  14800. if (rootStyle) {
  14801. rootStyle['-webkit-tap-highlight-color'] = 'transparent';
  14802. rootStyle['-webkit-user-select'] = 'none';
  14803. rootStyle['user-select'] = 'none';
  14804. rootStyle['-webkit-touch-callout'] = 'none';
  14805. root.innerHTML = '';
  14806. }
  14807. /**
  14808. * @type {module:zrender/Storage}
  14809. */
  14810. this.storage = storage;
  14811. if (!singleCanvas) {
  14812. var width = this._getWidth();
  14813. var height = this._getHeight();
  14814. this._width = width;
  14815. this._height = height;
  14816. var domRoot = document.createElement('div');
  14817. this._domRoot = domRoot;
  14818. var domRootStyle = domRoot.style;
  14819. // domRoot.onselectstart = returnFalse; // 避免页面选中的尴尬
  14820. domRootStyle.position = 'relative';
  14821. domRootStyle.overflow = 'hidden';
  14822. domRootStyle.width = this._width + 'px';
  14823. domRootStyle.height = this._height + 'px';
  14824. root.appendChild(domRoot);
  14825. /**
  14826. * @type {Object.<key, module:zrender/Layer>}
  14827. * @private
  14828. */
  14829. this._layers = {};
  14830. /**
  14831. * @type {Array.<number>}
  14832. * @private
  14833. */
  14834. this._zlevelList = [];
  14835. }
  14836. else {
  14837. // Use canvas width and height directly
  14838. var width = root.width;
  14839. var height = root.height;
  14840. this._width = width;
  14841. this._height = height;
  14842. // Create layer if only one given canvas
  14843. // Device pixel ratio is fixed to 1 because given canvas has its specified width and height
  14844. var mainLayer = new Layer(root, this, 1);
  14845. mainLayer.initContext();
  14846. // FIXME Use canvas width and height
  14847. // mainLayer.resize(width, height);
  14848. this._layers = {
  14849. 0: mainLayer
  14850. };
  14851. this._zlevelList = [0];
  14852. }
  14853. this._layerConfig = {};
  14854. this.pathToImage = this._createPathToImage();
  14855. };
  14856. Painter.prototype = {
  14857. constructor: Painter,
  14858. /**
  14859. * If painter use a single canvas
  14860. * @return {boolean}
  14861. */
  14862. isSingleCanvas: function () {
  14863. return this._singleCanvas;
  14864. },
  14865. /**
  14866. * @return {HTMLDivElement}
  14867. */
  14868. getViewportRoot: function () {
  14869. return this._singleCanvas ? this._layers[0].dom : this._domRoot;
  14870. },
  14871. /**
  14872. * 刷新
  14873. * @param {boolean} [paintAll=false] 强制绘制所有displayable
  14874. */
  14875. refresh: function (paintAll) {
  14876. var list = this.storage.getDisplayList(true);
  14877. var zlevelList = this._zlevelList;
  14878. this._paintList(list, paintAll);
  14879. // Paint custum layers
  14880. for (var i = 0; i < zlevelList.length; i++) {
  14881. var z = zlevelList[i];
  14882. var layer = this._layers[z];
  14883. if (!layer.isBuildin && layer.refresh) {
  14884. layer.refresh();
  14885. }
  14886. }
  14887. return this;
  14888. },
  14889. _paintList: function (list, paintAll) {
  14890. if (paintAll == null) {
  14891. paintAll = false;
  14892. }
  14893. this._updateLayerStatus(list);
  14894. var currentLayer;
  14895. var currentZLevel;
  14896. var ctx;
  14897. var viewWidth = this._width;
  14898. var viewHeight = this._height;
  14899. this.eachBuildinLayer(preProcessLayer);
  14900. // var invTransform = [];
  14901. var prevElClipPaths = null;
  14902. for (var i = 0, l = list.length; i < l; i++) {
  14903. var el = list[i];
  14904. var elZLevel = this._singleCanvas ? 0 : el.zlevel;
  14905. // Change draw layer
  14906. if (currentZLevel !== elZLevel) {
  14907. // Only 0 zlevel if only has one canvas
  14908. currentZLevel = elZLevel;
  14909. currentLayer = this.getLayer(currentZLevel);
  14910. if (!currentLayer.isBuildin) {
  14911. log(
  14912. 'ZLevel ' + currentZLevel
  14913. + ' has been used by unkown layer ' + currentLayer.id
  14914. );
  14915. }
  14916. ctx = currentLayer.ctx;
  14917. // Reset the count
  14918. currentLayer.__unusedCount = 0;
  14919. if (currentLayer.__dirty || paintAll) {
  14920. currentLayer.clear();
  14921. }
  14922. }
  14923. if (
  14924. (currentLayer.__dirty || paintAll)
  14925. // Ignore invisible element
  14926. && !el.invisible
  14927. // Ignore transparent element
  14928. && el.style.opacity !== 0
  14929. // Ignore scale 0 element, in some environment like node-canvas
  14930. // Draw a scale 0 element can cause all following draw wrong
  14931. && el.scale[0] && el.scale[1]
  14932. // Ignore culled element
  14933. && !(el.culling && isDisplayableCulled(el, viewWidth, viewHeight))
  14934. ) {
  14935. var clipPaths = el.__clipPaths;
  14936. // Optimize when clipping on group with several elements
  14937. if (isClipPathChanged(clipPaths, prevElClipPaths)) {
  14938. // If has previous clipping state, restore from it
  14939. if (prevElClipPaths) {
  14940. ctx.restore();
  14941. }
  14942. // New clipping state
  14943. if (clipPaths) {
  14944. ctx.save();
  14945. doClip(clipPaths, ctx);
  14946. }
  14947. prevElClipPaths = clipPaths;
  14948. }
  14949. el.beforeBrush && el.beforeBrush(ctx);
  14950. el.brush(ctx, false);
  14951. el.afterBrush && el.afterBrush(ctx);
  14952. }
  14953. el.__dirty = false;
  14954. }
  14955. // If still has clipping state
  14956. if (prevElClipPaths) {
  14957. ctx.restore();
  14958. }
  14959. this.eachBuildinLayer(postProcessLayer);
  14960. },
  14961. /**
  14962. * 获取 zlevel 所在层,如果不存在则会创建一个新的层
  14963. * @param {number} zlevel
  14964. * @return {module:zrender/Layer}
  14965. */
  14966. getLayer: function (zlevel) {
  14967. if (this._singleCanvas) {
  14968. return this._layers[0];
  14969. }
  14970. var layer = this._layers[zlevel];
  14971. if (!layer) {
  14972. // Create a new layer
  14973. layer = new Layer('zr_' + zlevel, this, this.dpr);
  14974. layer.isBuildin = true;
  14975. if (this._layerConfig[zlevel]) {
  14976. util.merge(layer, this._layerConfig[zlevel], true);
  14977. }
  14978. this.insertLayer(zlevel, layer);
  14979. // Context is created after dom inserted to document
  14980. // Or excanvas will get 0px clientWidth and clientHeight
  14981. layer.initContext();
  14982. }
  14983. return layer;
  14984. },
  14985. insertLayer: function (zlevel, layer) {
  14986. var layersMap = this._layers;
  14987. var zlevelList = this._zlevelList;
  14988. var len = zlevelList.length;
  14989. var prevLayer = null;
  14990. var i = -1;
  14991. var domRoot = this._domRoot;
  14992. if (layersMap[zlevel]) {
  14993. log('ZLevel ' + zlevel + ' has been used already');
  14994. return;
  14995. }
  14996. // Check if is a valid layer
  14997. if (!isLayerValid(layer)) {
  14998. log('Layer of zlevel ' + zlevel + ' is not valid');
  14999. return;
  15000. }
  15001. if (len > 0 && zlevel > zlevelList[0]) {
  15002. for (i = 0; i < len - 1; i++) {
  15003. if (
  15004. zlevelList[i] < zlevel
  15005. && zlevelList[i + 1] > zlevel
  15006. ) {
  15007. break;
  15008. }
  15009. }
  15010. prevLayer = layersMap[zlevelList[i]];
  15011. }
  15012. zlevelList.splice(i + 1, 0, zlevel);
  15013. if (prevLayer) {
  15014. var prevDom = prevLayer.dom;
  15015. if (prevDom.nextSibling) {
  15016. domRoot.insertBefore(
  15017. layer.dom,
  15018. prevDom.nextSibling
  15019. );
  15020. }
  15021. else {
  15022. domRoot.appendChild(layer.dom);
  15023. }
  15024. }
  15025. else {
  15026. if (domRoot.firstChild) {
  15027. domRoot.insertBefore(layer.dom, domRoot.firstChild);
  15028. }
  15029. else {
  15030. domRoot.appendChild(layer.dom);
  15031. }
  15032. }
  15033. layersMap[zlevel] = layer;
  15034. },
  15035. // Iterate each layer
  15036. eachLayer: function (cb, context) {
  15037. var zlevelList = this._zlevelList;
  15038. var z;
  15039. var i;
  15040. for (i = 0; i < zlevelList.length; i++) {
  15041. z = zlevelList[i];
  15042. cb.call(context, this._layers[z], z);
  15043. }
  15044. },
  15045. // Iterate each buildin layer
  15046. eachBuildinLayer: function (cb, context) {
  15047. var zlevelList = this._zlevelList;
  15048. var layer;
  15049. var z;
  15050. var i;
  15051. for (i = 0; i < zlevelList.length; i++) {
  15052. z = zlevelList[i];
  15053. layer = this._layers[z];
  15054. if (layer.isBuildin) {
  15055. cb.call(context, layer, z);
  15056. }
  15057. }
  15058. },
  15059. // Iterate each other layer except buildin layer
  15060. eachOtherLayer: function (cb, context) {
  15061. var zlevelList = this._zlevelList;
  15062. var layer;
  15063. var z;
  15064. var i;
  15065. for (i = 0; i < zlevelList.length; i++) {
  15066. z = zlevelList[i];
  15067. layer = this._layers[z];
  15068. if (! layer.isBuildin) {
  15069. cb.call(context, layer, z);
  15070. }
  15071. }
  15072. },
  15073. /**
  15074. * 获取所有已创建的层
  15075. * @param {Array.<module:zrender/Layer>} [prevLayer]
  15076. */
  15077. getLayers: function () {
  15078. return this._layers;
  15079. },
  15080. _updateLayerStatus: function (list) {
  15081. var layers = this._layers;
  15082. var elCounts = {};
  15083. this.eachBuildinLayer(function (layer, z) {
  15084. elCounts[z] = layer.elCount;
  15085. layer.elCount = 0;
  15086. });
  15087. for (var i = 0, l = list.length; i < l; i++) {
  15088. var el = list[i];
  15089. var zlevel = this._singleCanvas ? 0 : el.zlevel;
  15090. var layer = layers[zlevel];
  15091. if (layer) {
  15092. layer.elCount++;
  15093. // 已经被标记为需要刷新
  15094. if (layer.__dirty) {
  15095. continue;
  15096. }
  15097. layer.__dirty = el.__dirty;
  15098. }
  15099. }
  15100. // 层中的元素数量有发生变化
  15101. this.eachBuildinLayer(function (layer, z) {
  15102. if (elCounts[z] !== layer.elCount) {
  15103. layer.__dirty = true;
  15104. }
  15105. });
  15106. },
  15107. /**
  15108. * 清除hover层外所有内容
  15109. */
  15110. clear: function () {
  15111. this.eachBuildinLayer(this._clearLayer);
  15112. return this;
  15113. },
  15114. _clearLayer: function (layer) {
  15115. layer.clear();
  15116. },
  15117. /**
  15118. * 修改指定zlevel的绘制参数
  15119. *
  15120. * @param {string} zlevel
  15121. * @param {Object} config 配置对象
  15122. * @param {string} [config.clearColor=0] 每次清空画布的颜色
  15123. * @param {string} [config.motionBlur=false] 是否开启动态模糊
  15124. * @param {number} [config.lastFrameAlpha=0.7]
  15125. * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显
  15126. */
  15127. configLayer: function (zlevel, config) {
  15128. if (config) {
  15129. var layerConfig = this._layerConfig;
  15130. if (!layerConfig[zlevel]) {
  15131. layerConfig[zlevel] = config;
  15132. }
  15133. else {
  15134. util.merge(layerConfig[zlevel], config, true);
  15135. }
  15136. var layer = this._layers[zlevel];
  15137. if (layer) {
  15138. util.merge(layer, layerConfig[zlevel], true);
  15139. }
  15140. }
  15141. },
  15142. /**
  15143. * 删除指定层
  15144. * @param {number} zlevel 层所在的zlevel
  15145. */
  15146. delLayer: function (zlevel) {
  15147. var layers = this._layers;
  15148. var zlevelList = this._zlevelList;
  15149. var layer = layers[zlevel];
  15150. if (!layer) {
  15151. return;
  15152. }
  15153. layer.dom.parentNode.removeChild(layer.dom);
  15154. delete layers[zlevel];
  15155. zlevelList.splice(util.indexOf(zlevelList, zlevel), 1);
  15156. },
  15157. /**
  15158. * 区域大小变化后重绘
  15159. */
  15160. resize: function (width, height) {
  15161. var domRoot = this._domRoot;
  15162. // FIXME Why ?
  15163. domRoot.style.display = 'none';
  15164. width = width || this._getWidth();
  15165. height = height || this._getHeight();
  15166. domRoot.style.display = '';
  15167. // 优化没有实际改变的resize
  15168. if (this._width != width || height != this._height) {
  15169. domRoot.style.width = width + 'px';
  15170. domRoot.style.height = height + 'px';
  15171. for (var id in this._layers) {
  15172. this._layers[id].resize(width, height);
  15173. }
  15174. this.refresh(true);
  15175. }
  15176. this._width = width;
  15177. this._height = height;
  15178. return this;
  15179. },
  15180. /**
  15181. * 清除单独的一个层
  15182. * @param {number} zlevel
  15183. */
  15184. clearLayer: function (zlevel) {
  15185. var layer = this._layers[zlevel];
  15186. if (layer) {
  15187. layer.clear();
  15188. }
  15189. },
  15190. /**
  15191. * 释放
  15192. */
  15193. dispose: function () {
  15194. this.root.innerHTML = '';
  15195. this.root =
  15196. this.storage =
  15197. this._domRoot =
  15198. this._layers = null;
  15199. },
  15200. /**
  15201. * Get canvas which has all thing rendered
  15202. * @param {Object} opts
  15203. * @param {string} [opts.backgroundColor]
  15204. */
  15205. getRenderedCanvas: function (opts) {
  15206. opts = opts || {};
  15207. if (this._singleCanvas) {
  15208. return this._layers[0].dom;
  15209. }
  15210. var imageLayer = new Layer('image', this, opts.pixelRatio || this.dpr);
  15211. imageLayer.initContext();
  15212. var ctx = imageLayer.ctx;
  15213. imageLayer.clearColor = opts.backgroundColor;
  15214. imageLayer.clear();
  15215. var displayList = this.storage.getDisplayList(true);
  15216. for (var i = 0; i < displayList.length; i++) {
  15217. var el = displayList[i];
  15218. if (!el.invisible) {
  15219. el.beforeBrush && el.beforeBrush(ctx);
  15220. // TODO Check image cross origin
  15221. el.brush(ctx, false);
  15222. el.afterBrush && el.afterBrush(ctx);
  15223. }
  15224. }
  15225. return imageLayer.dom;
  15226. },
  15227. /**
  15228. * 获取绘图区域宽度
  15229. */
  15230. getWidth: function () {
  15231. return this._width;
  15232. },
  15233. /**
  15234. * 获取绘图区域高度
  15235. */
  15236. getHeight: function () {
  15237. return this._height;
  15238. },
  15239. _getWidth: function () {
  15240. var root = this.root;
  15241. var stl = document.defaultView.getComputedStyle(root);
  15242. // FIXME Better way to get the width and height when element has not been append to the document
  15243. return ((root.clientWidth || parseInt10(stl.width) || parseInt10(root.style.width))
  15244. - (parseInt10(stl.paddingLeft) || 0)
  15245. - (parseInt10(stl.paddingRight) || 0)) | 0;
  15246. },
  15247. _getHeight: function () {
  15248. var root = this.root;
  15249. var stl = document.defaultView.getComputedStyle(root);
  15250. return ((root.clientHeight || parseInt10(stl.height) || parseInt10(root.style.height))
  15251. - (parseInt10(stl.paddingTop) || 0)
  15252. - (parseInt10(stl.paddingBottom) || 0)) | 0;
  15253. },
  15254. _pathToImage: function (id, path, width, height, dpr) {
  15255. var canvas = document.createElement('canvas');
  15256. var ctx = canvas.getContext('2d');
  15257. canvas.width = width * dpr;
  15258. canvas.height = height * dpr;
  15259. ctx.clearRect(0, 0, width * dpr, height * dpr);
  15260. var pathTransform = {
  15261. position: path.position,
  15262. rotation: path.rotation,
  15263. scale: path.scale
  15264. };
  15265. path.position = [0, 0, 0];
  15266. path.rotation = 0;
  15267. path.scale = [1, 1];
  15268. if (path) {
  15269. path.brush(ctx);
  15270. }
  15271. var ImageShape = __webpack_require__(59);
  15272. var imgShape = new ImageShape({
  15273. id: id,
  15274. style: {
  15275. x: 0,
  15276. y: 0,
  15277. image: canvas
  15278. }
  15279. });
  15280. if (pathTransform.position != null) {
  15281. imgShape.position = path.position = pathTransform.position;
  15282. }
  15283. if (pathTransform.rotation != null) {
  15284. imgShape.rotation = path.rotation = pathTransform.rotation;
  15285. }
  15286. if (pathTransform.scale != null) {
  15287. imgShape.scale = path.scale = pathTransform.scale;
  15288. }
  15289. return imgShape;
  15290. },
  15291. _createPathToImage: function () {
  15292. var me = this;
  15293. return function (id, e, width, height) {
  15294. return me._pathToImage(
  15295. id, e, width, height, me.dpr
  15296. );
  15297. };
  15298. }
  15299. };
  15300. module.exports = Painter;
  15301. /***/ },
  15302. /* 87 */
  15303. /***/ function(module, exports, __webpack_require__) {
  15304. /**
  15305. * @module zrender/Layer
  15306. * @author pissang(https://www.github.com/pissang)
  15307. */
  15308. var util = __webpack_require__(3);
  15309. var config = __webpack_require__(40);
  15310. function returnFalse() {
  15311. return false;
  15312. }
  15313. /**
  15314. * 创建dom
  15315. *
  15316. * @inner
  15317. * @param {string} id dom id 待用
  15318. * @param {string} type dom type,such as canvas, div etc.
  15319. * @param {Painter} painter painter instance
  15320. * @param {number} number
  15321. */
  15322. function createDom(id, type, painter, dpr) {
  15323. var newDom = document.createElement(type);
  15324. var width = painter.getWidth();
  15325. var height = painter.getHeight();
  15326. var newDomStyle = newDom.style;
  15327. // 没append呢,请原谅我这样写,清晰~
  15328. newDomStyle.position = 'absolute';
  15329. newDomStyle.left = 0;
  15330. newDomStyle.top = 0;
  15331. newDomStyle.width = width + 'px';
  15332. newDomStyle.height = height + 'px';
  15333. newDom.width = width * dpr;
  15334. newDom.height = height * dpr;
  15335. // id不作为索引用,避免可能造成的重名,定义为私有属性
  15336. newDom.setAttribute('data-zr-dom-id', id);
  15337. return newDom;
  15338. }
  15339. /**
  15340. * @alias module:zrender/Layer
  15341. * @constructor
  15342. * @extends module:zrender/mixin/Transformable
  15343. * @param {string} id
  15344. * @param {module:zrender/Painter} painter
  15345. * @param {number} [dpr]
  15346. */
  15347. var Layer = function(id, painter, dpr) {
  15348. var dom;
  15349. dpr = dpr || config.devicePixelRatio;
  15350. if (typeof id === 'string') {
  15351. dom = createDom(id, 'canvas', painter, dpr);
  15352. }
  15353. // Not using isDom because in node it will return false
  15354. else if (util.isObject(id)) {
  15355. dom = id;
  15356. id = dom.id;
  15357. }
  15358. this.id = id;
  15359. this.dom = dom;
  15360. var domStyle = dom.style;
  15361. if (domStyle) { // Not in node
  15362. dom.onselectstart = returnFalse; // 避免页面选中的尴尬
  15363. domStyle['-webkit-user-select'] = 'none';
  15364. domStyle['user-select'] = 'none';
  15365. domStyle['-webkit-touch-callout'] = 'none';
  15366. domStyle['-webkit-tap-highlight-color'] = 'rgba(0,0,0,0)';
  15367. }
  15368. this.domBack = null;
  15369. this.ctxBack = null;
  15370. this.painter = painter;
  15371. this.config = null;
  15372. // Configs
  15373. /**
  15374. * 每次清空画布的颜色
  15375. * @type {string}
  15376. * @default 0
  15377. */
  15378. this.clearColor = 0;
  15379. /**
  15380. * 是否开启动态模糊
  15381. * @type {boolean}
  15382. * @default false
  15383. */
  15384. this.motionBlur = false;
  15385. /**
  15386. * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显
  15387. * @type {number}
  15388. * @default 0.7
  15389. */
  15390. this.lastFrameAlpha = 0.7;
  15391. /**
  15392. * Layer dpr
  15393. * @type {number}
  15394. */
  15395. this.dpr = dpr;
  15396. };
  15397. Layer.prototype = {
  15398. constructor: Layer,
  15399. elCount: 0,
  15400. __dirty: true,
  15401. initContext: function () {
  15402. this.ctx = this.dom.getContext('2d');
  15403. var dpr = this.dpr;
  15404. if (dpr != 1) {
  15405. this.ctx.scale(dpr, dpr);
  15406. }
  15407. },
  15408. createBackBuffer: function () {
  15409. var dpr = this.dpr;
  15410. this.domBack = createDom('back-' + this.id, 'canvas', this.painter, dpr);
  15411. this.ctxBack = this.domBack.getContext('2d');
  15412. if (dpr != 1) {
  15413. this.ctxBack.scale(dpr, dpr);
  15414. }
  15415. },
  15416. /**
  15417. * @param {number} width
  15418. * @param {number} height
  15419. */
  15420. resize: function (width, height) {
  15421. var dpr = this.dpr;
  15422. var dom = this.dom;
  15423. var domStyle = dom.style;
  15424. var domBack = this.domBack;
  15425. domStyle.width = width + 'px';
  15426. domStyle.height = height + 'px';
  15427. dom.width = width * dpr;
  15428. dom.height = height * dpr;
  15429. if (dpr != 1) {
  15430. this.ctx.scale(dpr, dpr);
  15431. }
  15432. if (domBack) {
  15433. domBack.width = width * dpr;
  15434. domBack.height = height * dpr;
  15435. if (dpr != 1) {
  15436. this.ctxBack.scale(dpr, dpr);
  15437. }
  15438. }
  15439. },
  15440. /**
  15441. * 清空该层画布
  15442. * @param {boolean} clearAll Clear all with out motion blur
  15443. */
  15444. clear: function (clearAll) {
  15445. var dom = this.dom;
  15446. var ctx = this.ctx;
  15447. var width = dom.width;
  15448. var height = dom.height;
  15449. var haveClearColor = this.clearColor;
  15450. var haveMotionBLur = this.motionBlur && !clearAll;
  15451. var lastFrameAlpha = this.lastFrameAlpha;
  15452. var dpr = this.dpr;
  15453. if (haveMotionBLur) {
  15454. if (!this.domBack) {
  15455. this.createBackBuffer();
  15456. }
  15457. this.ctxBack.globalCompositeOperation = 'copy';
  15458. this.ctxBack.drawImage(
  15459. dom, 0, 0,
  15460. width / dpr,
  15461. height / dpr
  15462. );
  15463. }
  15464. ctx.clearRect(0, 0, width / dpr, height / dpr);
  15465. if (haveClearColor) {
  15466. ctx.save();
  15467. ctx.fillStyle = this.clearColor;
  15468. ctx.fillRect(0, 0, width / dpr, height / dpr);
  15469. ctx.restore();
  15470. }
  15471. if (haveMotionBLur) {
  15472. var domBack = this.domBack;
  15473. ctx.save();
  15474. ctx.globalAlpha = lastFrameAlpha;
  15475. ctx.drawImage(domBack, 0, 0, width / dpr, height / dpr);
  15476. ctx.restore();
  15477. }
  15478. }
  15479. };
  15480. module.exports = Layer;
  15481. /***/ },
  15482. /* 88 */
  15483. /***/ function(module, exports, __webpack_require__) {
  15484. var graphic = __webpack_require__(42);
  15485. var zrUtil = __webpack_require__(3);
  15486. var PI = Math.PI;
  15487. /**
  15488. * @param {module:echarts/ExtensionAPI} api
  15489. * @param {Object} [opts]
  15490. * @param {string} [opts.text]
  15491. * @param {string} [opts.color]
  15492. * @param {string} [opts.textColor]
  15493. * @return {module:zrender/Element}
  15494. */
  15495. module.exports = function (api, opts) {
  15496. opts = opts || {};
  15497. zrUtil.defaults(opts, {
  15498. text: 'loading',
  15499. color: '#c23531',
  15500. textColor: '#000',
  15501. maskColor: 'rgba(255, 255, 255, 0.8)',
  15502. zlevel: 0
  15503. });
  15504. var mask = new graphic.Rect({
  15505. style: {
  15506. fill: opts.maskColor
  15507. },
  15508. zlevel: opts.zlevel,
  15509. z: 10000
  15510. });
  15511. var arc = new graphic.Arc({
  15512. shape: {
  15513. startAngle: -PI / 2,
  15514. endAngle: -PI / 2 + 0.1,
  15515. r: 10
  15516. },
  15517. style: {
  15518. stroke: opts.color,
  15519. lineCap: 'round',
  15520. lineWidth: 5
  15521. },
  15522. zlevel: opts.zlevel,
  15523. z: 10001
  15524. });
  15525. var labelRect = new graphic.Rect({
  15526. style: {
  15527. fill: 'none',
  15528. text: opts.text,
  15529. textPosition: 'right',
  15530. textDistance: 10,
  15531. textFill: opts.textColor
  15532. },
  15533. zlevel: opts.zlevel,
  15534. z: 10001
  15535. });
  15536. arc.animateShape(true)
  15537. .when(1000, {
  15538. endAngle: PI * 3 / 2
  15539. })
  15540. .start('circularInOut');
  15541. arc.animateShape(true)
  15542. .when(1000, {
  15543. startAngle: PI * 3 / 2
  15544. })
  15545. .delay(300)
  15546. .start('circularInOut');
  15547. var group = new graphic.Group();
  15548. group.add(arc);
  15549. group.add(labelRect);
  15550. group.add(mask);
  15551. // Inject resize
  15552. group.resize = function () {
  15553. var cx = api.getWidth() / 2;
  15554. var cy = api.getHeight() / 2;
  15555. arc.setShape({
  15556. cx: cx,
  15557. cy: cy
  15558. });
  15559. var r = arc.shape.r;
  15560. labelRect.setShape({
  15561. x: cx - r,
  15562. y: cy - r,
  15563. width: r * 2,
  15564. height: r * 2
  15565. });
  15566. mask.setShape({
  15567. x: 0,
  15568. y: 0,
  15569. width: api.getWidth(),
  15570. height: api.getHeight()
  15571. });
  15572. };
  15573. group.resize();
  15574. return group;
  15575. };
  15576. /***/ },
  15577. /* 89 */
  15578. /***/ function(module, exports, __webpack_require__) {
  15579. var Gradient = __webpack_require__(4);
  15580. module.exports = function (seriesType, styleType, ecModel) {
  15581. function encodeColor(seriesModel) {
  15582. var colorAccessPath = [styleType, 'normal', 'color'];
  15583. var colorList = ecModel.get('color');
  15584. var data = seriesModel.getData();
  15585. var color = seriesModel.get(colorAccessPath) // Set in itemStyle
  15586. || colorList[seriesModel.seriesIndex % colorList.length]; // Default color
  15587. // FIXME Set color function or use the platte color
  15588. data.setVisual('color', color);
  15589. // Only visible series has each data be visual encoded
  15590. if (!ecModel.isSeriesFiltered(seriesModel)) {
  15591. if (typeof color === 'function' && !(color instanceof Gradient)) {
  15592. data.each(function (idx) {
  15593. data.setItemVisual(
  15594. idx, 'color', color(seriesModel.getDataParams(idx))
  15595. );
  15596. });
  15597. }
  15598. data.each(function (idx) {
  15599. var itemModel = data.getItemModel(idx);
  15600. var color = itemModel.get(colorAccessPath, true);
  15601. if (color != null) {
  15602. data.setItemVisual(idx, 'color', color);
  15603. }
  15604. });
  15605. }
  15606. }
  15607. seriesType ? ecModel.eachSeriesByType(seriesType, encodeColor)
  15608. : ecModel.eachSeries(encodeColor);
  15609. };
  15610. /***/ },
  15611. /* 90 */
  15612. /***/ function(module, exports, __webpack_require__) {
  15613. // Compatitable with 2.0
  15614. var zrUtil = __webpack_require__(3);
  15615. var compatStyle = __webpack_require__(91);
  15616. function get(opt, path) {
  15617. path = path.split(',');
  15618. var obj = opt;
  15619. for (var i = 0; i < path.length; i++) {
  15620. obj = obj && obj[path[i]];
  15621. if (obj == null) {
  15622. break;
  15623. }
  15624. }
  15625. return obj;
  15626. }
  15627. function set(opt, path, val, overwrite) {
  15628. path = path.split(',');
  15629. var obj = opt;
  15630. var key;
  15631. for (var i = 0; i < path.length - 1; i++) {
  15632. key = path[i];
  15633. if (obj[key] == null) {
  15634. obj[key] = {};
  15635. }
  15636. obj = obj[key];
  15637. }
  15638. if (overwrite || obj[path[i]] == null) {
  15639. obj[path[i]] = val;
  15640. }
  15641. }
  15642. function compatLayoutProperties(option) {
  15643. each(LAYOUT_PROPERTIES, function (prop) {
  15644. if (prop[0] in option && !(prop[1] in option)) {
  15645. option[prop[1]] = option[prop[0]];
  15646. }
  15647. });
  15648. }
  15649. var LAYOUT_PROPERTIES = [
  15650. ['x', 'left'], ['y', 'top'], ['x2', 'right'], ['y2', 'bottom']
  15651. ];
  15652. var COMPATITABLE_COMPONENTS = [
  15653. 'grid', 'geo', 'parallel', 'legend', 'toolbox', 'title', 'visualMap', 'dataZoom', 'timeline'
  15654. ];
  15655. var COMPATITABLE_SERIES = [
  15656. 'bar', 'boxplot', 'candlestick', 'chord', 'effectScatter',
  15657. 'funnel', 'gauge', 'lines', 'graph', 'heatmap', 'line', 'map', 'parallel',
  15658. 'pie', 'radar', 'sankey', 'scatter', 'treemap'
  15659. ];
  15660. var each = zrUtil.each;
  15661. module.exports = function (option) {
  15662. each(option.series, function (seriesOpt) {
  15663. if (!zrUtil.isObject(seriesOpt)) {
  15664. return;
  15665. }
  15666. var seriesType = seriesOpt.type;
  15667. compatStyle(seriesOpt);
  15668. if (seriesType === 'pie' || seriesType === 'gauge') {
  15669. if (seriesOpt.clockWise != null) {
  15670. seriesOpt.clockwise = seriesOpt.clockWise;
  15671. }
  15672. }
  15673. if (seriesType === 'gauge') {
  15674. var pointerColor = get(seriesOpt, 'pointer.color');
  15675. pointerColor != null
  15676. && set(seriesOpt, 'itemStyle.normal.color', pointerColor);
  15677. }
  15678. for (var i = 0; i < COMPATITABLE_SERIES.length; i++) {
  15679. if (COMPATITABLE_SERIES[i] === seriesOpt.type) {
  15680. compatLayoutProperties(seriesOpt);
  15681. break;
  15682. }
  15683. }
  15684. });
  15685. // dataRange has changed to visualMap
  15686. if (option.dataRange) {
  15687. option.visualMap = option.dataRange;
  15688. }
  15689. each(COMPATITABLE_COMPONENTS, function (componentName) {
  15690. var options = option[componentName];
  15691. if (options) {
  15692. if (!zrUtil.isArray(options)) {
  15693. options = [options];
  15694. }
  15695. each(options, function (option) {
  15696. compatLayoutProperties(option);
  15697. });
  15698. }
  15699. });
  15700. };
  15701. /***/ },
  15702. /* 91 */
  15703. /***/ function(module, exports, __webpack_require__) {
  15704. var zrUtil = __webpack_require__(3);
  15705. var POSSIBLE_STYLES = [
  15706. 'areaStyle', 'lineStyle', 'nodeStyle', 'linkStyle',
  15707. 'chordStyle', 'label', 'labelLine'
  15708. ];
  15709. function compatItemStyle(opt) {
  15710. var itemStyleOpt = opt && opt.itemStyle;
  15711. if (itemStyleOpt) {
  15712. zrUtil.each(POSSIBLE_STYLES, function (styleName) {
  15713. var normalItemStyleOpt = itemStyleOpt.normal;
  15714. var emphasisItemStyleOpt = itemStyleOpt.emphasis;
  15715. if (normalItemStyleOpt && normalItemStyleOpt[styleName]) {
  15716. opt[styleName] = opt[styleName] || {};
  15717. if (!opt[styleName].normal) {
  15718. opt[styleName].normal = normalItemStyleOpt[styleName];
  15719. }
  15720. else {
  15721. zrUtil.merge(opt[styleName].normal, normalItemStyleOpt[styleName]);
  15722. }
  15723. normalItemStyleOpt[styleName] = null;
  15724. }
  15725. if (emphasisItemStyleOpt && emphasisItemStyleOpt[styleName]) {
  15726. opt[styleName] = opt[styleName] || {};
  15727. if (!opt[styleName].emphasis) {
  15728. opt[styleName].emphasis = emphasisItemStyleOpt[styleName];
  15729. }
  15730. else {
  15731. zrUtil.merge(opt[styleName].emphasis, emphasisItemStyleOpt[styleName]);
  15732. }
  15733. emphasisItemStyleOpt[styleName] = null;
  15734. }
  15735. });
  15736. }
  15737. }
  15738. module.exports = function (seriesOpt) {
  15739. if (!seriesOpt) {
  15740. return;
  15741. }
  15742. compatItemStyle(seriesOpt);
  15743. compatItemStyle(seriesOpt.markPoint);
  15744. compatItemStyle(seriesOpt.markLine);
  15745. var data = seriesOpt.data;
  15746. if (data) {
  15747. for (var i = 0; i < data.length; i++) {
  15748. compatItemStyle(data[i]);
  15749. }
  15750. // mark point data
  15751. var markPoint = seriesOpt.markPoint;
  15752. if (markPoint && markPoint.data) {
  15753. var mpData = markPoint.data;
  15754. for (var i = 0; i < mpData.length; i++) {
  15755. compatItemStyle(mpData[i]);
  15756. }
  15757. }
  15758. // mark line data
  15759. var markLine = seriesOpt.markLine;
  15760. if (markLine && markLine.data) {
  15761. var mlData = markLine.data;
  15762. for (var i = 0; i < mlData.length; i++) {
  15763. if (zrUtil.isArray(mlData[i])) {
  15764. compatItemStyle(mlData[i][0]);
  15765. compatItemStyle(mlData[i][1]);
  15766. }
  15767. else {
  15768. compatItemStyle(mlData[i]);
  15769. }
  15770. }
  15771. }
  15772. }
  15773. };
  15774. /***/ },
  15775. /* 92 */
  15776. /***/ function(module, exports, __webpack_require__) {
  15777. var zrUtil = __webpack_require__(3);
  15778. var echarts = __webpack_require__(1);
  15779. __webpack_require__(93);
  15780. __webpack_require__(98);
  15781. echarts.registerVisualCoding('chart', zrUtil.curry(
  15782. __webpack_require__(104), 'line', 'circle', 'line'
  15783. ));
  15784. echarts.registerLayout(zrUtil.curry(
  15785. __webpack_require__(105), 'line'
  15786. ));
  15787. // Down sample after filter
  15788. echarts.registerProcessor('statistic', zrUtil.curry(
  15789. __webpack_require__(106), 'line'
  15790. ));
  15791. // In case developer forget to include grid component
  15792. __webpack_require__(107);
  15793. /***/ },
  15794. /* 93 */
  15795. /***/ function(module, exports, __webpack_require__) {
  15796. 'use strict';
  15797. var createListFromArray = __webpack_require__(94);
  15798. var SeriesModel = __webpack_require__(27);
  15799. module.exports = SeriesModel.extend({
  15800. type: 'series.line',
  15801. dependencies: ['grid', 'polar'],
  15802. getInitialData: function (option, ecModel) {
  15803. return createListFromArray(option.data, this, ecModel);
  15804. },
  15805. defaultOption: {
  15806. zlevel: 0, // 一级层叠
  15807. z: 2, // 二级层叠
  15808. coordinateSystem: 'cartesian2d',
  15809. legendHoverLink: true,
  15810. hoverAnimation: true,
  15811. // stack: null
  15812. xAxisIndex: 0,
  15813. yAxisIndex: 0,
  15814. polarIndex: 0,
  15815. // If clip the overflow value
  15816. clipOverflow: true,
  15817. label: {
  15818. normal: {
  15819. position: 'top'
  15820. }
  15821. },
  15822. // itemStyle: {
  15823. // normal: {},
  15824. // emphasis: {}
  15825. // },
  15826. lineStyle: {
  15827. normal: {
  15828. width: 2,
  15829. type: 'solid'
  15830. }
  15831. },
  15832. // areaStyle: {},
  15833. smooth: false,
  15834. smoothMonotone: null,
  15835. // 拐点图形类型
  15836. symbol: 'emptyCircle',
  15837. // 拐点图形大小
  15838. symbolSize: 4,
  15839. // 拐点图形旋转控制
  15840. symbolRotate: null,
  15841. // 是否显示 symbol, 只有在 tooltip hover 的时候显示
  15842. showSymbol: true,
  15843. // 标志图形默认只有主轴显示(随主轴标签间隔隐藏策略)
  15844. showAllSymbol: false,
  15845. // 是否连接断点
  15846. connectNulls: false,
  15847. // 数据过滤,'average', 'max', 'min', 'sum'
  15848. sampling: 'none',
  15849. animationEasing: 'linear'
  15850. }
  15851. });
  15852. /***/ },
  15853. /* 94 */
  15854. /***/ function(module, exports, __webpack_require__) {
  15855. 'use strict';
  15856. var List = __webpack_require__(95);
  15857. var completeDimensions = __webpack_require__(97);
  15858. var zrUtil = __webpack_require__(3);
  15859. var modelUtil = __webpack_require__(5);
  15860. var CoordinateSystem = __webpack_require__(25);
  15861. var getDataItemValue = modelUtil.getDataItemValue;
  15862. var converDataValue = modelUtil.converDataValue;
  15863. function firstDataNotNull(data) {
  15864. var i = 0;
  15865. while (i < data.length && data[i] == null) {
  15866. i++;
  15867. }
  15868. return data[i];
  15869. }
  15870. function ifNeedCompleteOrdinalData(data) {
  15871. var sampleItem = firstDataNotNull(data);
  15872. return sampleItem != null
  15873. && !zrUtil.isArray(getDataItemValue(sampleItem));
  15874. }
  15875. /**
  15876. * Helper function to create a list from option data
  15877. */
  15878. function createListFromArray(data, seriesModel, ecModel) {
  15879. // If data is undefined
  15880. data = data || [];
  15881. if (!zrUtil.isArray(data)) {
  15882. throw new Error('Invalid data.');
  15883. }
  15884. var coordSysName = seriesModel.get('coordinateSystem');
  15885. var creator = creators[coordSysName];
  15886. var registeredCoordSys = CoordinateSystem.get(coordSysName);
  15887. // FIXME
  15888. var result = creator && creator(data, seriesModel, ecModel);
  15889. var dimensions = result && result.dimensions;
  15890. if (!dimensions) {
  15891. // Get dimensions from registered coordinate system
  15892. dimensions = (registeredCoordSys && registeredCoordSys.dimensions) || ['x', 'y'];
  15893. dimensions = completeDimensions(dimensions, data, dimensions.concat(['value']));
  15894. }
  15895. var categoryAxisModel = result && result.categoryAxisModel;
  15896. var categories;
  15897. var categoryDimIndex = dimensions[0].type === 'ordinal'
  15898. ? 0 : (dimensions[1].type === 'ordinal' ? 1 : -1);
  15899. var list = new List(dimensions, seriesModel);
  15900. var nameList = createNameList(result, data);
  15901. var dimValueGetter = (categoryAxisModel && ifNeedCompleteOrdinalData(data))
  15902. ? function (itemOpt, dimName, dataIndex, dimIndex) {
  15903. // Use dataIndex as ordinal value in categoryAxis
  15904. return dimIndex === categoryDimIndex
  15905. ? dataIndex
  15906. : converDataValue(getDataItemValue(itemOpt), dimensions[dimIndex]);
  15907. }
  15908. : function (itemOpt, dimName, dataIndex, dimIndex) {
  15909. var value = getDataItemValue(itemOpt);
  15910. var val = converDataValue(value && value[dimIndex], dimensions[dimIndex]);
  15911. if (categoryDimIndex === dimIndex) {
  15912. // If given value is a category string
  15913. if (typeof val === 'string') {
  15914. // Lazy get categories
  15915. categories = categories || categoryAxisModel.getCategories();
  15916. val = zrUtil.indexOf(categories, val);
  15917. if (val < 0 && !isNaN(val)) {
  15918. // In case some one write '1', '2' istead of 1, 2
  15919. val = +val;
  15920. }
  15921. }
  15922. }
  15923. return val;
  15924. };
  15925. list.initData(data, nameList, dimValueGetter);
  15926. return list;
  15927. }
  15928. function isStackable(axisType) {
  15929. return axisType !== 'category' && axisType !== 'time';
  15930. }
  15931. function getDimTypeByAxis(axisType) {
  15932. return axisType === 'category'
  15933. ? 'ordinal'
  15934. : axisType === 'time'
  15935. ? 'time'
  15936. : 'float';
  15937. }
  15938. /**
  15939. * Creaters for each coord system.
  15940. * @return {Object} {dimensions, categoryAxisModel};
  15941. */
  15942. var creators = {
  15943. cartesian2d: function (data, seriesModel, ecModel) {
  15944. var xAxisModel = ecModel.getComponent('xAxis', seriesModel.get('xAxisIndex'));
  15945. var yAxisModel = ecModel.getComponent('yAxis', seriesModel.get('yAxisIndex'));
  15946. if (!xAxisModel || !yAxisModel) {
  15947. throw new Error('Axis option not found');
  15948. }
  15949. var xAxisType = xAxisModel.get('type');
  15950. var yAxisType = yAxisModel.get('type');
  15951. var dimensions = [
  15952. {
  15953. name: 'x',
  15954. type: getDimTypeByAxis(xAxisType),
  15955. stackable: isStackable(xAxisType)
  15956. },
  15957. {
  15958. name: 'y',
  15959. // If two category axes
  15960. type: getDimTypeByAxis(yAxisType),
  15961. stackable: isStackable(yAxisType)
  15962. }
  15963. ];
  15964. var isXAxisCateogry = xAxisType === 'category';
  15965. completeDimensions(dimensions, data, ['x', 'y', 'z']);
  15966. return {
  15967. dimensions: dimensions,
  15968. categoryIndex: isXAxisCateogry ? 0 : 1,
  15969. categoryAxisModel: isXAxisCateogry
  15970. ? xAxisModel
  15971. : (yAxisType === 'category' ? yAxisModel : null)
  15972. };
  15973. },
  15974. polar: function (data, seriesModel, ecModel) {
  15975. var polarIndex = seriesModel.get('polarIndex') || 0;
  15976. var axisFinder = function (axisModel) {
  15977. return axisModel.get('polarIndex') === polarIndex;
  15978. };
  15979. var angleAxisModel = ecModel.findComponents({
  15980. mainType: 'angleAxis', filter: axisFinder
  15981. })[0];
  15982. var radiusAxisModel = ecModel.findComponents({
  15983. mainType: 'radiusAxis', filter: axisFinder
  15984. })[0];
  15985. if (!angleAxisModel || !radiusAxisModel) {
  15986. throw new Error('Axis option not found');
  15987. }
  15988. var radiusAxisType = radiusAxisModel.get('type');
  15989. var angleAxisType = angleAxisModel.get('type');
  15990. var dimensions = [
  15991. {
  15992. name: 'radius',
  15993. type: getDimTypeByAxis(radiusAxisType),
  15994. stackable: isStackable(radiusAxisType)
  15995. },
  15996. {
  15997. name: 'angle',
  15998. type: getDimTypeByAxis(angleAxisType),
  15999. stackable: isStackable(angleAxisType)
  16000. }
  16001. ];
  16002. var isAngleAxisCateogry = angleAxisType === 'category';
  16003. completeDimensions(dimensions, data, ['radius', 'angle', 'value']);
  16004. return {
  16005. dimensions: dimensions,
  16006. categoryIndex: isAngleAxisCateogry ? 1 : 0,
  16007. categoryAxisModel: isAngleAxisCateogry
  16008. ? angleAxisModel
  16009. : (radiusAxisType === 'category' ? radiusAxisModel : null)
  16010. };
  16011. },
  16012. geo: function (data, seriesModel, ecModel) {
  16013. // TODO Region
  16014. // 多个散点图系列在同一个地区的时候
  16015. return {
  16016. dimensions: completeDimensions([
  16017. {name: 'lng'},
  16018. {name: 'lat'}
  16019. ], data, ['lng', 'lat', 'value'])
  16020. };
  16021. }
  16022. };
  16023. function createNameList(result, data) {
  16024. var nameList = [];
  16025. if (result && result.categoryAxisModel) {
  16026. // FIXME Two category axis
  16027. var categories = result.categoryAxisModel.getCategories();
  16028. if (categories) {
  16029. var dataLen = data.length;
  16030. // Ordered data is given explicitly like
  16031. // [[3, 0.2], [1, 0.3], [2, 0.15]]
  16032. // or given scatter data,
  16033. // pick the category
  16034. if (zrUtil.isArray(data[0]) && data[0].length > 1) {
  16035. nameList = [];
  16036. for (var i = 0; i < dataLen; i++) {
  16037. nameList[i] = categories[data[i][result.categoryIndex || 0]];
  16038. }
  16039. }
  16040. else {
  16041. nameList = categories.slice(0);
  16042. }
  16043. }
  16044. }
  16045. return nameList;
  16046. }
  16047. module.exports = createListFromArray;
  16048. /***/ },
  16049. /* 95 */
  16050. /***/ function(module, exports, __webpack_require__) {
  16051. /* WEBPACK VAR INJECTION */(function(global) {/**
  16052. * List for data storage
  16053. * @module echarts/data/List
  16054. */
  16055. var UNDEFINED = 'undefined';
  16056. var globalObj = typeof window === 'undefined' ? global : window;
  16057. var Float64Array = typeof globalObj.Float64Array === UNDEFINED
  16058. ? Array : globalObj.Float64Array;
  16059. var Int32Array = typeof globalObj.Int32Array === UNDEFINED
  16060. ? Array : globalObj.Int32Array;
  16061. var dataCtors = {
  16062. 'float': Float64Array,
  16063. 'int': Int32Array,
  16064. // Ordinal data type can be string or int
  16065. 'ordinal': Array,
  16066. 'number': Array,
  16067. 'time': Array
  16068. };
  16069. var Model = __webpack_require__(8);
  16070. var DataDiffer = __webpack_require__(96);
  16071. var zrUtil = __webpack_require__(3);
  16072. var modelUtil = __webpack_require__(5);
  16073. var isObject = zrUtil.isObject;
  16074. var IMMUTABLE_PROPERTIES = [
  16075. 'stackedOn', '_nameList', '_idList', '_rawData'
  16076. ];
  16077. var transferImmuProperties = function (a, b) {
  16078. zrUtil.each(IMMUTABLE_PROPERTIES.concat(b.__wrappedMethods || []), function (propName) {
  16079. if (b.hasOwnProperty(propName)) {
  16080. a[propName] = b[propName];
  16081. }
  16082. });
  16083. a.__wrappedMethods = b.__wrappedMethods;
  16084. };
  16085. /**
  16086. * @constructor
  16087. * @alias module:echarts/data/List
  16088. *
  16089. * @param {Array.<string>} dimensions
  16090. * Dimensions should be concrete names like x, y, z, lng, lat, angle, radius
  16091. * @param {module:echarts/model/Model} hostModel
  16092. */
  16093. var List = function (dimensions, hostModel) {
  16094. dimensions = dimensions || ['x', 'y'];
  16095. var dimensionInfos = {};
  16096. var dimensionNames = [];
  16097. for (var i = 0; i < dimensions.length; i++) {
  16098. var dimensionName;
  16099. var dimensionInfo = {};
  16100. if (typeof dimensions[i] === 'string') {
  16101. dimensionName = dimensions[i];
  16102. dimensionInfo = {
  16103. name: dimensionName,
  16104. stackable: false,
  16105. // Type can be 'float', 'int', 'number'
  16106. // Default is number, Precision of float may not enough
  16107. type: 'number'
  16108. };
  16109. }
  16110. else {
  16111. dimensionInfo = dimensions[i];
  16112. dimensionName = dimensionInfo.name;
  16113. dimensionInfo.type = dimensionInfo.type || 'number';
  16114. }
  16115. dimensionNames.push(dimensionName);
  16116. dimensionInfos[dimensionName] = dimensionInfo;
  16117. }
  16118. /**
  16119. * @readOnly
  16120. * @type {Array.<string>}
  16121. */
  16122. this.dimensions = dimensionNames;
  16123. /**
  16124. * Infomation of each data dimension, like data type.
  16125. * @type {Object}
  16126. */
  16127. this._dimensionInfos = dimensionInfos;
  16128. /**
  16129. * @type {module:echarts/model/Model}
  16130. */
  16131. this.hostModel = hostModel;
  16132. /**
  16133. * @type {module:echarts/model/Model}
  16134. */
  16135. this.dataType;
  16136. /**
  16137. * Indices stores the indices of data subset after filtered.
  16138. * This data subset will be used in chart.
  16139. * @type {Array.<number>}
  16140. * @readOnly
  16141. */
  16142. this.indices = [];
  16143. /**
  16144. * Data storage
  16145. * @type {Object.<key, TypedArray|Array>}
  16146. * @private
  16147. */
  16148. this._storage = {};
  16149. /**
  16150. * @type {Array.<string>}
  16151. */
  16152. this._nameList = [];
  16153. /**
  16154. * @type {Array.<string>}
  16155. */
  16156. this._idList = [];
  16157. /**
  16158. * Models of data option is stored sparse for optimizing memory cost
  16159. * @type {Array.<module:echarts/model/Model>}
  16160. * @private
  16161. */
  16162. this._optionModels = [];
  16163. /**
  16164. * @param {module:echarts/data/List}
  16165. */
  16166. this.stackedOn = null;
  16167. /**
  16168. * Global visual properties after visual coding
  16169. * @type {Object}
  16170. * @private
  16171. */
  16172. this._visual = {};
  16173. /**
  16174. * Globel layout properties.
  16175. * @type {Object}
  16176. * @private
  16177. */
  16178. this._layout = {};
  16179. /**
  16180. * Item visual properties after visual coding
  16181. * @type {Array.<Object>}
  16182. * @private
  16183. */
  16184. this._itemVisuals = [];
  16185. /**
  16186. * Item layout properties after layout
  16187. * @type {Array.<Object>}
  16188. * @private
  16189. */
  16190. this._itemLayouts = [];
  16191. /**
  16192. * Graphic elemnents
  16193. * @type {Array.<module:zrender/Element>}
  16194. * @private
  16195. */
  16196. this._graphicEls = [];
  16197. /**
  16198. * @type {Array.<Array|Object>}
  16199. * @private
  16200. */
  16201. this._rawData;
  16202. /**
  16203. * @type {Object}
  16204. * @private
  16205. */
  16206. this._extent;
  16207. };
  16208. var listProto = List.prototype;
  16209. listProto.type = 'list';
  16210. /**
  16211. * Get dimension name
  16212. * @param {string|number} dim
  16213. * Dimension can be concrete names like x, y, z, lng, lat, angle, radius
  16214. * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius'
  16215. * @return {string} Concrete dim name.
  16216. */
  16217. listProto.getDimension = function (dim) {
  16218. if (!isNaN(dim)) {
  16219. dim = this.dimensions[dim] || dim;
  16220. }
  16221. return dim;
  16222. };
  16223. /**
  16224. * Get type and stackable info of particular dimension
  16225. * @param {string|number} dim
  16226. * Dimension can be concrete names like x, y, z, lng, lat, angle, radius
  16227. * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius'
  16228. */
  16229. listProto.getDimensionInfo = function (dim) {
  16230. return zrUtil.clone(this._dimensionInfos[this.getDimension(dim)]);
  16231. };
  16232. /**
  16233. * Initialize from data
  16234. * @param {Array.<Object|number|Array>} data
  16235. * @param {Array.<string>} [nameList]
  16236. * @param {Function} [dimValueGetter] (dataItem, dimName, dataIndex, dimIndex) => number
  16237. */
  16238. listProto.initData = function (data, nameList, dimValueGetter) {
  16239. data = data || [];
  16240. if (!zrUtil.isArray(data)) {
  16241. throw new Error('Invalid data.');
  16242. }
  16243. this._rawData = data;
  16244. // Clear
  16245. var storage = this._storage = {};
  16246. var indices = this.indices = [];
  16247. var dimensions = this.dimensions;
  16248. var size = data.length;
  16249. var dimensionInfoMap = this._dimensionInfos;
  16250. var idList = [];
  16251. var nameRepeatCount = {};
  16252. nameList = nameList || [];
  16253. // Init storage
  16254. for (var i = 0; i < dimensions.length; i++) {
  16255. var dimInfo = dimensionInfoMap[dimensions[i]];
  16256. var DataCtor = dataCtors[dimInfo.type];
  16257. storage[dimensions[i]] = new DataCtor(size);
  16258. }
  16259. // Default dim value getter
  16260. dimValueGetter = dimValueGetter || function (dataItem, dimName, dataIndex, dimIndex) {
  16261. var value = modelUtil.getDataItemValue(dataItem);
  16262. return modelUtil.converDataValue(
  16263. zrUtil.isArray(value)
  16264. ? value[dimIndex]
  16265. // If value is a single number or something else not array.
  16266. : value,
  16267. dimensionInfoMap[dimName]
  16268. );
  16269. };
  16270. for (var idx = 0; idx < data.length; idx++) {
  16271. var dataItem = data[idx];
  16272. // Each data item is value
  16273. // [1, 2]
  16274. // 2
  16275. // Bar chart, line chart which uses category axis
  16276. // only gives the 'y' value. 'x' value is the indices of cateogry
  16277. // Use a tempValue to normalize the value to be a (x, y) value
  16278. // Store the data by dimensions
  16279. for (var k = 0; k < dimensions.length; k++) {
  16280. var dim = dimensions[k];
  16281. var dimStorage = storage[dim];
  16282. // PENDING NULL is empty or zero
  16283. dimStorage[idx] = dimValueGetter(dataItem, dim, idx, k);
  16284. }
  16285. indices.push(idx);
  16286. }
  16287. // Use the name in option and create id
  16288. for (var i = 0; i < data.length; i++) {
  16289. var id = '';
  16290. if (!nameList[i]) {
  16291. nameList[i] = data[i].name;
  16292. // Try using the id in option
  16293. id = data[i].id;
  16294. }
  16295. var name = nameList[i] || '';
  16296. if (!id && name) {
  16297. // Use name as id and add counter to avoid same name
  16298. nameRepeatCount[name] = nameRepeatCount[name] || 0;
  16299. id = name;
  16300. if (nameRepeatCount[name] > 0) {
  16301. id += '__ec__' + nameRepeatCount[name];
  16302. }
  16303. nameRepeatCount[name]++;
  16304. }
  16305. id && (idList[i] = id);
  16306. }
  16307. this._nameList = nameList;
  16308. this._idList = idList;
  16309. };
  16310. /**
  16311. * @return {number}
  16312. */
  16313. listProto.count = function () {
  16314. return this.indices.length;
  16315. };
  16316. /**
  16317. * Get value. Return NaN if idx is out of range.
  16318. * @param {string} dim Dim must be concrete name.
  16319. * @param {number} idx
  16320. * @param {boolean} stack
  16321. * @return {number}
  16322. */
  16323. listProto.get = function (dim, idx, stack) {
  16324. var storage = this._storage;
  16325. var dataIndex = this.indices[idx];
  16326. // If value not exists
  16327. if (dataIndex == null) {
  16328. return NaN;
  16329. }
  16330. var value = storage[dim] && storage[dim][dataIndex];
  16331. // FIXME ordinal data type is not stackable
  16332. if (stack) {
  16333. var dimensionInfo = this._dimensionInfos[dim];
  16334. if (dimensionInfo && dimensionInfo.stackable) {
  16335. var stackedOn = this.stackedOn;
  16336. while (stackedOn) {
  16337. // Get no stacked data of stacked on
  16338. var stackedValue = stackedOn.get(dim, idx);
  16339. // Considering positive stack, negative stack and empty data
  16340. if ((value >= 0 && stackedValue > 0) // Positive stack
  16341. || (value <= 0 && stackedValue < 0) // Negative stack
  16342. ) {
  16343. value += stackedValue;
  16344. }
  16345. stackedOn = stackedOn.stackedOn;
  16346. }
  16347. }
  16348. }
  16349. return value;
  16350. };
  16351. /**
  16352. * Get value for multi dimensions.
  16353. * @param {Array.<string>} [dimensions] If ignored, using all dimensions.
  16354. * @param {number} idx
  16355. * @param {boolean} stack
  16356. * @return {number}
  16357. */
  16358. listProto.getValues = function (dimensions, idx, stack) {
  16359. var values = [];
  16360. if (!zrUtil.isArray(dimensions)) {
  16361. stack = idx;
  16362. idx = dimensions;
  16363. dimensions = this.dimensions;
  16364. }
  16365. for (var i = 0, len = dimensions.length; i < len; i++) {
  16366. values.push(this.get(dimensions[i], idx, stack));
  16367. }
  16368. return values;
  16369. };
  16370. /**
  16371. * If value is NaN. Inlcuding '-'
  16372. * @param {string} dim
  16373. * @param {number} idx
  16374. * @return {number}
  16375. */
  16376. listProto.hasValue = function (idx) {
  16377. var dimensions = this.dimensions;
  16378. var dimensionInfos = this._dimensionInfos;
  16379. for (var i = 0, len = dimensions.length; i < len; i++) {
  16380. if (
  16381. // Ordinal type can be string or number
  16382. dimensionInfos[dimensions[i]].type !== 'ordinal'
  16383. && isNaN(this.get(dimensions[i], idx))
  16384. ) {
  16385. return false;
  16386. }
  16387. }
  16388. return true;
  16389. };
  16390. /**
  16391. * Get extent of data in one dimension
  16392. * @param {string} dim
  16393. * @param {boolean} stack
  16394. */
  16395. listProto.getDataExtent = function (dim, stack) {
  16396. var dimData = this._storage[dim];
  16397. var dimInfo = this.getDimensionInfo(dim);
  16398. stack = (dimInfo && dimInfo.stackable) && stack;
  16399. var dimExtent = (this._extent || (this._extent = {}))[dim + (!!stack)];
  16400. var value;
  16401. if (dimExtent) {
  16402. return dimExtent;
  16403. }
  16404. // var dimInfo = this._dimensionInfos[dim];
  16405. if (dimData) {
  16406. var min = Infinity;
  16407. var max = -Infinity;
  16408. // var isOrdinal = dimInfo.type === 'ordinal';
  16409. for (var i = 0, len = this.count(); i < len; i++) {
  16410. value = this.get(dim, i, stack);
  16411. // FIXME
  16412. // if (isOrdinal && typeof value === 'string') {
  16413. // value = zrUtil.indexOf(dimData, value);
  16414. // }
  16415. value < min && (min = value);
  16416. value > max && (max = value);
  16417. }
  16418. return (this._extent[dim + stack] = [min, max]);
  16419. }
  16420. else {
  16421. return [Infinity, -Infinity];
  16422. }
  16423. };
  16424. /**
  16425. * Get sum of data in one dimension
  16426. * @param {string} dim
  16427. * @param {boolean} stack
  16428. */
  16429. listProto.getSum = function (dim, stack) {
  16430. var dimData = this._storage[dim];
  16431. var sum = 0;
  16432. if (dimData) {
  16433. for (var i = 0, len = this.count(); i < len; i++) {
  16434. var value = this.get(dim, i, stack);
  16435. if (!isNaN(value)) {
  16436. sum += value;
  16437. }
  16438. }
  16439. }
  16440. return sum;
  16441. };
  16442. /**
  16443. * Retreive the index with given value
  16444. * @param {number} idx
  16445. * @param {number} value
  16446. * @return {number}
  16447. */
  16448. // FIXME Precision of float value
  16449. listProto.indexOf = function (dim, value) {
  16450. var storage = this._storage;
  16451. var dimData = storage[dim];
  16452. var indices = this.indices;
  16453. if (dimData) {
  16454. for (var i = 0, len = indices.length; i < len; i++) {
  16455. var rawIndex = indices[i];
  16456. if (dimData[rawIndex] === value) {
  16457. return i;
  16458. }
  16459. }
  16460. }
  16461. return -1;
  16462. };
  16463. /**
  16464. * Retreive the index with given name
  16465. * @param {number} idx
  16466. * @param {number} name
  16467. * @return {number}
  16468. */
  16469. listProto.indexOfName = function (name) {
  16470. var indices = this.indices;
  16471. var nameList = this._nameList;
  16472. for (var i = 0, len = indices.length; i < len; i++) {
  16473. var rawIndex = indices[i];
  16474. if (nameList[rawIndex] === name) {
  16475. return i;
  16476. }
  16477. }
  16478. return -1;
  16479. };
  16480. /**
  16481. * Retreive the index of nearest value
  16482. * @param {string} dim
  16483. * @param {number} value
  16484. * @param {boolean} stack If given value is after stacked
  16485. * @return {number}
  16486. */
  16487. listProto.indexOfNearest = function (dim, value, stack) {
  16488. var storage = this._storage;
  16489. var dimData = storage[dim];
  16490. if (dimData) {
  16491. var minDist = Number.MAX_VALUE;
  16492. var nearestIdx = -1;
  16493. for (var i = 0, len = this.count(); i < len; i++) {
  16494. var diff = value - this.get(dim, i, stack);
  16495. var dist = Math.abs(diff);
  16496. if (dist < minDist
  16497. // For the case of two data are same on xAxis, which has sequence data.
  16498. // Show the nearest index
  16499. // https://github.com/ecomfe/echarts/issues/2869
  16500. || (dist === minDist && diff > 0)
  16501. ) {
  16502. minDist = dist;
  16503. nearestIdx = i;
  16504. }
  16505. }
  16506. return nearestIdx;
  16507. }
  16508. return -1;
  16509. };
  16510. /**
  16511. * Get raw data index
  16512. * @param {number} idx
  16513. * @return {number}
  16514. */
  16515. listProto.getRawIndex = function (idx) {
  16516. var rawIdx = this.indices[idx];
  16517. return rawIdx == null ? -1 : rawIdx;
  16518. };
  16519. /**
  16520. * Get raw data item
  16521. * @param {number} idx
  16522. * @return {number}
  16523. */
  16524. listProto.getRawDataItem = function (idx) {
  16525. return this._rawData[this.getRawIndex(idx)];
  16526. };
  16527. /**
  16528. * @param {number} idx
  16529. * @param {boolean} [notDefaultIdx=false]
  16530. * @return {string}
  16531. */
  16532. listProto.getName = function (idx) {
  16533. return this._nameList[this.indices[idx]] || '';
  16534. };
  16535. /**
  16536. * @param {number} idx
  16537. * @param {boolean} [notDefaultIdx=false]
  16538. * @return {string}
  16539. */
  16540. listProto.getId = function (idx) {
  16541. return this._idList[this.indices[idx]] || (this.getRawIndex(idx) + '');
  16542. };
  16543. function normalizeDimensions(dimensions) {
  16544. if (!zrUtil.isArray(dimensions)) {
  16545. dimensions = [dimensions];
  16546. }
  16547. return dimensions;
  16548. }
  16549. /**
  16550. * Data iteration
  16551. * @param {string|Array.<string>}
  16552. * @param {Function} cb
  16553. * @param {boolean} [stack=false]
  16554. * @param {*} [context=this]
  16555. *
  16556. * @example
  16557. * list.each('x', function (x, idx) {});
  16558. * list.each(['x', 'y'], function (x, y, idx) {});
  16559. * list.each(function (idx) {})
  16560. */
  16561. listProto.each = function (dimensions, cb, stack, context) {
  16562. if (typeof dimensions === 'function') {
  16563. context = stack;
  16564. stack = cb;
  16565. cb = dimensions;
  16566. dimensions = [];
  16567. }
  16568. dimensions = zrUtil.map(
  16569. normalizeDimensions(dimensions), this.getDimension, this
  16570. );
  16571. var value = [];
  16572. var dimSize = dimensions.length;
  16573. var indices = this.indices;
  16574. context = context || this;
  16575. for (var i = 0; i < indices.length; i++) {
  16576. if (dimSize === 0) {
  16577. cb.call(context, i);
  16578. }
  16579. // Simple optimization
  16580. else if (dimSize === 1) {
  16581. cb.call(context, this.get(dimensions[0], i, stack), i);
  16582. }
  16583. else {
  16584. for (var k = 0; k < dimSize; k++) {
  16585. value[k] = this.get(dimensions[k], i, stack);
  16586. }
  16587. // Index
  16588. value[k] = i;
  16589. cb.apply(context, value);
  16590. }
  16591. }
  16592. };
  16593. /**
  16594. * Data filter
  16595. * @param {string|Array.<string>}
  16596. * @param {Function} cb
  16597. * @param {boolean} [stack=false]
  16598. * @param {*} [context=this]
  16599. */
  16600. listProto.filterSelf = function (dimensions, cb, stack, context) {
  16601. if (typeof dimensions === 'function') {
  16602. context = stack;
  16603. stack = cb;
  16604. cb = dimensions;
  16605. dimensions = [];
  16606. }
  16607. dimensions = zrUtil.map(
  16608. normalizeDimensions(dimensions), this.getDimension, this
  16609. );
  16610. var newIndices = [];
  16611. var value = [];
  16612. var dimSize = dimensions.length;
  16613. var indices = this.indices;
  16614. context = context || this;
  16615. for (var i = 0; i < indices.length; i++) {
  16616. var keep;
  16617. // Simple optimization
  16618. if (dimSize === 1) {
  16619. keep = cb.call(
  16620. context, this.get(dimensions[0], i, stack), i
  16621. );
  16622. }
  16623. else {
  16624. for (var k = 0; k < dimSize; k++) {
  16625. value[k] = this.get(dimensions[k], i, stack);
  16626. }
  16627. value[k] = i;
  16628. keep = cb.apply(context, value);
  16629. }
  16630. if (keep) {
  16631. newIndices.push(indices[i]);
  16632. }
  16633. }
  16634. this.indices = newIndices;
  16635. // Reset data extent
  16636. this._extent = {};
  16637. return this;
  16638. };
  16639. /**
  16640. * Data mapping to a plain array
  16641. * @param {string|Array.<string>} [dimensions]
  16642. * @param {Function} cb
  16643. * @param {boolean} [stack=false]
  16644. * @param {*} [context=this]
  16645. * @return {Array}
  16646. */
  16647. listProto.mapArray = function (dimensions, cb, stack, context) {
  16648. if (typeof dimensions === 'function') {
  16649. context = stack;
  16650. stack = cb;
  16651. cb = dimensions;
  16652. dimensions = [];
  16653. }
  16654. var result = [];
  16655. this.each(dimensions, function () {
  16656. result.push(cb && cb.apply(this, arguments));
  16657. }, stack, context);
  16658. return result;
  16659. };
  16660. function cloneListForMapAndSample(original, excludeDimensions) {
  16661. var allDimensions = original.dimensions;
  16662. var list = new List(
  16663. zrUtil.map(allDimensions, original.getDimensionInfo, original),
  16664. original.hostModel
  16665. );
  16666. // FIXME If needs stackedOn, value may already been stacked
  16667. transferImmuProperties(list, original);
  16668. var storage = list._storage = {};
  16669. var originalStorage = original._storage;
  16670. // Init storage
  16671. for (var i = 0; i < allDimensions.length; i++) {
  16672. var dim = allDimensions[i];
  16673. var dimStore = originalStorage[dim];
  16674. if (zrUtil.indexOf(excludeDimensions, dim) >= 0) {
  16675. storage[dim] = new dimStore.constructor(
  16676. originalStorage[dim].length
  16677. );
  16678. }
  16679. else {
  16680. // Direct reference for other dimensions
  16681. storage[dim] = originalStorage[dim];
  16682. }
  16683. }
  16684. return list;
  16685. }
  16686. /**
  16687. * Data mapping to a new List with given dimensions
  16688. * @param {string|Array.<string>} dimensions
  16689. * @param {Function} cb
  16690. * @param {boolean} [stack=false]
  16691. * @param {*} [context=this]
  16692. * @return {Array}
  16693. */
  16694. listProto.map = function (dimensions, cb, stack, context) {
  16695. dimensions = zrUtil.map(
  16696. normalizeDimensions(dimensions), this.getDimension, this
  16697. );
  16698. var list = cloneListForMapAndSample(this, dimensions);
  16699. // Following properties are all immutable.
  16700. // So we can reference to the same value
  16701. var indices = list.indices = this.indices;
  16702. var storage = list._storage;
  16703. var tmpRetValue = [];
  16704. this.each(dimensions, function () {
  16705. var idx = arguments[arguments.length - 1];
  16706. var retValue = cb && cb.apply(this, arguments);
  16707. if (retValue != null) {
  16708. // a number
  16709. if (typeof retValue === 'number') {
  16710. tmpRetValue[0] = retValue;
  16711. retValue = tmpRetValue;
  16712. }
  16713. for (var i = 0; i < retValue.length; i++) {
  16714. var dim = dimensions[i];
  16715. var dimStore = storage[dim];
  16716. var rawIdx = indices[idx];
  16717. if (dimStore) {
  16718. dimStore[rawIdx] = retValue[i];
  16719. }
  16720. }
  16721. }
  16722. }, stack, context);
  16723. return list;
  16724. };
  16725. /**
  16726. * Large data down sampling on given dimension
  16727. * @param {string} dimension
  16728. * @param {number} rate
  16729. * @param {Function} sampleValue
  16730. * @param {Function} sampleIndex Sample index for name and id
  16731. */
  16732. listProto.downSample = function (dimension, rate, sampleValue, sampleIndex) {
  16733. var list = cloneListForMapAndSample(this, [dimension]);
  16734. var storage = this._storage;
  16735. var targetStorage = list._storage;
  16736. var originalIndices = this.indices;
  16737. var indices = list.indices = [];
  16738. var frameValues = [];
  16739. var frameIndices = [];
  16740. var frameSize = Math.floor(1 / rate);
  16741. var dimStore = targetStorage[dimension];
  16742. var len = this.count();
  16743. // Copy data from original data
  16744. for (var i = 0; i < storage[dimension].length; i++) {
  16745. targetStorage[dimension][i] = storage[dimension][i];
  16746. }
  16747. for (var i = 0; i < len; i += frameSize) {
  16748. // Last frame
  16749. if (frameSize > len - i) {
  16750. frameSize = len - i;
  16751. frameValues.length = frameSize;
  16752. }
  16753. for (var k = 0; k < frameSize; k++) {
  16754. var idx = originalIndices[i + k];
  16755. frameValues[k] = dimStore[idx];
  16756. frameIndices[k] = idx;
  16757. }
  16758. var value = sampleValue(frameValues);
  16759. var idx = frameIndices[sampleIndex(frameValues, value) || 0];
  16760. // Only write value on the filtered data
  16761. dimStore[idx] = value;
  16762. indices.push(idx);
  16763. }
  16764. return list;
  16765. };
  16766. /**
  16767. * Get model of one data item.
  16768. *
  16769. * @param {number} idx
  16770. */
  16771. // FIXME Model proxy ?
  16772. listProto.getItemModel = function (idx) {
  16773. var hostModel = this.hostModel;
  16774. idx = this.indices[idx];
  16775. return new Model(this._rawData[idx], hostModel, hostModel && hostModel.ecModel);
  16776. };
  16777. /**
  16778. * Create a data differ
  16779. * @param {module:echarts/data/List} otherList
  16780. * @return {module:echarts/data/DataDiffer}
  16781. */
  16782. listProto.diff = function (otherList) {
  16783. var idList = this._idList;
  16784. var otherIdList = otherList && otherList._idList;
  16785. return new DataDiffer(
  16786. otherList ? otherList.indices : [], this.indices, function (idx) {
  16787. return otherIdList[idx] || (idx + '');
  16788. }, function (idx) {
  16789. return idList[idx] || (idx + '');
  16790. }
  16791. );
  16792. };
  16793. /**
  16794. * Get visual property.
  16795. * @param {string} key
  16796. */
  16797. listProto.getVisual = function (key) {
  16798. var visual = this._visual;
  16799. return visual && visual[key];
  16800. };
  16801. /**
  16802. * Set visual property
  16803. * @param {string|Object} key
  16804. * @param {*} [value]
  16805. *
  16806. * @example
  16807. * setVisual('color', color);
  16808. * setVisual({
  16809. * 'color': color
  16810. * });
  16811. */
  16812. listProto.setVisual = function (key, val) {
  16813. if (isObject(key)) {
  16814. for (var name in key) {
  16815. if (key.hasOwnProperty(name)) {
  16816. this.setVisual(name, key[name]);
  16817. }
  16818. }
  16819. return;
  16820. }
  16821. this._visual = this._visual || {};
  16822. this._visual[key] = val;
  16823. };
  16824. /**
  16825. * Set layout property.
  16826. * @param {string} key
  16827. * @param {*} [val]
  16828. */
  16829. listProto.setLayout = function (key, val) {
  16830. if (isObject(key)) {
  16831. for (var name in key) {
  16832. if (key.hasOwnProperty(name)) {
  16833. this.setLayout(name, key[name]);
  16834. }
  16835. }
  16836. return;
  16837. }
  16838. this._layout[key] = val;
  16839. };
  16840. /**
  16841. * Get layout property.
  16842. * @param {string} key.
  16843. * @return {*}
  16844. */
  16845. listProto.getLayout = function (key) {
  16846. return this._layout[key];
  16847. };
  16848. /**
  16849. * Get layout of single data item
  16850. * @param {number} idx
  16851. */
  16852. listProto.getItemLayout = function (idx) {
  16853. return this._itemLayouts[idx];
  16854. };
  16855. /**
  16856. * Set layout of single data item
  16857. * @param {number} idx
  16858. * @param {Object} layout
  16859. * @param {boolean=} [merge=false]
  16860. */
  16861. listProto.setItemLayout = function (idx, layout, merge) {
  16862. this._itemLayouts[idx] = merge
  16863. ? zrUtil.extend(this._itemLayouts[idx] || {}, layout)
  16864. : layout;
  16865. };
  16866. /**
  16867. * Clear all layout of single data item
  16868. */
  16869. listProto.clearItemLayouts = function () {
  16870. this._itemLayouts.length = 0;
  16871. };
  16872. /**
  16873. * Get visual property of single data item
  16874. * @param {number} idx
  16875. * @param {string} key
  16876. * @param {boolean} ignoreParent
  16877. */
  16878. listProto.getItemVisual = function (idx, key, ignoreParent) {
  16879. var itemVisual = this._itemVisuals[idx];
  16880. var val = itemVisual && itemVisual[key];
  16881. if (val == null && !ignoreParent) {
  16882. // Use global visual property
  16883. return this.getVisual(key);
  16884. }
  16885. return val;
  16886. };
  16887. /**
  16888. * Set visual property of single data item
  16889. *
  16890. * @param {number} idx
  16891. * @param {string|Object} key
  16892. * @param {*} [value]
  16893. *
  16894. * @example
  16895. * setItemVisual(0, 'color', color);
  16896. * setItemVisual(0, {
  16897. * 'color': color
  16898. * });
  16899. */
  16900. listProto.setItemVisual = function (idx, key, value) {
  16901. var itemVisual = this._itemVisuals[idx] || {};
  16902. this._itemVisuals[idx] = itemVisual;
  16903. if (isObject(key)) {
  16904. for (var name in key) {
  16905. if (key.hasOwnProperty(name)) {
  16906. itemVisual[name] = key[name];
  16907. }
  16908. }
  16909. return;
  16910. }
  16911. itemVisual[key] = value;
  16912. };
  16913. var setItemDataAndSeriesIndex = function (child) {
  16914. child.seriesIndex = this.seriesIndex;
  16915. child.dataIndex = this.dataIndex;
  16916. child.dataType = this.dataType;
  16917. };
  16918. /**
  16919. * Set graphic element relative to data. It can be set as null
  16920. * @param {number} idx
  16921. * @param {module:zrender/Element} [el]
  16922. */
  16923. listProto.setItemGraphicEl = function (idx, el) {
  16924. var hostModel = this.hostModel;
  16925. if (el) {
  16926. // Add data index and series index for indexing the data by element
  16927. // Useful in tooltip
  16928. el.dataIndex = idx;
  16929. el.dataType = this.dataType;
  16930. el.seriesIndex = hostModel && hostModel.seriesIndex;
  16931. if (el.type === 'group') {
  16932. el.traverse(setItemDataAndSeriesIndex, el);
  16933. }
  16934. }
  16935. this._graphicEls[idx] = el;
  16936. };
  16937. /**
  16938. * @param {number} idx
  16939. * @return {module:zrender/Element}
  16940. */
  16941. listProto.getItemGraphicEl = function (idx) {
  16942. return this._graphicEls[idx];
  16943. };
  16944. /**
  16945. * @param {Function} cb
  16946. * @param {*} context
  16947. */
  16948. listProto.eachItemGraphicEl = function (cb, context) {
  16949. zrUtil.each(this._graphicEls, function (el, idx) {
  16950. if (el) {
  16951. cb && cb.call(context, el, idx);
  16952. }
  16953. });
  16954. };
  16955. /**
  16956. * Shallow clone a new list except visual and layout properties, and graph elements.
  16957. * New list only change the indices.
  16958. */
  16959. listProto.cloneShallow = function () {
  16960. var dimensionInfoList = zrUtil.map(this.dimensions, this.getDimensionInfo, this);
  16961. var list = new List(dimensionInfoList, this.hostModel);
  16962. // FIXME
  16963. list._storage = this._storage;
  16964. transferImmuProperties(list, this);
  16965. list.indices = this.indices.slice();
  16966. return list;
  16967. };
  16968. /**
  16969. * Wrap some method to add more feature
  16970. * @param {string} methodName
  16971. * @param {Function} injectFunction
  16972. */
  16973. listProto.wrapMethod = function (methodName, injectFunction) {
  16974. var originalMethod = this[methodName];
  16975. if (typeof originalMethod !== 'function') {
  16976. return;
  16977. }
  16978. this.__wrappedMethods = this.__wrappedMethods || [];
  16979. this.__wrappedMethods.push(methodName);
  16980. this[methodName] = function () {
  16981. var res = originalMethod.apply(this, arguments);
  16982. return injectFunction.apply(this, [res].concat(zrUtil.slice(arguments)));
  16983. };
  16984. };
  16985. // Methods that create a new list based on this list should be listed here.
  16986. // Notice that those method should `RETURN` the new list.
  16987. listProto.TRANSFERABLE_METHODS = ['cloneShallow', 'downSample', 'map'];
  16988. // Methods that change indices of this list should be listed here.
  16989. listProto.CHANGABLE_METHODS = ['filterSelf'];
  16990. module.exports = List;
  16991. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
  16992. /***/ },
  16993. /* 96 */
  16994. /***/ function(module, exports) {
  16995. 'use strict';
  16996. function defaultKeyGetter(item) {
  16997. return item;
  16998. }
  16999. function DataDiffer(oldArr, newArr, oldKeyGetter, newKeyGetter) {
  17000. this._old = oldArr;
  17001. this._new = newArr;
  17002. this._oldKeyGetter = oldKeyGetter || defaultKeyGetter;
  17003. this._newKeyGetter = newKeyGetter || defaultKeyGetter;
  17004. }
  17005. DataDiffer.prototype = {
  17006. constructor: DataDiffer,
  17007. /**
  17008. * Callback function when add a data
  17009. */
  17010. add: function (func) {
  17011. this._add = func;
  17012. return this;
  17013. },
  17014. /**
  17015. * Callback function when update a data
  17016. */
  17017. update: function (func) {
  17018. this._update = func;
  17019. return this;
  17020. },
  17021. /**
  17022. * Callback function when remove a data
  17023. */
  17024. remove: function (func) {
  17025. this._remove = func;
  17026. return this;
  17027. },
  17028. execute: function () {
  17029. var oldArr = this._old;
  17030. var newArr = this._new;
  17031. var oldKeyGetter = this._oldKeyGetter;
  17032. var newKeyGetter = this._newKeyGetter;
  17033. var oldDataIndexMap = {};
  17034. var newDataIndexMap = {};
  17035. var i;
  17036. initIndexMap(oldArr, oldDataIndexMap, oldKeyGetter);
  17037. initIndexMap(newArr, newDataIndexMap, newKeyGetter);
  17038. // Travel by inverted order to make sure order consistency
  17039. // when duplicate keys exists (consider newDataIndex.pop() below).
  17040. // For performance consideration, these code below do not look neat.
  17041. for (i = 0; i < oldArr.length; i++) {
  17042. var key = oldKeyGetter(oldArr[i]);
  17043. var idx = newDataIndexMap[key];
  17044. // idx can never be empty array here. see 'set null' logic below.
  17045. if (idx != null) {
  17046. // Consider there is duplicate key (for example, use dataItem.name as key).
  17047. // We should make sure every item in newArr and oldArr can be visited.
  17048. var len = idx.length;
  17049. if (len) {
  17050. len === 1 && (newDataIndexMap[key] = null);
  17051. idx = idx.unshift();
  17052. }
  17053. else {
  17054. newDataIndexMap[key] = null;
  17055. }
  17056. this._update && this._update(idx, i);
  17057. }
  17058. else {
  17059. this._remove && this._remove(i);
  17060. }
  17061. }
  17062. for (var key in newDataIndexMap) {
  17063. if (newDataIndexMap.hasOwnProperty(key)) {
  17064. var idx = newDataIndexMap[key];
  17065. if (idx == null) {
  17066. continue;
  17067. }
  17068. // idx can never be empty array here. see 'set null' logic above.
  17069. if (!idx.length) {
  17070. this._add && this._add(idx);
  17071. }
  17072. else {
  17073. for (var i = 0, len = idx.length; i < len; i++) {
  17074. this._add && this._add(idx[i]);
  17075. }
  17076. }
  17077. }
  17078. }
  17079. }
  17080. };
  17081. function initIndexMap(arr, map, keyGetter) {
  17082. for (var i = 0; i < arr.length; i++) {
  17083. var key = keyGetter(arr[i]);
  17084. var existence = map[key];
  17085. if (existence == null) {
  17086. map[key] = i;
  17087. }
  17088. else {
  17089. if (!existence.length) {
  17090. map[key] = existence = [existence];
  17091. }
  17092. existence.push(i);
  17093. }
  17094. }
  17095. }
  17096. module.exports = DataDiffer;
  17097. /***/ },
  17098. /* 97 */
  17099. /***/ function(module, exports, __webpack_require__) {
  17100. /**
  17101. * Complete dimensions by data (guess dimension).
  17102. */
  17103. var zrUtil = __webpack_require__(3);
  17104. /**
  17105. * Complete the dimensions array guessed from the data structure.
  17106. * @param {Array.<string>} dimensions Necessary dimensions, like ['x', 'y']
  17107. * @param {Array} data Data list. [[1, 2, 3], [2, 3, 4]]
  17108. * @param {Array.<string>} defaultNames Default names to fill not necessary dimensions, like ['value']
  17109. * @param {string} extraPrefix Prefix of name when filling the left dimensions.
  17110. * @return {Array.<string>}
  17111. */
  17112. function completeDimensions(dimensions, data, defaultNames, extraPrefix) {
  17113. if (!data) {
  17114. return dimensions;
  17115. }
  17116. var value0 = retrieveValue(data[0]);
  17117. var dimSize = zrUtil.isArray(value0) && value0.length || 1;
  17118. defaultNames = defaultNames || [];
  17119. extraPrefix = extraPrefix || 'extra';
  17120. for (var i = 0; i < dimSize; i++) {
  17121. if (!dimensions[i]) {
  17122. var name = defaultNames[i] || (extraPrefix + (i - defaultNames.length));
  17123. dimensions[i] = guessOrdinal(data, i)
  17124. ? {type: 'ordinal', name: name}
  17125. : name;
  17126. }
  17127. }
  17128. return dimensions;
  17129. }
  17130. // The rule should not be complex, otherwise user might not
  17131. // be able to known where the data is wrong.
  17132. function guessOrdinal(data, dimIndex) {
  17133. for (var i = 0, len = data.length; i < len; i++) {
  17134. var value = retrieveValue(data[i]);
  17135. if (!zrUtil.isArray(value)) {
  17136. return false;
  17137. }
  17138. var value = value[dimIndex];
  17139. if (value != null && isFinite(value)) {
  17140. return false;
  17141. }
  17142. else if (zrUtil.isString(value) && value !== '-') {
  17143. return true;
  17144. }
  17145. }
  17146. return false;
  17147. }
  17148. function retrieveValue(o) {
  17149. return zrUtil.isArray(o) ? o : zrUtil.isObject(o) ? o.value: o;
  17150. }
  17151. module.exports = completeDimensions;
  17152. /***/ },
  17153. /* 98 */
  17154. /***/ function(module, exports, __webpack_require__) {
  17155. 'use strict';
  17156. var zrUtil = __webpack_require__(3);
  17157. var SymbolDraw = __webpack_require__(99);
  17158. var Symbol = __webpack_require__(100);
  17159. var lineAnimationDiff = __webpack_require__(102);
  17160. var graphic = __webpack_require__(42);
  17161. var polyHelper = __webpack_require__(103);
  17162. var ChartView = __webpack_require__(41);
  17163. function isPointsSame(points1, points2) {
  17164. if (points1.length !== points2.length) {
  17165. return;
  17166. }
  17167. for (var i = 0; i < points1.length; i++) {
  17168. var p1 = points1[i];
  17169. var p2 = points2[i];
  17170. if (p1[0] !== p2[0] || p1[1] !== p2[1]) {
  17171. return;
  17172. }
  17173. }
  17174. return true;
  17175. }
  17176. function getSmooth(smooth) {
  17177. return typeof (smooth) === 'number' ? smooth : (smooth ? 0.3 : 0);
  17178. }
  17179. function getAxisExtentWithGap(axis) {
  17180. var extent = axis.getGlobalExtent();
  17181. if (axis.onBand) {
  17182. // Remove extra 1px to avoid line miter in clipped edge
  17183. var halfBandWidth = axis.getBandWidth() / 2 - 1;
  17184. var dir = extent[1] > extent[0] ? 1 : -1;
  17185. extent[0] += dir * halfBandWidth;
  17186. extent[1] -= dir * halfBandWidth;
  17187. }
  17188. return extent;
  17189. }
  17190. function sign(val) {
  17191. return val >= 0 ? 1 : -1;
  17192. }
  17193. /**
  17194. * @param {module:echarts/coord/cartesian/Cartesian2D|module:echarts/coord/polar/Polar} coordSys
  17195. * @param {module:echarts/data/List} data
  17196. * @param {Array.<Array.<number>>} points
  17197. * @private
  17198. */
  17199. function getStackedOnPoints(coordSys, data) {
  17200. var baseAxis = coordSys.getBaseAxis();
  17201. var valueAxis = coordSys.getOtherAxis(baseAxis);
  17202. var valueStart = baseAxis.onZero
  17203. ? 0 : valueAxis.scale.getExtent()[0];
  17204. var valueDim = valueAxis.dim;
  17205. var baseDataOffset = valueDim === 'x' || valueDim === 'radius' ? 1 : 0;
  17206. return data.mapArray([valueDim], function (val, idx) {
  17207. var stackedOnSameSign;
  17208. var stackedOn = data.stackedOn;
  17209. // Find first stacked value with same sign
  17210. while (stackedOn &&
  17211. sign(stackedOn.get(valueDim, idx)) === sign(val)
  17212. ) {
  17213. stackedOnSameSign = stackedOn;
  17214. break;
  17215. }
  17216. var stackedData = [];
  17217. stackedData[baseDataOffset] = data.get(baseAxis.dim, idx);
  17218. stackedData[1 - baseDataOffset] = stackedOnSameSign
  17219. ? stackedOnSameSign.get(valueDim, idx, true) : valueStart;
  17220. return coordSys.dataToPoint(stackedData);
  17221. }, true);
  17222. }
  17223. function queryDataIndex(data, payload) {
  17224. if (payload.dataIndex != null) {
  17225. return payload.dataIndex;
  17226. }
  17227. else if (payload.name != null) {
  17228. return data.indexOfName(payload.name);
  17229. }
  17230. }
  17231. function createGridClipShape(cartesian, hasAnimation, seriesModel) {
  17232. var xExtent = getAxisExtentWithGap(cartesian.getAxis('x'));
  17233. var yExtent = getAxisExtentWithGap(cartesian.getAxis('y'));
  17234. var isHorizontal = cartesian.getBaseAxis().isHorizontal();
  17235. var x = Math.min(xExtent[0], xExtent[1]);
  17236. var y = Math.min(yExtent[0], yExtent[1]);
  17237. var width = Math.max(xExtent[0], xExtent[1]) - x;
  17238. var height = Math.max(yExtent[0], yExtent[1]) - y;
  17239. var lineWidth = seriesModel.get('lineStyle.normal.width') || 2;
  17240. // Expand clip shape to avoid clipping when line value exceeds axis
  17241. var expandSize = seriesModel.get('clipOverflow') ? lineWidth / 2 : Math.max(width, height);
  17242. if (isHorizontal) {
  17243. y -= expandSize;
  17244. height += expandSize * 2;
  17245. }
  17246. else {
  17247. x -= expandSize;
  17248. width += expandSize * 2;
  17249. }
  17250. var clipPath = new graphic.Rect({
  17251. shape: {
  17252. x: x,
  17253. y: y,
  17254. width: width,
  17255. height: height
  17256. }
  17257. });
  17258. if (hasAnimation) {
  17259. clipPath.shape[isHorizontal ? 'width' : 'height'] = 0;
  17260. graphic.initProps(clipPath, {
  17261. shape: {
  17262. width: width,
  17263. height: height
  17264. }
  17265. }, seriesModel);
  17266. }
  17267. return clipPath;
  17268. }
  17269. function createPolarClipShape(polar, hasAnimation, seriesModel) {
  17270. var angleAxis = polar.getAngleAxis();
  17271. var radiusAxis = polar.getRadiusAxis();
  17272. var radiusExtent = radiusAxis.getExtent();
  17273. var angleExtent = angleAxis.getExtent();
  17274. var RADIAN = Math.PI / 180;
  17275. var clipPath = new graphic.Sector({
  17276. shape: {
  17277. cx: polar.cx,
  17278. cy: polar.cy,
  17279. r0: radiusExtent[0],
  17280. r: radiusExtent[1],
  17281. startAngle: -angleExtent[0] * RADIAN,
  17282. endAngle: -angleExtent[1] * RADIAN,
  17283. clockwise: angleAxis.inverse
  17284. }
  17285. });
  17286. if (hasAnimation) {
  17287. clipPath.shape.endAngle = -angleExtent[0] * RADIAN;
  17288. graphic.initProps(clipPath, {
  17289. shape: {
  17290. endAngle: -angleExtent[1] * RADIAN
  17291. }
  17292. }, seriesModel);
  17293. }
  17294. return clipPath;
  17295. }
  17296. function createClipShape(coordSys, hasAnimation, seriesModel) {
  17297. return coordSys.type === 'polar'
  17298. ? createPolarClipShape(coordSys, hasAnimation, seriesModel)
  17299. : createGridClipShape(coordSys, hasAnimation, seriesModel);
  17300. }
  17301. module.exports = ChartView.extend({
  17302. type: 'line',
  17303. init: function () {
  17304. var lineGroup = new graphic.Group();
  17305. var symbolDraw = new SymbolDraw();
  17306. this.group.add(symbolDraw.group);
  17307. this._symbolDraw = symbolDraw;
  17308. this._lineGroup = lineGroup;
  17309. },
  17310. render: function (seriesModel, ecModel, api) {
  17311. var coordSys = seriesModel.coordinateSystem;
  17312. var group = this.group;
  17313. var data = seriesModel.getData();
  17314. var lineStyleModel = seriesModel.getModel('lineStyle.normal');
  17315. var areaStyleModel = seriesModel.getModel('areaStyle.normal');
  17316. var points = data.mapArray(data.getItemLayout, true);
  17317. var isCoordSysPolar = coordSys.type === 'polar';
  17318. var prevCoordSys = this._coordSys;
  17319. var symbolDraw = this._symbolDraw;
  17320. var polyline = this._polyline;
  17321. var polygon = this._polygon;
  17322. var lineGroup = this._lineGroup;
  17323. var hasAnimation = seriesModel.get('animation');
  17324. var isAreaChart = !areaStyleModel.isEmpty();
  17325. var stackedOnPoints = getStackedOnPoints(coordSys, data);
  17326. var showSymbol = seriesModel.get('showSymbol');
  17327. var isSymbolIgnore = showSymbol && !isCoordSysPolar && !seriesModel.get('showAllSymbol')
  17328. && this._getSymbolIgnoreFunc(data, coordSys);
  17329. // Remove temporary symbols
  17330. var oldData = this._data;
  17331. oldData && oldData.eachItemGraphicEl(function (el, idx) {
  17332. if (el.__temp) {
  17333. group.remove(el);
  17334. oldData.setItemGraphicEl(idx, null);
  17335. }
  17336. });
  17337. // Remove previous created symbols if showSymbol changed to false
  17338. if (!showSymbol) {
  17339. symbolDraw.remove();
  17340. }
  17341. group.add(lineGroup);
  17342. // Initialization animation or coordinate system changed
  17343. if (
  17344. !(polyline && prevCoordSys.type === coordSys.type)
  17345. ) {
  17346. showSymbol && symbolDraw.updateData(data, isSymbolIgnore);
  17347. polyline = this._newPolyline(points, coordSys, hasAnimation);
  17348. if (isAreaChart) {
  17349. polygon = this._newPolygon(
  17350. points, stackedOnPoints,
  17351. coordSys, hasAnimation
  17352. );
  17353. }
  17354. lineGroup.setClipPath(createClipShape(coordSys, true, seriesModel));
  17355. }
  17356. else {
  17357. if (isAreaChart && !polygon) {
  17358. // If areaStyle is added
  17359. polygon = this._newPolygon(
  17360. points, stackedOnPoints,
  17361. coordSys, hasAnimation
  17362. );
  17363. }
  17364. else if (polygon && !isAreaChart) {
  17365. // If areaStyle is removed
  17366. lineGroup.remove(polygon);
  17367. polygon = this._polygon = null;
  17368. }
  17369. // Update clipPath
  17370. lineGroup.setClipPath(createClipShape(coordSys, false, seriesModel));
  17371. // Always update, or it is wrong in the case turning on legend
  17372. // because points are not changed
  17373. showSymbol && symbolDraw.updateData(data, isSymbolIgnore);
  17374. // Stop symbol animation and sync with line points
  17375. // FIXME performance?
  17376. data.eachItemGraphicEl(function (el) {
  17377. el.stopAnimation(true);
  17378. });
  17379. // In the case data zoom triggerred refreshing frequently
  17380. // Data may not change if line has a category axis. So it should animate nothing
  17381. if (!isPointsSame(this._stackedOnPoints, stackedOnPoints)
  17382. || !isPointsSame(this._points, points)
  17383. ) {
  17384. if (hasAnimation) {
  17385. this._updateAnimation(
  17386. data, stackedOnPoints, coordSys, api
  17387. );
  17388. }
  17389. else {
  17390. polyline.setShape({
  17391. points: points
  17392. });
  17393. polygon && polygon.setShape({
  17394. points: points,
  17395. stackedOnPoints: stackedOnPoints
  17396. });
  17397. }
  17398. }
  17399. }
  17400. polyline.useStyle(zrUtil.defaults(
  17401. // Use color in lineStyle first
  17402. lineStyleModel.getLineStyle(),
  17403. {
  17404. fill: 'none',
  17405. stroke: data.getVisual('color'),
  17406. lineJoin: 'bevel'
  17407. }
  17408. ));
  17409. var smooth = seriesModel.get('smooth');
  17410. smooth = getSmooth(seriesModel.get('smooth'));
  17411. polyline.setShape({
  17412. smooth: smooth,
  17413. smoothMonotone: seriesModel.get('smoothMonotone'),
  17414. connectNulls: seriesModel.get('connectNulls')
  17415. });
  17416. if (polygon) {
  17417. var stackedOn = data.stackedOn;
  17418. var stackedOnSmooth = 0;
  17419. polygon.useStyle(zrUtil.defaults(
  17420. areaStyleModel.getAreaStyle(),
  17421. {
  17422. fill: data.getVisual('color'),
  17423. opacity: 0.7,
  17424. lineJoin: 'bevel'
  17425. }
  17426. ));
  17427. if (stackedOn) {
  17428. var stackedOnSeries = stackedOn.hostModel;
  17429. stackedOnSmooth = getSmooth(stackedOnSeries.get('smooth'));
  17430. }
  17431. polygon.setShape({
  17432. smooth: smooth,
  17433. stackedOnSmooth: stackedOnSmooth,
  17434. smoothMonotone: seriesModel.get('smoothMonotone'),
  17435. connectNulls: seriesModel.get('connectNulls')
  17436. });
  17437. }
  17438. this._data = data;
  17439. // Save the coordinate system for transition animation when data changed
  17440. this._coordSys = coordSys;
  17441. this._stackedOnPoints = stackedOnPoints;
  17442. this._points = points;
  17443. },
  17444. highlight: function (seriesModel, ecModel, api, payload) {
  17445. var data = seriesModel.getData();
  17446. var dataIndex = queryDataIndex(data, payload);
  17447. if (dataIndex != null && dataIndex >= 0) {
  17448. var symbol = data.getItemGraphicEl(dataIndex);
  17449. if (!symbol) {
  17450. // Create a temporary symbol if it is not exists
  17451. var pt = data.getItemLayout(dataIndex);
  17452. symbol = new Symbol(data, dataIndex, api);
  17453. symbol.position = pt;
  17454. symbol.setZ(
  17455. seriesModel.get('zlevel'),
  17456. seriesModel.get('z')
  17457. );
  17458. symbol.ignore = isNaN(pt[0]) || isNaN(pt[1]);
  17459. symbol.__temp = true;
  17460. data.setItemGraphicEl(dataIndex, symbol);
  17461. // Stop scale animation
  17462. symbol.stopSymbolAnimation(true);
  17463. this.group.add(symbol);
  17464. }
  17465. symbol.highlight();
  17466. }
  17467. else {
  17468. // Highlight whole series
  17469. ChartView.prototype.highlight.call(
  17470. this, seriesModel, ecModel, api, payload
  17471. );
  17472. }
  17473. },
  17474. downplay: function (seriesModel, ecModel, api, payload) {
  17475. var data = seriesModel.getData();
  17476. var dataIndex = queryDataIndex(data, payload);
  17477. if (dataIndex != null && dataIndex >= 0) {
  17478. var symbol = data.getItemGraphicEl(dataIndex);
  17479. if (symbol) {
  17480. if (symbol.__temp) {
  17481. data.setItemGraphicEl(dataIndex, null);
  17482. this.group.remove(symbol);
  17483. }
  17484. else {
  17485. symbol.downplay();
  17486. }
  17487. }
  17488. }
  17489. else {
  17490. // Downplay whole series
  17491. ChartView.prototype.downplay.call(
  17492. this, seriesModel, ecModel, api, payload
  17493. );
  17494. }
  17495. },
  17496. /**
  17497. * @param {module:zrender/container/Group} group
  17498. * @param {Array.<Array.<number>>} points
  17499. * @private
  17500. */
  17501. _newPolyline: function (points) {
  17502. var polyline = this._polyline;
  17503. // Remove previous created polyline
  17504. if (polyline) {
  17505. this._lineGroup.remove(polyline);
  17506. }
  17507. polyline = new polyHelper.Polyline({
  17508. shape: {
  17509. points: points
  17510. },
  17511. silent: true,
  17512. z2: 10
  17513. });
  17514. this._lineGroup.add(polyline);
  17515. this._polyline = polyline;
  17516. return polyline;
  17517. },
  17518. /**
  17519. * @param {module:zrender/container/Group} group
  17520. * @param {Array.<Array.<number>>} stackedOnPoints
  17521. * @param {Array.<Array.<number>>} points
  17522. * @private
  17523. */
  17524. _newPolygon: function (points, stackedOnPoints) {
  17525. var polygon = this._polygon;
  17526. // Remove previous created polygon
  17527. if (polygon) {
  17528. this._lineGroup.remove(polygon);
  17529. }
  17530. polygon = new polyHelper.Polygon({
  17531. shape: {
  17532. points: points,
  17533. stackedOnPoints: stackedOnPoints
  17534. },
  17535. silent: true
  17536. });
  17537. this._lineGroup.add(polygon);
  17538. this._polygon = polygon;
  17539. return polygon;
  17540. },
  17541. /**
  17542. * @private
  17543. */
  17544. _getSymbolIgnoreFunc: function (data, coordSys) {
  17545. var categoryAxis = coordSys.getAxesByScale('ordinal')[0];
  17546. // `getLabelInterval` is provided by echarts/component/axis
  17547. if (categoryAxis && categoryAxis.isLabelIgnored) {
  17548. return zrUtil.bind(categoryAxis.isLabelIgnored, categoryAxis);
  17549. }
  17550. },
  17551. /**
  17552. * @private
  17553. */
  17554. // FIXME Two value axis
  17555. _updateAnimation: function (data, stackedOnPoints, coordSys, api) {
  17556. var polyline = this._polyline;
  17557. var polygon = this._polygon;
  17558. var seriesModel = data.hostModel;
  17559. var diff = lineAnimationDiff(
  17560. this._data, data,
  17561. this._stackedOnPoints, stackedOnPoints,
  17562. this._coordSys, coordSys
  17563. );
  17564. polyline.shape.points = diff.current;
  17565. graphic.updateProps(polyline, {
  17566. shape: {
  17567. points: diff.next
  17568. }
  17569. }, seriesModel);
  17570. if (polygon) {
  17571. polygon.setShape({
  17572. points: diff.current,
  17573. stackedOnPoints: diff.stackedOnCurrent
  17574. });
  17575. graphic.updateProps(polygon, {
  17576. shape: {
  17577. points: diff.next,
  17578. stackedOnPoints: diff.stackedOnNext
  17579. }
  17580. }, seriesModel);
  17581. }
  17582. var updatedDataInfo = [];
  17583. var diffStatus = diff.status;
  17584. for (var i = 0; i < diffStatus.length; i++) {
  17585. var cmd = diffStatus[i].cmd;
  17586. if (cmd === '=') {
  17587. var el = data.getItemGraphicEl(diffStatus[i].idx1);
  17588. if (el) {
  17589. updatedDataInfo.push({
  17590. el: el,
  17591. ptIdx: i // Index of points
  17592. });
  17593. }
  17594. }
  17595. }
  17596. if (polyline.animators && polyline.animators.length) {
  17597. polyline.animators[0].during(function () {
  17598. for (var i = 0; i < updatedDataInfo.length; i++) {
  17599. var el = updatedDataInfo[i].el;
  17600. el.attr('position', polyline.shape.points[updatedDataInfo[i].ptIdx]);
  17601. }
  17602. });
  17603. }
  17604. },
  17605. remove: function (ecModel) {
  17606. var group = this.group;
  17607. var oldData = this._data;
  17608. this._lineGroup.removeAll();
  17609. this._symbolDraw.remove(true);
  17610. // Remove temporary created elements when highlighting
  17611. oldData && oldData.eachItemGraphicEl(function (el, idx) {
  17612. if (el.__temp) {
  17613. group.remove(el);
  17614. oldData.setItemGraphicEl(idx, null);
  17615. }
  17616. });
  17617. this._polyline =
  17618. this._polygon =
  17619. this._coordSys =
  17620. this._points =
  17621. this._stackedOnPoints =
  17622. this._data = null;
  17623. }
  17624. });
  17625. /***/ },
  17626. /* 99 */
  17627. /***/ function(module, exports, __webpack_require__) {
  17628. /**
  17629. * @module echarts/chart/helper/SymbolDraw
  17630. */
  17631. var graphic = __webpack_require__(42);
  17632. var Symbol = __webpack_require__(100);
  17633. /**
  17634. * @constructor
  17635. * @alias module:echarts/chart/helper/SymbolDraw
  17636. * @param {module:zrender/graphic/Group} [symbolCtor]
  17637. */
  17638. function SymbolDraw(symbolCtor) {
  17639. this.group = new graphic.Group();
  17640. this._symbolCtor = symbolCtor || Symbol;
  17641. }
  17642. var symbolDrawProto = SymbolDraw.prototype;
  17643. function symbolNeedsDraw(data, idx, isIgnore) {
  17644. var point = data.getItemLayout(idx);
  17645. return point && !isNaN(point[0]) && !isNaN(point[1]) && !(isIgnore && isIgnore(idx))
  17646. && data.getItemVisual(idx, 'symbol') !== 'none';
  17647. }
  17648. /**
  17649. * Update symbols draw by new data
  17650. * @param {module:echarts/data/List} data
  17651. * @param {Array.<boolean>} [isIgnore]
  17652. */
  17653. symbolDrawProto.updateData = function (data, isIgnore) {
  17654. var group = this.group;
  17655. var seriesModel = data.hostModel;
  17656. var oldData = this._data;
  17657. var SymbolCtor = this._symbolCtor;
  17658. data.diff(oldData)
  17659. .add(function (newIdx) {
  17660. var point = data.getItemLayout(newIdx);
  17661. if (symbolNeedsDraw(data, newIdx, isIgnore)) {
  17662. var symbolEl = new SymbolCtor(data, newIdx);
  17663. symbolEl.attr('position', point);
  17664. data.setItemGraphicEl(newIdx, symbolEl);
  17665. group.add(symbolEl);
  17666. }
  17667. })
  17668. .update(function (newIdx, oldIdx) {
  17669. var symbolEl = oldData.getItemGraphicEl(oldIdx);
  17670. var point = data.getItemLayout(newIdx);
  17671. if (!symbolNeedsDraw(data, newIdx, isIgnore)) {
  17672. group.remove(symbolEl);
  17673. return;
  17674. }
  17675. if (!symbolEl) {
  17676. symbolEl = new SymbolCtor(data, newIdx);
  17677. symbolEl.attr('position', point);
  17678. }
  17679. else {
  17680. symbolEl.updateData(data, newIdx);
  17681. graphic.updateProps(symbolEl, {
  17682. position: point
  17683. }, seriesModel);
  17684. }
  17685. // Add back
  17686. group.add(symbolEl);
  17687. data.setItemGraphicEl(newIdx, symbolEl);
  17688. })
  17689. .remove(function (oldIdx) {
  17690. var el = oldData.getItemGraphicEl(oldIdx);
  17691. el && el.fadeOut(function () {
  17692. group.remove(el);
  17693. });
  17694. })
  17695. .execute();
  17696. this._data = data;
  17697. };
  17698. symbolDrawProto.updateLayout = function () {
  17699. var data = this._data;
  17700. if (data) {
  17701. // Not use animation
  17702. data.eachItemGraphicEl(function (el, idx) {
  17703. el.attr('position', data.getItemLayout(idx));
  17704. });
  17705. }
  17706. };
  17707. symbolDrawProto.remove = function (enableAnimation) {
  17708. var group = this.group;
  17709. var data = this._data;
  17710. if (data) {
  17711. if (enableAnimation) {
  17712. data.eachItemGraphicEl(function (el) {
  17713. el.fadeOut(function () {
  17714. group.remove(el);
  17715. });
  17716. });
  17717. }
  17718. else {
  17719. group.removeAll();
  17720. }
  17721. }
  17722. };
  17723. module.exports = SymbolDraw;
  17724. /***/ },
  17725. /* 100 */
  17726. /***/ function(module, exports, __webpack_require__) {
  17727. /**
  17728. * @module echarts/chart/helper/Symbol
  17729. */
  17730. var zrUtil = __webpack_require__(3);
  17731. var symbolUtil = __webpack_require__(101);
  17732. var graphic = __webpack_require__(42);
  17733. var numberUtil = __webpack_require__(7);
  17734. function normalizeSymbolSize(symbolSize) {
  17735. if (!zrUtil.isArray(symbolSize)) {
  17736. symbolSize = [+symbolSize, +symbolSize];
  17737. }
  17738. return symbolSize;
  17739. }
  17740. /**
  17741. * @constructor
  17742. * @alias {module:echarts/chart/helper/Symbol}
  17743. * @param {module:echarts/data/List} data
  17744. * @param {number} idx
  17745. * @extends {module:zrender/graphic/Group}
  17746. */
  17747. function Symbol(data, idx) {
  17748. graphic.Group.call(this);
  17749. this.updateData(data, idx);
  17750. }
  17751. var symbolProto = Symbol.prototype;
  17752. function driftSymbol(dx, dy) {
  17753. this.parent.drift(dx, dy);
  17754. }
  17755. symbolProto._createSymbol = function (symbolType, data, idx) {
  17756. // Remove paths created before
  17757. this.removeAll();
  17758. var seriesModel = data.hostModel;
  17759. var color = data.getItemVisual(idx, 'color');
  17760. var symbolPath = symbolUtil.createSymbol(
  17761. symbolType, -0.5, -0.5, 1, 1, color
  17762. );
  17763. symbolPath.attr({
  17764. z2: 100,
  17765. culling: true,
  17766. scale: [0, 0]
  17767. });
  17768. // Rewrite drift method
  17769. symbolPath.drift = driftSymbol;
  17770. var size = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'));
  17771. graphic.initProps(symbolPath, {
  17772. scale: size
  17773. }, seriesModel, idx);
  17774. this._symbolType = symbolType;
  17775. this.add(symbolPath);
  17776. };
  17777. /**
  17778. * Stop animation
  17779. * @param {boolean} toLastFrame
  17780. */
  17781. symbolProto.stopSymbolAnimation = function (toLastFrame) {
  17782. this.childAt(0).stopAnimation(toLastFrame);
  17783. };
  17784. /**
  17785. * Get scale(aka, current symbol size).
  17786. * Including the change caused by animation
  17787. */
  17788. symbolProto.getScale = function () {
  17789. return this.childAt(0).scale;
  17790. };
  17791. /**
  17792. * Highlight symbol
  17793. */
  17794. symbolProto.highlight = function () {
  17795. this.childAt(0).trigger('emphasis');
  17796. };
  17797. /**
  17798. * Downplay symbol
  17799. */
  17800. symbolProto.downplay = function () {
  17801. this.childAt(0).trigger('normal');
  17802. };
  17803. /**
  17804. * @param {number} zlevel
  17805. * @param {number} z
  17806. */
  17807. symbolProto.setZ = function (zlevel, z) {
  17808. var symbolPath = this.childAt(0);
  17809. symbolPath.zlevel = zlevel;
  17810. symbolPath.z = z;
  17811. };
  17812. symbolProto.setDraggable = function (draggable) {
  17813. var symbolPath = this.childAt(0);
  17814. symbolPath.draggable = draggable;
  17815. symbolPath.cursor = draggable ? 'move' : 'pointer';
  17816. };
  17817. /**
  17818. * Update symbol properties
  17819. * @param {module:echarts/data/List} data
  17820. * @param {number} idx
  17821. */
  17822. symbolProto.updateData = function (data, idx) {
  17823. var symbolType = data.getItemVisual(idx, 'symbol') || 'circle';
  17824. var seriesModel = data.hostModel;
  17825. var symbolSize = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'));
  17826. if (symbolType !== this._symbolType) {
  17827. this._createSymbol(symbolType, data, idx);
  17828. }
  17829. else {
  17830. var symbolPath = this.childAt(0);
  17831. graphic.updateProps(symbolPath, {
  17832. scale: symbolSize
  17833. }, seriesModel, idx);
  17834. }
  17835. this._updateCommon(data, idx, symbolSize);
  17836. this._seriesModel = seriesModel;
  17837. };
  17838. // Update common properties
  17839. var normalStyleAccessPath = ['itemStyle', 'normal'];
  17840. var emphasisStyleAccessPath = ['itemStyle', 'emphasis'];
  17841. var normalLabelAccessPath = ['label', 'normal'];
  17842. var emphasisLabelAccessPath = ['label', 'emphasis'];
  17843. symbolProto._updateCommon = function (data, idx, symbolSize) {
  17844. var symbolPath = this.childAt(0);
  17845. var seriesModel = data.hostModel;
  17846. var itemModel = data.getItemModel(idx);
  17847. var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath);
  17848. var color = data.getItemVisual(idx, 'color');
  17849. // Reset style
  17850. if (symbolPath.type !== 'image') {
  17851. symbolPath.useStyle({
  17852. strokeNoScale: true
  17853. });
  17854. }
  17855. var elStyle = symbolPath.style;
  17856. var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle();
  17857. symbolPath.rotation = (itemModel.getShallow('symbolRotate') || 0) * Math.PI / 180 || 0;
  17858. var symbolOffset = itemModel.getShallow('symbolOffset');
  17859. if (symbolOffset) {
  17860. var pos = symbolPath.position;
  17861. pos[0] = numberUtil.parsePercent(symbolOffset[0], symbolSize[0]);
  17862. pos[1] = numberUtil.parsePercent(symbolOffset[1], symbolSize[1]);
  17863. }
  17864. symbolPath.setColor(color);
  17865. zrUtil.extend(
  17866. elStyle,
  17867. // Color must be excluded.
  17868. // Because symbol provide setColor individually to set fill and stroke
  17869. normalItemStyleModel.getItemStyle(['color'])
  17870. );
  17871. var opacity = data.getItemVisual(idx, 'opacity');
  17872. if (opacity != null) {
  17873. elStyle.opacity = opacity;
  17874. }
  17875. var labelModel = itemModel.getModel(normalLabelAccessPath);
  17876. var hoverLabelModel = itemModel.getModel(emphasisLabelAccessPath);
  17877. // Get last value dim
  17878. var dimensions = data.dimensions.slice();
  17879. var valueDim;
  17880. var dataType;
  17881. while (dimensions.length && (
  17882. valueDim = dimensions.pop(),
  17883. dataType = data.getDimensionInfo(valueDim).type,
  17884. dataType === 'ordinal' || dataType === 'time'
  17885. )) {} // jshint ignore:line
  17886. if (valueDim != null && labelModel.get('show')) {
  17887. graphic.setText(elStyle, labelModel, color);
  17888. elStyle.text = zrUtil.retrieve(
  17889. seriesModel.getFormattedLabel(idx, 'normal'),
  17890. data.get(valueDim, idx)
  17891. );
  17892. }
  17893. else {
  17894. elStyle.text = '';
  17895. }
  17896. if (valueDim != null && hoverLabelModel.getShallow('show')) {
  17897. graphic.setText(hoverStyle, hoverLabelModel, color);
  17898. hoverStyle.text = zrUtil.retrieve(
  17899. seriesModel.getFormattedLabel(idx, 'emphasis'),
  17900. data.get(valueDim, idx)
  17901. );
  17902. }
  17903. else {
  17904. hoverStyle.text = '';
  17905. }
  17906. var size = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'));
  17907. symbolPath.off('mouseover')
  17908. .off('mouseout')
  17909. .off('emphasis')
  17910. .off('normal');
  17911. graphic.setHoverStyle(symbolPath, hoverStyle);
  17912. if (itemModel.getShallow('hoverAnimation')) {
  17913. var onEmphasis = function() {
  17914. var ratio = size[1] / size[0];
  17915. this.animateTo({
  17916. scale: [
  17917. Math.max(size[0] * 1.1, size[0] + 3),
  17918. Math.max(size[1] * 1.1, size[1] + 3 * ratio)
  17919. ]
  17920. }, 400, 'elasticOut');
  17921. };
  17922. var onNormal = function() {
  17923. this.animateTo({
  17924. scale: size
  17925. }, 400, 'elasticOut');
  17926. };
  17927. symbolPath.on('mouseover', onEmphasis)
  17928. .on('mouseout', onNormal)
  17929. .on('emphasis', onEmphasis)
  17930. .on('normal', onNormal);
  17931. }
  17932. };
  17933. symbolProto.fadeOut = function (cb) {
  17934. var symbolPath = this.childAt(0);
  17935. // Avoid trigger hoverAnimation when fading
  17936. symbolPath.off('mouseover')
  17937. .off('mouseout')
  17938. .off('emphasis')
  17939. .off('normal');
  17940. // Not show text when animating
  17941. symbolPath.style.text = '';
  17942. graphic.updateProps(symbolPath, {
  17943. scale: [0, 0]
  17944. }, this._seriesModel, this.dataIndex, cb);
  17945. };
  17946. zrUtil.inherits(Symbol, graphic.Group);
  17947. module.exports = Symbol;
  17948. /***/ },
  17949. /* 101 */
  17950. /***/ function(module, exports, __webpack_require__) {
  17951. 'use strict';
  17952. // Symbol factory
  17953. var graphic = __webpack_require__(42);
  17954. var BoundingRect = __webpack_require__(15);
  17955. /**
  17956. * Triangle shape
  17957. * @inner
  17958. */
  17959. var Triangle = graphic.extendShape({
  17960. type: 'triangle',
  17961. shape: {
  17962. cx: 0,
  17963. cy: 0,
  17964. width: 0,
  17965. height: 0
  17966. },
  17967. buildPath: function (path, shape) {
  17968. var cx = shape.cx;
  17969. var cy = shape.cy;
  17970. var width = shape.width / 2;
  17971. var height = shape.height / 2;
  17972. path.moveTo(cx, cy - height);
  17973. path.lineTo(cx + width, cy + height);
  17974. path.lineTo(cx - width, cy + height);
  17975. path.closePath();
  17976. }
  17977. });
  17978. /**
  17979. * Diamond shape
  17980. * @inner
  17981. */
  17982. var Diamond = graphic.extendShape({
  17983. type: 'diamond',
  17984. shape: {
  17985. cx: 0,
  17986. cy: 0,
  17987. width: 0,
  17988. height: 0
  17989. },
  17990. buildPath: function (path, shape) {
  17991. var cx = shape.cx;
  17992. var cy = shape.cy;
  17993. var width = shape.width / 2;
  17994. var height = shape.height / 2;
  17995. path.moveTo(cx, cy - height);
  17996. path.lineTo(cx + width, cy);
  17997. path.lineTo(cx, cy + height);
  17998. path.lineTo(cx - width, cy);
  17999. path.closePath();
  18000. }
  18001. });
  18002. /**
  18003. * Pin shape
  18004. * @inner
  18005. */
  18006. var Pin = graphic.extendShape({
  18007. type: 'pin',
  18008. shape: {
  18009. // x, y on the cusp
  18010. x: 0,
  18011. y: 0,
  18012. width: 0,
  18013. height: 0
  18014. },
  18015. buildPath: function (path, shape) {
  18016. var x = shape.x;
  18017. var y = shape.y;
  18018. var w = shape.width / 5 * 3;
  18019. // Height must be larger than width
  18020. var h = Math.max(w, shape.height);
  18021. var r = w / 2;
  18022. // Dist on y with tangent point and circle center
  18023. var dy = r * r / (h - r);
  18024. var cy = y - h + r + dy;
  18025. var angle = Math.asin(dy / r);
  18026. // Dist on x with tangent point and circle center
  18027. var dx = Math.cos(angle) * r;
  18028. var tanX = Math.sin(angle);
  18029. var tanY = Math.cos(angle);
  18030. path.arc(
  18031. x, cy, r,
  18032. Math.PI - angle,
  18033. Math.PI * 2 + angle
  18034. );
  18035. var cpLen = r * 0.6;
  18036. var cpLen2 = r * 0.7;
  18037. path.bezierCurveTo(
  18038. x + dx - tanX * cpLen, cy + dy + tanY * cpLen,
  18039. x, y - cpLen2,
  18040. x, y
  18041. );
  18042. path.bezierCurveTo(
  18043. x, y - cpLen2,
  18044. x - dx + tanX * cpLen, cy + dy + tanY * cpLen,
  18045. x - dx, cy + dy
  18046. );
  18047. path.closePath();
  18048. }
  18049. });
  18050. /**
  18051. * Arrow shape
  18052. * @inner
  18053. */
  18054. var Arrow = graphic.extendShape({
  18055. type: 'arrow',
  18056. shape: {
  18057. x: 0,
  18058. y: 0,
  18059. width: 0,
  18060. height: 0
  18061. },
  18062. buildPath: function (ctx, shape) {
  18063. var height = shape.height;
  18064. var width = shape.width;
  18065. var x = shape.x;
  18066. var y = shape.y;
  18067. var dx = width / 3 * 2;
  18068. ctx.moveTo(x, y);
  18069. ctx.lineTo(x + dx, y + height);
  18070. ctx.lineTo(x, y + height / 4 * 3);
  18071. ctx.lineTo(x - dx, y + height);
  18072. ctx.lineTo(x, y);
  18073. ctx.closePath();
  18074. }
  18075. });
  18076. /**
  18077. * Map of path contructors
  18078. * @type {Object.<string, module:zrender/graphic/Path>}
  18079. */
  18080. var symbolCtors = {
  18081. line: graphic.Line,
  18082. rect: graphic.Rect,
  18083. roundRect: graphic.Rect,
  18084. square: graphic.Rect,
  18085. circle: graphic.Circle,
  18086. diamond: Diamond,
  18087. pin: Pin,
  18088. arrow: Arrow,
  18089. triangle: Triangle
  18090. };
  18091. var symbolShapeMakers = {
  18092. line: function (x, y, w, h, shape) {
  18093. // FIXME
  18094. shape.x1 = x;
  18095. shape.y1 = y + h / 2;
  18096. shape.x2 = x + w;
  18097. shape.y2 = y + h / 2;
  18098. },
  18099. rect: function (x, y, w, h, shape) {
  18100. shape.x = x;
  18101. shape.y = y;
  18102. shape.width = w;
  18103. shape.height = h;
  18104. },
  18105. roundRect: function (x, y, w, h, shape) {
  18106. shape.x = x;
  18107. shape.y = y;
  18108. shape.width = w;
  18109. shape.height = h;
  18110. shape.r = Math.min(w, h) / 4;
  18111. },
  18112. square: function (x, y, w, h, shape) {
  18113. var size = Math.min(w, h);
  18114. shape.x = x;
  18115. shape.y = y;
  18116. shape.width = size;
  18117. shape.height = size;
  18118. },
  18119. circle: function (x, y, w, h, shape) {
  18120. // Put circle in the center of square
  18121. shape.cx = x + w / 2;
  18122. shape.cy = y + h / 2;
  18123. shape.r = Math.min(w, h) / 2;
  18124. },
  18125. diamond: function (x, y, w, h, shape) {
  18126. shape.cx = x + w / 2;
  18127. shape.cy = y + h / 2;
  18128. shape.width = w;
  18129. shape.height = h;
  18130. },
  18131. pin: function (x, y, w, h, shape) {
  18132. shape.x = x + w / 2;
  18133. shape.y = y + h / 2;
  18134. shape.width = w;
  18135. shape.height = h;
  18136. },
  18137. arrow: function (x, y, w, h, shape) {
  18138. shape.x = x + w / 2;
  18139. shape.y = y + h / 2;
  18140. shape.width = w;
  18141. shape.height = h;
  18142. },
  18143. triangle: function (x, y, w, h, shape) {
  18144. shape.cx = x + w / 2;
  18145. shape.cy = y + h / 2;
  18146. shape.width = w;
  18147. shape.height = h;
  18148. }
  18149. };
  18150. var symbolBuildProxies = {};
  18151. for (var name in symbolCtors) {
  18152. symbolBuildProxies[name] = new symbolCtors[name]();
  18153. }
  18154. var Symbol = graphic.extendShape({
  18155. type: 'symbol',
  18156. shape: {
  18157. symbolType: '',
  18158. x: 0,
  18159. y: 0,
  18160. width: 0,
  18161. height: 0
  18162. },
  18163. beforeBrush: function () {
  18164. var style = this.style;
  18165. var shape = this.shape;
  18166. // FIXME
  18167. if (shape.symbolType === 'pin' && style.textPosition === 'inside') {
  18168. style.textPosition = ['50%', '40%'];
  18169. style.textAlign = 'center';
  18170. style.textVerticalAlign = 'middle';
  18171. }
  18172. },
  18173. buildPath: function (ctx, shape) {
  18174. var symbolType = shape.symbolType;
  18175. var proxySymbol = symbolBuildProxies[symbolType];
  18176. if (shape.symbolType !== 'none') {
  18177. if (!proxySymbol) {
  18178. // Default rect
  18179. symbolType = 'rect';
  18180. proxySymbol = symbolBuildProxies[symbolType];
  18181. }
  18182. symbolShapeMakers[symbolType](
  18183. shape.x, shape.y, shape.width, shape.height, proxySymbol.shape
  18184. );
  18185. proxySymbol.buildPath(ctx, proxySymbol.shape);
  18186. }
  18187. }
  18188. });
  18189. // Provide setColor helper method to avoid determine if set the fill or stroke outside
  18190. var symbolPathSetColor = function (color) {
  18191. if (this.type !== 'image') {
  18192. var symbolStyle = this.style;
  18193. var symbolShape = this.shape;
  18194. if (symbolShape && symbolShape.symbolType === 'line') {
  18195. symbolStyle.stroke = color;
  18196. }
  18197. else if (this.__isEmptyBrush) {
  18198. symbolStyle.stroke = color;
  18199. symbolStyle.fill = '#fff';
  18200. }
  18201. else {
  18202. // FIXME 判断图形默认是填充还是描边,使用 onlyStroke ?
  18203. symbolStyle.fill && (symbolStyle.fill = color);
  18204. symbolStyle.stroke && (symbolStyle.stroke = color);
  18205. }
  18206. this.dirty();
  18207. }
  18208. };
  18209. var symbolUtil = {
  18210. /**
  18211. * Create a symbol element with given symbol configuration: shape, x, y, width, height, color
  18212. * @param {string} symbolType
  18213. * @param {number} x
  18214. * @param {number} y
  18215. * @param {number} w
  18216. * @param {number} h
  18217. * @param {string} color
  18218. */
  18219. createSymbol: function (symbolType, x, y, w, h, color) {
  18220. var isEmpty = symbolType.indexOf('empty') === 0;
  18221. if (isEmpty) {
  18222. symbolType = symbolType.substr(5, 1).toLowerCase() + symbolType.substr(6);
  18223. }
  18224. var symbolPath;
  18225. if (symbolType.indexOf('image://') === 0) {
  18226. symbolPath = new graphic.Image({
  18227. style: {
  18228. image: symbolType.slice(8),
  18229. x: x,
  18230. y: y,
  18231. width: w,
  18232. height: h
  18233. }
  18234. });
  18235. }
  18236. else if (symbolType.indexOf('path://') === 0) {
  18237. symbolPath = graphic.makePath(symbolType.slice(7), {}, new BoundingRect(x, y, w, h));
  18238. }
  18239. else {
  18240. symbolPath = new Symbol({
  18241. shape: {
  18242. symbolType: symbolType,
  18243. x: x,
  18244. y: y,
  18245. width: w,
  18246. height: h
  18247. }
  18248. });
  18249. }
  18250. symbolPath.__isEmptyBrush = isEmpty;
  18251. symbolPath.setColor = symbolPathSetColor;
  18252. symbolPath.setColor(color);
  18253. return symbolPath;
  18254. }
  18255. };
  18256. module.exports = symbolUtil;
  18257. /***/ },
  18258. /* 102 */
  18259. /***/ function(module, exports) {
  18260. // var arrayDiff = require('zrender/lib/core/arrayDiff');
  18261. // 'zrender/core/arrayDiff' has been used before, but it did
  18262. // not do well in performance when roam with fixed dataZoom window.
  18263. function sign(val) {
  18264. return val >= 0 ? 1 : -1;
  18265. }
  18266. function getStackedOnPoint(coordSys, data, idx) {
  18267. var baseAxis = coordSys.getBaseAxis();
  18268. var valueAxis = coordSys.getOtherAxis(baseAxis);
  18269. var valueStart = baseAxis.onZero
  18270. ? 0 : valueAxis.scale.getExtent()[0];
  18271. var valueDim = valueAxis.dim;
  18272. var baseDataOffset = valueDim === 'x' || valueDim === 'radius' ? 1 : 0;
  18273. var stackedOnSameSign;
  18274. var stackedOn = data.stackedOn;
  18275. var val = data.get(valueDim, idx);
  18276. // Find first stacked value with same sign
  18277. while (stackedOn &&
  18278. sign(stackedOn.get(valueDim, idx)) === sign(val)
  18279. ) {
  18280. stackedOnSameSign = stackedOn;
  18281. break;
  18282. }
  18283. var stackedData = [];
  18284. stackedData[baseDataOffset] = data.get(baseAxis.dim, idx);
  18285. stackedData[1 - baseDataOffset] = stackedOnSameSign
  18286. ? stackedOnSameSign.get(valueDim, idx, true) : valueStart;
  18287. return coordSys.dataToPoint(stackedData);
  18288. }
  18289. // function convertToIntId(newIdList, oldIdList) {
  18290. // // Generate int id instead of string id.
  18291. // // Compare string maybe slow in score function of arrDiff
  18292. // // Assume id in idList are all unique
  18293. // var idIndicesMap = {};
  18294. // var idx = 0;
  18295. // for (var i = 0; i < newIdList.length; i++) {
  18296. // idIndicesMap[newIdList[i]] = idx;
  18297. // newIdList[i] = idx++;
  18298. // }
  18299. // for (var i = 0; i < oldIdList.length; i++) {
  18300. // var oldId = oldIdList[i];
  18301. // // Same with newIdList
  18302. // if (idIndicesMap[oldId]) {
  18303. // oldIdList[i] = idIndicesMap[oldId];
  18304. // }
  18305. // else {
  18306. // oldIdList[i] = idx++;
  18307. // }
  18308. // }
  18309. // }
  18310. function diffData(oldData, newData) {
  18311. var diffResult = [];
  18312. newData.diff(oldData)
  18313. .add(function (idx) {
  18314. diffResult.push({cmd: '+', idx: idx});
  18315. })
  18316. .update(function (newIdx, oldIdx) {
  18317. diffResult.push({cmd: '=', idx: oldIdx, idx1: newIdx});
  18318. })
  18319. .remove(function (idx) {
  18320. diffResult.push({cmd: '-', idx: idx});
  18321. })
  18322. .execute();
  18323. return diffResult;
  18324. }
  18325. module.exports = function (
  18326. oldData, newData,
  18327. oldStackedOnPoints, newStackedOnPoints,
  18328. oldCoordSys, newCoordSys
  18329. ) {
  18330. var diff = diffData(oldData, newData);
  18331. // var newIdList = newData.mapArray(newData.getId);
  18332. // var oldIdList = oldData.mapArray(oldData.getId);
  18333. // convertToIntId(newIdList, oldIdList);
  18334. // // FIXME One data ?
  18335. // diff = arrayDiff(oldIdList, newIdList);
  18336. var currPoints = [];
  18337. var nextPoints = [];
  18338. // Points for stacking base line
  18339. var currStackedPoints = [];
  18340. var nextStackedPoints = [];
  18341. var status = [];
  18342. var sortedIndices = [];
  18343. var rawIndices = [];
  18344. var dims = newCoordSys.dimensions;
  18345. for (var i = 0; i < diff.length; i++) {
  18346. var diffItem = diff[i];
  18347. var pointAdded = true;
  18348. // FIXME, animation is not so perfect when dataZoom window moves fast
  18349. // Which is in case remvoing or add more than one data in the tail or head
  18350. switch (diffItem.cmd) {
  18351. case '=':
  18352. var currentPt = oldData.getItemLayout(diffItem.idx);
  18353. var nextPt = newData.getItemLayout(diffItem.idx1);
  18354. // If previous data is NaN, use next point directly
  18355. if (isNaN(currentPt[0]) || isNaN(currentPt[1])) {
  18356. currentPt = nextPt.slice();
  18357. }
  18358. currPoints.push(currentPt);
  18359. nextPoints.push(nextPt);
  18360. currStackedPoints.push(oldStackedOnPoints[diffItem.idx]);
  18361. nextStackedPoints.push(newStackedOnPoints[diffItem.idx1]);
  18362. rawIndices.push(newData.getRawIndex(diffItem.idx1));
  18363. break;
  18364. case '+':
  18365. var idx = diffItem.idx;
  18366. currPoints.push(
  18367. oldCoordSys.dataToPoint([
  18368. newData.get(dims[0], idx, true), newData.get(dims[1], idx, true)
  18369. ])
  18370. );
  18371. nextPoints.push(newData.getItemLayout(idx).slice());
  18372. currStackedPoints.push(
  18373. getStackedOnPoint(oldCoordSys, newData, idx)
  18374. );
  18375. nextStackedPoints.push(newStackedOnPoints[idx]);
  18376. rawIndices.push(newData.getRawIndex(idx));
  18377. break;
  18378. case '-':
  18379. var idx = diffItem.idx;
  18380. var rawIndex = oldData.getRawIndex(idx);
  18381. // Data is replaced. In the case of dynamic data queue
  18382. // FIXME FIXME FIXME
  18383. if (rawIndex !== idx) {
  18384. currPoints.push(oldData.getItemLayout(idx));
  18385. nextPoints.push(newCoordSys.dataToPoint([
  18386. oldData.get(dims[0], idx, true), oldData.get(dims[1], idx, true)
  18387. ]));
  18388. currStackedPoints.push(oldStackedOnPoints[idx]);
  18389. nextStackedPoints.push(
  18390. getStackedOnPoint(
  18391. newCoordSys, oldData, idx
  18392. )
  18393. );
  18394. rawIndices.push(rawIndex);
  18395. }
  18396. else {
  18397. pointAdded = false;
  18398. }
  18399. }
  18400. // Original indices
  18401. if (pointAdded) {
  18402. status.push(diffItem);
  18403. sortedIndices.push(sortedIndices.length);
  18404. }
  18405. }
  18406. // Diff result may be crossed if all items are changed
  18407. // Sort by data index
  18408. sortedIndices.sort(function (a, b) {
  18409. return rawIndices[a] - rawIndices[b];
  18410. });
  18411. var sortedCurrPoints = [];
  18412. var sortedNextPoints = [];
  18413. var sortedCurrStackedPoints = [];
  18414. var sortedNextStackedPoints = [];
  18415. var sortedStatus = [];
  18416. for (var i = 0; i < sortedIndices.length; i++) {
  18417. var idx = sortedIndices[i];
  18418. sortedCurrPoints[i] = currPoints[idx];
  18419. sortedNextPoints[i] = nextPoints[idx];
  18420. sortedCurrStackedPoints[i] = currStackedPoints[idx];
  18421. sortedNextStackedPoints[i] = nextStackedPoints[idx];
  18422. sortedStatus[i] = status[idx];
  18423. }
  18424. return {
  18425. current: sortedCurrPoints,
  18426. next: sortedNextPoints,
  18427. stackedOnCurrent: sortedCurrStackedPoints,
  18428. stackedOnNext: sortedNextStackedPoints,
  18429. status: sortedStatus
  18430. };
  18431. };
  18432. /***/ },
  18433. /* 103 */
  18434. /***/ function(module, exports, __webpack_require__) {
  18435. // Poly path support NaN point
  18436. var Path = __webpack_require__(44);
  18437. var vec2 = __webpack_require__(16);
  18438. var vec2Min = vec2.min;
  18439. var vec2Max = vec2.max;
  18440. var scaleAndAdd = vec2.scaleAndAdd;
  18441. var v2Copy = vec2.copy;
  18442. // Temporary variable
  18443. var v = [];
  18444. var cp0 = [];
  18445. var cp1 = [];
  18446. function isPointNull(p) {
  18447. return isNaN(p[0]) || isNaN(p[1]);
  18448. }
  18449. function drawSegment(
  18450. ctx, points, start, segLen, allLen,
  18451. dir, smoothMin, smoothMax, smooth, smoothMonotone, connectNulls
  18452. ) {
  18453. var prevIdx = 0;
  18454. var idx = start;
  18455. for (var k = 0; k < segLen; k++) {
  18456. var p = points[idx];
  18457. if (idx >= allLen || idx < 0) {
  18458. break;
  18459. }
  18460. if (isPointNull(p)) {
  18461. if (connectNulls) {
  18462. idx += dir;
  18463. continue;
  18464. }
  18465. break;
  18466. }
  18467. if (idx === start) {
  18468. ctx[dir > 0 ? 'moveTo' : 'lineTo'](p[0], p[1]);
  18469. v2Copy(cp0, p);
  18470. }
  18471. else {
  18472. if (smooth > 0) {
  18473. var nextIdx = idx + dir;
  18474. var nextP = points[nextIdx];
  18475. if (connectNulls) {
  18476. // Find next point not null
  18477. while (nextP && isPointNull(points[nextIdx])) {
  18478. nextIdx += dir;
  18479. nextP = points[nextIdx];
  18480. }
  18481. }
  18482. var ratioNextSeg = 0.5;
  18483. var prevP = points[prevIdx];
  18484. var nextP = points[nextIdx];
  18485. // Last point
  18486. if (!nextP || isPointNull(nextP)) {
  18487. v2Copy(cp1, p);
  18488. }
  18489. else {
  18490. // If next data is null in not connect case
  18491. if (isPointNull(nextP) && !connectNulls) {
  18492. nextP = p;
  18493. }
  18494. vec2.sub(v, nextP, prevP);
  18495. var lenPrevSeg;
  18496. var lenNextSeg;
  18497. if (smoothMonotone === 'x' || smoothMonotone === 'y') {
  18498. var dim = smoothMonotone === 'x' ? 0 : 1;
  18499. lenPrevSeg = Math.abs(p[dim] - prevP[dim]);
  18500. lenNextSeg = Math.abs(p[dim] - nextP[dim]);
  18501. }
  18502. else {
  18503. lenPrevSeg = vec2.dist(p, prevP);
  18504. lenNextSeg = vec2.dist(p, nextP);
  18505. }
  18506. // Use ratio of seg length
  18507. ratioNextSeg = lenNextSeg / (lenNextSeg + lenPrevSeg);
  18508. scaleAndAdd(cp1, p, v, -smooth * (1 - ratioNextSeg));
  18509. }
  18510. // Smooth constraint
  18511. vec2Min(cp0, cp0, smoothMax);
  18512. vec2Max(cp0, cp0, smoothMin);
  18513. vec2Min(cp1, cp1, smoothMax);
  18514. vec2Max(cp1, cp1, smoothMin);
  18515. ctx.bezierCurveTo(
  18516. cp0[0], cp0[1],
  18517. cp1[0], cp1[1],
  18518. p[0], p[1]
  18519. );
  18520. // cp0 of next segment
  18521. scaleAndAdd(cp0, p, v, smooth * ratioNextSeg);
  18522. }
  18523. else {
  18524. ctx.lineTo(p[0], p[1]);
  18525. }
  18526. }
  18527. prevIdx = idx;
  18528. idx += dir;
  18529. }
  18530. return k;
  18531. }
  18532. function getBoundingBox(points, smoothConstraint) {
  18533. var ptMin = [Infinity, Infinity];
  18534. var ptMax = [-Infinity, -Infinity];
  18535. if (smoothConstraint) {
  18536. for (var i = 0; i < points.length; i++) {
  18537. var pt = points[i];
  18538. if (pt[0] < ptMin[0]) { ptMin[0] = pt[0]; }
  18539. if (pt[1] < ptMin[1]) { ptMin[1] = pt[1]; }
  18540. if (pt[0] > ptMax[0]) { ptMax[0] = pt[0]; }
  18541. if (pt[1] > ptMax[1]) { ptMax[1] = pt[1]; }
  18542. }
  18543. }
  18544. return {
  18545. min: smoothConstraint ? ptMin : ptMax,
  18546. max: smoothConstraint ? ptMax : ptMin
  18547. };
  18548. }
  18549. module.exports = {
  18550. Polyline: Path.extend({
  18551. type: 'ec-polyline',
  18552. shape: {
  18553. points: [],
  18554. smooth: 0,
  18555. smoothConstraint: true,
  18556. smoothMonotone: null,
  18557. connectNulls: false
  18558. },
  18559. style: {
  18560. fill: null,
  18561. stroke: '#000'
  18562. },
  18563. buildPath: function (ctx, shape) {
  18564. var points = shape.points;
  18565. var i = 0;
  18566. var len = points.length;
  18567. var result = getBoundingBox(points, shape.smoothConstraint);
  18568. if (shape.connectNulls) {
  18569. // Must remove first and last null values avoid draw error in polygon
  18570. for (; len > 0; len--) {
  18571. if (!isPointNull(points[len - 1])) {
  18572. break;
  18573. }
  18574. }
  18575. for (; i < len; i++) {
  18576. if (!isPointNull(points[i])) {
  18577. break;
  18578. }
  18579. }
  18580. }
  18581. while (i < len) {
  18582. i += drawSegment(
  18583. ctx, points, i, len, len,
  18584. 1, result.min, result.max, shape.smooth,
  18585. shape.smoothMonotone, shape.connectNulls
  18586. ) + 1;
  18587. }
  18588. }
  18589. }),
  18590. Polygon: Path.extend({
  18591. type: 'ec-polygon',
  18592. shape: {
  18593. points: [],
  18594. // Offset between stacked base points and points
  18595. stackedOnPoints: [],
  18596. smooth: 0,
  18597. stackedOnSmooth: 0,
  18598. smoothConstraint: true,
  18599. smoothMonotone: null,
  18600. connectNulls: false
  18601. },
  18602. buildPath: function (ctx, shape) {
  18603. var points = shape.points;
  18604. var stackedOnPoints = shape.stackedOnPoints;
  18605. var i = 0;
  18606. var len = points.length;
  18607. var smoothMonotone = shape.smoothMonotone;
  18608. var bbox = getBoundingBox(points, shape.smoothConstraint);
  18609. var stackedOnBBox = getBoundingBox(stackedOnPoints, shape.smoothConstraint);
  18610. if (shape.connectNulls) {
  18611. // Must remove first and last null values avoid draw error in polygon
  18612. for (; len > 0; len--) {
  18613. if (!isPointNull(points[len - 1])) {
  18614. break;
  18615. }
  18616. }
  18617. for (; i < len; i++) {
  18618. if (!isPointNull(points[i])) {
  18619. break;
  18620. }
  18621. }
  18622. }
  18623. while (i < len) {
  18624. var k = drawSegment(
  18625. ctx, points, i, len, len,
  18626. 1, bbox.min, bbox.max, shape.smooth,
  18627. smoothMonotone, shape.connectNulls
  18628. );
  18629. drawSegment(
  18630. ctx, stackedOnPoints, i + k - 1, k, len,
  18631. -1, stackedOnBBox.min, stackedOnBBox.max, shape.stackedOnSmooth,
  18632. smoothMonotone, shape.connectNulls
  18633. );
  18634. i += k + 1;
  18635. ctx.closePath();
  18636. }
  18637. }
  18638. })
  18639. };
  18640. /***/ },
  18641. /* 104 */
  18642. /***/ function(module, exports) {
  18643. module.exports = function (seriesType, defaultSymbolType, legendSymbol, ecModel, api) {
  18644. // Encoding visual for all series include which is filtered for legend drawing
  18645. ecModel.eachRawSeriesByType(seriesType, function (seriesModel) {
  18646. var data = seriesModel.getData();
  18647. var symbolType = seriesModel.get('symbol') || defaultSymbolType;
  18648. var symbolSize = seriesModel.get('symbolSize');
  18649. data.setVisual({
  18650. legendSymbol: legendSymbol || symbolType,
  18651. symbol: symbolType,
  18652. symbolSize: symbolSize
  18653. });
  18654. // Only visible series has each data be visual encoded
  18655. if (!ecModel.isSeriesFiltered(seriesModel)) {
  18656. if (typeof symbolSize === 'function') {
  18657. data.each(function (idx) {
  18658. var rawValue = seriesModel.getRawValue(idx);
  18659. // FIXME
  18660. var params = seriesModel.getDataParams(idx);
  18661. data.setItemVisual(idx, 'symbolSize', symbolSize(rawValue, params));
  18662. });
  18663. }
  18664. data.each(function (idx) {
  18665. var itemModel = data.getItemModel(idx);
  18666. var itemSymbolType = itemModel.get('symbol', true);
  18667. var itemSymbolSize = itemModel.get('symbolSize', true);
  18668. // If has item symbol
  18669. if (itemSymbolType != null) {
  18670. data.setItemVisual(idx, 'symbol', itemSymbolType);
  18671. }
  18672. if (itemSymbolSize != null) {
  18673. // PENDING Transform symbolSize ?
  18674. data.setItemVisual(idx, 'symbolSize', itemSymbolSize);
  18675. }
  18676. });
  18677. }
  18678. });
  18679. };
  18680. /***/ },
  18681. /* 105 */
  18682. /***/ function(module, exports) {
  18683. module.exports = function (seriesType, ecModel, api) {
  18684. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  18685. var data = seriesModel.getData();
  18686. var coordSys = seriesModel.coordinateSystem;
  18687. if (coordSys) {
  18688. var dims = coordSys.dimensions;
  18689. data.each(dims, function (x, y, idx) {
  18690. var point;
  18691. if (!isNaN(x) && !isNaN(y)) {
  18692. point = coordSys.dataToPoint([x, y]);
  18693. }
  18694. else {
  18695. // Also {Array.<number>}, not undefined to avoid if...else... statement
  18696. point = [NaN, NaN];
  18697. }
  18698. data.setItemLayout(idx, point);
  18699. }, true);
  18700. }
  18701. });
  18702. };
  18703. /***/ },
  18704. /* 106 */
  18705. /***/ function(module, exports) {
  18706. var samplers = {
  18707. average: function (frame) {
  18708. var sum = 0;
  18709. var count = 0;
  18710. for (var i = 0; i < frame.length; i++) {
  18711. if (!isNaN(frame[i])) {
  18712. sum += frame[i];
  18713. count++;
  18714. }
  18715. }
  18716. // Return NaN if count is 0
  18717. return count === 0 ? NaN : sum / count;
  18718. },
  18719. sum: function (frame) {
  18720. var sum = 0;
  18721. for (var i = 0; i < frame.length; i++) {
  18722. // Ignore NaN
  18723. sum += frame[i] || 0;
  18724. }
  18725. return sum;
  18726. },
  18727. max: function (frame) {
  18728. var max = -Infinity;
  18729. for (var i = 0; i < frame.length; i++) {
  18730. frame[i] > max && (max = frame[i]);
  18731. }
  18732. return max;
  18733. },
  18734. min: function (frame) {
  18735. var min = Infinity;
  18736. for (var i = 0; i < frame.length; i++) {
  18737. frame[i] < min && (min = frame[i]);
  18738. }
  18739. return min;
  18740. },
  18741. // TODO
  18742. // Median
  18743. nearest: function (frame) {
  18744. return frame[0];
  18745. }
  18746. };
  18747. var indexSampler = function (frame, value) {
  18748. return Math.round(frame.length / 2);
  18749. };
  18750. module.exports = function (seriesType, ecModel, api) {
  18751. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  18752. var data = seriesModel.getData();
  18753. var sampling = seriesModel.get('sampling');
  18754. var coordSys = seriesModel.coordinateSystem;
  18755. // Only cartesian2d support down sampling
  18756. if (coordSys.type === 'cartesian2d' && sampling) {
  18757. var baseAxis = coordSys.getBaseAxis();
  18758. var valueAxis = coordSys.getOtherAxis(baseAxis);
  18759. var extent = baseAxis.getExtent();
  18760. // Coordinste system has been resized
  18761. var size = extent[1] - extent[0];
  18762. var rate = Math.round(data.count() / size);
  18763. if (rate > 1) {
  18764. var sampler;
  18765. if (typeof sampling === 'string') {
  18766. sampler = samplers[sampling];
  18767. }
  18768. else if (typeof sampling === 'function') {
  18769. sampler = sampling;
  18770. }
  18771. if (sampler) {
  18772. data = data.downSample(
  18773. valueAxis.dim, 1 / rate, sampler, indexSampler
  18774. );
  18775. seriesModel.setData(data);
  18776. }
  18777. }
  18778. }
  18779. }, this);
  18780. };
  18781. /***/ },
  18782. /* 107 */
  18783. /***/ function(module, exports, __webpack_require__) {
  18784. 'use strict';
  18785. var graphic = __webpack_require__(42);
  18786. var zrUtil = __webpack_require__(3);
  18787. __webpack_require__(108);
  18788. __webpack_require__(125);
  18789. // Grid view
  18790. __webpack_require__(1).extendComponentView({
  18791. type: 'grid',
  18792. render: function (gridModel, ecModel) {
  18793. this.group.removeAll();
  18794. if (gridModel.get('show')) {
  18795. this.group.add(new graphic.Rect({
  18796. shape:gridModel.coordinateSystem.getRect(),
  18797. style: zrUtil.defaults({
  18798. fill: gridModel.get('backgroundColor')
  18799. }, gridModel.getItemStyle()),
  18800. silent: true
  18801. }));
  18802. }
  18803. }
  18804. });
  18805. /***/ },
  18806. /* 108 */
  18807. /***/ function(module, exports, __webpack_require__) {
  18808. /**
  18809. * Grid is a region which contains at most 4 cartesian systems
  18810. *
  18811. * TODO Default cartesian
  18812. */
  18813. var factory = exports;
  18814. var layout = __webpack_require__(21);
  18815. var axisHelper = __webpack_require__(109);
  18816. var zrUtil = __webpack_require__(3);
  18817. var Cartesian2D = __webpack_require__(115);
  18818. var Axis2D = __webpack_require__(117);
  18819. var each = zrUtil.each;
  18820. var ifAxisCrossZero = axisHelper.ifAxisCrossZero;
  18821. var niceScaleExtent = axisHelper.niceScaleExtent;
  18822. // 依赖 GridModel, AxisModel 做预处理
  18823. __webpack_require__(120);
  18824. /**
  18825. * Check if the axis is used in the specified grid
  18826. * @inner
  18827. */
  18828. function isAxisUsedInTheGrid(axisModel, gridModel, ecModel) {
  18829. return ecModel.getComponent('grid', axisModel.get('gridIndex')) === gridModel;
  18830. }
  18831. function getLabelUnionRect(axis) {
  18832. var axisModel = axis.model;
  18833. var labels = axisModel.getFormattedLabels();
  18834. var rect;
  18835. var step = 1;
  18836. var labelCount = labels.length;
  18837. if (labelCount > 40) {
  18838. // Simple optimization for large amount of labels
  18839. step = Math.ceil(labelCount / 40);
  18840. }
  18841. for (var i = 0; i < labelCount; i += step) {
  18842. if (!axis.isLabelIgnored(i)) {
  18843. var singleRect = axisModel.getTextRect(labels[i]);
  18844. // FIXME consider label rotate
  18845. rect ? rect.union(singleRect) : (rect = singleRect);
  18846. }
  18847. }
  18848. return rect;
  18849. }
  18850. function Grid(gridModel, ecModel, api) {
  18851. /**
  18852. * @type {Object.<string, module:echarts/coord/cartesian/Cartesian2D>}
  18853. * @private
  18854. */
  18855. this._coordsMap = {};
  18856. /**
  18857. * @type {Array.<module:echarts/coord/cartesian/Cartesian>}
  18858. * @private
  18859. */
  18860. this._coordsList = [];
  18861. /**
  18862. * @type {Object.<string, module:echarts/coord/cartesian/Axis2D>}
  18863. * @private
  18864. */
  18865. this._axesMap = {};
  18866. /**
  18867. * @type {Array.<module:echarts/coord/cartesian/Axis2D>}
  18868. * @private
  18869. */
  18870. this._axesList = [];
  18871. this._initCartesian(gridModel, ecModel, api);
  18872. this._model = gridModel;
  18873. }
  18874. var gridProto = Grid.prototype;
  18875. gridProto.type = 'grid';
  18876. gridProto.getRect = function () {
  18877. return this._rect;
  18878. };
  18879. gridProto.update = function (ecModel, api) {
  18880. var axesMap = this._axesMap;
  18881. this._updateScale(ecModel, this._model);
  18882. function ifAxisCanNotOnZero(otherAxisDim) {
  18883. var axes = axesMap[otherAxisDim];
  18884. for (var idx in axes) {
  18885. var axis = axes[idx];
  18886. if (axis && (axis.type === 'category' || !ifAxisCrossZero(axis))) {
  18887. return true;
  18888. }
  18889. }
  18890. return false;
  18891. }
  18892. each(axesMap.x, function (xAxis) {
  18893. niceScaleExtent(xAxis, xAxis.model);
  18894. });
  18895. each(axesMap.y, function (yAxis) {
  18896. niceScaleExtent(yAxis, yAxis.model);
  18897. });
  18898. // Fix configuration
  18899. each(axesMap.x, function (xAxis) {
  18900. // onZero can not be enabled in these two situations
  18901. // 1. When any other axis is a category axis
  18902. // 2. When any other axis not across 0 point
  18903. if (ifAxisCanNotOnZero('y')) {
  18904. xAxis.onZero = false;
  18905. }
  18906. });
  18907. each(axesMap.y, function (yAxis) {
  18908. if (ifAxisCanNotOnZero('x')) {
  18909. yAxis.onZero = false;
  18910. }
  18911. });
  18912. // Resize again if containLabel is enabled
  18913. // FIXME It may cause getting wrong grid size in data processing stage
  18914. this.resize(this._model, api);
  18915. };
  18916. /**
  18917. * Resize the grid
  18918. * @param {module:echarts/coord/cartesian/GridModel} gridModel
  18919. * @param {module:echarts/ExtensionAPI} api
  18920. */
  18921. gridProto.resize = function (gridModel, api) {
  18922. var gridRect = layout.getLayoutRect(
  18923. gridModel.getBoxLayoutParams(), {
  18924. width: api.getWidth(),
  18925. height: api.getHeight()
  18926. });
  18927. this._rect = gridRect;
  18928. var axesList = this._axesList;
  18929. adjustAxes();
  18930. // Minus label size
  18931. if (gridModel.get('containLabel')) {
  18932. each(axesList, function (axis) {
  18933. if (!axis.model.get('axisLabel.inside')) {
  18934. var labelUnionRect = getLabelUnionRect(axis);
  18935. if (labelUnionRect) {
  18936. var dim = axis.isHorizontal() ? 'height' : 'width';
  18937. var margin = axis.model.get('axisLabel.margin');
  18938. gridRect[dim] -= labelUnionRect[dim] + margin;
  18939. if (axis.position === 'top') {
  18940. gridRect.y += labelUnionRect.height + margin;
  18941. }
  18942. else if (axis.position === 'left') {
  18943. gridRect.x += labelUnionRect.width + margin;
  18944. }
  18945. }
  18946. }
  18947. });
  18948. adjustAxes();
  18949. }
  18950. function adjustAxes() {
  18951. each(axesList, function (axis) {
  18952. var isHorizontal = axis.isHorizontal();
  18953. var extent = isHorizontal ? [0, gridRect.width] : [0, gridRect.height];
  18954. var idx = axis.inverse ? 1 : 0;
  18955. axis.setExtent(extent[idx], extent[1 - idx]);
  18956. updateAxisTransfrom(axis, isHorizontal ? gridRect.x : gridRect.y);
  18957. });
  18958. }
  18959. };
  18960. /**
  18961. * @param {string} axisType
  18962. * @param {ndumber} [axisIndex]
  18963. */
  18964. gridProto.getAxis = function (axisType, axisIndex) {
  18965. var axesMapOnDim = this._axesMap[axisType];
  18966. if (axesMapOnDim != null) {
  18967. if (axisIndex == null) {
  18968. // Find first axis
  18969. for (var name in axesMapOnDim) {
  18970. return axesMapOnDim[name];
  18971. }
  18972. }
  18973. return axesMapOnDim[axisIndex];
  18974. }
  18975. };
  18976. gridProto.getCartesian = function (xAxisIndex, yAxisIndex) {
  18977. var key = 'x' + xAxisIndex + 'y' + yAxisIndex;
  18978. return this._coordsMap[key];
  18979. };
  18980. /**
  18981. * Initialize cartesian coordinate systems
  18982. * @private
  18983. */
  18984. gridProto._initCartesian = function (gridModel, ecModel, api) {
  18985. var axisPositionUsed = {
  18986. left: false,
  18987. right: false,
  18988. top: false,
  18989. bottom: false
  18990. };
  18991. var axesMap = {
  18992. x: {},
  18993. y: {}
  18994. };
  18995. var axesCount = {
  18996. x: 0,
  18997. y: 0
  18998. };
  18999. /// Create axis
  19000. ecModel.eachComponent('xAxis', createAxisCreator('x'), this);
  19001. ecModel.eachComponent('yAxis', createAxisCreator('y'), this);
  19002. if (!axesCount.x || !axesCount.y) {
  19003. // Roll back when there no either x or y axis
  19004. this._axesMap = {};
  19005. this._axesList = [];
  19006. return;
  19007. }
  19008. this._axesMap = axesMap;
  19009. /// Create cartesian2d
  19010. each(axesMap.x, function (xAxis, xAxisIndex) {
  19011. each(axesMap.y, function (yAxis, yAxisIndex) {
  19012. var key = 'x' + xAxisIndex + 'y' + yAxisIndex;
  19013. var cartesian = new Cartesian2D(key);
  19014. cartesian.grid = this;
  19015. this._coordsMap[key] = cartesian;
  19016. this._coordsList.push(cartesian);
  19017. cartesian.addAxis(xAxis);
  19018. cartesian.addAxis(yAxis);
  19019. }, this);
  19020. }, this);
  19021. function createAxisCreator(axisType) {
  19022. return function (axisModel, idx) {
  19023. if (!isAxisUsedInTheGrid(axisModel, gridModel, ecModel)) {
  19024. return;
  19025. }
  19026. var axisPosition = axisModel.get('position');
  19027. if (axisType === 'x') {
  19028. // Fix position
  19029. if (axisPosition !== 'top' && axisPosition !== 'bottom') {
  19030. // Default bottom of X
  19031. axisPosition = 'bottom';
  19032. }
  19033. if (axisPositionUsed[axisPosition]) {
  19034. axisPosition = axisPosition === 'top' ? 'bottom' : 'top';
  19035. }
  19036. }
  19037. else {
  19038. // Fix position
  19039. if (axisPosition !== 'left' && axisPosition !== 'right') {
  19040. // Default left of Y
  19041. axisPosition = 'left';
  19042. }
  19043. if (axisPositionUsed[axisPosition]) {
  19044. axisPosition = axisPosition === 'left' ? 'right' : 'left';
  19045. }
  19046. }
  19047. axisPositionUsed[axisPosition] = true;
  19048. var axis = new Axis2D(
  19049. axisType, axisHelper.createScaleByModel(axisModel),
  19050. [0, 0],
  19051. axisModel.get('type'),
  19052. axisPosition
  19053. );
  19054. var isCategory = axis.type === 'category';
  19055. axis.onBand = isCategory && axisModel.get('boundaryGap');
  19056. axis.inverse = axisModel.get('inverse');
  19057. axis.onZero = axisModel.get('axisLine.onZero');
  19058. // Inject axis into axisModel
  19059. axisModel.axis = axis;
  19060. // Inject axisModel into axis
  19061. axis.model = axisModel;
  19062. // Index of axis, can be used as key
  19063. axis.index = idx;
  19064. this._axesList.push(axis);
  19065. axesMap[axisType][idx] = axis;
  19066. axesCount[axisType]++;
  19067. };
  19068. }
  19069. };
  19070. /**
  19071. * Update cartesian properties from series
  19072. * @param {module:echarts/model/Option} option
  19073. * @private
  19074. */
  19075. gridProto._updateScale = function (ecModel, gridModel) {
  19076. // Reset scale
  19077. zrUtil.each(this._axesList, function (axis) {
  19078. axis.scale.setExtent(Infinity, -Infinity);
  19079. });
  19080. ecModel.eachSeries(function (seriesModel) {
  19081. if (seriesModel.get('coordinateSystem') === 'cartesian2d') {
  19082. var xAxisIndex = seriesModel.get('xAxisIndex');
  19083. var yAxisIndex = seriesModel.get('yAxisIndex');
  19084. var xAxisModel = ecModel.getComponent('xAxis', xAxisIndex);
  19085. var yAxisModel = ecModel.getComponent('yAxis', yAxisIndex);
  19086. if (!isAxisUsedInTheGrid(xAxisModel, gridModel, ecModel)
  19087. || !isAxisUsedInTheGrid(yAxisModel, gridModel, ecModel)
  19088. ) {
  19089. return;
  19090. }
  19091. var cartesian = this.getCartesian(xAxisIndex, yAxisIndex);
  19092. var data = seriesModel.getData();
  19093. var xAxis = cartesian.getAxis('x');
  19094. var yAxis = cartesian.getAxis('y');
  19095. if (data.type === 'list') {
  19096. unionExtent(data, xAxis, seriesModel);
  19097. unionExtent(data, yAxis, seriesModel);
  19098. }
  19099. }
  19100. }, this);
  19101. function unionExtent(data, axis, seriesModel) {
  19102. each(seriesModel.coordDimToDataDim(axis.dim), function (dim) {
  19103. axis.scale.unionExtent(data.getDataExtent(
  19104. dim, axis.scale.type !== 'ordinal'
  19105. ));
  19106. });
  19107. }
  19108. };
  19109. /**
  19110. * @inner
  19111. */
  19112. function updateAxisTransfrom(axis, coordBase) {
  19113. var axisExtent = axis.getExtent();
  19114. var axisExtentSum = axisExtent[0] + axisExtent[1];
  19115. // Fast transform
  19116. axis.toGlobalCoord = axis.dim === 'x'
  19117. ? function (coord) {
  19118. return coord + coordBase;
  19119. }
  19120. : function (coord) {
  19121. return axisExtentSum - coord + coordBase;
  19122. };
  19123. axis.toLocalCoord = axis.dim === 'x'
  19124. ? function (coord) {
  19125. return coord - coordBase;
  19126. }
  19127. : function (coord) {
  19128. return axisExtentSum - coord + coordBase;
  19129. };
  19130. }
  19131. Grid.create = function (ecModel, api) {
  19132. var grids = [];
  19133. ecModel.eachComponent('grid', function (gridModel, idx) {
  19134. var grid = new Grid(gridModel, ecModel, api);
  19135. grid.name = 'grid_' + idx;
  19136. grid.resize(gridModel, api);
  19137. gridModel.coordinateSystem = grid;
  19138. grids.push(grid);
  19139. });
  19140. // Inject the coordinateSystems into seriesModel
  19141. ecModel.eachSeries(function (seriesModel) {
  19142. if (seriesModel.get('coordinateSystem') !== 'cartesian2d') {
  19143. return;
  19144. }
  19145. var xAxisIndex = seriesModel.get('xAxisIndex');
  19146. // TODO Validate
  19147. var xAxisModel = ecModel.getComponent('xAxis', xAxisIndex);
  19148. var grid = grids[xAxisModel.get('gridIndex')];
  19149. seriesModel.coordinateSystem = grid.getCartesian(
  19150. xAxisIndex, seriesModel.get('yAxisIndex')
  19151. );
  19152. });
  19153. return grids;
  19154. };
  19155. // For deciding which dimensions to use when creating list data
  19156. Grid.dimensions = Cartesian2D.prototype.dimensions;
  19157. __webpack_require__(25).register('cartesian2d', Grid);
  19158. module.exports = Grid;
  19159. /***/ },
  19160. /* 109 */
  19161. /***/ function(module, exports, __webpack_require__) {
  19162. var OrdinalScale = __webpack_require__(110);
  19163. var IntervalScale = __webpack_require__(112);
  19164. __webpack_require__(113);
  19165. __webpack_require__(114);
  19166. var Scale = __webpack_require__(111);
  19167. var numberUtil = __webpack_require__(7);
  19168. var zrUtil = __webpack_require__(3);
  19169. var textContain = __webpack_require__(14);
  19170. var axisHelper = {};
  19171. /**
  19172. * Get axis scale extent before niced.
  19173. */
  19174. axisHelper.getScaleExtent = function (axis, model) {
  19175. var scale = axis.scale;
  19176. var originalExtent = scale.getExtent();
  19177. var span = originalExtent[1] - originalExtent[0];
  19178. if (scale.type === 'ordinal') {
  19179. // If series has no data, scale extent may be wrong
  19180. if (!isFinite(span)) {
  19181. return [0, 0];
  19182. }
  19183. else {
  19184. return originalExtent;
  19185. }
  19186. }
  19187. var min = model.getMin ? model.getMin() : model.get('min');
  19188. var max = model.getMax ? model.getMax() : model.get('max');
  19189. var crossZero = model.getNeedCrossZero
  19190. ? model.getNeedCrossZero() : !model.get('scale');
  19191. var boundaryGap = model.get('boundaryGap');
  19192. if (!zrUtil.isArray(boundaryGap)) {
  19193. boundaryGap = [boundaryGap || 0, boundaryGap || 0];
  19194. }
  19195. boundaryGap[0] = numberUtil.parsePercent(boundaryGap[0], 1);
  19196. boundaryGap[1] = numberUtil.parsePercent(boundaryGap[1], 1);
  19197. var fixMin = true;
  19198. var fixMax = true;
  19199. // Add boundary gap
  19200. if (min == null) {
  19201. min = originalExtent[0] - boundaryGap[0] * span;
  19202. fixMin = false;
  19203. }
  19204. if (max == null) {
  19205. max = originalExtent[1] + boundaryGap[1] * span;
  19206. fixMax = false;
  19207. }
  19208. if (min === 'dataMin') {
  19209. min = originalExtent[0];
  19210. }
  19211. if (max === 'dataMax') {
  19212. max = originalExtent[1];
  19213. }
  19214. // Evaluate if axis needs cross zero
  19215. if (crossZero) {
  19216. // Axis is over zero and min is not set
  19217. if (min > 0 && max > 0 && !fixMin) {
  19218. min = 0;
  19219. }
  19220. // Axis is under zero and max is not set
  19221. if (min < 0 && max < 0 && !fixMax) {
  19222. max = 0;
  19223. }
  19224. }
  19225. return [min, max];
  19226. };
  19227. axisHelper.niceScaleExtent = function (axis, model) {
  19228. var scale = axis.scale;
  19229. var extent = axisHelper.getScaleExtent(axis, model);
  19230. var fixMin = (model.getMin ? model.getMin() : model.get('min')) != null;
  19231. var fixMax = (model.getMax ? model.getMax() : model.get('max')) != null;
  19232. var splitNumber = model.get('splitNumber');
  19233. scale.setExtent(extent[0], extent[1]);
  19234. scale.niceExtent(splitNumber, fixMin, fixMax);
  19235. // Use minInterval to constraint the calculated interval.
  19236. // If calculated interval is less than minInterval. increase the interval quantity until
  19237. // it is larger than minInterval.
  19238. // For example:
  19239. // minInterval is 1, calculated interval is 0.2, so increase it to be 1. In this way we can get
  19240. // an integer axis.
  19241. var minInterval = model.get('minInterval');
  19242. if (isFinite(minInterval) && !fixMin && !fixMax && scale.type === 'interval') {
  19243. var interval = scale.getInterval();
  19244. var intervalScale = Math.max(Math.abs(interval), minInterval) / interval;
  19245. // while (interval < minInterval) {
  19246. // var quantity = numberUtil.quantity(interval);
  19247. // interval = quantity * 10;
  19248. // scaleQuantity *= 10;
  19249. // }
  19250. extent = scale.getExtent();
  19251. scale.setExtent(intervalScale * extent[0], extent[1] * intervalScale);
  19252. scale.niceExtent(splitNumber);
  19253. }
  19254. // If some one specified the min, max. And the default calculated interval
  19255. // is not good enough. He can specify the interval. It is often appeared
  19256. // in angle axis with angle 0 - 360. Interval calculated in interval scale is hard
  19257. // to be 60.
  19258. // FIXME
  19259. var interval = model.get('interval');
  19260. if (interval != null) {
  19261. scale.setInterval && scale.setInterval(interval);
  19262. }
  19263. };
  19264. /**
  19265. * @param {module:echarts/model/Model} model
  19266. * @param {string} [axisType] Default retrieve from model.type
  19267. * @return {module:echarts/scale/*}
  19268. */
  19269. axisHelper.createScaleByModel = function(model, axisType) {
  19270. axisType = axisType || model.get('type');
  19271. if (axisType) {
  19272. switch (axisType) {
  19273. // Buildin scale
  19274. case 'category':
  19275. return new OrdinalScale(
  19276. model.getCategories(), [Infinity, -Infinity]
  19277. );
  19278. case 'value':
  19279. return new IntervalScale();
  19280. // Extended scale, like time and log
  19281. default:
  19282. return (Scale.getClass(axisType) || IntervalScale).create(model);
  19283. }
  19284. }
  19285. };
  19286. /**
  19287. * Check if the axis corss 0
  19288. */
  19289. axisHelper.ifAxisCrossZero = function (axis) {
  19290. var dataExtent = axis.scale.getExtent();
  19291. var min = dataExtent[0];
  19292. var max = dataExtent[1];
  19293. return !((min > 0 && max > 0) || (min < 0 && max < 0));
  19294. };
  19295. /**
  19296. * @param {Array.<number>} tickCoords In axis self coordinate.
  19297. * @param {Array.<string>} labels
  19298. * @param {string} font
  19299. * @param {boolean} isAxisHorizontal
  19300. * @return {number}
  19301. */
  19302. axisHelper.getAxisLabelInterval = function (tickCoords, labels, font, isAxisHorizontal) {
  19303. // FIXME
  19304. // 不同角的axis和label,不只是horizontal和vertical.
  19305. var textSpaceTakenRect;
  19306. var autoLabelInterval = 0;
  19307. var accumulatedLabelInterval = 0;
  19308. var step = 1;
  19309. if (labels.length > 40) {
  19310. // Simple optimization for large amount of labels
  19311. step = Math.round(labels.length / 40);
  19312. }
  19313. for (var i = 0; i < tickCoords.length; i += step) {
  19314. var tickCoord = tickCoords[i];
  19315. var rect = textContain.getBoundingRect(
  19316. labels[i], font, 'center', 'top'
  19317. );
  19318. rect[isAxisHorizontal ? 'x' : 'y'] += tickCoord;
  19319. rect[isAxisHorizontal ? 'width' : 'height'] *= 1.5;
  19320. if (!textSpaceTakenRect) {
  19321. textSpaceTakenRect = rect.clone();
  19322. }
  19323. // There is no space for current label;
  19324. else if (textSpaceTakenRect.intersect(rect)) {
  19325. accumulatedLabelInterval++;
  19326. autoLabelInterval = Math.max(autoLabelInterval, accumulatedLabelInterval);
  19327. }
  19328. else {
  19329. textSpaceTakenRect.union(rect);
  19330. // Reset
  19331. accumulatedLabelInterval = 0;
  19332. }
  19333. }
  19334. if (autoLabelInterval === 0 && step > 1) {
  19335. return step;
  19336. }
  19337. return autoLabelInterval * step;
  19338. };
  19339. /**
  19340. * @param {Object} axis
  19341. * @param {Function} labelFormatter
  19342. * @return {Array.<string>}
  19343. */
  19344. axisHelper.getFormattedLabels = function (axis, labelFormatter) {
  19345. var scale = axis.scale;
  19346. var labels = scale.getTicksLabels();
  19347. var ticks = scale.getTicks();
  19348. if (typeof labelFormatter === 'string') {
  19349. labelFormatter = (function (tpl) {
  19350. return function (val) {
  19351. return tpl.replace('{value}', val);
  19352. };
  19353. })(labelFormatter);
  19354. return zrUtil.map(labels, labelFormatter);
  19355. }
  19356. else if (typeof labelFormatter === 'function') {
  19357. return zrUtil.map(ticks, function (tick, idx) {
  19358. return labelFormatter(
  19359. axis.type === 'category' ? scale.getLabel(tick) : tick,
  19360. idx
  19361. );
  19362. }, this);
  19363. }
  19364. else {
  19365. return labels;
  19366. }
  19367. };
  19368. module.exports = axisHelper;
  19369. /***/ },
  19370. /* 110 */
  19371. /***/ function(module, exports, __webpack_require__) {
  19372. /**
  19373. * Linear continuous scale
  19374. * @module echarts/coord/scale/Ordinal
  19375. *
  19376. * http://en.wikipedia.org/wiki/Level_of_measurement
  19377. */
  19378. // FIXME only one data
  19379. var zrUtil = __webpack_require__(3);
  19380. var Scale = __webpack_require__(111);
  19381. var scaleProto = Scale.prototype;
  19382. var OrdinalScale = Scale.extend({
  19383. type: 'ordinal',
  19384. init: function (data, extent) {
  19385. this._data = data;
  19386. this._extent = extent || [0, data.length - 1];
  19387. },
  19388. parse: function (val) {
  19389. return typeof val === 'string'
  19390. ? zrUtil.indexOf(this._data, val)
  19391. // val might be float.
  19392. : Math.round(val);
  19393. },
  19394. contain: function (rank) {
  19395. rank = this.parse(rank);
  19396. return scaleProto.contain.call(this, rank)
  19397. && this._data[rank] != null;
  19398. },
  19399. /**
  19400. * Normalize given rank or name to linear [0, 1]
  19401. * @param {number|string} [val]
  19402. * @return {number}
  19403. */
  19404. normalize: function (val) {
  19405. return scaleProto.normalize.call(this, this.parse(val));
  19406. },
  19407. scale: function (val) {
  19408. return Math.round(scaleProto.scale.call(this, val));
  19409. },
  19410. /**
  19411. * @return {Array}
  19412. */
  19413. getTicks: function () {
  19414. var ticks = [];
  19415. var extent = this._extent;
  19416. var rank = extent[0];
  19417. while (rank <= extent[1]) {
  19418. ticks.push(rank);
  19419. rank++;
  19420. }
  19421. return ticks;
  19422. },
  19423. /**
  19424. * Get item on rank n
  19425. * @param {number} n
  19426. * @return {string}
  19427. */
  19428. getLabel: function (n) {
  19429. return this._data[n];
  19430. },
  19431. /**
  19432. * @return {number}
  19433. */
  19434. count: function () {
  19435. return this._extent[1] - this._extent[0] + 1;
  19436. },
  19437. niceTicks: zrUtil.noop,
  19438. niceExtent: zrUtil.noop
  19439. });
  19440. /**
  19441. * @return {module:echarts/scale/Time}
  19442. */
  19443. OrdinalScale.create = function () {
  19444. return new OrdinalScale();
  19445. };
  19446. module.exports = OrdinalScale;
  19447. /***/ },
  19448. /* 111 */
  19449. /***/ function(module, exports, __webpack_require__) {
  19450. /**
  19451. * // Scale class management
  19452. * @module echarts/scale/Scale
  19453. */
  19454. var clazzUtil = __webpack_require__(9);
  19455. function Scale() {
  19456. /**
  19457. * Extent
  19458. * @type {Array.<number>}
  19459. * @protected
  19460. */
  19461. this._extent = [Infinity, -Infinity];
  19462. /**
  19463. * Step is calculated in adjustExtent
  19464. * @type {Array.<number>}
  19465. * @protected
  19466. */
  19467. this._interval = 0;
  19468. this.init && this.init.apply(this, arguments);
  19469. }
  19470. var scaleProto = Scale.prototype;
  19471. /**
  19472. * Parse input val to valid inner number.
  19473. * @param {*} val
  19474. * @return {number}
  19475. */
  19476. scaleProto.parse = function (val) {
  19477. // Notice: This would be a trap here, If the implementation
  19478. // of this method depends on extent, and this method is used
  19479. // before extent set (like in dataZoom), it would be wrong.
  19480. // Nevertheless, parse does not depend on extent generally.
  19481. return val;
  19482. };
  19483. scaleProto.contain = function (val) {
  19484. var extent = this._extent;
  19485. return val >= extent[0] && val <= extent[1];
  19486. };
  19487. /**
  19488. * Normalize value to linear [0, 1], return 0.5 if extent span is 0
  19489. * @param {number} val
  19490. * @return {number}
  19491. */
  19492. scaleProto.normalize = function (val) {
  19493. var extent = this._extent;
  19494. if (extent[1] === extent[0]) {
  19495. return 0.5;
  19496. }
  19497. return (val - extent[0]) / (extent[1] - extent[0]);
  19498. };
  19499. /**
  19500. * Scale normalized value
  19501. * @param {number} val
  19502. * @return {number}
  19503. */
  19504. scaleProto.scale = function (val) {
  19505. var extent = this._extent;
  19506. return val * (extent[1] - extent[0]) + extent[0];
  19507. };
  19508. /**
  19509. * Set extent from data
  19510. * @param {Array.<number>} other
  19511. */
  19512. scaleProto.unionExtent = function (other) {
  19513. var extent = this._extent;
  19514. other[0] < extent[0] && (extent[0] = other[0]);
  19515. other[1] > extent[1] && (extent[1] = other[1]);
  19516. // not setExtent because in log axis it may transformed to power
  19517. // this.setExtent(extent[0], extent[1]);
  19518. };
  19519. /**
  19520. * Get extent
  19521. * @return {Array.<number>}
  19522. */
  19523. scaleProto.getExtent = function () {
  19524. return this._extent.slice();
  19525. };
  19526. /**
  19527. * Set extent
  19528. * @param {number} start
  19529. * @param {number} end
  19530. */
  19531. scaleProto.setExtent = function (start, end) {
  19532. var thisExtent = this._extent;
  19533. if (!isNaN(start)) {
  19534. thisExtent[0] = start;
  19535. }
  19536. if (!isNaN(end)) {
  19537. thisExtent[1] = end;
  19538. }
  19539. };
  19540. /**
  19541. * @return {Array.<string>}
  19542. */
  19543. scaleProto.getTicksLabels = function () {
  19544. var labels = [];
  19545. var ticks = this.getTicks();
  19546. for (var i = 0; i < ticks.length; i++) {
  19547. labels.push(this.getLabel(ticks[i]));
  19548. }
  19549. return labels;
  19550. };
  19551. clazzUtil.enableClassExtend(Scale);
  19552. clazzUtil.enableClassManagement(Scale, {
  19553. registerWhenExtend: true
  19554. });
  19555. module.exports = Scale;
  19556. /***/ },
  19557. /* 112 */
  19558. /***/ function(module, exports, __webpack_require__) {
  19559. /**
  19560. * Interval scale
  19561. * @module echarts/scale/Interval
  19562. */
  19563. var numberUtil = __webpack_require__(7);
  19564. var formatUtil = __webpack_require__(6);
  19565. var Scale = __webpack_require__(111);
  19566. var mathFloor = Math.floor;
  19567. var mathCeil = Math.ceil;
  19568. /**
  19569. * @alias module:echarts/coord/scale/Interval
  19570. * @constructor
  19571. */
  19572. var IntervalScale = Scale.extend({
  19573. type: 'interval',
  19574. _interval: 0,
  19575. setExtent: function (start, end) {
  19576. var thisExtent = this._extent;
  19577. //start,end may be a Number like '25',so...
  19578. if (!isNaN(start)) {
  19579. thisExtent[0] = parseFloat(start);
  19580. }
  19581. if (!isNaN(end)) {
  19582. thisExtent[1] = parseFloat(end);
  19583. }
  19584. },
  19585. unionExtent: function (other) {
  19586. var extent = this._extent;
  19587. other[0] < extent[0] && (extent[0] = other[0]);
  19588. other[1] > extent[1] && (extent[1] = other[1]);
  19589. // unionExtent may called by it's sub classes
  19590. IntervalScale.prototype.setExtent.call(this, extent[0], extent[1]);
  19591. },
  19592. /**
  19593. * Get interval
  19594. */
  19595. getInterval: function () {
  19596. if (!this._interval) {
  19597. this.niceTicks();
  19598. }
  19599. return this._interval;
  19600. },
  19601. /**
  19602. * Set interval
  19603. */
  19604. setInterval: function (interval) {
  19605. this._interval = interval;
  19606. // Dropped auto calculated niceExtent and use user setted extent
  19607. // We assume user wan't to set both interval, min, max to get a better result
  19608. this._niceExtent = this._extent.slice();
  19609. },
  19610. /**
  19611. * @return {Array.<number>}
  19612. */
  19613. getTicks: function () {
  19614. if (!this._interval) {
  19615. this.niceTicks();
  19616. }
  19617. var interval = this._interval;
  19618. var extent = this._extent;
  19619. var ticks = [];
  19620. // Consider this case: using dataZoom toolbox, zoom and zoom.
  19621. var safeLimit = 10000;
  19622. if (interval) {
  19623. var niceExtent = this._niceExtent;
  19624. if (extent[0] < niceExtent[0]) {
  19625. ticks.push(extent[0]);
  19626. }
  19627. var tick = niceExtent[0];
  19628. while (tick <= niceExtent[1]) {
  19629. ticks.push(tick);
  19630. // Avoid rounding error
  19631. tick = numberUtil.round(tick + interval);
  19632. if (ticks.length > safeLimit) {
  19633. return [];
  19634. }
  19635. }
  19636. if (extent[1] > niceExtent[1]) {
  19637. ticks.push(extent[1]);
  19638. }
  19639. }
  19640. return ticks;
  19641. },
  19642. /**
  19643. * @return {Array.<string>}
  19644. */
  19645. getTicksLabels: function () {
  19646. var labels = [];
  19647. var ticks = this.getTicks();
  19648. for (var i = 0; i < ticks.length; i++) {
  19649. labels.push(this.getLabel(ticks[i]));
  19650. }
  19651. return labels;
  19652. },
  19653. /**
  19654. * @param {number} n
  19655. * @return {number}
  19656. */
  19657. getLabel: function (data) {
  19658. return formatUtil.addCommas(data);
  19659. },
  19660. /**
  19661. * Update interval and extent of intervals for nice ticks
  19662. *
  19663. * @param {number} [splitNumber = 5] Desired number of ticks
  19664. */
  19665. niceTicks: function (splitNumber) {
  19666. splitNumber = splitNumber || 5;
  19667. var extent = this._extent;
  19668. var span = extent[1] - extent[0];
  19669. if (!isFinite(span)) {
  19670. return;
  19671. }
  19672. // User may set axis min 0 and data are all negative
  19673. // FIXME If it needs to reverse ?
  19674. if (span < 0) {
  19675. span = -span;
  19676. extent.reverse();
  19677. }
  19678. // From "Nice Numbers for Graph Labels" of Graphic Gems
  19679. // var niceSpan = numberUtil.nice(span, false);
  19680. var step = numberUtil.nice(span / splitNumber, true);
  19681. // Niced extent inside original extent
  19682. var niceExtent = [
  19683. numberUtil.round(mathCeil(extent[0] / step) * step),
  19684. numberUtil.round(mathFloor(extent[1] / step) * step)
  19685. ];
  19686. this._interval = step;
  19687. this._niceExtent = niceExtent;
  19688. },
  19689. /**
  19690. * Nice extent.
  19691. * @param {number} [splitNumber = 5] Given approx tick number
  19692. * @param {boolean} [fixMin=false]
  19693. * @param {boolean} [fixMax=false]
  19694. */
  19695. niceExtent: function (splitNumber, fixMin, fixMax) {
  19696. var extent = this._extent;
  19697. // If extent start and end are same, expand them
  19698. if (extent[0] === extent[1]) {
  19699. if (extent[0] !== 0) {
  19700. // Expand extent
  19701. var expandSize = extent[0] / 2;
  19702. extent[0] -= expandSize;
  19703. extent[1] += expandSize;
  19704. }
  19705. else {
  19706. extent[1] = 1;
  19707. }
  19708. }
  19709. var span = extent[1] - extent[0];
  19710. // If there are no data and extent are [Infinity, -Infinity]
  19711. if (!isFinite(span)) {
  19712. extent[0] = 0;
  19713. extent[1] = 1;
  19714. }
  19715. this.niceTicks(splitNumber);
  19716. // var extent = this._extent;
  19717. var interval = this._interval;
  19718. if (!fixMin) {
  19719. extent[0] = numberUtil.round(mathFloor(extent[0] / interval) * interval);
  19720. }
  19721. if (!fixMax) {
  19722. extent[1] = numberUtil.round(mathCeil(extent[1] / interval) * interval);
  19723. }
  19724. }
  19725. });
  19726. /**
  19727. * @return {module:echarts/scale/Time}
  19728. */
  19729. IntervalScale.create = function () {
  19730. return new IntervalScale();
  19731. };
  19732. module.exports = IntervalScale;
  19733. /***/ },
  19734. /* 113 */
  19735. /***/ function(module, exports, __webpack_require__) {
  19736. /**
  19737. * Interval scale
  19738. * @module echarts/coord/scale/Time
  19739. */
  19740. var zrUtil = __webpack_require__(3);
  19741. var numberUtil = __webpack_require__(7);
  19742. var formatUtil = __webpack_require__(6);
  19743. var IntervalScale = __webpack_require__(112);
  19744. var intervalScaleProto = IntervalScale.prototype;
  19745. var mathCeil = Math.ceil;
  19746. var mathFloor = Math.floor;
  19747. var ONE_SECOND = 1000;
  19748. var ONE_MINUTE = ONE_SECOND * 60;
  19749. var ONE_HOUR = ONE_MINUTE * 60;
  19750. var ONE_DAY = ONE_HOUR * 24;
  19751. // FIXME 公用?
  19752. var bisect = function (a, x, lo, hi) {
  19753. while (lo < hi) {
  19754. var mid = lo + hi >>> 1;
  19755. if (a[mid][2] < x) {
  19756. lo = mid + 1;
  19757. }
  19758. else {
  19759. hi = mid;
  19760. }
  19761. }
  19762. return lo;
  19763. };
  19764. /**
  19765. * @alias module:echarts/coord/scale/Time
  19766. * @constructor
  19767. */
  19768. var TimeScale = IntervalScale.extend({
  19769. type: 'time',
  19770. // Overwrite
  19771. getLabel: function (val) {
  19772. var stepLvl = this._stepLvl;
  19773. var date = new Date(val);
  19774. return formatUtil.formatTime(stepLvl[0], date);
  19775. },
  19776. // Overwrite
  19777. niceExtent: function (approxTickNum, fixMin, fixMax) {
  19778. var extent = this._extent;
  19779. // If extent start and end are same, expand them
  19780. if (extent[0] === extent[1]) {
  19781. // Expand extent
  19782. extent[0] -= ONE_DAY;
  19783. extent[1] += ONE_DAY;
  19784. }
  19785. // If there are no data and extent are [Infinity, -Infinity]
  19786. if (extent[1] === -Infinity && extent[0] === Infinity) {
  19787. var d = new Date();
  19788. extent[1] = new Date(d.getFullYear(), d.getMonth(), d.getDate());
  19789. extent[0] = extent[1] - ONE_DAY;
  19790. }
  19791. this.niceTicks(approxTickNum);
  19792. // var extent = this._extent;
  19793. var interval = this._interval;
  19794. if (!fixMin) {
  19795. extent[0] = numberUtil.round(mathFloor(extent[0] / interval) * interval);
  19796. }
  19797. if (!fixMax) {
  19798. extent[1] = numberUtil.round(mathCeil(extent[1] / interval) * interval);
  19799. }
  19800. },
  19801. // Overwrite
  19802. niceTicks: function (approxTickNum) {
  19803. approxTickNum = approxTickNum || 10;
  19804. var extent = this._extent;
  19805. var span = extent[1] - extent[0];
  19806. var approxInterval = span / approxTickNum;
  19807. var scaleLevelsLen = scaleLevels.length;
  19808. var idx = bisect(scaleLevels, approxInterval, 0, scaleLevelsLen);
  19809. var level = scaleLevels[Math.min(idx, scaleLevelsLen - 1)];
  19810. var interval = level[2];
  19811. // Same with interval scale if span is much larger than 1 year
  19812. if (level[0] === 'year') {
  19813. var yearSpan = span / interval;
  19814. // From "Nice Numbers for Graph Labels" of Graphic Gems
  19815. // var niceYearSpan = numberUtil.nice(yearSpan, false);
  19816. var yearStep = numberUtil.nice(yearSpan / approxTickNum, true);
  19817. interval *= yearStep;
  19818. }
  19819. var niceExtent = [
  19820. mathCeil(extent[0] / interval) * interval,
  19821. mathFloor(extent[1] / interval) * interval
  19822. ];
  19823. this._stepLvl = level;
  19824. // Interval will be used in getTicks
  19825. this._interval = interval;
  19826. this._niceExtent = niceExtent;
  19827. },
  19828. parse: function (val) {
  19829. // val might be float.
  19830. return +numberUtil.parseDate(val);
  19831. }
  19832. });
  19833. zrUtil.each(['contain', 'normalize'], function (methodName) {
  19834. TimeScale.prototype[methodName] = function (val) {
  19835. return intervalScaleProto[methodName].call(this, this.parse(val));
  19836. };
  19837. });
  19838. // Steps from d3
  19839. var scaleLevels = [
  19840. // Format step interval
  19841. ['hh:mm:ss', 1, ONE_SECOND], // 1s
  19842. ['hh:mm:ss', 5, ONE_SECOND * 5], // 5s
  19843. ['hh:mm:ss', 10, ONE_SECOND * 10], // 10s
  19844. ['hh:mm:ss', 15, ONE_SECOND * 15], // 15s
  19845. ['hh:mm:ss', 30, ONE_SECOND * 30], // 30s
  19846. ['hh:mm\nMM-dd',1, ONE_MINUTE], // 1m
  19847. ['hh:mm\nMM-dd',5, ONE_MINUTE * 5], // 5m
  19848. ['hh:mm\nMM-dd',10, ONE_MINUTE * 10], // 10m
  19849. ['hh:mm\nMM-dd',15, ONE_MINUTE * 15], // 15m
  19850. ['hh:mm\nMM-dd',30, ONE_MINUTE * 30], // 30m
  19851. ['hh:mm\nMM-dd',1, ONE_HOUR], // 1h
  19852. ['hh:mm\nMM-dd',2, ONE_HOUR * 2], // 2h
  19853. ['hh:mm\nMM-dd',6, ONE_HOUR * 6], // 6h
  19854. ['hh:mm\nMM-dd',12, ONE_HOUR * 12], // 12h
  19855. ['MM-dd\nyyyy', 1, ONE_DAY], // 1d
  19856. ['week', 7, ONE_DAY * 7], // 7d
  19857. ['month', 1, ONE_DAY * 31], // 1M
  19858. ['quarter', 3, ONE_DAY * 380 / 4], // 3M
  19859. ['half-year', 6, ONE_DAY * 380 / 2], // 6M
  19860. ['year', 1, ONE_DAY * 380] // 1Y
  19861. ];
  19862. /**
  19863. * @return {module:echarts/scale/Time}
  19864. */
  19865. TimeScale.create = function () {
  19866. return new TimeScale();
  19867. };
  19868. module.exports = TimeScale;
  19869. /***/ },
  19870. /* 114 */
  19871. /***/ function(module, exports, __webpack_require__) {
  19872. /**
  19873. * Log scale
  19874. * @module echarts/scale/Log
  19875. */
  19876. var zrUtil = __webpack_require__(3);
  19877. var Scale = __webpack_require__(111);
  19878. var numberUtil = __webpack_require__(7);
  19879. // Use some method of IntervalScale
  19880. var IntervalScale = __webpack_require__(112);
  19881. var scaleProto = Scale.prototype;
  19882. var intervalScaleProto = IntervalScale.prototype;
  19883. var mathFloor = Math.floor;
  19884. var mathCeil = Math.ceil;
  19885. var mathPow = Math.pow;
  19886. var LOG_BASE = 10;
  19887. var mathLog = Math.log;
  19888. var LogScale = Scale.extend({
  19889. type: 'log',
  19890. /**
  19891. * @return {Array.<number>}
  19892. */
  19893. getTicks: function () {
  19894. return zrUtil.map(intervalScaleProto.getTicks.call(this), function (val) {
  19895. return numberUtil.round(mathPow(LOG_BASE, val));
  19896. });
  19897. },
  19898. /**
  19899. * @param {number} val
  19900. * @return {string}
  19901. */
  19902. getLabel: intervalScaleProto.getLabel,
  19903. /**
  19904. * @param {number} val
  19905. * @return {number}
  19906. */
  19907. scale: function (val) {
  19908. val = scaleProto.scale.call(this, val);
  19909. return mathPow(LOG_BASE, val);
  19910. },
  19911. /**
  19912. * @param {number} start
  19913. * @param {number} end
  19914. */
  19915. setExtent: function (start, end) {
  19916. start = mathLog(start) / mathLog(LOG_BASE);
  19917. end = mathLog(end) / mathLog(LOG_BASE);
  19918. intervalScaleProto.setExtent.call(this, start, end);
  19919. },
  19920. /**
  19921. * @return {number} end
  19922. */
  19923. getExtent: function () {
  19924. var extent = scaleProto.getExtent.call(this);
  19925. extent[0] = mathPow(LOG_BASE, extent[0]);
  19926. extent[1] = mathPow(LOG_BASE, extent[1]);
  19927. return extent;
  19928. },
  19929. /**
  19930. * @param {Array.<number>} extent
  19931. */
  19932. unionExtent: function (extent) {
  19933. extent[0] = mathLog(extent[0]) / mathLog(LOG_BASE);
  19934. extent[1] = mathLog(extent[1]) / mathLog(LOG_BASE);
  19935. scaleProto.unionExtent.call(this, extent);
  19936. },
  19937. /**
  19938. * Update interval and extent of intervals for nice ticks
  19939. * @param {number} [approxTickNum = 10] Given approx tick number
  19940. */
  19941. niceTicks: function (approxTickNum) {
  19942. approxTickNum = approxTickNum || 10;
  19943. var extent = this._extent;
  19944. var span = extent[1] - extent[0];
  19945. if (span === Infinity || span <= 0) {
  19946. return;
  19947. }
  19948. var interval = mathPow(10, mathFloor(mathLog(span / approxTickNum) / Math.LN10));
  19949. var err = approxTickNum / span * interval;
  19950. // Filter ticks to get closer to the desired count.
  19951. if (err <= 0.5) {
  19952. interval *= 10;
  19953. }
  19954. var niceExtent = [
  19955. numberUtil.round(mathCeil(extent[0] / interval) * interval),
  19956. numberUtil.round(mathFloor(extent[1] / interval) * interval)
  19957. ];
  19958. this._interval = interval;
  19959. this._niceExtent = niceExtent;
  19960. },
  19961. /**
  19962. * Nice extent.
  19963. * @param {number} [approxTickNum = 10] Given approx tick number
  19964. * @param {boolean} [fixMin=false]
  19965. * @param {boolean} [fixMax=false]
  19966. */
  19967. niceExtent: intervalScaleProto.niceExtent
  19968. });
  19969. zrUtil.each(['contain', 'normalize'], function (methodName) {
  19970. LogScale.prototype[methodName] = function (val) {
  19971. val = mathLog(val) / mathLog(LOG_BASE);
  19972. return scaleProto[methodName].call(this, val);
  19973. };
  19974. });
  19975. LogScale.create = function () {
  19976. return new LogScale();
  19977. };
  19978. module.exports = LogScale;
  19979. /***/ },
  19980. /* 115 */
  19981. /***/ function(module, exports, __webpack_require__) {
  19982. 'use strict';
  19983. var zrUtil = __webpack_require__(3);
  19984. var Cartesian = __webpack_require__(116);
  19985. function Cartesian2D(name) {
  19986. Cartesian.call(this, name);
  19987. }
  19988. Cartesian2D.prototype = {
  19989. constructor: Cartesian2D,
  19990. type: 'cartesian2d',
  19991. /**
  19992. * @type {Array.<string>}
  19993. * @readOnly
  19994. */
  19995. dimensions: ['x', 'y'],
  19996. /**
  19997. * Base axis will be used on stacking.
  19998. *
  19999. * @return {module:echarts/coord/cartesian/Axis2D}
  20000. */
  20001. getBaseAxis: function () {
  20002. return this.getAxesByScale('ordinal')[0]
  20003. || this.getAxesByScale('time')[0]
  20004. || this.getAxis('x');
  20005. },
  20006. /**
  20007. * If contain point
  20008. * @param {Array.<number>} point
  20009. * @return {boolean}
  20010. */
  20011. containPoint: function (point) {
  20012. var axisX = this.getAxis('x');
  20013. var axisY = this.getAxis('y');
  20014. return axisX.contain(axisX.toLocalCoord(point[0]))
  20015. && axisY.contain(axisY.toLocalCoord(point[1]));
  20016. },
  20017. /**
  20018. * If contain data
  20019. * @param {Array.<number>} data
  20020. * @return {boolean}
  20021. */
  20022. containData: function (data) {
  20023. return this.getAxis('x').containData(data[0])
  20024. && this.getAxis('y').containData(data[1]);
  20025. },
  20026. /**
  20027. * Convert series data to an array of points
  20028. * @param {module:echarts/data/List} data
  20029. * @param {boolean} stack
  20030. * @return {Array}
  20031. * Return array of points. For example:
  20032. * `[[10, 10], [20, 20], [30, 30]]`
  20033. */
  20034. dataToPoints: function (data, stack) {
  20035. return data.mapArray(['x', 'y'], function (x, y) {
  20036. return this.dataToPoint([x, y]);
  20037. }, stack, this);
  20038. },
  20039. /**
  20040. * @param {Array.<number>} data
  20041. * @param {boolean} [clamp=false]
  20042. * @return {Array.<number>}
  20043. */
  20044. dataToPoint: function (data, clamp) {
  20045. var xAxis = this.getAxis('x');
  20046. var yAxis = this.getAxis('y');
  20047. return [
  20048. xAxis.toGlobalCoord(xAxis.dataToCoord(data[0], clamp)),
  20049. yAxis.toGlobalCoord(yAxis.dataToCoord(data[1], clamp))
  20050. ];
  20051. },
  20052. /**
  20053. * @param {Array.<number>} point
  20054. * @param {boolean} [clamp=false]
  20055. * @return {Array.<number>}
  20056. */
  20057. pointToData: function (point, clamp) {
  20058. var xAxis = this.getAxis('x');
  20059. var yAxis = this.getAxis('y');
  20060. return [
  20061. xAxis.coordToData(xAxis.toLocalCoord(point[0]), clamp),
  20062. yAxis.coordToData(yAxis.toLocalCoord(point[1]), clamp)
  20063. ];
  20064. },
  20065. /**
  20066. * Get other axis
  20067. * @param {module:echarts/coord/cartesian/Axis2D} axis
  20068. */
  20069. getOtherAxis: function (axis) {
  20070. return this.getAxis(axis.dim === 'x' ? 'y' : 'x');
  20071. }
  20072. };
  20073. zrUtil.inherits(Cartesian2D, Cartesian);
  20074. module.exports = Cartesian2D;
  20075. /***/ },
  20076. /* 116 */
  20077. /***/ function(module, exports, __webpack_require__) {
  20078. 'use strict';
  20079. /**
  20080. * Cartesian coordinate system
  20081. * @module echarts/coord/Cartesian
  20082. *
  20083. */
  20084. var zrUtil = __webpack_require__(3);
  20085. function dimAxisMapper(dim) {
  20086. return this._axes[dim];
  20087. }
  20088. /**
  20089. * @alias module:echarts/coord/Cartesian
  20090. * @constructor
  20091. */
  20092. var Cartesian = function (name) {
  20093. this._axes = {};
  20094. this._dimList = [];
  20095. /**
  20096. * @type {string}
  20097. */
  20098. this.name = name || '';
  20099. };
  20100. Cartesian.prototype = {
  20101. constructor: Cartesian,
  20102. type: 'cartesian',
  20103. /**
  20104. * Get axis
  20105. * @param {number|string} dim
  20106. * @return {module:echarts/coord/Cartesian~Axis}
  20107. */
  20108. getAxis: function (dim) {
  20109. return this._axes[dim];
  20110. },
  20111. /**
  20112. * Get axes list
  20113. * @return {Array.<module:echarts/coord/Cartesian~Axis>}
  20114. */
  20115. getAxes: function () {
  20116. return zrUtil.map(this._dimList, dimAxisMapper, this);
  20117. },
  20118. /**
  20119. * Get axes list by given scale type
  20120. */
  20121. getAxesByScale: function (scaleType) {
  20122. scaleType = scaleType.toLowerCase();
  20123. return zrUtil.filter(
  20124. this.getAxes(),
  20125. function (axis) {
  20126. return axis.scale.type === scaleType;
  20127. }
  20128. );
  20129. },
  20130. /**
  20131. * Add axis
  20132. * @param {module:echarts/coord/Cartesian.Axis}
  20133. */
  20134. addAxis: function (axis) {
  20135. var dim = axis.dim;
  20136. this._axes[dim] = axis;
  20137. this._dimList.push(dim);
  20138. },
  20139. /**
  20140. * Convert data to coord in nd space
  20141. * @param {Array.<number>|Object.<string, number>} val
  20142. * @return {Array.<number>|Object.<string, number>}
  20143. */
  20144. dataToCoord: function (val) {
  20145. return this._dataCoordConvert(val, 'dataToCoord');
  20146. },
  20147. /**
  20148. * Convert coord in nd space to data
  20149. * @param {Array.<number>|Object.<string, number>} val
  20150. * @return {Array.<number>|Object.<string, number>}
  20151. */
  20152. coordToData: function (val) {
  20153. return this._dataCoordConvert(val, 'coordToData');
  20154. },
  20155. _dataCoordConvert: function (input, method) {
  20156. var dimList = this._dimList;
  20157. var output = input instanceof Array ? [] : {};
  20158. for (var i = 0; i < dimList.length; i++) {
  20159. var dim = dimList[i];
  20160. var axis = this._axes[dim];
  20161. output[dim] = axis[method](input[dim]);
  20162. }
  20163. return output;
  20164. }
  20165. };
  20166. module.exports = Cartesian;
  20167. /***/ },
  20168. /* 117 */
  20169. /***/ function(module, exports, __webpack_require__) {
  20170. var zrUtil = __webpack_require__(3);
  20171. var Axis = __webpack_require__(118);
  20172. var axisLabelInterval = __webpack_require__(119);
  20173. /**
  20174. * Extend axis 2d
  20175. * @constructor module:echarts/coord/cartesian/Axis2D
  20176. * @extends {module:echarts/coord/cartesian/Axis}
  20177. * @param {string} dim
  20178. * @param {*} scale
  20179. * @param {Array.<number>} coordExtent
  20180. * @param {string} axisType
  20181. * @param {string} position
  20182. */
  20183. var Axis2D = function (dim, scale, coordExtent, axisType, position) {
  20184. Axis.call(this, dim, scale, coordExtent);
  20185. /**
  20186. * Axis type
  20187. * - 'category'
  20188. * - 'value'
  20189. * - 'time'
  20190. * - 'log'
  20191. * @type {string}
  20192. */
  20193. this.type = axisType || 'value';
  20194. /**
  20195. * Axis position
  20196. * - 'top'
  20197. * - 'bottom'
  20198. * - 'left'
  20199. * - 'right'
  20200. */
  20201. this.position = position || 'bottom';
  20202. };
  20203. Axis2D.prototype = {
  20204. constructor: Axis2D,
  20205. /**
  20206. * Index of axis, can be used as key
  20207. */
  20208. index: 0,
  20209. /**
  20210. * If axis is on the zero position of the other axis
  20211. * @type {boolean}
  20212. */
  20213. onZero: false,
  20214. /**
  20215. * Axis model
  20216. * @param {module:echarts/coord/cartesian/AxisModel}
  20217. */
  20218. model: null,
  20219. isHorizontal: function () {
  20220. var position = this.position;
  20221. return position === 'top' || position === 'bottom';
  20222. },
  20223. getGlobalExtent: function () {
  20224. var ret = this.getExtent();
  20225. ret[0] = this.toGlobalCoord(ret[0]);
  20226. ret[1] = this.toGlobalCoord(ret[1]);
  20227. return ret;
  20228. },
  20229. /**
  20230. * @return {number}
  20231. */
  20232. getLabelInterval: function () {
  20233. var labelInterval = this._labelInterval;
  20234. if (!labelInterval) {
  20235. labelInterval = this._labelInterval = axisLabelInterval(this);
  20236. }
  20237. return labelInterval;
  20238. },
  20239. /**
  20240. * If label is ignored.
  20241. * Automatically used when axis is category and label can not be all shown
  20242. * @param {number} idx
  20243. * @return {boolean}
  20244. */
  20245. isLabelIgnored: function (idx) {
  20246. if (this.type === 'category') {
  20247. var labelInterval = this.getLabelInterval();
  20248. return ((typeof labelInterval === 'function')
  20249. && !labelInterval(idx, this.scale.getLabel(idx)))
  20250. || idx % (labelInterval + 1);
  20251. }
  20252. },
  20253. /**
  20254. * Transform global coord to local coord,
  20255. * i.e. var localCoord = axis.toLocalCoord(80);
  20256. * designate by module:echarts/coord/cartesian/Grid.
  20257. * @type {Function}
  20258. */
  20259. toLocalCoord: null,
  20260. /**
  20261. * Transform global coord to local coord,
  20262. * i.e. var globalCoord = axis.toLocalCoord(40);
  20263. * designate by module:echarts/coord/cartesian/Grid.
  20264. * @type {Function}
  20265. */
  20266. toGlobalCoord: null
  20267. };
  20268. zrUtil.inherits(Axis2D, Axis);
  20269. module.exports = Axis2D;
  20270. /***/ },
  20271. /* 118 */
  20272. /***/ function(module, exports, __webpack_require__) {
  20273. var numberUtil = __webpack_require__(7);
  20274. var linearMap = numberUtil.linearMap;
  20275. var zrUtil = __webpack_require__(3);
  20276. function fixExtentWithBands(extent, nTick) {
  20277. var size = extent[1] - extent[0];
  20278. var len = nTick;
  20279. var margin = size / len / 2;
  20280. extent[0] += margin;
  20281. extent[1] -= margin;
  20282. }
  20283. var normalizedExtent = [0, 1];
  20284. /**
  20285. * @name module:echarts/coord/CartesianAxis
  20286. * @constructor
  20287. */
  20288. var Axis = function (dim, scale, extent) {
  20289. /**
  20290. * Axis dimension. Such as 'x', 'y', 'z', 'angle', 'radius'
  20291. * @type {string}
  20292. */
  20293. this.dim = dim;
  20294. /**
  20295. * Axis scale
  20296. * @type {module:echarts/coord/scale/*}
  20297. */
  20298. this.scale = scale;
  20299. /**
  20300. * @type {Array.<number>}
  20301. * @private
  20302. */
  20303. this._extent = extent || [0, 0];
  20304. /**
  20305. * @type {boolean}
  20306. */
  20307. this.inverse = false;
  20308. /**
  20309. * Usually true when axis has a ordinal scale
  20310. * @type {boolean}
  20311. */
  20312. this.onBand = false;
  20313. };
  20314. Axis.prototype = {
  20315. constructor: Axis,
  20316. /**
  20317. * If axis extent contain given coord
  20318. * @param {number} coord
  20319. * @return {boolean}
  20320. */
  20321. contain: function (coord) {
  20322. var extent = this._extent;
  20323. var min = Math.min(extent[0], extent[1]);
  20324. var max = Math.max(extent[0], extent[1]);
  20325. return coord >= min && coord <= max;
  20326. },
  20327. /**
  20328. * If axis extent contain given data
  20329. * @param {number} data
  20330. * @return {boolean}
  20331. */
  20332. containData: function (data) {
  20333. return this.contain(this.dataToCoord(data));
  20334. },
  20335. /**
  20336. * Get coord extent.
  20337. * @return {Array.<number>}
  20338. */
  20339. getExtent: function () {
  20340. var ret = this._extent.slice();
  20341. return ret;
  20342. },
  20343. /**
  20344. * Get precision used for formatting
  20345. * @param {Array.<number>} [dataExtent]
  20346. * @return {number}
  20347. */
  20348. getPixelPrecision: function (dataExtent) {
  20349. return numberUtil.getPixelPrecision(
  20350. dataExtent || this.scale.getExtent(),
  20351. this._extent
  20352. );
  20353. },
  20354. /**
  20355. * Set coord extent
  20356. * @param {number} start
  20357. * @param {number} end
  20358. */
  20359. setExtent: function (start, end) {
  20360. var extent = this._extent;
  20361. extent[0] = start;
  20362. extent[1] = end;
  20363. },
  20364. /**
  20365. * Convert data to coord. Data is the rank if it has a ordinal scale
  20366. * @param {number} data
  20367. * @param {boolean} clamp
  20368. * @return {number}
  20369. */
  20370. dataToCoord: function (data, clamp) {
  20371. var extent = this._extent;
  20372. var scale = this.scale;
  20373. data = scale.normalize(data);
  20374. if (this.onBand && scale.type === 'ordinal') {
  20375. extent = extent.slice();
  20376. fixExtentWithBands(extent, scale.count());
  20377. }
  20378. return linearMap(data, normalizedExtent, extent, clamp);
  20379. },
  20380. /**
  20381. * Convert coord to data. Data is the rank if it has a ordinal scale
  20382. * @param {number} coord
  20383. * @param {boolean} clamp
  20384. * @return {number}
  20385. */
  20386. coordToData: function (coord, clamp) {
  20387. var extent = this._extent;
  20388. var scale = this.scale;
  20389. if (this.onBand && scale.type === 'ordinal') {
  20390. extent = extent.slice();
  20391. fixExtentWithBands(extent, scale.count());
  20392. }
  20393. var t = linearMap(coord, extent, normalizedExtent, clamp);
  20394. return this.scale.scale(t);
  20395. },
  20396. /**
  20397. * @return {Array.<number>}
  20398. */
  20399. getTicksCoords: function () {
  20400. if (this.onBand) {
  20401. var bands = this.getBands();
  20402. var coords = [];
  20403. for (var i = 0; i < bands.length; i++) {
  20404. coords.push(bands[i][0]);
  20405. }
  20406. if (bands[i - 1]) {
  20407. coords.push(bands[i - 1][1]);
  20408. }
  20409. return coords;
  20410. }
  20411. else {
  20412. return zrUtil.map(this.scale.getTicks(), this.dataToCoord, this);
  20413. }
  20414. },
  20415. /**
  20416. * Coords of labels are on the ticks or on the middle of bands
  20417. * @return {Array.<number>}
  20418. */
  20419. getLabelsCoords: function () {
  20420. if (this.onBand) {
  20421. var bands = this.getBands();
  20422. var coords = [];
  20423. var band;
  20424. for (var i = 0; i < bands.length; i++) {
  20425. band = bands[i];
  20426. coords.push((band[0] + band[1]) / 2);
  20427. }
  20428. return coords;
  20429. }
  20430. else {
  20431. return zrUtil.map(this.scale.getTicks(), this.dataToCoord, this);
  20432. }
  20433. },
  20434. /**
  20435. * Get bands.
  20436. *
  20437. * If axis has labels [1, 2, 3, 4]. Bands on the axis are
  20438. * |---1---|---2---|---3---|---4---|.
  20439. *
  20440. * @return {Array}
  20441. */
  20442. // FIXME Situation when labels is on ticks
  20443. getBands: function () {
  20444. var extent = this.getExtent();
  20445. var bands = [];
  20446. var len = this.scale.count();
  20447. var start = extent[0];
  20448. var end = extent[1];
  20449. var span = end - start;
  20450. for (var i = 0; i < len; i++) {
  20451. bands.push([
  20452. span * i / len + start,
  20453. span * (i + 1) / len + start
  20454. ]);
  20455. }
  20456. return bands;
  20457. },
  20458. /**
  20459. * Get width of band
  20460. * @return {number}
  20461. */
  20462. getBandWidth: function () {
  20463. var axisExtent = this._extent;
  20464. var dataExtent = this.scale.getExtent();
  20465. var len = dataExtent[1] - dataExtent[0] + (this.onBand ? 1 : 0);
  20466. // Fix #2728, avoid NaN when only one data.
  20467. len === 0 && (len = 1);
  20468. var size = Math.abs(axisExtent[1] - axisExtent[0]);
  20469. return Math.abs(size) / len;
  20470. }
  20471. };
  20472. module.exports = Axis;
  20473. /***/ },
  20474. /* 119 */
  20475. /***/ function(module, exports, __webpack_require__) {
  20476. 'use strict';
  20477. /**
  20478. * Helper function for axisLabelInterval calculation
  20479. */
  20480. var zrUtil = __webpack_require__(3);
  20481. var axisHelper = __webpack_require__(109);
  20482. module.exports = function (axis) {
  20483. var axisModel = axis.model;
  20484. var labelModel = axisModel.getModel('axisLabel');
  20485. var labelInterval = labelModel.get('interval');
  20486. if (!(axis.type === 'category' && labelInterval === 'auto')) {
  20487. return labelInterval === 'auto' ? 0 : labelInterval;
  20488. }
  20489. return axisHelper.getAxisLabelInterval(
  20490. zrUtil.map(axis.scale.getTicks(), axis.dataToCoord, axis),
  20491. axisModel.getFormattedLabels(),
  20492. labelModel.getModel('textStyle').getFont(),
  20493. axis.isHorizontal()
  20494. );
  20495. };
  20496. /***/ },
  20497. /* 120 */
  20498. /***/ function(module, exports, __webpack_require__) {
  20499. 'use strict';
  20500. // Grid 是在有直角坐标系的时候必须要存在的
  20501. // 所以这里也要被 Cartesian2D 依赖
  20502. __webpack_require__(121);
  20503. var ComponentModel = __webpack_require__(19);
  20504. module.exports = ComponentModel.extend({
  20505. type: 'grid',
  20506. dependencies: ['xAxis', 'yAxis'],
  20507. layoutMode: 'box',
  20508. /**
  20509. * @type {module:echarts/coord/cartesian/Grid}
  20510. */
  20511. coordinateSystem: null,
  20512. defaultOption: {
  20513. show: false,
  20514. zlevel: 0,
  20515. z: 0,
  20516. left: '10%',
  20517. top: 60,
  20518. right: '10%',
  20519. bottom: 60,
  20520. // If grid size contain label
  20521. containLabel: false,
  20522. // width: {totalWidth} - left - right,
  20523. // height: {totalHeight} - top - bottom,
  20524. backgroundColor: 'rgba(0,0,0,0)',
  20525. borderWidth: 1,
  20526. borderColor: '#ccc'
  20527. }
  20528. });
  20529. /***/ },
  20530. /* 121 */
  20531. /***/ function(module, exports, __webpack_require__) {
  20532. 'use strict';
  20533. var ComponentModel = __webpack_require__(19);
  20534. var zrUtil = __webpack_require__(3);
  20535. var axisModelCreator = __webpack_require__(122);
  20536. var AxisModel = ComponentModel.extend({
  20537. type: 'cartesian2dAxis',
  20538. /**
  20539. * @type {module:echarts/coord/cartesian/Axis2D}
  20540. */
  20541. axis: null,
  20542. /**
  20543. * @override
  20544. */
  20545. init: function () {
  20546. AxisModel.superApply(this, 'init', arguments);
  20547. this._resetRange();
  20548. },
  20549. /**
  20550. * @override
  20551. */
  20552. mergeOption: function () {
  20553. AxisModel.superApply(this, 'mergeOption', arguments);
  20554. this._resetRange();
  20555. },
  20556. /**
  20557. * @override
  20558. */
  20559. restoreData: function () {
  20560. AxisModel.superApply(this, 'restoreData', arguments);
  20561. this._resetRange();
  20562. },
  20563. /**
  20564. * @public
  20565. * @param {number} rangeStart
  20566. * @param {number} rangeEnd
  20567. */
  20568. setRange: function (rangeStart, rangeEnd) {
  20569. this.option.rangeStart = rangeStart;
  20570. this.option.rangeEnd = rangeEnd;
  20571. },
  20572. /**
  20573. * @public
  20574. * @return {Array.<number|string|Date>}
  20575. */
  20576. getMin: function () {
  20577. var option = this.option;
  20578. return option.rangeStart != null ? option.rangeStart : option.min;
  20579. },
  20580. /**
  20581. * @public
  20582. * @return {Array.<number|string|Date>}
  20583. */
  20584. getMax: function () {
  20585. var option = this.option;
  20586. return option.rangeEnd != null ? option.rangeEnd : option.max;
  20587. },
  20588. /**
  20589. * @public
  20590. * @return {boolean}
  20591. */
  20592. getNeedCrossZero: function () {
  20593. var option = this.option;
  20594. return (option.rangeStart != null || option.rangeEnd != null)
  20595. ? false : !option.scale;
  20596. },
  20597. /**
  20598. * @private
  20599. */
  20600. _resetRange: function () {
  20601. // rangeStart and rangeEnd is readonly.
  20602. this.option.rangeStart = this.option.rangeEnd = null;
  20603. }
  20604. });
  20605. function getAxisType(axisDim, option) {
  20606. // Default axis with data is category axis
  20607. return option.type || (option.data ? 'category' : 'value');
  20608. }
  20609. zrUtil.merge(AxisModel.prototype, __webpack_require__(124));
  20610. var extraOption = {
  20611. gridIndex: 0
  20612. };
  20613. axisModelCreator('x', AxisModel, getAxisType, extraOption);
  20614. axisModelCreator('y', AxisModel, getAxisType, extraOption);
  20615. module.exports = AxisModel;
  20616. /***/ },
  20617. /* 122 */
  20618. /***/ function(module, exports, __webpack_require__) {
  20619. var axisDefault = __webpack_require__(123);
  20620. var zrUtil = __webpack_require__(3);
  20621. var ComponentModel = __webpack_require__(19);
  20622. var layout = __webpack_require__(21);
  20623. // FIXME axisType is fixed ?
  20624. var AXIS_TYPES = ['value', 'category', 'time', 'log'];
  20625. /**
  20626. * Generate sub axis model class
  20627. * @param {string} axisName 'x' 'y' 'radius' 'angle' 'parallel'
  20628. * @param {module:echarts/model/Component} BaseAxisModelClass
  20629. * @param {Function} axisTypeDefaulter
  20630. * @param {Object} [extraDefaultOption]
  20631. */
  20632. module.exports = function (axisName, BaseAxisModelClass, axisTypeDefaulter, extraDefaultOption) {
  20633. zrUtil.each(AXIS_TYPES, function (axisType) {
  20634. BaseAxisModelClass.extend({
  20635. type: axisName + 'Axis.' + axisType,
  20636. mergeDefaultAndTheme: function (option, ecModel) {
  20637. var layoutMode = this.layoutMode;
  20638. var inputPositionParams = layoutMode
  20639. ? layout.getLayoutParams(option) : {};
  20640. var themeModel = ecModel.getTheme();
  20641. zrUtil.merge(option, themeModel.get(axisType + 'Axis'));
  20642. zrUtil.merge(option, this.getDefaultOption());
  20643. option.type = axisTypeDefaulter(axisName, option);
  20644. if (layoutMode) {
  20645. layout.mergeLayoutParam(option, inputPositionParams, layoutMode);
  20646. }
  20647. },
  20648. defaultOption: zrUtil.mergeAll(
  20649. [
  20650. {},
  20651. axisDefault[axisType + 'Axis'],
  20652. extraDefaultOption
  20653. ],
  20654. true
  20655. )
  20656. });
  20657. });
  20658. ComponentModel.registerSubTypeDefaulter(
  20659. axisName + 'Axis',
  20660. zrUtil.curry(axisTypeDefaulter, axisName)
  20661. );
  20662. };
  20663. /***/ },
  20664. /* 123 */
  20665. /***/ function(module, exports, __webpack_require__) {
  20666. var zrUtil = __webpack_require__(3);
  20667. var defaultOption = {
  20668. show: true,
  20669. zlevel: 0, // 一级层叠
  20670. z: 0, // 二级层叠
  20671. // 反向坐标轴
  20672. inverse: false,
  20673. // 坐标轴名字,默认为空
  20674. name: '',
  20675. // 坐标轴名字位置,支持'start' | 'middle' | 'end'
  20676. nameLocation: 'end',
  20677. // 坐标轴文字样式,默认取全局样式
  20678. nameTextStyle: {},
  20679. // 文字与轴线距离
  20680. nameGap: 15,
  20681. // 是否能触发鼠标事件
  20682. silent: true,
  20683. // 坐标轴线
  20684. axisLine: {
  20685. // 默认显示,属性show控制显示与否
  20686. show: true,
  20687. onZero: true,
  20688. // 属性lineStyle控制线条样式
  20689. lineStyle: {
  20690. color: '#333',
  20691. width: 1,
  20692. type: 'solid'
  20693. }
  20694. },
  20695. // 坐标轴小标记
  20696. axisTick: {
  20697. // 属性show控制显示与否,默认显示
  20698. show: true,
  20699. // 控制小标记是否在grid里
  20700. inside: false,
  20701. // 属性length控制线长
  20702. length: 5,
  20703. // 属性lineStyle控制线条样式
  20704. lineStyle: {
  20705. color: '#333',
  20706. width: 1
  20707. }
  20708. },
  20709. // 坐标轴文本标签,详见axis.axisLabel
  20710. axisLabel: {
  20711. show: true,
  20712. // 控制文本标签是否在grid里
  20713. inside: false,
  20714. rotate: 0,
  20715. margin: 8,
  20716. // formatter: null,
  20717. // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  20718. textStyle: {
  20719. color: '#333',
  20720. fontSize: 12
  20721. }
  20722. },
  20723. // 分隔线
  20724. splitLine: {
  20725. // 默认显示,属性show控制显示与否
  20726. show: true,
  20727. // 属性lineStyle(详见lineStyle)控制线条样式
  20728. lineStyle: {
  20729. color: ['#ccc'],
  20730. width: 1,
  20731. type: 'solid'
  20732. }
  20733. },
  20734. // 分隔区域
  20735. splitArea: {
  20736. // 默认不显示,属性show控制显示与否
  20737. show: false,
  20738. // 属性areaStyle(详见areaStyle)控制区域样式
  20739. areaStyle: {
  20740. color: ['rgba(250,250,250,0.3)','rgba(200,200,200,0.3)']
  20741. }
  20742. }
  20743. };
  20744. var categoryAxis = zrUtil.merge({
  20745. // 类目起始和结束两端空白策略
  20746. boundaryGap: true,
  20747. // 坐标轴小标记
  20748. axisTick: {
  20749. interval: 'auto'
  20750. },
  20751. // 坐标轴文本标签,详见axis.axisLabel
  20752. axisLabel: {
  20753. interval: 'auto'
  20754. }
  20755. }, defaultOption);
  20756. var valueAxis = zrUtil.defaults({
  20757. // 数值起始和结束两端空白策略
  20758. boundaryGap: [0, 0],
  20759. // 最小值, 设置成 'dataMin' 则从数据中计算最小值
  20760. // min: null,
  20761. // 最大值,设置成 'dataMax' 则从数据中计算最大值
  20762. // max: null,
  20763. // Readonly prop, specifies start value of the range when using data zoom.
  20764. // rangeStart: null
  20765. // Readonly prop, specifies end value of the range when using data zoom.
  20766. // rangeEnd: null
  20767. // 脱离0值比例,放大聚焦到最终_min,_max区间
  20768. // scale: false,
  20769. // 分割段数,默认为5
  20770. splitNumber: 5
  20771. // Minimum interval
  20772. // minInterval: null
  20773. }, defaultOption);
  20774. // FIXME
  20775. var timeAxis = zrUtil.defaults({
  20776. scale: true,
  20777. min: 'dataMin',
  20778. max: 'dataMax'
  20779. }, valueAxis);
  20780. var logAxis = zrUtil.defaults({}, valueAxis);
  20781. logAxis.scale = true;
  20782. module.exports = {
  20783. categoryAxis: categoryAxis,
  20784. valueAxis: valueAxis,
  20785. timeAxis: timeAxis,
  20786. logAxis: logAxis
  20787. };
  20788. /***/ },
  20789. /* 124 */
  20790. /***/ function(module, exports, __webpack_require__) {
  20791. var zrUtil = __webpack_require__(3);
  20792. var axisHelper = __webpack_require__(109);
  20793. function getName(obj) {
  20794. if (zrUtil.isObject(obj) && obj.value != null) {
  20795. return obj.value;
  20796. }
  20797. else {
  20798. return obj;
  20799. }
  20800. }
  20801. /**
  20802. * Get categories
  20803. */
  20804. function getCategories() {
  20805. return this.get('type') === 'category'
  20806. && zrUtil.map(this.get('data'), getName);
  20807. }
  20808. /**
  20809. * Format labels
  20810. * @return {Array.<string>}
  20811. */
  20812. function getFormattedLabels() {
  20813. return axisHelper.getFormattedLabels(
  20814. this.axis,
  20815. this.get('axisLabel.formatter')
  20816. );
  20817. }
  20818. module.exports = {
  20819. getFormattedLabels: getFormattedLabels,
  20820. getCategories: getCategories
  20821. };
  20822. /***/ },
  20823. /* 125 */
  20824. /***/ function(module, exports, __webpack_require__) {
  20825. 'use strict';
  20826. // TODO boundaryGap
  20827. __webpack_require__(121);
  20828. __webpack_require__(126);
  20829. /***/ },
  20830. /* 126 */
  20831. /***/ function(module, exports, __webpack_require__) {
  20832. var zrUtil = __webpack_require__(3);
  20833. var graphic = __webpack_require__(42);
  20834. var AxisBuilder = __webpack_require__(127);
  20835. var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick;
  20836. var getInterval = AxisBuilder.getInterval;
  20837. var axisBuilderAttrs = [
  20838. 'axisLine', 'axisLabel', 'axisTick', 'axisName'
  20839. ];
  20840. var selfBuilderAttrs = [
  20841. 'splitLine', 'splitArea'
  20842. ];
  20843. var AxisView = __webpack_require__(1).extendComponentView({
  20844. type: 'axis',
  20845. render: function (axisModel, ecModel) {
  20846. this.group.removeAll();
  20847. if (!axisModel.get('show')) {
  20848. return;
  20849. }
  20850. var gridModel = ecModel.getComponent('grid', axisModel.get('gridIndex'));
  20851. var layout = layoutAxis(gridModel, axisModel);
  20852. var axisBuilder = new AxisBuilder(axisModel, layout);
  20853. zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder);
  20854. this.group.add(axisBuilder.getGroup());
  20855. zrUtil.each(selfBuilderAttrs, function (name) {
  20856. if (axisModel.get(name +'.show')) {
  20857. this['_' + name](axisModel, gridModel, layout.labelInterval);
  20858. }
  20859. }, this);
  20860. },
  20861. /**
  20862. * @param {module:echarts/coord/cartesian/AxisModel} axisModel
  20863. * @param {module:echarts/coord/cartesian/GridModel} gridModel
  20864. * @param {number|Function} labelInterval
  20865. * @private
  20866. */
  20867. _splitLine: function (axisModel, gridModel, labelInterval) {
  20868. var axis = axisModel.axis;
  20869. var splitLineModel = axisModel.getModel('splitLine');
  20870. var lineStyleModel = splitLineModel.getModel('lineStyle');
  20871. var lineWidth = lineStyleModel.get('width');
  20872. var lineColors = lineStyleModel.get('color');
  20873. var lineInterval = getInterval(splitLineModel, labelInterval);
  20874. lineColors = zrUtil.isArray(lineColors) ? lineColors : [lineColors];
  20875. var gridRect = gridModel.coordinateSystem.getRect();
  20876. var isHorizontal = axis.isHorizontal();
  20877. var splitLines = [];
  20878. var lineCount = 0;
  20879. var ticksCoords = axis.getTicksCoords();
  20880. var p1 = [];
  20881. var p2 = [];
  20882. for (var i = 0; i < ticksCoords.length; i++) {
  20883. if (ifIgnoreOnTick(axis, i, lineInterval)) {
  20884. continue;
  20885. }
  20886. var tickCoord = axis.toGlobalCoord(ticksCoords[i]);
  20887. if (isHorizontal) {
  20888. p1[0] = tickCoord;
  20889. p1[1] = gridRect.y;
  20890. p2[0] = tickCoord;
  20891. p2[1] = gridRect.y + gridRect.height;
  20892. }
  20893. else {
  20894. p1[0] = gridRect.x;
  20895. p1[1] = tickCoord;
  20896. p2[0] = gridRect.x + gridRect.width;
  20897. p2[1] = tickCoord;
  20898. }
  20899. var colorIndex = (lineCount++) % lineColors.length;
  20900. splitLines[colorIndex] = splitLines[colorIndex] || [];
  20901. splitLines[colorIndex].push(new graphic.Line(graphic.subPixelOptimizeLine({
  20902. shape: {
  20903. x1: p1[0],
  20904. y1: p1[1],
  20905. x2: p2[0],
  20906. y2: p2[1]
  20907. },
  20908. style: {
  20909. lineWidth: lineWidth
  20910. },
  20911. silent: true
  20912. })));
  20913. }
  20914. // Simple optimization
  20915. // Batching the lines if color are the same
  20916. var lineStyle = lineStyleModel.getLineStyle();
  20917. for (var i = 0; i < splitLines.length; i++) {
  20918. this.group.add(graphic.mergePath(splitLines[i], {
  20919. style: zrUtil.defaults({
  20920. stroke: lineColors[i % lineColors.length]
  20921. }, lineStyle),
  20922. silent: true
  20923. }));
  20924. }
  20925. },
  20926. /**
  20927. * @param {module:echarts/coord/cartesian/AxisModel} axisModel
  20928. * @param {module:echarts/coord/cartesian/GridModel} gridModel
  20929. * @param {number|Function} labelInterval
  20930. * @private
  20931. */
  20932. _splitArea: function (axisModel, gridModel, labelInterval) {
  20933. var axis = axisModel.axis;
  20934. var splitAreaModel = axisModel.getModel('splitArea');
  20935. var areaStyleModel = splitAreaModel.getModel('areaStyle');
  20936. var areaColors = areaStyleModel.get('color');
  20937. var gridRect = gridModel.coordinateSystem.getRect();
  20938. var ticksCoords = axis.getTicksCoords();
  20939. var prevX = axis.toGlobalCoord(ticksCoords[0]);
  20940. var prevY = axis.toGlobalCoord(ticksCoords[0]);
  20941. var splitAreaRects = [];
  20942. var count = 0;
  20943. var areaInterval = getInterval(splitAreaModel, labelInterval);
  20944. areaColors = zrUtil.isArray(areaColors) ? areaColors : [areaColors];
  20945. for (var i = 1; i < ticksCoords.length; i++) {
  20946. if (ifIgnoreOnTick(axis, i, areaInterval)) {
  20947. continue;
  20948. }
  20949. var tickCoord = axis.toGlobalCoord(ticksCoords[i]);
  20950. var x;
  20951. var y;
  20952. var width;
  20953. var height;
  20954. if (axis.isHorizontal()) {
  20955. x = prevX;
  20956. y = gridRect.y;
  20957. width = tickCoord - x;
  20958. height = gridRect.height;
  20959. }
  20960. else {
  20961. x = gridRect.x;
  20962. y = prevY;
  20963. width = gridRect.width;
  20964. height = tickCoord - y;
  20965. }
  20966. var colorIndex = (count++) % areaColors.length;
  20967. splitAreaRects[colorIndex] = splitAreaRects[colorIndex] || [];
  20968. splitAreaRects[colorIndex].push(new graphic.Rect({
  20969. shape: {
  20970. x: x,
  20971. y: y,
  20972. width: width,
  20973. height: height
  20974. },
  20975. silent: true
  20976. }));
  20977. prevX = x + width;
  20978. prevY = y + height;
  20979. }
  20980. // Simple optimization
  20981. // Batching the rects if color are the same
  20982. var areaStyle = areaStyleModel.getAreaStyle();
  20983. for (var i = 0; i < splitAreaRects.length; i++) {
  20984. this.group.add(graphic.mergePath(splitAreaRects[i], {
  20985. style: zrUtil.defaults({
  20986. fill: areaColors[i % areaColors.length]
  20987. }, areaStyle),
  20988. silent: true
  20989. }));
  20990. }
  20991. }
  20992. });
  20993. AxisView.extend({
  20994. type: 'xAxis'
  20995. });
  20996. AxisView.extend({
  20997. type: 'yAxis'
  20998. });
  20999. /**
  21000. * @inner
  21001. */
  21002. function layoutAxis(gridModel, axisModel) {
  21003. var grid = gridModel.coordinateSystem;
  21004. var axis = axisModel.axis;
  21005. var layout = {};
  21006. var rawAxisPosition = axis.position;
  21007. var axisPosition = axis.onZero ? 'onZero' : rawAxisPosition;
  21008. var axisDim = axis.dim;
  21009. // [left, right, top, bottom]
  21010. var rect = grid.getRect();
  21011. var rectBound = [rect.x, rect.x + rect.width, rect.y, rect.y + rect.height];
  21012. var posMap = {
  21013. x: {top: rectBound[2], bottom: rectBound[3]},
  21014. y: {left: rectBound[0], right: rectBound[1]}
  21015. };
  21016. posMap.x.onZero = Math.max(Math.min(getZero('y'), posMap.x.bottom), posMap.x.top);
  21017. posMap.y.onZero = Math.max(Math.min(getZero('x'), posMap.y.right), posMap.y.left);
  21018. function getZero(dim, val) {
  21019. var theAxis = grid.getAxis(dim);
  21020. return theAxis.toGlobalCoord(theAxis.dataToCoord(0));
  21021. }
  21022. // Axis position
  21023. layout.position = [
  21024. axisDim === 'y' ? posMap.y[axisPosition] : rectBound[0],
  21025. axisDim === 'x' ? posMap.x[axisPosition] : rectBound[3]
  21026. ];
  21027. // Axis rotation
  21028. var r = {x: 0, y: 1};
  21029. layout.rotation = Math.PI / 2 * r[axisDim];
  21030. // Tick and label direction, x y is axisDim
  21031. var dirMap = {top: -1, bottom: 1, left: -1, right: 1};
  21032. layout.labelDirection = layout.tickDirection = layout.nameDirection = dirMap[rawAxisPosition];
  21033. if (axis.onZero) {
  21034. layout.labelOffset = posMap[axisDim][rawAxisPosition] - posMap[axisDim].onZero;
  21035. }
  21036. if (axisModel.getModel('axisTick').get('inside')) {
  21037. layout.tickDirection = -layout.tickDirection;
  21038. }
  21039. if (axisModel.getModel('axisLabel').get('inside')) {
  21040. layout.labelDirection = -layout.labelDirection;
  21041. }
  21042. // Special label rotation
  21043. var labelRotation = axisModel.getModel('axisLabel').get('rotate');
  21044. layout.labelRotation = axisPosition === 'top' ? -labelRotation : labelRotation;
  21045. // label interval when auto mode.
  21046. layout.labelInterval = axis.getLabelInterval();
  21047. // Over splitLine and splitArea
  21048. layout.z2 = 1;
  21049. return layout;
  21050. }
  21051. /***/ },
  21052. /* 127 */
  21053. /***/ function(module, exports, __webpack_require__) {
  21054. var zrUtil = __webpack_require__(3);
  21055. var graphic = __webpack_require__(42);
  21056. var Model = __webpack_require__(8);
  21057. var numberUtil = __webpack_require__(7);
  21058. var remRadian = numberUtil.remRadian;
  21059. var isRadianAroundZero = numberUtil.isRadianAroundZero;
  21060. var PI = Math.PI;
  21061. function makeAxisEventDataBase(axisModel) {
  21062. var eventData = {
  21063. componentType: axisModel.mainType
  21064. };
  21065. eventData[axisModel.mainType + 'Index'] = axisModel.componentIndex;
  21066. return eventData;
  21067. }
  21068. /**
  21069. * A final axis is translated and rotated from a "standard axis".
  21070. * So opt.position and opt.rotation is required.
  21071. *
  21072. * A standard axis is and axis from [0, 0] to [0, axisExtent[1]],
  21073. * for example: (0, 0) ------------> (0, 50)
  21074. *
  21075. * nameDirection or tickDirection or labelDirection is 1 means tick
  21076. * or label is below the standard axis, whereas is -1 means above
  21077. * the standard axis. labelOffset means offset between label and axis,
  21078. * which is useful when 'onZero', where axisLabel is in the grid and
  21079. * label in outside grid.
  21080. *
  21081. * Tips: like always,
  21082. * positive rotation represents anticlockwise, and negative rotation
  21083. * represents clockwise.
  21084. * The direction of position coordinate is the same as the direction
  21085. * of screen coordinate.
  21086. *
  21087. * Do not need to consider axis 'inverse', which is auto processed by
  21088. * axis extent.
  21089. *
  21090. * @param {module:zrender/container/Group} group
  21091. * @param {Object} axisModel
  21092. * @param {Object} opt Standard axis parameters.
  21093. * @param {Array.<number>} opt.position [x, y]
  21094. * @param {number} opt.rotation by radian
  21095. * @param {number} [opt.nameDirection=1] 1 or -1 Used when nameLocation is 'middle'.
  21096. * @param {number} [opt.tickDirection=1] 1 or -1
  21097. * @param {number} [opt.labelDirection=1] 1 or -1
  21098. * @param {number} [opt.labelOffset=0] Usefull when onZero.
  21099. * @param {string} [opt.axisName] default get from axisModel.
  21100. * @param {number} [opt.labelRotation] by degree, default get from axisModel.
  21101. * @param {number} [opt.labelInterval] Default label interval when label
  21102. * interval from model is null or 'auto'.
  21103. * @param {number} [opt.strokeContainThreshold] Default label interval when label
  21104. * @param {number} [opt.axisLineSilent=true] If axis line is silent
  21105. */
  21106. var AxisBuilder = function (axisModel, opt) {
  21107. /**
  21108. * @readOnly
  21109. */
  21110. this.opt = opt;
  21111. /**
  21112. * @readOnly
  21113. */
  21114. this.axisModel = axisModel;
  21115. // Default value
  21116. zrUtil.defaults(
  21117. opt,
  21118. {
  21119. labelOffset: 0,
  21120. nameDirection: 1,
  21121. tickDirection: 1,
  21122. labelDirection: 1,
  21123. silent: true
  21124. }
  21125. );
  21126. /**
  21127. * @readOnly
  21128. */
  21129. this.group = new graphic.Group({
  21130. position: opt.position.slice(),
  21131. rotation: opt.rotation
  21132. });
  21133. };
  21134. AxisBuilder.prototype = {
  21135. constructor: AxisBuilder,
  21136. hasBuilder: function (name) {
  21137. return !!builders[name];
  21138. },
  21139. add: function (name) {
  21140. builders[name].call(this);
  21141. },
  21142. getGroup: function () {
  21143. return this.group;
  21144. }
  21145. };
  21146. var builders = {
  21147. /**
  21148. * @private
  21149. */
  21150. axisLine: function () {
  21151. var opt = this.opt;
  21152. var axisModel = this.axisModel;
  21153. if (!axisModel.get('axisLine.show')) {
  21154. return;
  21155. }
  21156. var extent = this.axisModel.axis.getExtent();
  21157. this.group.add(new graphic.Line({
  21158. shape: {
  21159. x1: extent[0],
  21160. y1: 0,
  21161. x2: extent[1],
  21162. y2: 0
  21163. },
  21164. style: zrUtil.extend(
  21165. {lineCap: 'round'},
  21166. axisModel.getModel('axisLine.lineStyle').getLineStyle()
  21167. ),
  21168. strokeContainThreshold: opt.strokeContainThreshold,
  21169. silent: !!opt.axisLineSilent,
  21170. z2: 1
  21171. }));
  21172. },
  21173. /**
  21174. * @private
  21175. */
  21176. axisTick: function () {
  21177. var axisModel = this.axisModel;
  21178. if (!axisModel.get('axisTick.show')) {
  21179. return;
  21180. }
  21181. var axis = axisModel.axis;
  21182. var tickModel = axisModel.getModel('axisTick');
  21183. var opt = this.opt;
  21184. var lineStyleModel = tickModel.getModel('lineStyle');
  21185. var tickLen = tickModel.get('length');
  21186. var tickInterval = getInterval(tickModel, opt.labelInterval);
  21187. var ticksCoords = axis.getTicksCoords();
  21188. var tickLines = [];
  21189. for (var i = 0; i < ticksCoords.length; i++) {
  21190. // Only ordinal scale support tick interval
  21191. if (ifIgnoreOnTick(axis, i, tickInterval)) {
  21192. continue;
  21193. }
  21194. var tickCoord = ticksCoords[i];
  21195. // Tick line
  21196. tickLines.push(new graphic.Line(graphic.subPixelOptimizeLine({
  21197. shape: {
  21198. x1: tickCoord,
  21199. y1: 0,
  21200. x2: tickCoord,
  21201. y2: opt.tickDirection * tickLen
  21202. },
  21203. style: {
  21204. lineWidth: lineStyleModel.get('width')
  21205. },
  21206. silent: true
  21207. })));
  21208. }
  21209. this.group.add(graphic.mergePath(tickLines, {
  21210. style: lineStyleModel.getLineStyle(),
  21211. z2: 2,
  21212. silent: true
  21213. }));
  21214. },
  21215. /**
  21216. * @param {module:echarts/coord/cartesian/AxisModel} axisModel
  21217. * @param {module:echarts/coord/cartesian/GridModel} gridModel
  21218. * @private
  21219. */
  21220. axisLabel: function () {
  21221. var axisModel = this.axisModel;
  21222. if (!axisModel.get('axisLabel.show')) {
  21223. return;
  21224. }
  21225. var opt = this.opt;
  21226. var axis = axisModel.axis;
  21227. var labelModel = axisModel.getModel('axisLabel');
  21228. var textStyleModel = labelModel.getModel('textStyle');
  21229. var labelMargin = labelModel.get('margin');
  21230. var ticks = axis.scale.getTicks();
  21231. var labels = axisModel.getFormattedLabels();
  21232. // Special label rotate.
  21233. var labelRotation = opt.labelRotation;
  21234. if (labelRotation == null) {
  21235. labelRotation = labelModel.get('rotate') || 0;
  21236. }
  21237. // To radian.
  21238. labelRotation = labelRotation * PI / 180;
  21239. var labelLayout = innerTextLayout(opt, labelRotation, opt.labelDirection);
  21240. var categoryData = axisModel.get('data');
  21241. var textEls = [];
  21242. var isSilent = axisModel.get('silent');
  21243. for (var i = 0; i < ticks.length; i++) {
  21244. if (ifIgnoreOnTick(axis, i, opt.labelInterval)) {
  21245. continue;
  21246. }
  21247. var itemTextStyleModel = textStyleModel;
  21248. if (categoryData && categoryData[i] && categoryData[i].textStyle) {
  21249. itemTextStyleModel = new Model(
  21250. categoryData[i].textStyle, textStyleModel, axisModel.ecModel
  21251. );
  21252. }
  21253. var textColor = itemTextStyleModel.getTextColor();
  21254. var tickCoord = axis.dataToCoord(ticks[i]);
  21255. var pos = [
  21256. tickCoord,
  21257. opt.labelOffset + opt.labelDirection * labelMargin
  21258. ];
  21259. var labelBeforeFormat = axis.scale.getLabel(ticks[i]);
  21260. var textEl = new graphic.Text({
  21261. style: {
  21262. text: labels[i],
  21263. textAlign: itemTextStyleModel.get('align', true) || labelLayout.textAlign,
  21264. textVerticalAlign: itemTextStyleModel.get('baseline', true) || labelLayout.verticalAlign,
  21265. textFont: itemTextStyleModel.getFont(),
  21266. fill: typeof textColor === 'function' ? textColor(labelBeforeFormat) : textColor
  21267. },
  21268. position: pos,
  21269. rotation: labelLayout.rotation,
  21270. silent: isSilent,
  21271. z2: 10
  21272. });
  21273. // Pack data for mouse event
  21274. textEl.eventData = makeAxisEventDataBase(axisModel);
  21275. textEl.eventData.targetType = 'axisLabel';
  21276. textEl.eventData.value = labelBeforeFormat;
  21277. textEls.push(textEl);
  21278. this.group.add(textEl);
  21279. }
  21280. function isTwoLabelOverlapped(current, next) {
  21281. var firstRect = current && current.getBoundingRect().clone();
  21282. var nextRect = next && next.getBoundingRect().clone();
  21283. if (firstRect && nextRect) {
  21284. firstRect.applyTransform(current.getLocalTransform());
  21285. nextRect.applyTransform(next.getLocalTransform());
  21286. return firstRect.intersect(nextRect);
  21287. }
  21288. }
  21289. if (axis.type !== 'category') {
  21290. // If min or max are user set, we need to check
  21291. // If the tick on min(max) are overlap on their neighbour tick
  21292. // If they are overlapped, we need to hide the min(max) tick label
  21293. if (axisModel.getMin ? axisModel.getMin() : axisModel.get('min')) {
  21294. var firstLabel = textEls[0];
  21295. var nextLabel = textEls[1];
  21296. if (isTwoLabelOverlapped(firstLabel, nextLabel)) {
  21297. firstLabel.ignore = true;
  21298. }
  21299. }
  21300. if (axisModel.getMax ? axisModel.getMax() : axisModel.get('max')) {
  21301. var lastLabel = textEls[textEls.length - 1];
  21302. var prevLabel = textEls[textEls.length - 2];
  21303. if (isTwoLabelOverlapped(prevLabel, lastLabel)) {
  21304. lastLabel.ignore = true;
  21305. }
  21306. }
  21307. }
  21308. },
  21309. /**
  21310. * @private
  21311. */
  21312. axisName: function () {
  21313. var opt = this.opt;
  21314. var axisModel = this.axisModel;
  21315. var name = this.opt.axisName;
  21316. // If name is '', do not get name from axisMode.
  21317. if (name == null) {
  21318. name = axisModel.get('name');
  21319. }
  21320. if (!name) {
  21321. return;
  21322. }
  21323. var nameLocation = axisModel.get('nameLocation');
  21324. var nameDirection = opt.nameDirection;
  21325. var textStyleModel = axisModel.getModel('nameTextStyle');
  21326. var gap = axisModel.get('nameGap') || 0;
  21327. var extent = this.axisModel.axis.getExtent();
  21328. var gapSignal = extent[0] > extent[1] ? -1 : 1;
  21329. var pos = [
  21330. nameLocation === 'start'
  21331. ? extent[0] - gapSignal * gap
  21332. : nameLocation === 'end'
  21333. ? extent[1] + gapSignal * gap
  21334. : (extent[0] + extent[1]) / 2, // 'middle'
  21335. // Reuse labelOffset.
  21336. nameLocation === 'middle' ? opt.labelOffset + nameDirection * gap : 0
  21337. ];
  21338. var labelLayout;
  21339. if (nameLocation === 'middle') {
  21340. labelLayout = innerTextLayout(opt, opt.rotation, nameDirection);
  21341. }
  21342. else {
  21343. labelLayout = endTextLayout(opt, nameLocation, extent);
  21344. }
  21345. var textEl = new graphic.Text({
  21346. style: {
  21347. text: name,
  21348. textFont: textStyleModel.getFont(),
  21349. fill: textStyleModel.getTextColor()
  21350. || axisModel.get('axisLine.lineStyle.color'),
  21351. textAlign: labelLayout.textAlign,
  21352. textVerticalAlign: labelLayout.verticalAlign
  21353. },
  21354. position: pos,
  21355. rotation: labelLayout.rotation,
  21356. silent: axisModel.get('silent'),
  21357. z2: 1
  21358. });
  21359. textEl.eventData = makeAxisEventDataBase(axisModel);
  21360. textEl.eventData.targetType = 'axisName';
  21361. textEl.eventData.name = name;
  21362. this.group.add(textEl);
  21363. }
  21364. };
  21365. /**
  21366. * @inner
  21367. */
  21368. function innerTextLayout(opt, textRotation, direction) {
  21369. var rotationDiff = remRadian(textRotation - opt.rotation);
  21370. var textAlign;
  21371. var verticalAlign;
  21372. if (isRadianAroundZero(rotationDiff)) { // Label is parallel with axis line.
  21373. verticalAlign = direction > 0 ? 'top' : 'bottom';
  21374. textAlign = 'center';
  21375. }
  21376. else if (isRadianAroundZero(rotationDiff - PI)) { // Label is inverse parallel with axis line.
  21377. verticalAlign = direction > 0 ? 'bottom' : 'top';
  21378. textAlign = 'center';
  21379. }
  21380. else {
  21381. verticalAlign = 'middle';
  21382. if (rotationDiff > 0 && rotationDiff < PI) {
  21383. textAlign = direction > 0 ? 'right' : 'left';
  21384. }
  21385. else {
  21386. textAlign = direction > 0 ? 'left' : 'right';
  21387. }
  21388. }
  21389. return {
  21390. rotation: rotationDiff,
  21391. textAlign: textAlign,
  21392. verticalAlign: verticalAlign
  21393. };
  21394. }
  21395. /**
  21396. * @inner
  21397. */
  21398. function endTextLayout(opt, textPosition, extent) {
  21399. var rotationDiff = remRadian(-opt.rotation);
  21400. var textAlign;
  21401. var verticalAlign;
  21402. var inverse = extent[0] > extent[1];
  21403. var onLeft = (textPosition === 'start' && !inverse)
  21404. || (textPosition !== 'start' && inverse);
  21405. if (isRadianAroundZero(rotationDiff - PI / 2)) {
  21406. verticalAlign = onLeft ? 'bottom' : 'top';
  21407. textAlign = 'center';
  21408. }
  21409. else if (isRadianAroundZero(rotationDiff - PI * 1.5)) {
  21410. verticalAlign = onLeft ? 'top' : 'bottom';
  21411. textAlign = 'center';
  21412. }
  21413. else {
  21414. verticalAlign = 'middle';
  21415. if (rotationDiff < PI * 1.5 && rotationDiff > PI / 2) {
  21416. textAlign = onLeft ? 'left' : 'right';
  21417. }
  21418. else {
  21419. textAlign = onLeft ? 'right' : 'left';
  21420. }
  21421. }
  21422. return {
  21423. rotation: rotationDiff,
  21424. textAlign: textAlign,
  21425. verticalAlign: verticalAlign
  21426. };
  21427. }
  21428. /**
  21429. * @static
  21430. */
  21431. var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick = function (axis, i, interval) {
  21432. var rawTick;
  21433. var scale = axis.scale;
  21434. return scale.type === 'ordinal'
  21435. && (
  21436. typeof interval === 'function'
  21437. ? (
  21438. rawTick = scale.getTicks()[i],
  21439. !interval(rawTick, scale.getLabel(rawTick))
  21440. )
  21441. : i % (interval + 1)
  21442. );
  21443. };
  21444. /**
  21445. * @static
  21446. */
  21447. var getInterval = AxisBuilder.getInterval = function (model, labelInterval) {
  21448. var interval = model.get('interval');
  21449. if (interval == null || interval == 'auto') {
  21450. interval = labelInterval;
  21451. }
  21452. return interval;
  21453. };
  21454. module.exports = AxisBuilder;
  21455. /***/ },
  21456. /* 128 */
  21457. /***/ function(module, exports, __webpack_require__) {
  21458. var zrUtil = __webpack_require__(3);
  21459. __webpack_require__(108);
  21460. __webpack_require__(129);
  21461. __webpack_require__(130);
  21462. var barLayoutGrid = __webpack_require__(132);
  21463. var echarts = __webpack_require__(1);
  21464. echarts.registerLayout(zrUtil.curry(barLayoutGrid, 'bar'));
  21465. // Visual coding for legend
  21466. echarts.registerVisualCoding('chart', function (ecModel) {
  21467. ecModel.eachSeriesByType('bar', function (seriesModel) {
  21468. var data = seriesModel.getData();
  21469. data.setVisual('legendSymbol', 'roundRect');
  21470. });
  21471. });
  21472. // In case developer forget to include grid component
  21473. __webpack_require__(107);
  21474. /***/ },
  21475. /* 129 */
  21476. /***/ function(module, exports, __webpack_require__) {
  21477. 'use strict';
  21478. var SeriesModel = __webpack_require__(27);
  21479. var createListFromArray = __webpack_require__(94);
  21480. module.exports = SeriesModel.extend({
  21481. type: 'series.bar',
  21482. dependencies: ['grid', 'polar'],
  21483. getInitialData: function (option, ecModel) {
  21484. return createListFromArray(option.data, this, ecModel);
  21485. },
  21486. getMarkerPosition: function (value) {
  21487. var coordSys = this.coordinateSystem;
  21488. if (coordSys) {
  21489. var pt = coordSys.dataToPoint(value);
  21490. var data = this.getData();
  21491. var offset = data.getLayout('offset');
  21492. var size = data.getLayout('size');
  21493. var offsetIndex = coordSys.getBaseAxis().isHorizontal() ? 0 : 1;
  21494. pt[offsetIndex] += offset + size / 2;
  21495. return pt;
  21496. }
  21497. return [NaN, NaN];
  21498. },
  21499. defaultOption: {
  21500. zlevel: 0, // 一级层叠
  21501. z: 2, // 二级层叠
  21502. coordinateSystem: 'cartesian2d',
  21503. legendHoverLink: true,
  21504. // stack: null
  21505. // Cartesian coordinate system
  21506. xAxisIndex: 0,
  21507. yAxisIndex: 0,
  21508. // 最小高度改为0
  21509. barMinHeight: 0,
  21510. // barMaxWidth: null,
  21511. // 默认自适应
  21512. // barWidth: null,
  21513. // 柱间距离,默认为柱形宽度的30%,可设固定值
  21514. // barGap: '30%',
  21515. // 类目间柱形距离,默认为类目间距的20%,可设固定值
  21516. // barCategoryGap: '20%',
  21517. // label: {
  21518. // normal: {
  21519. // show: false
  21520. // }
  21521. // },
  21522. itemStyle: {
  21523. normal: {
  21524. // color: '各异',
  21525. // 柱条边线
  21526. barBorderColor: '#fff',
  21527. // 柱条边线线宽,单位px,默认为1
  21528. barBorderWidth: 0
  21529. },
  21530. emphasis: {
  21531. // color: '各异',
  21532. // 柱条边线
  21533. barBorderColor: '#fff',
  21534. // 柱条边线线宽,单位px,默认为1
  21535. barBorderWidth: 0
  21536. }
  21537. }
  21538. }
  21539. });
  21540. /***/ },
  21541. /* 130 */
  21542. /***/ function(module, exports, __webpack_require__) {
  21543. 'use strict';
  21544. var zrUtil = __webpack_require__(3);
  21545. var graphic = __webpack_require__(42);
  21546. zrUtil.extend(__webpack_require__(8).prototype, __webpack_require__(131));
  21547. function fixLayoutWithLineWidth(layout, lineWidth) {
  21548. var signX = layout.width > 0 ? 1 : -1;
  21549. var signY = layout.height > 0 ? 1 : -1;
  21550. // In case width or height are too small.
  21551. lineWidth = Math.min(lineWidth, Math.abs(layout.width), Math.abs(layout.height));
  21552. layout.x += signX * lineWidth / 2;
  21553. layout.y += signY * lineWidth / 2;
  21554. layout.width -= signX * lineWidth;
  21555. layout.height -= signY * lineWidth;
  21556. }
  21557. module.exports = __webpack_require__(1).extendChartView({
  21558. type: 'bar',
  21559. render: function (seriesModel, ecModel, api) {
  21560. var coordinateSystemType = seriesModel.get('coordinateSystem');
  21561. if (coordinateSystemType === 'cartesian2d') {
  21562. this._renderOnCartesian(seriesModel, ecModel, api);
  21563. }
  21564. return this.group;
  21565. },
  21566. _renderOnCartesian: function (seriesModel, ecModel, api) {
  21567. var group = this.group;
  21568. var data = seriesModel.getData();
  21569. var oldData = this._data;
  21570. var cartesian = seriesModel.coordinateSystem;
  21571. var baseAxis = cartesian.getBaseAxis();
  21572. var isHorizontal = baseAxis.isHorizontal();
  21573. var enableAnimation = seriesModel.get('animation');
  21574. var barBorderWidthQuery = ['itemStyle', 'normal', 'barBorderWidth'];
  21575. function createRect(dataIndex, isUpdate) {
  21576. var layout = data.getItemLayout(dataIndex);
  21577. var lineWidth = data.getItemModel(dataIndex).get(barBorderWidthQuery) || 0;
  21578. fixLayoutWithLineWidth(layout, lineWidth);
  21579. var rect = new graphic.Rect({
  21580. shape: zrUtil.extend({}, layout)
  21581. });
  21582. // Animation
  21583. if (enableAnimation) {
  21584. var rectShape = rect.shape;
  21585. var animateProperty = isHorizontal ? 'height' : 'width';
  21586. var animateTarget = {};
  21587. rectShape[animateProperty] = 0;
  21588. animateTarget[animateProperty] = layout[animateProperty];
  21589. graphic[isUpdate? 'updateProps' : 'initProps'](rect, {
  21590. shape: animateTarget
  21591. }, seriesModel, dataIndex);
  21592. }
  21593. return rect;
  21594. }
  21595. data.diff(oldData)
  21596. .add(function (dataIndex) {
  21597. // 空数据
  21598. if (!data.hasValue(dataIndex)) {
  21599. return;
  21600. }
  21601. var rect = createRect(dataIndex);
  21602. data.setItemGraphicEl(dataIndex, rect);
  21603. group.add(rect);
  21604. })
  21605. .update(function (newIndex, oldIndex) {
  21606. var rect = oldData.getItemGraphicEl(oldIndex);
  21607. // 空数据
  21608. if (!data.hasValue(newIndex)) {
  21609. group.remove(rect);
  21610. return;
  21611. }
  21612. if (!rect) {
  21613. rect = createRect(newIndex, true);
  21614. }
  21615. var layout = data.getItemLayout(newIndex);
  21616. var lineWidth = data.getItemModel(newIndex).get(barBorderWidthQuery) || 0;
  21617. fixLayoutWithLineWidth(layout, lineWidth);
  21618. graphic.updateProps(rect, {
  21619. shape: layout
  21620. }, seriesModel, newIndex);
  21621. data.setItemGraphicEl(newIndex, rect);
  21622. // Add back
  21623. group.add(rect);
  21624. })
  21625. .remove(function (idx) {
  21626. var rect = oldData.getItemGraphicEl(idx);
  21627. if (rect) {
  21628. // Not show text when animating
  21629. rect.style.text = '';
  21630. graphic.updateProps(rect, {
  21631. shape: {
  21632. width: 0
  21633. }
  21634. }, seriesModel, idx, function () {
  21635. group.remove(rect);
  21636. });
  21637. }
  21638. })
  21639. .execute();
  21640. this._updateStyle(seriesModel, data, isHorizontal);
  21641. this._data = data;
  21642. },
  21643. _updateStyle: function (seriesModel, data, isHorizontal) {
  21644. function setLabel(style, model, color, labelText, labelPositionOutside) {
  21645. graphic.setText(style, model, color);
  21646. style.text = labelText;
  21647. if (style.textPosition === 'outside') {
  21648. style.textPosition = labelPositionOutside;
  21649. }
  21650. }
  21651. data.eachItemGraphicEl(function (rect, idx) {
  21652. var itemModel = data.getItemModel(idx);
  21653. var color = data.getItemVisual(idx, 'color');
  21654. var opacity = data.getItemVisual(idx, 'opacity');
  21655. var layout = data.getItemLayout(idx);
  21656. var itemStyleModel = itemModel.getModel('itemStyle.normal');
  21657. var hoverStyle = itemModel.getModel('itemStyle.emphasis').getBarItemStyle();
  21658. rect.setShape('r', itemStyleModel.get('barBorderRadius') || 0);
  21659. rect.useStyle(zrUtil.defaults(
  21660. {
  21661. fill: color,
  21662. opacity: opacity
  21663. },
  21664. itemStyleModel.getBarItemStyle()
  21665. ));
  21666. var labelPositionOutside = isHorizontal
  21667. ? (layout.height > 0 ? 'bottom' : 'top')
  21668. : (layout.width > 0 ? 'left' : 'right');
  21669. var labelModel = itemModel.getModel('label.normal');
  21670. var hoverLabelModel = itemModel.getModel('label.emphasis');
  21671. var rectStyle = rect.style;
  21672. if (labelModel.get('show')) {
  21673. setLabel(
  21674. rectStyle, labelModel, color,
  21675. zrUtil.retrieve(
  21676. seriesModel.getFormattedLabel(idx, 'normal'),
  21677. seriesModel.getRawValue(idx)
  21678. ),
  21679. labelPositionOutside
  21680. );
  21681. }
  21682. else {
  21683. rectStyle.text = '';
  21684. }
  21685. if (hoverLabelModel.get('show')) {
  21686. setLabel(
  21687. hoverStyle, hoverLabelModel, color,
  21688. zrUtil.retrieve(
  21689. seriesModel.getFormattedLabel(idx, 'emphasis'),
  21690. seriesModel.getRawValue(idx)
  21691. ),
  21692. labelPositionOutside
  21693. );
  21694. }
  21695. else {
  21696. hoverStyle.text = '';
  21697. }
  21698. graphic.setHoverStyle(rect, hoverStyle);
  21699. });
  21700. },
  21701. remove: function (ecModel, api) {
  21702. var group = this.group;
  21703. if (ecModel.get('animation')) {
  21704. if (this._data) {
  21705. this._data.eachItemGraphicEl(function (el) {
  21706. // Not show text when animating
  21707. el.style.text = '';
  21708. graphic.updateProps(el, {
  21709. shape: {
  21710. width: 0
  21711. }
  21712. }, ecModel, el.dataIndex, function () {
  21713. group.remove(el);
  21714. });
  21715. });
  21716. }
  21717. }
  21718. else {
  21719. group.removeAll();
  21720. }
  21721. }
  21722. });
  21723. /***/ },
  21724. /* 131 */
  21725. /***/ function(module, exports, __webpack_require__) {
  21726. module.exports = {
  21727. getBarItemStyle: __webpack_require__(11)(
  21728. [
  21729. ['fill', 'color'],
  21730. ['stroke', 'borderColor'],
  21731. ['lineWidth', 'borderWidth'],
  21732. // Compatitable with 2
  21733. ['stroke', 'barBorderColor'],
  21734. ['lineWidth', 'barBorderWidth'],
  21735. ['opacity'],
  21736. ['shadowBlur'],
  21737. ['shadowOffsetX'],
  21738. ['shadowOffsetY'],
  21739. ['shadowColor']
  21740. ]
  21741. )
  21742. };
  21743. /***/ },
  21744. /* 132 */
  21745. /***/ function(module, exports, __webpack_require__) {
  21746. 'use strict';
  21747. var zrUtil = __webpack_require__(3);
  21748. var numberUtil = __webpack_require__(7);
  21749. var parsePercent = numberUtil.parsePercent;
  21750. function getSeriesStackId(seriesModel) {
  21751. return seriesModel.get('stack') || '__ec_stack_' + seriesModel.seriesIndex;
  21752. }
  21753. function calBarWidthAndOffset(barSeries, api) {
  21754. // Columns info on each category axis. Key is cartesian name
  21755. var columnsMap = {};
  21756. zrUtil.each(barSeries, function (seriesModel, idx) {
  21757. var cartesian = seriesModel.coordinateSystem;
  21758. var baseAxis = cartesian.getBaseAxis();
  21759. var columnsOnAxis = columnsMap[baseAxis.index] || {
  21760. remainedWidth: baseAxis.getBandWidth(),
  21761. autoWidthCount: 0,
  21762. categoryGap: '20%',
  21763. gap: '30%',
  21764. axis: baseAxis,
  21765. stacks: {}
  21766. };
  21767. var stacks = columnsOnAxis.stacks;
  21768. columnsMap[baseAxis.index] = columnsOnAxis;
  21769. var stackId = getSeriesStackId(seriesModel);
  21770. if (!stacks[stackId]) {
  21771. columnsOnAxis.autoWidthCount++;
  21772. }
  21773. stacks[stackId] = stacks[stackId] || {
  21774. width: 0,
  21775. maxWidth: 0
  21776. };
  21777. var barWidth = seriesModel.get('barWidth');
  21778. var barMaxWidth = seriesModel.get('barMaxWidth');
  21779. var barGap = seriesModel.get('barGap');
  21780. var barCategoryGap = seriesModel.get('barCategoryGap');
  21781. // TODO
  21782. if (barWidth && ! stacks[stackId].width) {
  21783. barWidth = Math.min(columnsOnAxis.remainedWidth, barWidth);
  21784. stacks[stackId].width = barWidth;
  21785. columnsOnAxis.remainedWidth -= barWidth;
  21786. }
  21787. barMaxWidth && (stacks[stackId].maxWidth = barMaxWidth);
  21788. (barGap != null) && (columnsOnAxis.gap = barGap);
  21789. (barCategoryGap != null) && (columnsOnAxis.categoryGap = barCategoryGap);
  21790. });
  21791. var result = {};
  21792. zrUtil.each(columnsMap, function (columnsOnAxis, coordSysName) {
  21793. result[coordSysName] = {};
  21794. var stacks = columnsOnAxis.stacks;
  21795. var baseAxis = columnsOnAxis.axis;
  21796. var bandWidth = baseAxis.getBandWidth();
  21797. var categoryGap = parsePercent(columnsOnAxis.categoryGap, bandWidth);
  21798. var barGapPercent = parsePercent(columnsOnAxis.gap, 1);
  21799. var remainedWidth = columnsOnAxis.remainedWidth;
  21800. var autoWidthCount = columnsOnAxis.autoWidthCount;
  21801. var autoWidth = (remainedWidth - categoryGap)
  21802. / (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
  21803. autoWidth = Math.max(autoWidth, 0);
  21804. // Find if any auto calculated bar exceeded maxBarWidth
  21805. zrUtil.each(stacks, function (column, stack) {
  21806. var maxWidth = column.maxWidth;
  21807. if (!column.width && maxWidth && maxWidth < autoWidth) {
  21808. maxWidth = Math.min(maxWidth, remainedWidth);
  21809. remainedWidth -= maxWidth;
  21810. column.width = maxWidth;
  21811. autoWidthCount--;
  21812. }
  21813. });
  21814. // Recalculate width again
  21815. autoWidth = (remainedWidth - categoryGap)
  21816. / (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
  21817. autoWidth = Math.max(autoWidth, 0);
  21818. var widthSum = 0;
  21819. var lastColumn;
  21820. zrUtil.each(stacks, function (column, idx) {
  21821. if (!column.width) {
  21822. column.width = autoWidth;
  21823. }
  21824. lastColumn = column;
  21825. widthSum += column.width * (1 + barGapPercent);
  21826. });
  21827. if (lastColumn) {
  21828. widthSum -= lastColumn.width * barGapPercent;
  21829. }
  21830. var offset = -widthSum / 2;
  21831. zrUtil.each(stacks, function (column, stackId) {
  21832. result[coordSysName][stackId] = result[coordSysName][stackId] || {
  21833. offset: offset,
  21834. width: column.width
  21835. };
  21836. offset += column.width * (1 + barGapPercent);
  21837. });
  21838. });
  21839. return result;
  21840. }
  21841. /**
  21842. * @param {string} seriesType
  21843. * @param {module:echarts/model/Global} ecModel
  21844. * @param {module:echarts/ExtensionAPI} api
  21845. */
  21846. function barLayoutGrid(seriesType, ecModel, api) {
  21847. var barWidthAndOffset = calBarWidthAndOffset(
  21848. zrUtil.filter(
  21849. ecModel.getSeriesByType(seriesType),
  21850. function (seriesModel) {
  21851. return !ecModel.isSeriesFiltered(seriesModel)
  21852. && seriesModel.coordinateSystem
  21853. && seriesModel.coordinateSystem.type === 'cartesian2d';
  21854. }
  21855. )
  21856. );
  21857. var lastStackCoords = {};
  21858. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  21859. var data = seriesModel.getData();
  21860. var cartesian = seriesModel.coordinateSystem;
  21861. var baseAxis = cartesian.getBaseAxis();
  21862. var stackId = getSeriesStackId(seriesModel);
  21863. var columnLayoutInfo = barWidthAndOffset[baseAxis.index][stackId];
  21864. var columnOffset = columnLayoutInfo.offset;
  21865. var columnWidth = columnLayoutInfo.width;
  21866. var valueAxis = cartesian.getOtherAxis(baseAxis);
  21867. var barMinHeight = seriesModel.get('barMinHeight') || 0;
  21868. var valueAxisStart = baseAxis.onZero
  21869. ? valueAxis.toGlobalCoord(valueAxis.dataToCoord(0))
  21870. : valueAxis.getGlobalExtent()[0];
  21871. var coords = cartesian.dataToPoints(data, true);
  21872. lastStackCoords[stackId] = lastStackCoords[stackId] || [];
  21873. data.setLayout({
  21874. offset: columnOffset,
  21875. size: columnWidth
  21876. });
  21877. data.each(valueAxis.dim, function (value, idx) {
  21878. // 空数据
  21879. if (isNaN(value)) {
  21880. return;
  21881. }
  21882. if (!lastStackCoords[stackId][idx]) {
  21883. lastStackCoords[stackId][idx] = {
  21884. // Positive stack
  21885. p: valueAxisStart,
  21886. // Negative stack
  21887. n: valueAxisStart
  21888. };
  21889. }
  21890. var sign = value >= 0 ? 'p' : 'n';
  21891. var coord = coords[idx];
  21892. var lastCoord = lastStackCoords[stackId][idx][sign];
  21893. var x, y, width, height;
  21894. if (valueAxis.isHorizontal()) {
  21895. x = lastCoord;
  21896. y = coord[1] + columnOffset;
  21897. width = coord[0] - lastCoord;
  21898. height = columnWidth;
  21899. if (Math.abs(width) < barMinHeight) {
  21900. width = (width < 0 ? -1 : 1) * barMinHeight;
  21901. }
  21902. lastStackCoords[stackId][idx][sign] += width;
  21903. }
  21904. else {
  21905. x = coord[0] + columnOffset;
  21906. y = lastCoord;
  21907. width = columnWidth;
  21908. height = coord[1] - lastCoord;
  21909. if (Math.abs(height) < barMinHeight) {
  21910. // Include zero to has a positive bar
  21911. height = (height <= 0 ? -1 : 1) * barMinHeight;
  21912. }
  21913. lastStackCoords[stackId][idx][sign] += height;
  21914. }
  21915. data.setItemLayout(idx, {
  21916. x: x,
  21917. y: y,
  21918. width: width,
  21919. height: height
  21920. });
  21921. }, true);
  21922. }, this);
  21923. }
  21924. module.exports = barLayoutGrid;
  21925. /***/ },
  21926. /* 133 */
  21927. /***/ function(module, exports, __webpack_require__) {
  21928. var zrUtil = __webpack_require__(3);
  21929. var echarts = __webpack_require__(1);
  21930. __webpack_require__(134);
  21931. __webpack_require__(136);
  21932. __webpack_require__(137)('pie', [{
  21933. type: 'pieToggleSelect',
  21934. event: 'pieselectchanged',
  21935. method: 'toggleSelected'
  21936. }, {
  21937. type: 'pieSelect',
  21938. event: 'pieselected',
  21939. method: 'select'
  21940. }, {
  21941. type: 'pieUnSelect',
  21942. event: 'pieunselected',
  21943. method: 'unSelect'
  21944. }]);
  21945. echarts.registerVisualCoding(
  21946. 'chart', zrUtil.curry(__webpack_require__(138), 'pie')
  21947. );
  21948. echarts.registerLayout(zrUtil.curry(
  21949. __webpack_require__(139), 'pie'
  21950. ));
  21951. echarts.registerProcessor(
  21952. 'filter', zrUtil.curry(__webpack_require__(141), 'pie')
  21953. );
  21954. /***/ },
  21955. /* 134 */
  21956. /***/ function(module, exports, __webpack_require__) {
  21957. 'use strict';
  21958. var List = __webpack_require__(95);
  21959. var zrUtil = __webpack_require__(3);
  21960. var modelUtil = __webpack_require__(5);
  21961. var completeDimensions = __webpack_require__(97);
  21962. var dataSelectableMixin = __webpack_require__(135);
  21963. var PieSeries = __webpack_require__(1).extendSeriesModel({
  21964. type: 'series.pie',
  21965. // Overwrite
  21966. init: function (option) {
  21967. PieSeries.superApply(this, 'init', arguments);
  21968. // Enable legend selection for each data item
  21969. // Use a function instead of direct access because data reference may changed
  21970. this.legendDataProvider = function () {
  21971. return this._dataBeforeProcessed;
  21972. };
  21973. this.updateSelectedMap(option.data);
  21974. this._defaultLabelLine(option);
  21975. },
  21976. // Overwrite
  21977. mergeOption: function (newOption) {
  21978. PieSeries.superCall(this, 'mergeOption', newOption);
  21979. this.updateSelectedMap(this.option.data);
  21980. },
  21981. getInitialData: function (option, ecModel) {
  21982. var dimensions = completeDimensions(['value'], option.data);
  21983. var list = new List(dimensions, this);
  21984. list.initData(option.data);
  21985. return list;
  21986. },
  21987. // Overwrite
  21988. getDataParams: function (dataIndex) {
  21989. var data = this._data;
  21990. var params = PieSeries.superCall(this, 'getDataParams', dataIndex);
  21991. var sum = data.getSum('value');
  21992. // FIXME toFixed?
  21993. //
  21994. // Percent is 0 if sum is 0
  21995. params.percent = !sum ? 0 : +(data.get('value', dataIndex) / sum * 100).toFixed(2);
  21996. params.$vars.push('percent');
  21997. return params;
  21998. },
  21999. _defaultLabelLine: function (option) {
  22000. // Extend labelLine emphasis
  22001. modelUtil.defaultEmphasis(option.labelLine, ['show']);
  22002. var labelLineNormalOpt = option.labelLine.normal;
  22003. var labelLineEmphasisOpt = option.labelLine.emphasis;
  22004. // Not show label line if `label.normal.show = false`
  22005. labelLineNormalOpt.show = labelLineNormalOpt.show
  22006. && option.label.normal.show;
  22007. labelLineEmphasisOpt.show = labelLineEmphasisOpt.show
  22008. && option.label.emphasis.show;
  22009. },
  22010. defaultOption: {
  22011. zlevel: 0,
  22012. z: 2,
  22013. legendHoverLink: true,
  22014. hoverAnimation: true,
  22015. // 默认全局居中
  22016. center: ['50%', '50%'],
  22017. radius: [0, '75%'],
  22018. // 默认顺时针
  22019. clockwise: true,
  22020. startAngle: 90,
  22021. // 最小角度改为0
  22022. minAngle: 0,
  22023. // 选中是扇区偏移量
  22024. selectedOffset: 10,
  22025. // If use strategy to avoid label overlapping
  22026. avoidLabelOverlap: true,
  22027. // 选择模式,默认关闭,可选single,multiple
  22028. // selectedMode: false,
  22029. // 南丁格尔玫瑰图模式,'radius'(半径) | 'area'(面积)
  22030. // roseType: null,
  22031. label: {
  22032. normal: {
  22033. // If rotate around circle
  22034. rotate: false,
  22035. show: true,
  22036. // 'outer', 'inside', 'center'
  22037. position: 'outer'
  22038. // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  22039. // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
  22040. // distance: 当position为inner时有效,为label位置到圆心的距离与圆半径(环状图为内外半径和)的比例系数
  22041. },
  22042. emphasis: {}
  22043. },
  22044. // Enabled when label.normal.position is 'outer'
  22045. labelLine: {
  22046. normal: {
  22047. show: true,
  22048. // 引导线两段中的第一段长度
  22049. length: 15,
  22050. // 引导线两段中的第二段长度
  22051. length2: 15,
  22052. smooth: false,
  22053. lineStyle: {
  22054. // color: 各异,
  22055. width: 1,
  22056. type: 'solid'
  22057. }
  22058. }
  22059. },
  22060. itemStyle: {
  22061. normal: {
  22062. // color: 各异,
  22063. borderColor: 'rgba(0,0,0,0)',
  22064. borderWidth: 1
  22065. },
  22066. emphasis: {
  22067. // color: 各异,
  22068. borderColor: 'rgba(0,0,0,0)',
  22069. borderWidth: 1
  22070. }
  22071. },
  22072. animationEasing: 'cubicOut',
  22073. data: []
  22074. }
  22075. });
  22076. zrUtil.mixin(PieSeries, dataSelectableMixin);
  22077. module.exports = PieSeries;
  22078. /***/ },
  22079. /* 135 */
  22080. /***/ function(module, exports, __webpack_require__) {
  22081. /**
  22082. * Data selectable mixin for chart series.
  22083. * To eanble data select, option of series must have `selectedMode`.
  22084. * And each data item will use `selected` to toggle itself selected status
  22085. *
  22086. * @module echarts/chart/helper/DataSelectable
  22087. */
  22088. var zrUtil = __webpack_require__(3);
  22089. module.exports = {
  22090. updateSelectedMap: function (targetList) {
  22091. this._selectTargetMap = zrUtil.reduce(targetList || [], function (targetMap, target) {
  22092. targetMap[target.name] = target;
  22093. return targetMap;
  22094. }, {});
  22095. },
  22096. /**
  22097. * @param {string} name
  22098. */
  22099. // PENGING If selectedMode is null ?
  22100. select: function (name) {
  22101. var targetMap = this._selectTargetMap;
  22102. var target = targetMap[name];
  22103. var selectedMode = this.get('selectedMode');
  22104. if (selectedMode === 'single') {
  22105. zrUtil.each(targetMap, function (target) {
  22106. target.selected = false;
  22107. });
  22108. }
  22109. target && (target.selected = true);
  22110. },
  22111. /**
  22112. * @param {string} name
  22113. */
  22114. unSelect: function (name) {
  22115. var target = this._selectTargetMap[name];
  22116. // var selectedMode = this.get('selectedMode');
  22117. // selectedMode !== 'single' && target && (target.selected = false);
  22118. target && (target.selected = false);
  22119. },
  22120. /**
  22121. * @param {string} name
  22122. */
  22123. toggleSelected: function (name) {
  22124. var target = this._selectTargetMap[name];
  22125. if (target != null) {
  22126. this[target.selected ? 'unSelect' : 'select'](name);
  22127. return target.selected;
  22128. }
  22129. },
  22130. /**
  22131. * @param {string} name
  22132. */
  22133. isSelected: function (name) {
  22134. var target = this._selectTargetMap[name];
  22135. return target && target.selected;
  22136. }
  22137. };
  22138. /***/ },
  22139. /* 136 */
  22140. /***/ function(module, exports, __webpack_require__) {
  22141. var graphic = __webpack_require__(42);
  22142. var zrUtil = __webpack_require__(3);
  22143. /**
  22144. * @param {module:echarts/model/Series} seriesModel
  22145. * @param {boolean} hasAnimation
  22146. * @inner
  22147. */
  22148. function updateDataSelected(uid, seriesModel, hasAnimation, api) {
  22149. var data = seriesModel.getData();
  22150. var dataIndex = this.dataIndex;
  22151. var name = data.getName(dataIndex);
  22152. var selectedOffset = seriesModel.get('selectedOffset');
  22153. api.dispatchAction({
  22154. type: 'pieToggleSelect',
  22155. from: uid,
  22156. name: name,
  22157. seriesId: seriesModel.id
  22158. });
  22159. data.each(function (idx) {
  22160. toggleItemSelected(
  22161. data.getItemGraphicEl(idx),
  22162. data.getItemLayout(idx),
  22163. seriesModel.isSelected(data.getName(idx)),
  22164. selectedOffset,
  22165. hasAnimation
  22166. );
  22167. });
  22168. }
  22169. /**
  22170. * @param {module:zrender/graphic/Sector} el
  22171. * @param {Object} layout
  22172. * @param {boolean} isSelected
  22173. * @param {number} selectedOffset
  22174. * @param {boolean} hasAnimation
  22175. * @inner
  22176. */
  22177. function toggleItemSelected(el, layout, isSelected, selectedOffset, hasAnimation) {
  22178. var midAngle = (layout.startAngle + layout.endAngle) / 2;
  22179. var dx = Math.cos(midAngle);
  22180. var dy = Math.sin(midAngle);
  22181. var offset = isSelected ? selectedOffset : 0;
  22182. var position = [dx * offset, dy * offset];
  22183. hasAnimation
  22184. // animateTo will stop revious animation like update transition
  22185. ? el.animate()
  22186. .when(200, {
  22187. position: position
  22188. })
  22189. .start('bounceOut')
  22190. : el.attr('position', position);
  22191. }
  22192. /**
  22193. * Piece of pie including Sector, Label, LabelLine
  22194. * @constructor
  22195. * @extends {module:zrender/graphic/Group}
  22196. */
  22197. function PiePiece(data, idx) {
  22198. graphic.Group.call(this);
  22199. var sector = new graphic.Sector({
  22200. z2: 2
  22201. });
  22202. var polyline = new graphic.Polyline();
  22203. var text = new graphic.Text();
  22204. this.add(sector);
  22205. this.add(polyline);
  22206. this.add(text);
  22207. this.updateData(data, idx, true);
  22208. // Hover to change label and labelLine
  22209. function onEmphasis() {
  22210. polyline.ignore = polyline.hoverIgnore;
  22211. text.ignore = text.hoverIgnore;
  22212. }
  22213. function onNormal() {
  22214. polyline.ignore = polyline.normalIgnore;
  22215. text.ignore = text.normalIgnore;
  22216. }
  22217. this.on('emphasis', onEmphasis)
  22218. .on('normal', onNormal)
  22219. .on('mouseover', onEmphasis)
  22220. .on('mouseout', onNormal);
  22221. }
  22222. var piePieceProto = PiePiece.prototype;
  22223. function getLabelStyle(data, idx, state, labelModel, labelPosition) {
  22224. var textStyleModel = labelModel.getModel('textStyle');
  22225. var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner';
  22226. return {
  22227. fill: textStyleModel.getTextColor()
  22228. || (isLabelInside ? '#fff' : data.getItemVisual(idx, 'color')),
  22229. opacity: data.getItemVisual(idx, 'opacity'),
  22230. textFont: textStyleModel.getFont(),
  22231. text: zrUtil.retrieve(
  22232. data.hostModel.getFormattedLabel(idx, state), data.getName(idx)
  22233. )
  22234. };
  22235. }
  22236. piePieceProto.updateData = function (data, idx, firstCreate) {
  22237. var sector = this.childAt(0);
  22238. var seriesModel = data.hostModel;
  22239. var itemModel = data.getItemModel(idx);
  22240. var layout = data.getItemLayout(idx);
  22241. var sectorShape = zrUtil.extend({}, layout);
  22242. sectorShape.label = null;
  22243. if (firstCreate) {
  22244. sector.setShape(sectorShape);
  22245. sector.shape.endAngle = layout.startAngle;
  22246. graphic.updateProps(sector, {
  22247. shape: {
  22248. endAngle: layout.endAngle
  22249. }
  22250. }, seriesModel, idx);
  22251. }
  22252. else {
  22253. graphic.updateProps(sector, {
  22254. shape: sectorShape
  22255. }, seriesModel, idx);
  22256. }
  22257. // Update common style
  22258. var itemStyleModel = itemModel.getModel('itemStyle');
  22259. var visualColor = data.getItemVisual(idx, 'color');
  22260. sector.useStyle(
  22261. zrUtil.defaults(
  22262. {
  22263. fill: visualColor
  22264. },
  22265. itemStyleModel.getModel('normal').getItemStyle()
  22266. )
  22267. );
  22268. sector.hoverStyle = itemStyleModel.getModel('emphasis').getItemStyle();
  22269. // Toggle selected
  22270. toggleItemSelected(
  22271. this,
  22272. data.getItemLayout(idx),
  22273. itemModel.get('selected'),
  22274. seriesModel.get('selectedOffset'),
  22275. seriesModel.get('animation')
  22276. );
  22277. function onEmphasis() {
  22278. // Sector may has animation of updating data. Force to move to the last frame
  22279. // Or it may stopped on the wrong shape
  22280. sector.stopAnimation(true);
  22281. sector.animateTo({
  22282. shape: {
  22283. r: layout.r + 10
  22284. }
  22285. }, 300, 'elasticOut');
  22286. }
  22287. function onNormal() {
  22288. sector.stopAnimation(true);
  22289. sector.animateTo({
  22290. shape: {
  22291. r: layout.r
  22292. }
  22293. }, 300, 'elasticOut');
  22294. }
  22295. sector.off('mouseover').off('mouseout').off('emphasis').off('normal');
  22296. if (itemModel.get('hoverAnimation')) {
  22297. sector
  22298. .on('mouseover', onEmphasis)
  22299. .on('mouseout', onNormal)
  22300. .on('emphasis', onEmphasis)
  22301. .on('normal', onNormal);
  22302. }
  22303. this._updateLabel(data, idx);
  22304. graphic.setHoverStyle(this);
  22305. };
  22306. piePieceProto._updateLabel = function (data, idx) {
  22307. var labelLine = this.childAt(1);
  22308. var labelText = this.childAt(2);
  22309. var seriesModel = data.hostModel;
  22310. var itemModel = data.getItemModel(idx);
  22311. var layout = data.getItemLayout(idx);
  22312. var labelLayout = layout.label;
  22313. var visualColor = data.getItemVisual(idx, 'color');
  22314. graphic.updateProps(labelLine, {
  22315. shape: {
  22316. points: labelLayout.linePoints || [
  22317. [labelLayout.x, labelLayout.y], [labelLayout.x, labelLayout.y], [labelLayout.x, labelLayout.y]
  22318. ]
  22319. }
  22320. }, seriesModel, idx);
  22321. graphic.updateProps(labelText, {
  22322. style: {
  22323. x: labelLayout.x,
  22324. y: labelLayout.y
  22325. }
  22326. }, seriesModel, idx);
  22327. labelText.attr({
  22328. style: {
  22329. textVerticalAlign: labelLayout.verticalAlign,
  22330. textAlign: labelLayout.textAlign,
  22331. textFont: labelLayout.font
  22332. },
  22333. rotation: labelLayout.rotation,
  22334. origin: [labelLayout.x, labelLayout.y],
  22335. z2: 10
  22336. });
  22337. var labelModel = itemModel.getModel('label.normal');
  22338. var labelHoverModel = itemModel.getModel('label.emphasis');
  22339. var labelLineModel = itemModel.getModel('labelLine.normal');
  22340. var labelLineHoverModel = itemModel.getModel('labelLine.emphasis');
  22341. var labelPosition = labelModel.get('position') || labelHoverModel.get('position');
  22342. labelText.setStyle(getLabelStyle(data, idx, 'normal', labelModel, labelPosition));
  22343. labelText.ignore = labelText.normalIgnore = !labelModel.get('show');
  22344. labelText.hoverIgnore = !labelHoverModel.get('show');
  22345. labelLine.ignore = labelLine.normalIgnore = !labelLineModel.get('show');
  22346. labelLine.hoverIgnore = !labelLineHoverModel.get('show');
  22347. // Default use item visual color
  22348. labelLine.setStyle({
  22349. stroke: visualColor,
  22350. opacity: data.getItemVisual(idx, 'opacity')
  22351. });
  22352. labelLine.setStyle(labelLineModel.getModel('lineStyle').getLineStyle());
  22353. labelText.hoverStyle = getLabelStyle(data, idx, 'emphasis', labelHoverModel, labelPosition);
  22354. labelLine.hoverStyle = labelLineHoverModel.getModel('lineStyle').getLineStyle();
  22355. var smooth = labelLineModel.get('smooth');
  22356. if (smooth && smooth === true) {
  22357. smooth = 0.4;
  22358. }
  22359. labelLine.setShape({
  22360. smooth: smooth
  22361. });
  22362. };
  22363. zrUtil.inherits(PiePiece, graphic.Group);
  22364. // Pie view
  22365. var Pie = __webpack_require__(41).extend({
  22366. type: 'pie',
  22367. init: function () {
  22368. var sectorGroup = new graphic.Group();
  22369. this._sectorGroup = sectorGroup;
  22370. },
  22371. render: function (seriesModel, ecModel, api, payload) {
  22372. if (payload && (payload.from === this.uid)) {
  22373. return;
  22374. }
  22375. var data = seriesModel.getData();
  22376. var oldData = this._data;
  22377. var group = this.group;
  22378. var hasAnimation = ecModel.get('animation');
  22379. var isFirstRender = !oldData;
  22380. var onSectorClick = zrUtil.curry(
  22381. updateDataSelected, this.uid, seriesModel, hasAnimation, api
  22382. );
  22383. var selectedMode = seriesModel.get('selectedMode');
  22384. data.diff(oldData)
  22385. .add(function (idx) {
  22386. var piePiece = new PiePiece(data, idx);
  22387. if (isFirstRender) {
  22388. piePiece.eachChild(function (child) {
  22389. child.stopAnimation(true);
  22390. });
  22391. }
  22392. selectedMode && piePiece.on('click', onSectorClick);
  22393. data.setItemGraphicEl(idx, piePiece);
  22394. group.add(piePiece);
  22395. })
  22396. .update(function (newIdx, oldIdx) {
  22397. var piePiece = oldData.getItemGraphicEl(oldIdx);
  22398. piePiece.updateData(data, newIdx);
  22399. piePiece.off('click');
  22400. selectedMode && piePiece.on('click', onSectorClick);
  22401. group.add(piePiece);
  22402. data.setItemGraphicEl(newIdx, piePiece);
  22403. })
  22404. .remove(function (idx) {
  22405. var piePiece = oldData.getItemGraphicEl(idx);
  22406. group.remove(piePiece);
  22407. })
  22408. .execute();
  22409. if (hasAnimation && isFirstRender && data.count() > 0) {
  22410. var shape = data.getItemLayout(0);
  22411. var r = Math.max(api.getWidth(), api.getHeight()) / 2;
  22412. var removeClipPath = zrUtil.bind(group.removeClipPath, group);
  22413. group.setClipPath(this._createClipPath(
  22414. shape.cx, shape.cy, r, shape.startAngle, shape.clockwise, removeClipPath, seriesModel
  22415. ));
  22416. }
  22417. this._data = data;
  22418. },
  22419. _createClipPath: function (
  22420. cx, cy, r, startAngle, clockwise, cb, seriesModel
  22421. ) {
  22422. var clipPath = new graphic.Sector({
  22423. shape: {
  22424. cx: cx,
  22425. cy: cy,
  22426. r0: 0,
  22427. r: r,
  22428. startAngle: startAngle,
  22429. endAngle: startAngle,
  22430. clockwise: clockwise
  22431. }
  22432. });
  22433. graphic.initProps(clipPath, {
  22434. shape: {
  22435. endAngle: startAngle + (clockwise ? 1 : -1) * Math.PI * 2
  22436. }
  22437. }, seriesModel, cb);
  22438. return clipPath;
  22439. }
  22440. });
  22441. module.exports = Pie;
  22442. /***/ },
  22443. /* 137 */
  22444. /***/ function(module, exports, __webpack_require__) {
  22445. var echarts = __webpack_require__(1);
  22446. var zrUtil = __webpack_require__(3);
  22447. module.exports = function (seriesType, actionInfos) {
  22448. zrUtil.each(actionInfos, function (actionInfo) {
  22449. actionInfo.update = 'updateView';
  22450. /**
  22451. * @payload
  22452. * @property {string} seriesName
  22453. * @property {string} name
  22454. */
  22455. echarts.registerAction(actionInfo, function (payload, ecModel) {
  22456. var selected = {};
  22457. ecModel.eachComponent(
  22458. {mainType: 'series', subType: seriesType, query: payload},
  22459. function (seriesModel) {
  22460. if (seriesModel[actionInfo.method]) {
  22461. seriesModel[actionInfo.method](payload.name);
  22462. }
  22463. var data = seriesModel.getData();
  22464. // Create selected map
  22465. data.each(function (idx) {
  22466. var name = data.getName(idx);
  22467. selected[name] = seriesModel.isSelected(name) || false;
  22468. });
  22469. }
  22470. );
  22471. return {
  22472. name: payload.name,
  22473. selected: selected
  22474. };
  22475. });
  22476. });
  22477. };
  22478. /***/ },
  22479. /* 138 */
  22480. /***/ function(module, exports) {
  22481. // Pick color from palette for each data item
  22482. module.exports = function (seriesType, ecModel) {
  22483. var globalColorList = ecModel.get('color');
  22484. var offset = 0;
  22485. ecModel.eachRawSeriesByType(seriesType, function (seriesModel) {
  22486. var colorList = seriesModel.get('color', true);
  22487. var dataAll = seriesModel.getRawData();
  22488. if (!ecModel.isSeriesFiltered(seriesModel)) {
  22489. var data = seriesModel.getData();
  22490. data.each(function (idx) {
  22491. var itemModel = data.getItemModel(idx);
  22492. var rawIdx = data.getRawIndex(idx);
  22493. // If series.itemStyle.normal.color is a function. itemVisual may be encoded
  22494. var singleDataColor = data.getItemVisual(idx, 'color', true);
  22495. if (!singleDataColor) {
  22496. var paletteColor = colorList ? colorList[rawIdx % colorList.length]
  22497. : globalColorList[(rawIdx + offset) % globalColorList.length];
  22498. var color = itemModel.get('itemStyle.normal.color') || paletteColor;
  22499. // Legend may use the visual info in data before processed
  22500. dataAll.setItemVisual(rawIdx, 'color', color);
  22501. data.setItemVisual(idx, 'color', color);
  22502. }
  22503. else {
  22504. // Set data all color for legend
  22505. dataAll.setItemVisual(rawIdx, 'color', singleDataColor);
  22506. }
  22507. });
  22508. }
  22509. offset += dataAll.count();
  22510. });
  22511. };
  22512. /***/ },
  22513. /* 139 */
  22514. /***/ function(module, exports, __webpack_require__) {
  22515. // TODO minAngle
  22516. var numberUtil = __webpack_require__(7);
  22517. var parsePercent = numberUtil.parsePercent;
  22518. var labelLayout = __webpack_require__(140);
  22519. var zrUtil = __webpack_require__(3);
  22520. var PI2 = Math.PI * 2;
  22521. var RADIAN = Math.PI / 180;
  22522. module.exports = function (seriesType, ecModel, api) {
  22523. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  22524. var center = seriesModel.get('center');
  22525. var radius = seriesModel.get('radius');
  22526. if (!zrUtil.isArray(radius)) {
  22527. radius = [0, radius];
  22528. }
  22529. if (!zrUtil.isArray(center)) {
  22530. center = [center, center];
  22531. }
  22532. var width = api.getWidth();
  22533. var height = api.getHeight();
  22534. var size = Math.min(width, height);
  22535. var cx = parsePercent(center[0], width);
  22536. var cy = parsePercent(center[1], height);
  22537. var r0 = parsePercent(radius[0], size / 2);
  22538. var r = parsePercent(radius[1], size / 2);
  22539. var data = seriesModel.getData();
  22540. var startAngle = -seriesModel.get('startAngle') * RADIAN;
  22541. var minAngle = seriesModel.get('minAngle') * RADIAN;
  22542. var sum = data.getSum('value');
  22543. // Sum may be 0
  22544. var unitRadian = Math.PI / (sum || data.count()) * 2;
  22545. var clockwise = seriesModel.get('clockwise');
  22546. var roseType = seriesModel.get('roseType');
  22547. // [0...max]
  22548. var extent = data.getDataExtent('value');
  22549. extent[0] = 0;
  22550. // In the case some sector angle is smaller than minAngle
  22551. var restAngle = PI2;
  22552. var valueSumLargerThanMinAngle = 0;
  22553. var currentAngle = startAngle;
  22554. var dir = clockwise ? 1 : -1;
  22555. data.each('value', function (value, idx) {
  22556. var angle;
  22557. // FIXME 兼容 2.0 但是 roseType 是 area 的时候才是这样?
  22558. if (roseType !== 'area') {
  22559. angle = sum === 0 ? unitRadian : (value * unitRadian);
  22560. }
  22561. else {
  22562. angle = PI2 / (data.count() || 1);
  22563. }
  22564. if (angle < minAngle) {
  22565. angle = minAngle;
  22566. restAngle -= minAngle;
  22567. }
  22568. else {
  22569. valueSumLargerThanMinAngle += value;
  22570. }
  22571. var endAngle = currentAngle + dir * angle;
  22572. data.setItemLayout(idx, {
  22573. angle: angle,
  22574. startAngle: currentAngle,
  22575. endAngle: endAngle,
  22576. clockwise: clockwise,
  22577. cx: cx,
  22578. cy: cy,
  22579. r0: r0,
  22580. r: roseType
  22581. ? numberUtil.linearMap(value, extent, [r0, r])
  22582. : r
  22583. });
  22584. currentAngle = endAngle;
  22585. }, true);
  22586. // Some sector is constrained by minAngle
  22587. // Rest sectors needs recalculate angle
  22588. if (restAngle < PI2) {
  22589. // Average the angle if rest angle is not enough after all angles is
  22590. // Constrained by minAngle
  22591. if (restAngle <= 1e-3) {
  22592. var angle = PI2 / data.count();
  22593. data.each(function (idx) {
  22594. var layout = data.getItemLayout(idx);
  22595. layout.startAngle = startAngle + dir * idx * angle;
  22596. layout.endAngle = startAngle + dir * (idx + 1) * angle;
  22597. });
  22598. }
  22599. else {
  22600. unitRadian = restAngle / valueSumLargerThanMinAngle;
  22601. currentAngle = startAngle;
  22602. data.each('value', function (value, idx) {
  22603. var layout = data.getItemLayout(idx);
  22604. var angle = layout.angle === minAngle
  22605. ? minAngle : value * unitRadian;
  22606. layout.startAngle = currentAngle;
  22607. layout.endAngle = currentAngle + dir * angle;
  22608. currentAngle += angle;
  22609. });
  22610. }
  22611. }
  22612. labelLayout(seriesModel, r, width, height);
  22613. });
  22614. };
  22615. /***/ },
  22616. /* 140 */
  22617. /***/ function(module, exports, __webpack_require__) {
  22618. 'use strict';
  22619. // FIXME emphasis label position is not same with normal label position
  22620. var textContain = __webpack_require__(14);
  22621. function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
  22622. list.sort(function (a, b) {
  22623. return a.y - b.y;
  22624. });
  22625. // 压
  22626. function shiftDown(start, end, delta, dir) {
  22627. for (var j = start; j < end; j++) {
  22628. list[j].y += delta;
  22629. if (j > start
  22630. && j + 1 < end
  22631. && list[j + 1].y > list[j].y + list[j].height
  22632. ) {
  22633. shiftUp(j, delta / 2);
  22634. return;
  22635. }
  22636. }
  22637. shiftUp(end - 1, delta / 2);
  22638. }
  22639. // 弹
  22640. function shiftUp(end, delta) {
  22641. for (var j = end; j >= 0; j--) {
  22642. list[j].y -= delta;
  22643. if (j > 0
  22644. && list[j].y > list[j - 1].y + list[j - 1].height
  22645. ) {
  22646. break;
  22647. }
  22648. }
  22649. }
  22650. function changeX(list, isDownList, cx, cy, r, dir) {
  22651. var lastDeltaX = dir > 0
  22652. ? isDownList // 右侧
  22653. ? Number.MAX_VALUE // 下
  22654. : 0 // 上
  22655. : isDownList // 左侧
  22656. ? Number.MAX_VALUE // 下
  22657. : 0; // 上
  22658. for (var i = 0, l = list.length; i < l; i++) {
  22659. // Not change x for center label
  22660. if (list[i].position === 'center') {
  22661. continue;
  22662. }
  22663. var deltaY = Math.abs(list[i].y - cy);
  22664. var length = list[i].len;
  22665. var length2 = list[i].len2;
  22666. var deltaX = (deltaY < r + length)
  22667. ? Math.sqrt(
  22668. (r + length + length2) * (r + length + length2)
  22669. - deltaY * deltaY
  22670. )
  22671. : Math.abs(list[i].x - cx);
  22672. if (isDownList && deltaX >= lastDeltaX) {
  22673. // 右下,左下
  22674. deltaX = lastDeltaX - 10;
  22675. }
  22676. if (!isDownList && deltaX <= lastDeltaX) {
  22677. // 右上,左上
  22678. deltaX = lastDeltaX + 10;
  22679. }
  22680. list[i].x = cx + deltaX * dir;
  22681. lastDeltaX = deltaX;
  22682. }
  22683. }
  22684. var lastY = 0;
  22685. var delta;
  22686. var len = list.length;
  22687. var upList = [];
  22688. var downList = [];
  22689. for (var i = 0; i < len; i++) {
  22690. delta = list[i].y - lastY;
  22691. if (delta < 0) {
  22692. shiftDown(i, len, -delta, dir);
  22693. }
  22694. lastY = list[i].y + list[i].height;
  22695. }
  22696. if (viewHeight - lastY < 0) {
  22697. shiftUp(len - 1, lastY - viewHeight);
  22698. }
  22699. for (var i = 0; i < len; i++) {
  22700. if (list[i].y >= cy) {
  22701. downList.push(list[i]);
  22702. }
  22703. else {
  22704. upList.push(list[i]);
  22705. }
  22706. }
  22707. changeX(upList, false, cx, cy, r, dir);
  22708. changeX(downList, true, cx, cy, r, dir);
  22709. }
  22710. function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight) {
  22711. var leftList = [];
  22712. var rightList = [];
  22713. for (var i = 0; i < labelLayoutList.length; i++) {
  22714. if (labelLayoutList[i].x < cx) {
  22715. leftList.push(labelLayoutList[i]);
  22716. }
  22717. else {
  22718. rightList.push(labelLayoutList[i]);
  22719. }
  22720. }
  22721. adjustSingleSide(rightList, cx, cy, r, 1, viewWidth, viewHeight);
  22722. adjustSingleSide(leftList, cx, cy, r, -1, viewWidth, viewHeight);
  22723. for (var i = 0; i < labelLayoutList.length; i++) {
  22724. var linePoints = labelLayoutList[i].linePoints;
  22725. if (linePoints) {
  22726. var dist = linePoints[1][0] - linePoints[2][0];
  22727. if (labelLayoutList[i].x < cx) {
  22728. linePoints[2][0] = labelLayoutList[i].x + 3;
  22729. }
  22730. else {
  22731. linePoints[2][0] = labelLayoutList[i].x - 3;
  22732. }
  22733. linePoints[1][1] = linePoints[2][1] = labelLayoutList[i].y;
  22734. linePoints[1][0] = linePoints[2][0] + dist;
  22735. }
  22736. }
  22737. }
  22738. module.exports = function (seriesModel, r, viewWidth, viewHeight) {
  22739. var data = seriesModel.getData();
  22740. var labelLayoutList = [];
  22741. var cx;
  22742. var cy;
  22743. var hasLabelRotate = false;
  22744. data.each(function (idx) {
  22745. var layout = data.getItemLayout(idx);
  22746. var itemModel = data.getItemModel(idx);
  22747. var labelModel = itemModel.getModel('label.normal');
  22748. // Use position in normal or emphasis
  22749. var labelPosition = labelModel.get('position') || itemModel.get('label.emphasis.position');
  22750. var labelLineModel = itemModel.getModel('labelLine.normal');
  22751. var labelLineLen = labelLineModel.get('length');
  22752. var labelLineLen2 = labelLineModel.get('length2');
  22753. var midAngle = (layout.startAngle + layout.endAngle) / 2;
  22754. var dx = Math.cos(midAngle);
  22755. var dy = Math.sin(midAngle);
  22756. var textX;
  22757. var textY;
  22758. var linePoints;
  22759. var textAlign;
  22760. cx = layout.cx;
  22761. cy = layout.cy;
  22762. var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner';
  22763. if (labelPosition === 'center') {
  22764. textX = layout.cx;
  22765. textY = layout.cy;
  22766. textAlign = 'center';
  22767. }
  22768. else {
  22769. var x1 = (isLabelInside ? (layout.r + layout.r0) / 2 * dx : layout.r * dx) + cx;
  22770. var y1 = (isLabelInside ? (layout.r + layout.r0) / 2 * dy : layout.r * dy) + cy;
  22771. textX = x1 + dx * 3;
  22772. textY = y1 + dy * 3;
  22773. if (!isLabelInside) {
  22774. // For roseType
  22775. var x2 = x1 + dx * (labelLineLen + r - layout.r);
  22776. var y2 = y1 + dy * (labelLineLen + r - layout.r);
  22777. var x3 = x2 + ((dx < 0 ? -1 : 1) * labelLineLen2);
  22778. var y3 = y2;
  22779. textX = x3 + (dx < 0 ? -5 : 5);
  22780. textY = y3;
  22781. linePoints = [[x1, y1], [x2, y2], [x3, y3]];
  22782. }
  22783. textAlign = isLabelInside ? 'center' : (dx > 0 ? 'left' : 'right');
  22784. }
  22785. var font = labelModel.getModel('textStyle').getFont();
  22786. var labelRotate = labelModel.get('rotate')
  22787. ? (dx < 0 ? -midAngle + Math.PI : -midAngle) : 0;
  22788. var text = seriesModel.getFormattedLabel(idx, 'normal')
  22789. || data.getName(idx);
  22790. var textRect = textContain.getBoundingRect(
  22791. text, font, textAlign, 'top'
  22792. );
  22793. hasLabelRotate = !!labelRotate;
  22794. layout.label = {
  22795. x: textX,
  22796. y: textY,
  22797. position: labelPosition,
  22798. height: textRect.height,
  22799. len: labelLineLen,
  22800. len2: labelLineLen2,
  22801. linePoints: linePoints,
  22802. textAlign: textAlign,
  22803. verticalAlign: 'middle',
  22804. font: font,
  22805. rotation: labelRotate
  22806. };
  22807. // Not layout the inside label
  22808. if (!isLabelInside) {
  22809. labelLayoutList.push(layout.label);
  22810. }
  22811. });
  22812. if (!hasLabelRotate && seriesModel.get('avoidLabelOverlap')) {
  22813. avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight);
  22814. }
  22815. };
  22816. /***/ },
  22817. /* 141 */
  22818. /***/ function(module, exports) {
  22819. module.exports = function (seriesType, ecModel) {
  22820. var legendModels = ecModel.findComponents({
  22821. mainType: 'legend'
  22822. });
  22823. if (!legendModels || !legendModels.length) {
  22824. return;
  22825. }
  22826. ecModel.eachSeriesByType(seriesType, function (series) {
  22827. var data = series.getData();
  22828. data.filterSelf(function (idx) {
  22829. var name = data.getName(idx);
  22830. // If in any legend component the status is not selected.
  22831. for (var i = 0; i < legendModels.length; i++) {
  22832. if (!legendModels[i].isSelected(name)) {
  22833. return false;
  22834. }
  22835. }
  22836. return true;
  22837. }, this);
  22838. }, this);
  22839. };
  22840. /***/ },
  22841. /* 142 */
  22842. /***/ function(module, exports, __webpack_require__) {
  22843. var zrUtil = __webpack_require__(3);
  22844. var echarts = __webpack_require__(1);
  22845. __webpack_require__(143);
  22846. __webpack_require__(144);
  22847. echarts.registerVisualCoding('chart', zrUtil.curry(
  22848. __webpack_require__(104), 'scatter', 'circle', null
  22849. ));
  22850. echarts.registerLayout(zrUtil.curry(
  22851. __webpack_require__(105), 'scatter'
  22852. ));
  22853. // In case developer forget to include grid component
  22854. __webpack_require__(107);
  22855. /***/ },
  22856. /* 143 */
  22857. /***/ function(module, exports, __webpack_require__) {
  22858. 'use strict';
  22859. var createListFromArray = __webpack_require__(94);
  22860. var SeriesModel = __webpack_require__(27);
  22861. module.exports = SeriesModel.extend({
  22862. type: 'series.scatter',
  22863. dependencies: ['grid', 'polar'],
  22864. getInitialData: function (option, ecModel) {
  22865. var list = createListFromArray(option.data, this, ecModel);
  22866. return list;
  22867. },
  22868. defaultOption: {
  22869. coordinateSystem: 'cartesian2d',
  22870. zlevel: 0,
  22871. z: 2,
  22872. legendHoverLink: true,
  22873. hoverAnimation: true,
  22874. // Cartesian coordinate system
  22875. xAxisIndex: 0,
  22876. yAxisIndex: 0,
  22877. // Polar coordinate system
  22878. polarIndex: 0,
  22879. // Geo coordinate system
  22880. geoIndex: 0,
  22881. // symbol: null, // 图形类型
  22882. symbolSize: 10, // 图形大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2
  22883. // symbolRotate: null, // 图形旋转控制
  22884. large: false,
  22885. // Available when large is true
  22886. largeThreshold: 2000,
  22887. // label: {
  22888. // normal: {
  22889. // show: false
  22890. // distance: 5,
  22891. // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  22892. // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为
  22893. // 'inside'|'left'|'right'|'top'|'bottom'
  22894. // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
  22895. // }
  22896. // },
  22897. itemStyle: {
  22898. normal: {
  22899. opacity: 0.8
  22900. // color: 各异
  22901. }
  22902. }
  22903. }
  22904. });
  22905. /***/ },
  22906. /* 144 */
  22907. /***/ function(module, exports, __webpack_require__) {
  22908. var SymbolDraw = __webpack_require__(99);
  22909. var LargeSymbolDraw = __webpack_require__(145);
  22910. __webpack_require__(1).extendChartView({
  22911. type: 'scatter',
  22912. init: function () {
  22913. this._normalSymbolDraw = new SymbolDraw();
  22914. this._largeSymbolDraw = new LargeSymbolDraw();
  22915. },
  22916. render: function (seriesModel, ecModel, api) {
  22917. var data = seriesModel.getData();
  22918. var largeSymbolDraw = this._largeSymbolDraw;
  22919. var normalSymbolDraw = this._normalSymbolDraw;
  22920. var group = this.group;
  22921. var symbolDraw = seriesModel.get('large') && data.count() > seriesModel.get('largeThreshold')
  22922. ? largeSymbolDraw : normalSymbolDraw;
  22923. this._symbolDraw = symbolDraw;
  22924. symbolDraw.updateData(data);
  22925. group.add(symbolDraw.group);
  22926. group.remove(
  22927. symbolDraw === largeSymbolDraw
  22928. ? normalSymbolDraw.group : largeSymbolDraw.group
  22929. );
  22930. },
  22931. updateLayout: function (seriesModel) {
  22932. this._symbolDraw.updateLayout(seriesModel);
  22933. },
  22934. remove: function (ecModel, api) {
  22935. this._symbolDraw && this._symbolDraw.remove(api, true);
  22936. }
  22937. });
  22938. /***/ },
  22939. /* 145 */
  22940. /***/ function(module, exports, __webpack_require__) {
  22941. var graphic = __webpack_require__(42);
  22942. var symbolUtil = __webpack_require__(101);
  22943. var zrUtil = __webpack_require__(3);
  22944. var LargeSymbolPath = graphic.extendShape({
  22945. shape: {
  22946. points: null,
  22947. sizes: null
  22948. },
  22949. symbolProxy: null,
  22950. buildPath: function (path, shape) {
  22951. var points = shape.points;
  22952. var sizes = shape.sizes;
  22953. var symbolProxy = this.symbolProxy;
  22954. var symbolProxyShape = symbolProxy.shape;
  22955. for (var i = 0; i < points.length; i++) {
  22956. var pt = points[i];
  22957. var size = sizes[i];
  22958. if (size[0] < 4) {
  22959. // Optimize for small symbol
  22960. path.rect(
  22961. pt[0] - size[0] / 2, pt[1] - size[1] / 2,
  22962. size[0], size[1]
  22963. );
  22964. }
  22965. else {
  22966. symbolProxyShape.x = pt[0] - size[0] / 2;
  22967. symbolProxyShape.y = pt[1] - size[1] / 2;
  22968. symbolProxyShape.width = size[0];
  22969. symbolProxyShape.height = size[1];
  22970. symbolProxy.buildPath(path, symbolProxyShape);
  22971. }
  22972. }
  22973. }
  22974. });
  22975. function LargeSymbolDraw() {
  22976. this.group = new graphic.Group();
  22977. this._symbolEl = new LargeSymbolPath({
  22978. silent: true
  22979. });
  22980. }
  22981. var largeSymbolProto = LargeSymbolDraw.prototype;
  22982. /**
  22983. * Update symbols draw by new data
  22984. * @param {module:echarts/data/List} data
  22985. */
  22986. largeSymbolProto.updateData = function (data) {
  22987. this.group.removeAll();
  22988. var symbolEl = this._symbolEl;
  22989. var seriesModel = data.hostModel;
  22990. symbolEl.setShape({
  22991. points: data.mapArray(data.getItemLayout),
  22992. sizes: data.mapArray(
  22993. function (idx) {
  22994. var size = data.getItemVisual(idx, 'symbolSize');
  22995. if (!zrUtil.isArray(size)) {
  22996. size = [size, size];
  22997. }
  22998. return size;
  22999. }
  23000. )
  23001. });
  23002. // Create symbolProxy to build path for each data
  23003. symbolEl.symbolProxy = symbolUtil.createSymbol(
  23004. data.getVisual('symbol'), 0, 0, 0, 0
  23005. );
  23006. // Use symbolProxy setColor method
  23007. symbolEl.setColor = symbolEl.symbolProxy.setColor;
  23008. symbolEl.useStyle(
  23009. seriesModel.getModel('itemStyle.normal').getItemStyle(['color'])
  23010. );
  23011. var visualColor = data.getVisual('color');
  23012. if (visualColor) {
  23013. symbolEl.setColor(visualColor);
  23014. }
  23015. // Add back
  23016. this.group.add(this._symbolEl);
  23017. };
  23018. largeSymbolProto.updateLayout = function (seriesModel) {
  23019. var data = seriesModel.getData();
  23020. this._symbolEl.setShape({
  23021. points: data.mapArray(data.getItemLayout)
  23022. });
  23023. };
  23024. largeSymbolProto.remove = function () {
  23025. this.group.removeAll();
  23026. };
  23027. module.exports = LargeSymbolDraw;
  23028. /***/ },
  23029. /* 146 */
  23030. /***/ function(module, exports, __webpack_require__) {
  23031. var zrUtil = __webpack_require__(3);
  23032. var echarts = __webpack_require__(1);
  23033. // Must use radar component
  23034. __webpack_require__(147);
  23035. __webpack_require__(152);
  23036. __webpack_require__(153);
  23037. echarts.registerVisualCoding(
  23038. 'chart', zrUtil.curry(__webpack_require__(138), 'radar')
  23039. );
  23040. echarts.registerVisualCoding('chart', zrUtil.curry(
  23041. __webpack_require__(104), 'radar', 'circle', null
  23042. ));
  23043. echarts.registerLayout(__webpack_require__(154));
  23044. echarts.registerProcessor(
  23045. 'filter', zrUtil.curry(__webpack_require__(141), 'radar')
  23046. );
  23047. echarts.registerPreprocessor(__webpack_require__(155));
  23048. /***/ },
  23049. /* 147 */
  23050. /***/ function(module, exports, __webpack_require__) {
  23051. __webpack_require__(148);
  23052. __webpack_require__(150);
  23053. __webpack_require__(151);
  23054. /***/ },
  23055. /* 148 */
  23056. /***/ function(module, exports, __webpack_require__) {
  23057. // TODO clockwise
  23058. var zrUtil = __webpack_require__(3);
  23059. var IndicatorAxis = __webpack_require__(149);
  23060. var IntervalScale = __webpack_require__(112);
  23061. var numberUtil = __webpack_require__(7);
  23062. var axisHelper = __webpack_require__(109);
  23063. function Radar(radarModel, ecModel, api) {
  23064. this._model = radarModel;
  23065. /**
  23066. * Radar dimensions
  23067. * @type {Array.<string>}
  23068. */
  23069. this.dimensions = [];
  23070. this._indicatorAxes = zrUtil.map(radarModel.getIndicatorModels(), function (indicatorModel, idx) {
  23071. var dim = 'indicator_' + idx;
  23072. var indicatorAxis = new IndicatorAxis(dim, new IntervalScale());
  23073. indicatorAxis.name = indicatorModel.get('name');
  23074. // Inject model and axis
  23075. indicatorAxis.model = indicatorModel;
  23076. indicatorModel.axis = indicatorAxis;
  23077. this.dimensions.push(dim);
  23078. return indicatorAxis;
  23079. }, this);
  23080. this.resize(radarModel, api);
  23081. /**
  23082. * @type {number}
  23083. * @readOnly
  23084. */
  23085. this.cx;
  23086. /**
  23087. * @type {number}
  23088. * @readOnly
  23089. */
  23090. this.cy;
  23091. /**
  23092. * @type {number}
  23093. * @readOnly
  23094. */
  23095. this.r;
  23096. /**
  23097. * @type {number}
  23098. * @readOnly
  23099. */
  23100. this.startAngle;
  23101. }
  23102. Radar.prototype.getIndicatorAxes = function () {
  23103. return this._indicatorAxes;
  23104. };
  23105. Radar.prototype.dataToPoint = function (value, indicatorIndex) {
  23106. var indicatorAxis = this._indicatorAxes[indicatorIndex];
  23107. return this.coordToPoint(indicatorAxis.dataToCoord(value), indicatorIndex);
  23108. };
  23109. Radar.prototype.coordToPoint = function (coord, indicatorIndex) {
  23110. var indicatorAxis = this._indicatorAxes[indicatorIndex];
  23111. var angle = indicatorAxis.angle;
  23112. var x = this.cx + coord * Math.cos(angle);
  23113. var y = this.cy - coord * Math.sin(angle);
  23114. return [x, y];
  23115. };
  23116. Radar.prototype.pointToData = function (pt) {
  23117. var dx = pt[0] - this.cx;
  23118. var dy = pt[1] - this.cy;
  23119. var radius = Math.sqrt(dx * dx + dy * dy);
  23120. dx /= radius;
  23121. dy /= radius;
  23122. var radian = Math.atan2(-dy, dx);
  23123. // Find the closest angle
  23124. // FIXME index can calculated directly
  23125. var minRadianDiff = Infinity;
  23126. var closestAxis;
  23127. var closestAxisIdx = -1;
  23128. for (var i = 0; i < this._indicatorAxes.length; i++) {
  23129. var indicatorAxis = this._indicatorAxes[i];
  23130. var diff = Math.abs(radian - indicatorAxis.angle);
  23131. if (diff < minRadianDiff) {
  23132. closestAxis = indicatorAxis;
  23133. closestAxisIdx = i;
  23134. minRadianDiff = diff;
  23135. }
  23136. }
  23137. return [closestAxisIdx, +(closestAxis && closestAxis.coodToData(radius))];
  23138. };
  23139. Radar.prototype.resize = function (radarModel, api) {
  23140. var center = radarModel.get('center');
  23141. var viewWidth = api.getWidth();
  23142. var viewHeight = api.getHeight();
  23143. var viewSize = Math.min(viewWidth, viewHeight) / 2;
  23144. this.cx = numberUtil.parsePercent(center[0], viewWidth);
  23145. this.cy = numberUtil.parsePercent(center[1], viewHeight);
  23146. this.startAngle = radarModel.get('startAngle') * Math.PI / 180;
  23147. this.r = numberUtil.parsePercent(radarModel.get('radius'), viewSize);
  23148. zrUtil.each(this._indicatorAxes, function (indicatorAxis, idx) {
  23149. indicatorAxis.setExtent(0, this.r);
  23150. var angle = (this.startAngle + idx * Math.PI * 2 / this._indicatorAxes.length);
  23151. // Normalize to [-PI, PI]
  23152. angle = Math.atan2(Math.sin(angle), Math.cos(angle));
  23153. indicatorAxis.angle = angle;
  23154. }, this);
  23155. };
  23156. Radar.prototype.update = function (ecModel, api) {
  23157. var indicatorAxes = this._indicatorAxes;
  23158. var radarModel = this._model;
  23159. zrUtil.each(indicatorAxes, function (indicatorAxis) {
  23160. indicatorAxis.scale.setExtent(Infinity, -Infinity);
  23161. });
  23162. ecModel.eachSeriesByType('radar', function (radarSeries, idx) {
  23163. if (radarSeries.get('coordinateSystem') !== 'radar'
  23164. || ecModel.getComponent('radar', radarSeries.get('radarIndex')) !== radarModel
  23165. ) {
  23166. return;
  23167. }
  23168. var data = radarSeries.getData();
  23169. zrUtil.each(indicatorAxes, function (indicatorAxis) {
  23170. indicatorAxis.scale.unionExtent(data.getDataExtent(indicatorAxis.dim));
  23171. });
  23172. }, this);
  23173. var splitNumber = radarModel.get('splitNumber');
  23174. function increaseInterval(interval) {
  23175. var exp10 = Math.pow(10, Math.floor(Math.log(interval) / Math.LN10));
  23176. // Increase interval
  23177. var f = interval / exp10;
  23178. if (f === 2) {
  23179. f = 5;
  23180. }
  23181. else { // f is 2 or 5
  23182. f *= 2;
  23183. }
  23184. return f * exp10;
  23185. }
  23186. // Force all the axis fixing the maxSplitNumber.
  23187. zrUtil.each(indicatorAxes, function (indicatorAxis, idx) {
  23188. var rawExtent = axisHelper.getScaleExtent(indicatorAxis, indicatorAxis.model);
  23189. axisHelper.niceScaleExtent(indicatorAxis, indicatorAxis.model);
  23190. var axisModel = indicatorAxis.model;
  23191. var scale = indicatorAxis.scale;
  23192. var fixedMin = axisModel.get('min');
  23193. var fixedMax = axisModel.get('max');
  23194. var interval = scale.getInterval();
  23195. if (fixedMin != null && fixedMax != null) {
  23196. // User set min, max, divide to get new interval
  23197. // FIXME precision
  23198. scale.setInterval(
  23199. (fixedMax - fixedMin) / splitNumber
  23200. );
  23201. }
  23202. else if (fixedMin != null) {
  23203. var max;
  23204. // User set min, expand extent on the other side
  23205. do {
  23206. max = fixedMin + interval * splitNumber;
  23207. scale.setExtent(+fixedMin, max);
  23208. // Interval must been set after extent
  23209. // FIXME
  23210. scale.setInterval(interval);
  23211. interval = increaseInterval(interval);
  23212. } while (max < rawExtent[1] && isFinite(max) && isFinite(rawExtent[1]));
  23213. }
  23214. else if (fixedMax != null) {
  23215. var min;
  23216. // User set min, expand extent on the other side
  23217. do {
  23218. min = fixedMax - interval * splitNumber;
  23219. scale.setExtent(min, +fixedMax);
  23220. scale.setInterval(interval);
  23221. interval = increaseInterval(interval);
  23222. } while (min > rawExtent[0] && isFinite(min) && isFinite(rawExtent[0]));
  23223. }
  23224. else {
  23225. var nicedSplitNumber = scale.getTicks().length - 1;
  23226. if (nicedSplitNumber > splitNumber) {
  23227. interval = increaseInterval(interval);
  23228. }
  23229. // PENDING
  23230. var center = Math.round((rawExtent[0] + rawExtent[1]) / 2 / interval) * interval;
  23231. var halfSplitNumber = Math.round(splitNumber / 2);
  23232. scale.setExtent(
  23233. numberUtil.round(center - halfSplitNumber * interval),
  23234. numberUtil.round(center + (splitNumber - halfSplitNumber) * interval)
  23235. );
  23236. scale.setInterval(interval);
  23237. }
  23238. });
  23239. };
  23240. /**
  23241. * Radar dimensions is based on the data
  23242. * @type {Array}
  23243. */
  23244. Radar.dimensions = [];
  23245. Radar.create = function (ecModel, api) {
  23246. var radarList = [];
  23247. ecModel.eachComponent('radar', function (radarModel) {
  23248. var radar = new Radar(radarModel, ecModel, api);
  23249. radarList.push(radar);
  23250. radarModel.coordinateSystem = radar;
  23251. });
  23252. ecModel.eachSeriesByType('radar', function (radarSeries) {
  23253. if (radarSeries.get('coordinateSystem') === 'radar') {
  23254. // Inject coordinate system
  23255. radarSeries.coordinateSystem = radarList[radarSeries.get('radarIndex') || 0];
  23256. }
  23257. });
  23258. return radarList;
  23259. };
  23260. __webpack_require__(25).register('radar', Radar);
  23261. module.exports = Radar;
  23262. /***/ },
  23263. /* 149 */
  23264. /***/ function(module, exports, __webpack_require__) {
  23265. var zrUtil = __webpack_require__(3);
  23266. var Axis = __webpack_require__(118);
  23267. function IndicatorAxis(dim, scale, radiusExtent) {
  23268. Axis.call(this, dim, scale, radiusExtent);
  23269. /**
  23270. * Axis type
  23271. * - 'category'
  23272. * - 'value'
  23273. * - 'time'
  23274. * - 'log'
  23275. * @type {string}
  23276. */
  23277. this.type = 'value';
  23278. this.angle = 0;
  23279. /**
  23280. * Indicator name
  23281. * @type {string}
  23282. */
  23283. this.name = '';
  23284. /**
  23285. * @type {module:echarts/model/Model}
  23286. */
  23287. this.model;
  23288. }
  23289. zrUtil.inherits(IndicatorAxis, Axis);
  23290. module.exports = IndicatorAxis;
  23291. /***/ },
  23292. /* 150 */
  23293. /***/ function(module, exports, __webpack_require__) {
  23294. var axisDefault = __webpack_require__(123);
  23295. var valueAxisDefault = axisDefault.valueAxis;
  23296. var Model = __webpack_require__(8);
  23297. var zrUtil = __webpack_require__(3);
  23298. var axisModelCommonMixin = __webpack_require__(124);
  23299. function defaultsShow(opt, show) {
  23300. return zrUtil.defaults({
  23301. show: show
  23302. }, opt);
  23303. }
  23304. var RadarModel = __webpack_require__(1).extendComponentModel({
  23305. type: 'radar',
  23306. optionUpdated: function () {
  23307. var boundaryGap = this.get('boundaryGap');
  23308. var splitNumber = this.get('splitNumber');
  23309. var scale = this.get('scale');
  23310. var axisLine = this.get('axisLine');
  23311. var axisTick = this.get('axisTick');
  23312. var axisLabel = this.get('axisLabel');
  23313. var nameTextStyle = this.get('name.textStyle');
  23314. var showName = this.get('name.show');
  23315. var nameFormatter = this.get('name.formatter');
  23316. var nameGap = this.get('nameGap');
  23317. var indicatorModels = zrUtil.map(this.get('indicator') || [], function (indicatorOpt) {
  23318. // PENDING
  23319. if (indicatorOpt.max != null && indicatorOpt.max > 0) {
  23320. indicatorOpt.min = 0;
  23321. }
  23322. else if (indicatorOpt.min != null && indicatorOpt.min < 0) {
  23323. indicatorOpt.max = 0;
  23324. }
  23325. // Use same configuration
  23326. indicatorOpt = zrUtil.merge(zrUtil.clone(indicatorOpt), {
  23327. boundaryGap: boundaryGap,
  23328. splitNumber: splitNumber,
  23329. scale: scale,
  23330. axisLine: axisLine,
  23331. axisTick: axisTick,
  23332. axisLabel: axisLabel,
  23333. // Competitable with 2 and use text
  23334. name: indicatorOpt.text,
  23335. nameLocation: 'end',
  23336. nameGap: nameGap,
  23337. // min: 0,
  23338. nameTextStyle: nameTextStyle
  23339. }, false);
  23340. if (!showName) {
  23341. indicatorOpt.name = '';
  23342. }
  23343. if (typeof nameFormatter === 'string') {
  23344. indicatorOpt.name = nameFormatter.replace('{value}', indicatorOpt.name);
  23345. }
  23346. else if (typeof nameFormatter === 'function') {
  23347. indicatorOpt.name = nameFormatter(
  23348. indicatorOpt.name, indicatorOpt
  23349. );
  23350. }
  23351. return zrUtil.extend(
  23352. new Model(indicatorOpt, null, this.ecModel),
  23353. axisModelCommonMixin
  23354. );
  23355. }, this);
  23356. this.getIndicatorModels = function () {
  23357. return indicatorModels;
  23358. };
  23359. },
  23360. defaultOption: {
  23361. zlevel: 0,
  23362. z: 0,
  23363. center: ['50%', '50%'],
  23364. radius: '75%',
  23365. startAngle: 90,
  23366. name: {
  23367. show: true
  23368. // formatter: null
  23369. // textStyle: {}
  23370. },
  23371. boundaryGap: [0, 0],
  23372. splitNumber: 5,
  23373. nameGap: 15,
  23374. scale: false,
  23375. // Polygon or circle
  23376. shape: 'polygon',
  23377. axisLine: zrUtil.merge(
  23378. {
  23379. lineStyle: {
  23380. color: '#bbb'
  23381. }
  23382. },
  23383. valueAxisDefault.axisLine
  23384. ),
  23385. axisLabel: defaultsShow(valueAxisDefault.axisLabel, false),
  23386. axisTick: defaultsShow(valueAxisDefault.axisTick, false),
  23387. splitLine: defaultsShow(valueAxisDefault.splitLine, true),
  23388. splitArea: defaultsShow(valueAxisDefault.splitArea, true),
  23389. // {text, min, max}
  23390. indicator: []
  23391. }
  23392. });
  23393. module.exports = RadarModel;
  23394. /***/ },
  23395. /* 151 */
  23396. /***/ function(module, exports, __webpack_require__) {
  23397. var AxisBuilder = __webpack_require__(127);
  23398. var zrUtil = __webpack_require__(3);
  23399. var graphic = __webpack_require__(42);
  23400. var axisBuilderAttrs = [
  23401. 'axisLine', 'axisLabel', 'axisTick', 'axisName'
  23402. ];
  23403. module.exports = __webpack_require__(1).extendComponentView({
  23404. type: 'radar',
  23405. render: function (radarModel, ecModel, api) {
  23406. var group = this.group;
  23407. group.removeAll();
  23408. this._buildAxes(radarModel);
  23409. this._buildSplitLineAndArea(radarModel);
  23410. },
  23411. _buildAxes: function (radarModel) {
  23412. var radar = radarModel.coordinateSystem;
  23413. var indicatorAxes = radar.getIndicatorAxes();
  23414. var axisBuilders = zrUtil.map(indicatorAxes, function (indicatorAxis) {
  23415. var axisBuilder = new AxisBuilder(indicatorAxis.model, {
  23416. position: [radar.cx, radar.cy],
  23417. rotation: indicatorAxis.angle,
  23418. labelDirection: -1,
  23419. tickDirection: -1,
  23420. nameDirection: 1
  23421. });
  23422. return axisBuilder;
  23423. });
  23424. zrUtil.each(axisBuilders, function (axisBuilder) {
  23425. zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder);
  23426. this.group.add(axisBuilder.getGroup());
  23427. }, this);
  23428. },
  23429. _buildSplitLineAndArea: function (radarModel) {
  23430. var radar = radarModel.coordinateSystem;
  23431. var splitNumber = radarModel.get('splitNumber');
  23432. var indicatorAxes = radar.getIndicatorAxes();
  23433. if (!indicatorAxes.length) {
  23434. return;
  23435. }
  23436. var shape = radarModel.get('shape');
  23437. var splitLineModel = radarModel.getModel('splitLine');
  23438. var splitAreaModel = radarModel.getModel('splitArea');
  23439. var lineStyleModel = splitLineModel.getModel('lineStyle');
  23440. var areaStyleModel = splitAreaModel.getModel('areaStyle');
  23441. var showSplitLine = splitLineModel.get('show');
  23442. var showSplitArea = splitAreaModel.get('show');
  23443. var splitLineColors = lineStyleModel.get('color');
  23444. var splitAreaColors = areaStyleModel.get('color');
  23445. splitLineColors = zrUtil.isArray(splitLineColors) ? splitLineColors : [splitLineColors];
  23446. splitAreaColors = zrUtil.isArray(splitAreaColors) ? splitAreaColors : [splitAreaColors];
  23447. var splitLines = [];
  23448. var splitAreas = [];
  23449. function getColorIndex(areaOrLine, areaOrLineColorList, idx) {
  23450. var colorIndex = idx % areaOrLineColorList.length;
  23451. areaOrLine[colorIndex] = areaOrLine[colorIndex] || [];
  23452. return colorIndex;
  23453. }
  23454. if (shape === 'circle') {
  23455. var ticksRadius = indicatorAxes[0].getTicksCoords();
  23456. var cx = radar.cx;
  23457. var cy = radar.cy;
  23458. for (var i = 0; i < ticksRadius.length; i++) {
  23459. if (showSplitLine) {
  23460. var colorIndex = getColorIndex(splitLines, splitLineColors, i);
  23461. splitLines[colorIndex].push(new graphic.Circle({
  23462. shape: {
  23463. cx: cx,
  23464. cy: cy,
  23465. r: ticksRadius[i]
  23466. }
  23467. }));
  23468. }
  23469. if (showSplitArea && i < ticksRadius.length - 1) {
  23470. var colorIndex = getColorIndex(splitAreas, splitAreaColors, i);
  23471. splitAreas[colorIndex].push(new graphic.Ring({
  23472. shape: {
  23473. cx: cx,
  23474. cy: cy,
  23475. r0: ticksRadius[i],
  23476. r: ticksRadius[i + 1]
  23477. }
  23478. }));
  23479. }
  23480. }
  23481. }
  23482. // Polyyon
  23483. else {
  23484. var axesTicksPoints = zrUtil.map(indicatorAxes, function (indicatorAxis, idx) {
  23485. var ticksCoords = indicatorAxis.getTicksCoords();
  23486. return zrUtil.map(ticksCoords, function (tickCoord) {
  23487. return radar.coordToPoint(tickCoord, idx);
  23488. });
  23489. });
  23490. var prevPoints = [];
  23491. for (var i = 0; i <= splitNumber; i++) {
  23492. var points = [];
  23493. for (var j = 0; j < indicatorAxes.length; j++) {
  23494. points.push(axesTicksPoints[j][i]);
  23495. }
  23496. // Close
  23497. points.push(points[0].slice());
  23498. if (showSplitLine) {
  23499. var colorIndex = getColorIndex(splitLines, splitLineColors, i);
  23500. splitLines[colorIndex].push(new graphic.Polyline({
  23501. shape: {
  23502. points: points
  23503. }
  23504. }));
  23505. }
  23506. if (showSplitArea && prevPoints) {
  23507. var colorIndex = getColorIndex(splitAreas, splitAreaColors, i - 1);
  23508. splitAreas[colorIndex].push(new graphic.Polygon({
  23509. shape: {
  23510. points: points.concat(prevPoints)
  23511. }
  23512. }));
  23513. }
  23514. prevPoints = points.slice().reverse();
  23515. }
  23516. }
  23517. var lineStyle = lineStyleModel.getLineStyle();
  23518. var areaStyle = areaStyleModel.getAreaStyle();
  23519. // Add splitArea before splitLine
  23520. zrUtil.each(splitAreas, function (splitAreas, idx) {
  23521. this.group.add(graphic.mergePath(
  23522. splitAreas, {
  23523. style: zrUtil.defaults({
  23524. stroke: 'none',
  23525. fill: splitAreaColors[idx % splitAreaColors.length]
  23526. }, areaStyle),
  23527. silent: true
  23528. }
  23529. ));
  23530. }, this);
  23531. zrUtil.each(splitLines, function (splitLines, idx) {
  23532. this.group.add(graphic.mergePath(
  23533. splitLines, {
  23534. style: zrUtil.defaults({
  23535. fill: 'none',
  23536. stroke: splitLineColors[idx % splitLineColors.length]
  23537. }, lineStyle),
  23538. silent: true
  23539. }
  23540. ));
  23541. }, this);
  23542. }
  23543. });
  23544. /***/ },
  23545. /* 152 */
  23546. /***/ function(module, exports, __webpack_require__) {
  23547. 'use strict';
  23548. var SeriesModel = __webpack_require__(27);
  23549. var List = __webpack_require__(95);
  23550. var completeDimensions = __webpack_require__(97);
  23551. var zrUtil = __webpack_require__(3);
  23552. var RadarSeries = SeriesModel.extend({
  23553. type: 'series.radar',
  23554. dependencies: ['radar'],
  23555. // Overwrite
  23556. init: function (option) {
  23557. RadarSeries.superApply(this, 'init', arguments);
  23558. // Enable legend selection for each data item
  23559. // Use a function instead of direct access because data reference may changed
  23560. this.legendDataProvider = function () {
  23561. return this._dataBeforeProcessed;
  23562. };
  23563. },
  23564. getInitialData: function (option, ecModel) {
  23565. var data = option.data || [];
  23566. var dimensions = completeDimensions(
  23567. [], data, [], 'indicator_'
  23568. );
  23569. var list = new List(dimensions, this);
  23570. list.initData(data);
  23571. return list;
  23572. },
  23573. formatTooltip: function (dataIndex) {
  23574. var value = this.getRawValue(dataIndex);
  23575. var coordSys = this.coordinateSystem;
  23576. var indicatorAxes = coordSys.getIndicatorAxes();
  23577. return this._data.getName(dataIndex) + '<br />'
  23578. + zrUtil.map(indicatorAxes, function (axis, idx) {
  23579. return axis.name + ' : ' + value[idx];
  23580. }).join('<br />');
  23581. },
  23582. defaultOption: {
  23583. zlevel: 0,
  23584. z: 2,
  23585. coordinateSystem: 'radar',
  23586. legendHoverLink: true,
  23587. radarIndex: 0,
  23588. lineStyle: {
  23589. normal: {
  23590. width: 2,
  23591. type: 'solid'
  23592. }
  23593. },
  23594. label: {
  23595. normal: {
  23596. position: 'top'
  23597. }
  23598. },
  23599. // areaStyle: {
  23600. // },
  23601. // itemStyle: {}
  23602. symbol: 'emptyCircle',
  23603. symbolSize: 4
  23604. // symbolRotate: null
  23605. }
  23606. });
  23607. module.exports = RadarSeries;
  23608. /***/ },
  23609. /* 153 */
  23610. /***/ function(module, exports, __webpack_require__) {
  23611. var graphic = __webpack_require__(42);
  23612. var zrUtil = __webpack_require__(3);
  23613. var symbolUtil = __webpack_require__(101);
  23614. function normalizeSymbolSize(symbolSize) {
  23615. if (!zrUtil.isArray(symbolSize)) {
  23616. symbolSize = [+symbolSize, +symbolSize];
  23617. }
  23618. return symbolSize;
  23619. }
  23620. module.exports = __webpack_require__(1).extendChartView({
  23621. type: 'radar',
  23622. render: function (seriesModel, ecModel, api) {
  23623. var polar = seriesModel.coordinateSystem;
  23624. var group = this.group;
  23625. var data = seriesModel.getData();
  23626. var oldData = this._data;
  23627. function createSymbol(data, idx) {
  23628. var symbolType = data.getItemVisual(idx, 'symbol') || 'circle';
  23629. var color = data.getItemVisual(idx, 'color');
  23630. if (symbolType === 'none') {
  23631. return;
  23632. }
  23633. var symbolPath = symbolUtil.createSymbol(
  23634. symbolType, -0.5, -0.5, 1, 1, color
  23635. );
  23636. symbolPath.attr({
  23637. style: {
  23638. strokeNoScale: true
  23639. },
  23640. z2: 100,
  23641. scale: normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'))
  23642. });
  23643. return symbolPath;
  23644. }
  23645. function updateSymbols(oldPoints, newPoints, symbolGroup, data, idx, isInit) {
  23646. // Simply rerender all
  23647. symbolGroup.removeAll();
  23648. for (var i = 0; i < newPoints.length - 1; i++) {
  23649. var symbolPath = createSymbol(data, idx);
  23650. if (symbolPath) {
  23651. symbolPath.__dimIdx = i;
  23652. if (oldPoints[i]) {
  23653. symbolPath.attr('position', oldPoints[i]);
  23654. graphic[isInit ? 'initProps' : 'updateProps'](
  23655. symbolPath, {
  23656. position: newPoints[i]
  23657. }, seriesModel, idx
  23658. );
  23659. }
  23660. else {
  23661. symbolPath.attr('position', newPoints[i]);
  23662. }
  23663. symbolGroup.add(symbolPath);
  23664. }
  23665. }
  23666. }
  23667. function getInitialPoints(points) {
  23668. return zrUtil.map(points, function (pt) {
  23669. return [polar.cx, polar.cy];
  23670. });
  23671. }
  23672. data.diff(oldData)
  23673. .add(function (idx) {
  23674. var points = data.getItemLayout(idx);
  23675. if (!points) {
  23676. return;
  23677. }
  23678. var polygon = new graphic.Polygon();
  23679. var polyline = new graphic.Polyline();
  23680. var target = {
  23681. shape: {
  23682. points: points
  23683. }
  23684. };
  23685. polygon.shape.points = getInitialPoints(points);
  23686. polyline.shape.points = getInitialPoints(points);
  23687. graphic.initProps(polygon, target, seriesModel, idx);
  23688. graphic.initProps(polyline, target, seriesModel, idx);
  23689. var itemGroup = new graphic.Group();
  23690. var symbolGroup = new graphic.Group();
  23691. itemGroup.add(polyline);
  23692. itemGroup.add(polygon);
  23693. itemGroup.add(symbolGroup);
  23694. updateSymbols(
  23695. polyline.shape.points, points, symbolGroup, data, idx, true
  23696. );
  23697. data.setItemGraphicEl(idx, itemGroup);
  23698. })
  23699. .update(function (newIdx, oldIdx) {
  23700. var itemGroup = oldData.getItemGraphicEl(oldIdx);
  23701. var polyline = itemGroup.childAt(0);
  23702. var polygon = itemGroup.childAt(1);
  23703. var symbolGroup = itemGroup.childAt(2);
  23704. var target = {
  23705. shape: {
  23706. points: data.getItemLayout(newIdx)
  23707. }
  23708. };
  23709. if (!target.shape.points) {
  23710. return;
  23711. }
  23712. updateSymbols(
  23713. polyline.shape.points, target.shape.points, symbolGroup, data, newIdx, false
  23714. );
  23715. graphic.updateProps(polyline, target, seriesModel);
  23716. graphic.updateProps(polygon, target, seriesModel);
  23717. data.setItemGraphicEl(newIdx, itemGroup);
  23718. })
  23719. .remove(function (idx) {
  23720. group.remove(oldData.getItemGraphicEl(idx));
  23721. })
  23722. .execute();
  23723. data.eachItemGraphicEl(function (itemGroup, idx) {
  23724. var itemModel = data.getItemModel(idx);
  23725. var polyline = itemGroup.childAt(0);
  23726. var polygon = itemGroup.childAt(1);
  23727. var symbolGroup = itemGroup.childAt(2);
  23728. var color = data.getItemVisual(idx, 'color');
  23729. group.add(itemGroup);
  23730. polyline.useStyle(
  23731. zrUtil.extend(
  23732. itemModel.getModel('lineStyle.normal').getLineStyle(),
  23733. {
  23734. fill: 'none',
  23735. stroke: color
  23736. }
  23737. )
  23738. );
  23739. polyline.hoverStyle = itemModel.getModel('lineStyle.emphasis').getLineStyle();
  23740. var areaStyleModel = itemModel.getModel('areaStyle.normal');
  23741. var hoverAreaStyleModel = itemModel.getModel('areaStyle.emphasis');
  23742. var polygonIgnore = areaStyleModel.isEmpty() && areaStyleModel.parentModel.isEmpty();
  23743. var hoverPolygonIgnore = hoverAreaStyleModel.isEmpty() && hoverAreaStyleModel.parentModel.isEmpty();
  23744. hoverPolygonIgnore = hoverPolygonIgnore && polygonIgnore;
  23745. polygon.ignore = polygonIgnore;
  23746. polygon.useStyle(
  23747. zrUtil.defaults(
  23748. areaStyleModel.getAreaStyle(),
  23749. {
  23750. fill: color,
  23751. opacity: 0.7
  23752. }
  23753. )
  23754. );
  23755. polygon.hoverStyle = hoverAreaStyleModel.getAreaStyle();
  23756. var itemStyle = itemModel.getModel('itemStyle.normal').getItemStyle(['color']);
  23757. var itemHoverStyle = itemModel.getModel('itemStyle.emphasis').getItemStyle();
  23758. var labelModel = itemModel.getModel('label.normal');
  23759. var labelHoverModel = itemModel.getModel('label.emphasis');
  23760. symbolGroup.eachChild(function (symbolPath) {
  23761. symbolPath.setStyle(itemStyle);
  23762. symbolPath.hoverStyle = zrUtil.clone(itemHoverStyle);
  23763. var defaultText = data.get(data.dimensions[symbolPath.__dimIdx], idx);
  23764. graphic.setText(symbolPath.style, labelModel, color);
  23765. symbolPath.setStyle({
  23766. text: labelModel.get('show') ? zrUtil.retrieve(
  23767. seriesModel.getFormattedLabel(
  23768. idx, 'normal', null, symbolPath.__dimIdx
  23769. ),
  23770. defaultText
  23771. ) : ''
  23772. });
  23773. graphic.setText(symbolPath.hoverStyle, labelHoverModel, color);
  23774. symbolPath.hoverStyle.text = labelHoverModel.get('show') ? zrUtil.retrieve(
  23775. seriesModel.getFormattedLabel(
  23776. idx, 'emphasis', null, symbolPath.__dimIdx
  23777. ),
  23778. defaultText
  23779. ) : '';
  23780. });
  23781. function onEmphasis() {
  23782. polygon.attr('ignore', hoverPolygonIgnore);
  23783. }
  23784. function onNormal() {
  23785. polygon.attr('ignore', polygonIgnore);
  23786. }
  23787. itemGroup.off('mouseover').off('mouseout').off('normal').off('emphasis');
  23788. itemGroup.on('emphasis', onEmphasis)
  23789. .on('mouseover', onEmphasis)
  23790. .on('normal', onNormal)
  23791. .on('mouseout', onNormal);
  23792. graphic.setHoverStyle(itemGroup);
  23793. });
  23794. this._data = data;
  23795. },
  23796. remove: function () {
  23797. this.group.removeAll();
  23798. this._data = null;
  23799. }
  23800. });
  23801. /***/ },
  23802. /* 154 */
  23803. /***/ function(module, exports) {
  23804. module.exports = function (ecModel, api) {
  23805. ecModel.eachSeriesByType('radar', function (seriesModel) {
  23806. var data = seriesModel.getData();
  23807. var points = [];
  23808. var coordSys = seriesModel.coordinateSystem;
  23809. if (!coordSys) {
  23810. return;
  23811. }
  23812. function pointsConverter(val, idx) {
  23813. points[idx] = points[idx] || [];
  23814. points[idx][i] = coordSys.dataToPoint(val, i);
  23815. }
  23816. for (var i = 0; i < coordSys.getIndicatorAxes().length; i++) {
  23817. var dim = data.dimensions[i];
  23818. data.each(dim, pointsConverter);
  23819. }
  23820. data.each(function (idx) {
  23821. // Close polygon
  23822. points[idx][0] && points[idx].push(points[idx][0].slice());
  23823. data.setItemLayout(idx, points[idx]);
  23824. });
  23825. });
  23826. };
  23827. /***/ },
  23828. /* 155 */
  23829. /***/ function(module, exports, __webpack_require__) {
  23830. // Backward compat for radar chart in 2
  23831. var zrUtil = __webpack_require__(3);
  23832. module.exports = function (option) {
  23833. var polarOptArr = option.polar;
  23834. if (polarOptArr) {
  23835. if (!zrUtil.isArray(polarOptArr)) {
  23836. polarOptArr = [polarOptArr];
  23837. }
  23838. var polarNotRadar = [];
  23839. zrUtil.each(polarOptArr, function (polarOpt, idx) {
  23840. if (polarOpt.indicator) {
  23841. if (polarOpt.type && !polarOpt.shape) {
  23842. polarOpt.shape = polarOpt.type;
  23843. }
  23844. option.radar = option.radar || [];
  23845. if (!zrUtil.isArray(option.radar)) {
  23846. option.radar = [option.radar];
  23847. }
  23848. option.radar.push(polarOpt);
  23849. }
  23850. else {
  23851. polarNotRadar.push(polarOpt);
  23852. }
  23853. });
  23854. option.polar = polarNotRadar;
  23855. }
  23856. zrUtil.each(option.series, function (seriesOpt) {
  23857. if (seriesOpt.type === 'radar' && seriesOpt.polarIndex) {
  23858. seriesOpt.radarIndex = seriesOpt.polarIndex;
  23859. }
  23860. });
  23861. };
  23862. /***/ },
  23863. /* 156 */
  23864. /***/ function(module, exports, __webpack_require__) {
  23865. var echarts = __webpack_require__(1);
  23866. __webpack_require__(157);
  23867. __webpack_require__(167);
  23868. __webpack_require__(171);
  23869. __webpack_require__(158);
  23870. echarts.registerLayout(__webpack_require__(173));
  23871. echarts.registerVisualCoding('chart', __webpack_require__(174));
  23872. echarts.registerProcessor('statistic', __webpack_require__(175));
  23873. echarts.registerPreprocessor(__webpack_require__(176));
  23874. __webpack_require__(137)('map', [{
  23875. type: 'mapToggleSelect',
  23876. event: 'mapselectchanged',
  23877. method: 'toggleSelected'
  23878. }, {
  23879. type: 'mapSelect',
  23880. event: 'mapselected',
  23881. method: 'select'
  23882. }, {
  23883. type: 'mapUnSelect',
  23884. event: 'mapunselected',
  23885. method: 'unSelect'
  23886. }]);
  23887. /***/ },
  23888. /* 157 */
  23889. /***/ function(module, exports, __webpack_require__) {
  23890. var List = __webpack_require__(95);
  23891. var SeriesModel = __webpack_require__(27);
  23892. var zrUtil = __webpack_require__(3);
  23893. var completeDimensions = __webpack_require__(97);
  23894. var formatUtil = __webpack_require__(6);
  23895. var encodeHTML = formatUtil.encodeHTML;
  23896. var addCommas = formatUtil.addCommas;
  23897. var dataSelectableMixin = __webpack_require__(135);
  23898. var geoCreator = __webpack_require__(158);
  23899. var MapSeries = SeriesModel.extend({
  23900. type: 'series.map',
  23901. /**
  23902. * Only first map series of same mapType will drawMap
  23903. * @type {boolean}
  23904. */
  23905. needsDrawMap: false,
  23906. /**
  23907. * Group of all map series with same mapType
  23908. * @type {boolean}
  23909. */
  23910. seriesGroup: [],
  23911. init: function (option) {
  23912. option = this._fillOption(option, option.map);
  23913. this.option = option;
  23914. MapSeries.superApply(this, 'init', arguments);
  23915. this.updateSelectedMap(option.data);
  23916. },
  23917. getInitialData: function (option) {
  23918. var dimensions = completeDimensions(['value'], option.data || []);
  23919. var list = new List(dimensions, this);
  23920. list.initData(option.data);
  23921. return list;
  23922. },
  23923. mergeOption: function (newOption) {
  23924. if (newOption.data) {
  23925. newOption = this._fillOption(newOption, this.option.map);
  23926. }
  23927. MapSeries.superCall(this, 'mergeOption', newOption);
  23928. this.updateSelectedMap(this.option.data);
  23929. },
  23930. _fillOption: function (option, mapName) {
  23931. // Shallow clone
  23932. option = zrUtil.extend({}, option);
  23933. option.data = geoCreator.getFilledRegions(option.data, mapName);
  23934. return option;
  23935. },
  23936. getRawValue: function (dataIndex) {
  23937. // Use value stored in data instead because it is calculated from multiple series
  23938. // FIXME Provide all value of multiple series ?
  23939. return this._data.get('value', dataIndex);
  23940. },
  23941. /**
  23942. * Get model of region
  23943. * @param {string} name
  23944. * @return {module:echarts/model/Model}
  23945. */
  23946. getRegionModel: function (regionName) {
  23947. var data = this.getData();
  23948. return data.getItemModel(data.indexOfName(regionName));
  23949. },
  23950. /**
  23951. * Map tooltip formatter
  23952. *
  23953. * @param {number} dataIndex
  23954. */
  23955. formatTooltip: function (dataIndex) {
  23956. var data = this._data;
  23957. var formattedValue = addCommas(this.getRawValue(dataIndex));
  23958. var name = data.getName(dataIndex);
  23959. var seriesGroup = this.seriesGroup;
  23960. var seriesNames = [];
  23961. for (var i = 0; i < seriesGroup.length; i++) {
  23962. if (!isNaN(seriesGroup[i].getRawValue(dataIndex))) {
  23963. seriesNames.push(
  23964. encodeHTML(seriesGroup[i].name)
  23965. );
  23966. }
  23967. }
  23968. return seriesNames.join(', ') + '<br />'
  23969. + name + ' : ' + formattedValue;
  23970. },
  23971. defaultOption: {
  23972. // 一级层叠
  23973. zlevel: 0,
  23974. // 二级层叠
  23975. z: 2,
  23976. coordinateSystem: 'geo',
  23977. // 各省的 map 暂时都用中文
  23978. map: 'china',
  23979. // 'center' | 'left' | 'right' | 'x%' | {number}
  23980. left: 'center',
  23981. // 'center' | 'top' | 'bottom' | 'x%' | {number}
  23982. top: 'center',
  23983. // right
  23984. // bottom
  23985. // width:
  23986. // height // 自适应
  23987. // 数值合并方式,默认加和,可选为:
  23988. // 'sum' | 'average' | 'max' | 'min'
  23989. // mapValueCalculation: 'sum',
  23990. // 地图数值计算结果小数精度
  23991. // mapValuePrecision: 0,
  23992. // 显示图例颜色标识(系列标识的小圆点),图例开启时有效
  23993. showLegendSymbol: true,
  23994. // 选择模式,默认关闭,可选single,multiple
  23995. // selectedMode: false,
  23996. dataRangeHoverLink: true,
  23997. // 是否开启缩放及漫游模式
  23998. // roam: false,
  23999. // Default on center of map
  24000. center: null,
  24001. zoom: 1,
  24002. scaleLimit: null,
  24003. label: {
  24004. normal: {
  24005. show: false,
  24006. textStyle: {
  24007. color: '#000'
  24008. }
  24009. },
  24010. emphasis: {
  24011. show: true,
  24012. textStyle: {
  24013. color: 'rgb(100,0,0)'
  24014. }
  24015. }
  24016. },
  24017. // scaleLimit: null,
  24018. itemStyle: {
  24019. normal: {
  24020. // color: 各异,
  24021. borderWidth: 0.5,
  24022. borderColor: '#444',
  24023. areaColor: '#eee'
  24024. },
  24025. // 也是选中样式
  24026. emphasis: {
  24027. areaColor: 'rgba(255,215, 0, 0.8)'
  24028. }
  24029. }
  24030. },
  24031. setZoom: function (zoom) {
  24032. this.option.zoom = zoom;
  24033. },
  24034. setCenter: function (center) {
  24035. this.option.center = center;
  24036. }
  24037. });
  24038. zrUtil.mixin(MapSeries, dataSelectableMixin);
  24039. module.exports = MapSeries;
  24040. /***/ },
  24041. /* 158 */
  24042. /***/ function(module, exports, __webpack_require__) {
  24043. var Geo = __webpack_require__(159);
  24044. var layout = __webpack_require__(21);
  24045. var zrUtil = __webpack_require__(3);
  24046. var mapDataStores = {};
  24047. /**
  24048. * Resize method bound to the geo
  24049. * @param {module:echarts/coord/geo/GeoModel|module:echarts/chart/map/MapModel} geoModel
  24050. * @param {module:echarts/ExtensionAPI} api
  24051. */
  24052. function resizeGeo (geoModel, api) {
  24053. var rect = this.getBoundingRect();
  24054. var boxLayoutOption = geoModel.getBoxLayoutParams();
  24055. // 0.75 rate
  24056. boxLayoutOption.aspect = rect.width / rect.height * 0.75;
  24057. var viewRect = layout.getLayoutRect(boxLayoutOption, {
  24058. width: api.getWidth(),
  24059. height: api.getHeight()
  24060. });
  24061. this.setViewRect(viewRect.x, viewRect.y, viewRect.width, viewRect.height);
  24062. this.setCenter(geoModel.get('center'));
  24063. this.setZoom(geoModel.get('zoom'));
  24064. }
  24065. /**
  24066. * @param {module:echarts/coord/Geo} geo
  24067. * @param {module:echarts/model/Model} model
  24068. * @inner
  24069. */
  24070. function setGeoCoords(geo, model) {
  24071. zrUtil.each(model.get('geoCoord'), function (geoCoord, name) {
  24072. geo.addGeoCoord(name, geoCoord);
  24073. });
  24074. }
  24075. function mapNotExistsError(name) {
  24076. console.error('Map ' + name + ' not exists');
  24077. }
  24078. var geoCreator = {
  24079. // For deciding which dimensions to use when creating list data
  24080. dimensions: Geo.prototype.dimensions,
  24081. create: function (ecModel, api) {
  24082. var geoList = [];
  24083. // FIXME Create each time may be slow
  24084. ecModel.eachComponent('geo', function (geoModel, idx) {
  24085. var name = geoModel.get('map');
  24086. var mapData = mapDataStores[name];
  24087. if (!mapData) {
  24088. mapNotExistsError(name);
  24089. }
  24090. var geo = new Geo(
  24091. name + idx, name,
  24092. mapData && mapData.geoJson, mapData && mapData.specialAreas,
  24093. geoModel.get('nameMap')
  24094. );
  24095. geo.zoomLimit = geoModel.get('scaleLimit');
  24096. geoList.push(geo);
  24097. setGeoCoords(geo, geoModel);
  24098. geoModel.coordinateSystem = geo;
  24099. geo.model = geoModel;
  24100. // Inject resize method
  24101. geo.resize = resizeGeo;
  24102. geo.resize(geoModel, api);
  24103. });
  24104. ecModel.eachSeries(function (seriesModel) {
  24105. var coordSys = seriesModel.get('coordinateSystem');
  24106. if (coordSys === 'geo') {
  24107. var geoIndex = seriesModel.get('geoIndex') || 0;
  24108. seriesModel.coordinateSystem = geoList[geoIndex];
  24109. }
  24110. });
  24111. // If has map series
  24112. var mapModelGroupBySeries = {};
  24113. ecModel.eachSeriesByType('map', function (seriesModel) {
  24114. var mapType = seriesModel.get('map');
  24115. mapModelGroupBySeries[mapType] = mapModelGroupBySeries[mapType] || [];
  24116. mapModelGroupBySeries[mapType].push(seriesModel);
  24117. });
  24118. zrUtil.each(mapModelGroupBySeries, function (mapSeries, mapType) {
  24119. var mapData = mapDataStores[mapType];
  24120. if (!mapData) {
  24121. mapNotExistsError(name);
  24122. }
  24123. var nameMapList = zrUtil.map(mapSeries, function (singleMapSeries) {
  24124. return singleMapSeries.get('nameMap');
  24125. });
  24126. var geo = new Geo(
  24127. mapType, mapType,
  24128. mapData && mapData.geoJson, mapData && mapData.specialAreas,
  24129. zrUtil.mergeAll(nameMapList)
  24130. );
  24131. geo.zoomLimit = zrUtil.retrieve.apply(null, zrUtil.map(mapSeries, function (singleMapSeries) {
  24132. return singleMapSeries.get('scaleLimit');
  24133. }));
  24134. geoList.push(geo);
  24135. // Inject resize method
  24136. geo.resize = resizeGeo;
  24137. geo.resize(mapSeries[0], api);
  24138. zrUtil.each(mapSeries, function (singleMapSeries) {
  24139. singleMapSeries.coordinateSystem = geo;
  24140. setGeoCoords(geo, singleMapSeries);
  24141. });
  24142. });
  24143. return geoList;
  24144. },
  24145. /**
  24146. * @param {string} mapName
  24147. * @param {Object|string} geoJson
  24148. * @param {Object} [specialAreas]
  24149. *
  24150. * @example
  24151. * $.get('USA.json', function (geoJson) {
  24152. * echarts.registerMap('USA', geoJson);
  24153. * // Or
  24154. * echarts.registerMap('USA', {
  24155. * geoJson: geoJson,
  24156. * specialAreas: {}
  24157. * })
  24158. * });
  24159. */
  24160. registerMap: function (mapName, geoJson, specialAreas) {
  24161. if (geoJson.geoJson && !geoJson.features) {
  24162. specialAreas = geoJson.specialAreas;
  24163. geoJson = geoJson.geoJson;
  24164. }
  24165. if (typeof geoJson === 'string') {
  24166. geoJson = (typeof JSON !== 'undefined' && JSON.parse)
  24167. ? JSON.parse(geoJson) : (new Function('return (' + geoJson + ');'))();
  24168. }
  24169. mapDataStores[mapName] = {
  24170. geoJson: geoJson,
  24171. specialAreas: specialAreas
  24172. };
  24173. },
  24174. /**
  24175. * @param {string} mapName
  24176. * @return {Object}
  24177. */
  24178. getMap: function (mapName) {
  24179. return mapDataStores[mapName];
  24180. },
  24181. /**
  24182. * Fill given regions array
  24183. * @param {Array.<Object>} originRegionArr
  24184. * @param {string} mapName
  24185. * @return {Array}
  24186. */
  24187. getFilledRegions: function (originRegionArr, mapName) {
  24188. // Not use the original
  24189. var regionsArr = (originRegionArr || []).slice();
  24190. var map = geoCreator.getMap(mapName);
  24191. var geoJson = map && map.geoJson;
  24192. var dataNameMap = {};
  24193. var features = geoJson.features;
  24194. for (var i = 0; i < regionsArr.length; i++) {
  24195. dataNameMap[regionsArr[i].name] = regionsArr[i];
  24196. }
  24197. for (var i = 0; i < features.length; i++) {
  24198. var name = features[i].properties.name;
  24199. if (!dataNameMap[name]) {
  24200. regionsArr.push({
  24201. name: name
  24202. });
  24203. }
  24204. }
  24205. return regionsArr;
  24206. }
  24207. };
  24208. // Inject methods into echarts
  24209. var echarts = __webpack_require__(1);
  24210. echarts.registerMap = geoCreator.registerMap;
  24211. echarts.getMap = geoCreator.getMap;
  24212. // TODO
  24213. echarts.loadMap = function () {};
  24214. echarts.registerCoordinateSystem('geo', geoCreator);
  24215. module.exports = geoCreator;
  24216. /***/ },
  24217. /* 159 */
  24218. /***/ function(module, exports, __webpack_require__) {
  24219. var parseGeoJson = __webpack_require__(160);
  24220. var zrUtil = __webpack_require__(3);
  24221. var BoundingRect = __webpack_require__(15);
  24222. var View = __webpack_require__(163);
  24223. // Geo fix functions
  24224. var geoFixFuncs = [
  24225. __webpack_require__(164),
  24226. __webpack_require__(165),
  24227. __webpack_require__(166)
  24228. ];
  24229. /**
  24230. * [Geo description]
  24231. * @param {string} name Geo name
  24232. * @param {string} map Map type
  24233. * @param {Object} geoJson
  24234. * @param {Object} [specialAreas]
  24235. * Specify the positioned areas by left, top, width, height
  24236. * @param {Object.<string, string>} [nameMap]
  24237. * Specify name alias
  24238. */
  24239. function Geo(name, map, geoJson, specialAreas, nameMap) {
  24240. View.call(this, name);
  24241. /**
  24242. * Map type
  24243. * @type {string}
  24244. */
  24245. this.map = map;
  24246. this._nameCoordMap = {};
  24247. this.loadGeoJson(geoJson, specialAreas, nameMap);
  24248. }
  24249. Geo.prototype = {
  24250. constructor: Geo,
  24251. type: 'geo',
  24252. /**
  24253. * @param {Array.<string>}
  24254. * @readOnly
  24255. */
  24256. dimensions: ['lng', 'lat'],
  24257. /**
  24258. * If contain given lng,lat coord
  24259. * @param {Array.<number>}
  24260. * @readOnly
  24261. */
  24262. containCoord: function (coord) {
  24263. var regions = this.regions;
  24264. for (var i = 0; i < regions.length; i++) {
  24265. if (regions[i].contain(coord)) {
  24266. return true;
  24267. }
  24268. }
  24269. return false;
  24270. },
  24271. /**
  24272. * @param {Object} geoJson
  24273. * @param {Object} [specialAreas]
  24274. * Specify the positioned areas by left, top, width, height
  24275. * @param {Object.<string, string>} [nameMap]
  24276. * Specify name alias
  24277. */
  24278. loadGeoJson: function (geoJson, specialAreas, nameMap) {
  24279. // https://jsperf.com/try-catch-performance-overhead
  24280. try {
  24281. this.regions = geoJson ? parseGeoJson(geoJson) : [];
  24282. }
  24283. catch (e) {
  24284. throw 'Invalid geoJson format\n' + e;
  24285. }
  24286. specialAreas = specialAreas || {};
  24287. nameMap = nameMap || {};
  24288. var regions = this.regions;
  24289. var regionsMap = {};
  24290. for (var i = 0; i < regions.length; i++) {
  24291. var regionName = regions[i].name;
  24292. // Try use the alias in nameMap
  24293. regionName = nameMap[regionName] || regionName;
  24294. regions[i].name = regionName;
  24295. regionsMap[regionName] = regions[i];
  24296. // Add geoJson
  24297. this.addGeoCoord(regionName, regions[i].center);
  24298. // Some area like Alaska in USA map needs to be tansformed
  24299. // to look better
  24300. var specialArea = specialAreas[regionName];
  24301. if (specialArea) {
  24302. regions[i].transformTo(
  24303. specialArea.left, specialArea.top, specialArea.width, specialArea.height
  24304. );
  24305. }
  24306. }
  24307. this._regionsMap = regionsMap;
  24308. this._rect = null;
  24309. zrUtil.each(geoFixFuncs, function (fixFunc) {
  24310. fixFunc(this);
  24311. }, this);
  24312. },
  24313. // Overwrite
  24314. transformTo: function (x, y, width, height) {
  24315. var rect = this.getBoundingRect();
  24316. rect = rect.clone();
  24317. // Longitute is inverted
  24318. rect.y = -rect.y - rect.height;
  24319. var viewTransform = this._viewTransform;
  24320. viewTransform.transform = rect.calculateTransform(
  24321. new BoundingRect(x, y, width, height)
  24322. );
  24323. viewTransform.decomposeTransform();
  24324. var scale = viewTransform.scale;
  24325. scale[1] = -scale[1];
  24326. viewTransform.updateTransform();
  24327. this._updateTransform();
  24328. },
  24329. /**
  24330. * @param {string} name
  24331. * @return {module:echarts/coord/geo/Region}
  24332. */
  24333. getRegion: function (name) {
  24334. return this._regionsMap[name];
  24335. },
  24336. getRegionByCoord: function (coord) {
  24337. var regions = this.regions;
  24338. for (var i = 0; i < regions.length; i++) {
  24339. if (regions[i].contain(coord)) {
  24340. return regions[i];
  24341. }
  24342. }
  24343. },
  24344. /**
  24345. * Add geoCoord for indexing by name
  24346. * @param {string} name
  24347. * @param {Array.<number>} geoCoord
  24348. */
  24349. addGeoCoord: function (name, geoCoord) {
  24350. this._nameCoordMap[name] = geoCoord;
  24351. },
  24352. /**
  24353. * Get geoCoord by name
  24354. * @param {string} name
  24355. * @return {Array.<number>}
  24356. */
  24357. getGeoCoord: function (name) {
  24358. return this._nameCoordMap[name];
  24359. },
  24360. // Overwrite
  24361. getBoundingRect: function () {
  24362. if (this._rect) {
  24363. return this._rect;
  24364. }
  24365. var rect;
  24366. var regions = this.regions;
  24367. for (var i = 0; i < regions.length; i++) {
  24368. var regionRect = regions[i].getBoundingRect();
  24369. rect = rect || regionRect.clone();
  24370. rect.union(regionRect);
  24371. }
  24372. // FIXME Always return new ?
  24373. return (this._rect = rect || new BoundingRect(0, 0, 0, 0));
  24374. },
  24375. /**
  24376. * Convert series data to a list of points
  24377. * @param {module:echarts/data/List} data
  24378. * @param {boolean} stack
  24379. * @return {Array}
  24380. * Return list of points. For example:
  24381. * `[[10, 10], [20, 20], [30, 30]]`
  24382. */
  24383. dataToPoints: function (data) {
  24384. var item = [];
  24385. return data.mapArray(['lng', 'lat'], function (lon, lat) {
  24386. item[0] = lon;
  24387. item[1] = lat;
  24388. return this.dataToPoint(item);
  24389. }, this);
  24390. },
  24391. // Overwrite
  24392. /**
  24393. * @param {string|Array.<number>} data
  24394. * @return {Array.<number>}
  24395. */
  24396. dataToPoint: function (data) {
  24397. if (typeof data === 'string') {
  24398. // Map area name to geoCoord
  24399. data = this.getGeoCoord(data);
  24400. }
  24401. if (data) {
  24402. return View.prototype.dataToPoint.call(this, data);
  24403. }
  24404. }
  24405. };
  24406. zrUtil.mixin(Geo, View);
  24407. module.exports = Geo;
  24408. /***/ },
  24409. /* 160 */
  24410. /***/ function(module, exports, __webpack_require__) {
  24411. /**
  24412. * Parse and decode geo json
  24413. * @module echarts/coord/geo/parseGeoJson
  24414. */
  24415. var zrUtil = __webpack_require__(3);
  24416. var Region = __webpack_require__(161);
  24417. function decode(json) {
  24418. if (!json.UTF8Encoding) {
  24419. return json;
  24420. }
  24421. var features = json.features;
  24422. for (var f = 0; f < features.length; f++) {
  24423. var feature = features[f];
  24424. var geometry = feature.geometry;
  24425. var coordinates = geometry.coordinates;
  24426. var encodeOffsets = geometry.encodeOffsets;
  24427. for (var c = 0; c < coordinates.length; c++) {
  24428. var coordinate = coordinates[c];
  24429. if (geometry.type === 'Polygon') {
  24430. coordinates[c] = decodePolygon(
  24431. coordinate,
  24432. encodeOffsets[c]
  24433. );
  24434. }
  24435. else if (geometry.type === 'MultiPolygon') {
  24436. for (var c2 = 0; c2 < coordinate.length; c2++) {
  24437. var polygon = coordinate[c2];
  24438. coordinate[c2] = decodePolygon(
  24439. polygon,
  24440. encodeOffsets[c][c2]
  24441. );
  24442. }
  24443. }
  24444. }
  24445. }
  24446. // Has been decoded
  24447. json.UTF8Encoding = false;
  24448. return json;
  24449. }
  24450. function decodePolygon(coordinate, encodeOffsets) {
  24451. var result = [];
  24452. var prevX = encodeOffsets[0];
  24453. var prevY = encodeOffsets[1];
  24454. for (var i = 0; i < coordinate.length; i += 2) {
  24455. var x = coordinate.charCodeAt(i) - 64;
  24456. var y = coordinate.charCodeAt(i + 1) - 64;
  24457. // ZigZag decoding
  24458. x = (x >> 1) ^ (-(x & 1));
  24459. y = (y >> 1) ^ (-(y & 1));
  24460. // Delta deocding
  24461. x += prevX;
  24462. y += prevY;
  24463. prevX = x;
  24464. prevY = y;
  24465. // Dequantize
  24466. result.push([x / 1024, y / 1024]);
  24467. }
  24468. return result;
  24469. }
  24470. /**
  24471. * @inner
  24472. */
  24473. function flattern2D(array) {
  24474. var ret = [];
  24475. for (var i = 0; i < array.length; i++) {
  24476. for (var k = 0; k < array[i].length; k++) {
  24477. ret.push(array[i][k]);
  24478. }
  24479. }
  24480. return ret;
  24481. }
  24482. /**
  24483. * @alias module:echarts/coord/geo/parseGeoJson
  24484. * @param {Object} geoJson
  24485. * @return {module:zrender/container/Group}
  24486. */
  24487. module.exports = function (geoJson) {
  24488. decode(geoJson);
  24489. return zrUtil.map(zrUtil.filter(geoJson.features, function (featureObj) {
  24490. // Output of mapshaper may have geometry null
  24491. return featureObj.geometry && featureObj.properties;
  24492. }), function (featureObj) {
  24493. var properties = featureObj.properties;
  24494. var geometry = featureObj.geometry;
  24495. var coordinates = geometry.coordinates;
  24496. if (geometry.type === 'MultiPolygon') {
  24497. coordinates = flattern2D(coordinates);
  24498. }
  24499. return new Region(
  24500. properties.name,
  24501. coordinates,
  24502. properties.cp
  24503. );
  24504. });
  24505. };
  24506. /***/ },
  24507. /* 161 */
  24508. /***/ function(module, exports, __webpack_require__) {
  24509. /**
  24510. * @module echarts/coord/geo/Region
  24511. */
  24512. var polygonContain = __webpack_require__(162);
  24513. var BoundingRect = __webpack_require__(15);
  24514. var bbox = __webpack_require__(50);
  24515. var vec2 = __webpack_require__(16);
  24516. /**
  24517. * @param {string} name
  24518. * @param {Array} contours
  24519. * @param {Array.<number>} cp
  24520. */
  24521. function Region(name, contours, cp) {
  24522. /**
  24523. * @type {string}
  24524. * @readOnly
  24525. */
  24526. this.name = name;
  24527. /**
  24528. * @type {Array.<Array>}
  24529. * @readOnly
  24530. */
  24531. this.contours = contours;
  24532. if (!cp) {
  24533. var rect = this.getBoundingRect();
  24534. cp = [
  24535. rect.x + rect.width / 2,
  24536. rect.y + rect.height / 2
  24537. ];
  24538. }
  24539. else {
  24540. cp = [cp[0], cp[1]];
  24541. }
  24542. /**
  24543. * @type {Array.<number>}
  24544. */
  24545. this.center = cp;
  24546. }
  24547. Region.prototype = {
  24548. constructor: Region,
  24549. /**
  24550. * @return {module:zrender/core/BoundingRect}
  24551. */
  24552. getBoundingRect: function () {
  24553. var rect = this._rect;
  24554. if (rect) {
  24555. return rect;
  24556. }
  24557. var MAX_NUMBER = Number.MAX_VALUE;
  24558. var min = [MAX_NUMBER, MAX_NUMBER];
  24559. var max = [-MAX_NUMBER, -MAX_NUMBER];
  24560. var min2 = [];
  24561. var max2 = [];
  24562. var contours = this.contours;
  24563. for (var i = 0; i < contours.length; i++) {
  24564. bbox.fromPoints(contours[i], min2, max2);
  24565. vec2.min(min, min, min2);
  24566. vec2.max(max, max, max2);
  24567. }
  24568. // No data
  24569. if (i === 0) {
  24570. min[0] = min[1] = max[0] = max[1] = 0;
  24571. }
  24572. return (this._rect = new BoundingRect(
  24573. min[0], min[1], max[0] - min[0], max[1] - min[1]
  24574. ));
  24575. },
  24576. /**
  24577. * @param {<Array.<number>} coord
  24578. * @return {boolean}
  24579. */
  24580. contain: function (coord) {
  24581. var rect = this.getBoundingRect();
  24582. var contours = this.contours;
  24583. if (rect.contain(coord[0], coord[1])) {
  24584. for (var i = 0, len = contours.length; i < len; i++) {
  24585. if (polygonContain.contain(contours[i], coord[0], coord[1])) {
  24586. return true;
  24587. }
  24588. }
  24589. }
  24590. return false;
  24591. },
  24592. transformTo: function (x, y, width, height) {
  24593. var rect = this.getBoundingRect();
  24594. var aspect = rect.width / rect.height;
  24595. if (!width) {
  24596. width = aspect * height;
  24597. }
  24598. else if (!height) {
  24599. height = width / aspect ;
  24600. }
  24601. var target = new BoundingRect(x, y, width, height);
  24602. var transform = rect.calculateTransform(target);
  24603. var contours = this.contours;
  24604. for (var i = 0; i < contours.length; i++) {
  24605. for (var p = 0; p < contours[i].length; p++) {
  24606. vec2.applyTransform(contours[i][p], contours[i][p], transform);
  24607. }
  24608. }
  24609. rect = this._rect;
  24610. rect.copy(target);
  24611. // Update center
  24612. this.center = [
  24613. rect.x + rect.width / 2,
  24614. rect.y + rect.height / 2
  24615. ];
  24616. }
  24617. };
  24618. module.exports = Region;
  24619. /***/ },
  24620. /* 162 */
  24621. /***/ function(module, exports, __webpack_require__) {
  24622. var windingLine = __webpack_require__(57);
  24623. var EPSILON = 1e-8;
  24624. function isAroundEqual(a, b) {
  24625. return Math.abs(a - b) < EPSILON;
  24626. }
  24627. function contain(points, x, y) {
  24628. var w = 0;
  24629. var p = points[0];
  24630. if (!p) {
  24631. return false;
  24632. }
  24633. for (var i = 1; i < points.length; i++) {
  24634. var p2 = points[i];
  24635. w += windingLine(p[0], p[1], p2[0], p2[1], x, y);
  24636. p = p2;
  24637. }
  24638. // Close polygon
  24639. var p0 = points[0];
  24640. if (!isAroundEqual(p[0], p0[0]) || !isAroundEqual(p[1], p0[1])) {
  24641. w += windingLine(p[0], p[1], p0[0], p0[1], x, y);
  24642. }
  24643. return w !== 0;
  24644. }
  24645. module.exports = {
  24646. contain: contain
  24647. };
  24648. /***/ },
  24649. /* 163 */
  24650. /***/ function(module, exports, __webpack_require__) {
  24651. /**
  24652. * Simple view coordinate system
  24653. * Mapping given x, y to transformd view x, y
  24654. */
  24655. var vector = __webpack_require__(16);
  24656. var matrix = __webpack_require__(17);
  24657. var Transformable = __webpack_require__(33);
  24658. var zrUtil = __webpack_require__(3);
  24659. var BoundingRect = __webpack_require__(15);
  24660. var v2ApplyTransform = vector.applyTransform;
  24661. // Dummy transform node
  24662. function TransformDummy() {
  24663. Transformable.call(this);
  24664. }
  24665. zrUtil.mixin(TransformDummy, Transformable);
  24666. function View(name) {
  24667. /**
  24668. * @type {string}
  24669. */
  24670. this.name = name;
  24671. /**
  24672. * @type {Object}
  24673. */
  24674. this.zoomLimit;
  24675. Transformable.call(this);
  24676. this._roamTransform = new TransformDummy();
  24677. this._viewTransform = new TransformDummy();
  24678. this._center;
  24679. this._zoom;
  24680. }
  24681. View.prototype = {
  24682. constructor: View,
  24683. type: 'view',
  24684. /**
  24685. * @param {Array.<string>}
  24686. * @readOnly
  24687. */
  24688. dimensions: ['x', 'y'],
  24689. /**
  24690. * Set bounding rect
  24691. * @param {number} x
  24692. * @param {number} y
  24693. * @param {number} width
  24694. * @param {number} height
  24695. */
  24696. // PENDING to getRect
  24697. setBoundingRect: function (x, y, width, height) {
  24698. this._rect = new BoundingRect(x, y, width, height);
  24699. return this._rect;
  24700. },
  24701. /**
  24702. * @return {module:zrender/core/BoundingRect}
  24703. */
  24704. // PENDING to getRect
  24705. getBoundingRect: function () {
  24706. return this._rect;
  24707. },
  24708. /**
  24709. * @param {number} x
  24710. * @param {number} y
  24711. * @param {number} width
  24712. * @param {number} height
  24713. */
  24714. setViewRect: function (x, y, width, height) {
  24715. width = width;
  24716. height = height;
  24717. this.transformTo(x, y, width, height);
  24718. this._viewRect = new BoundingRect(x, y, width, height);
  24719. },
  24720. /**
  24721. * Transformed to particular position and size
  24722. * @param {number} x
  24723. * @param {number} y
  24724. * @param {number} width
  24725. * @param {number} height
  24726. */
  24727. transformTo: function (x, y, width, height) {
  24728. var rect = this.getBoundingRect();
  24729. var viewTransform = this._viewTransform;
  24730. viewTransform.transform = rect.calculateTransform(
  24731. new BoundingRect(x, y, width, height)
  24732. );
  24733. viewTransform.decomposeTransform();
  24734. this._updateTransform();
  24735. },
  24736. /**
  24737. * Set center of view
  24738. * @param {Array.<number>} [centerCoord]
  24739. */
  24740. setCenter: function (centerCoord) {
  24741. if (!centerCoord) {
  24742. return;
  24743. }
  24744. this._center = centerCoord;
  24745. this._updateCenterAndZoom();
  24746. },
  24747. /**
  24748. * @param {number} zoom
  24749. */
  24750. setZoom: function (zoom) {
  24751. zoom = zoom || 1;
  24752. var zoomLimit = this.zoomLimit;
  24753. if (zoomLimit) {
  24754. if (zoomLimit.max != null) {
  24755. zoom = Math.min(zoomLimit.max, zoom);
  24756. }
  24757. if (zoomLimit.min != null) {
  24758. zoom = Math.max(zoomLimit.min, zoom);
  24759. }
  24760. }
  24761. this._zoom = zoom;
  24762. this._updateCenterAndZoom();
  24763. },
  24764. /**
  24765. * Get default center without roam
  24766. */
  24767. getDefaultCenter: function () {
  24768. // Rect before any transform
  24769. var rawRect = this.getBoundingRect();
  24770. var cx = rawRect.x + rawRect.width / 2;
  24771. var cy = rawRect.y + rawRect.height / 2;
  24772. return [cx, cy];
  24773. },
  24774. getCenter: function () {
  24775. return this._center || this.getDefaultCenter();
  24776. },
  24777. getZoom: function () {
  24778. return this._zoom || 1;
  24779. },
  24780. /**
  24781. * @return {Array.<number}
  24782. */
  24783. getRoamTransform: function () {
  24784. return this._roamTransform;
  24785. },
  24786. _updateCenterAndZoom: function () {
  24787. // Must update after view transform updated
  24788. var viewTransformMatrix = this._viewTransform.getLocalTransform();
  24789. var roamTransform = this._roamTransform;
  24790. var defaultCenter = this.getDefaultCenter();
  24791. var center = this.getCenter();
  24792. var zoom = this.getZoom();
  24793. center = vector.applyTransform([], center, viewTransformMatrix);
  24794. defaultCenter = vector.applyTransform([], defaultCenter, viewTransformMatrix);
  24795. roamTransform.origin = center;
  24796. roamTransform.position = [
  24797. defaultCenter[0] - center[0],
  24798. defaultCenter[1] - center[1]
  24799. ];
  24800. roamTransform.scale = [zoom, zoom];
  24801. this._updateTransform();
  24802. },
  24803. /**
  24804. * Update transform from roam and mapLocation
  24805. * @private
  24806. */
  24807. _updateTransform: function () {
  24808. var roamTransform = this._roamTransform;
  24809. var viewTransform = this._viewTransform;
  24810. viewTransform.parent = roamTransform;
  24811. roamTransform.updateTransform();
  24812. viewTransform.updateTransform();
  24813. viewTransform.transform
  24814. && matrix.copy(this.transform || (this.transform = []), viewTransform.transform);
  24815. if (this.transform) {
  24816. this.invTransform = this.invTransform || [];
  24817. matrix.invert(this.invTransform, this.transform);
  24818. }
  24819. else {
  24820. this.invTransform = null;
  24821. }
  24822. this.decomposeTransform();
  24823. },
  24824. /**
  24825. * @return {module:zrender/core/BoundingRect}
  24826. */
  24827. getViewRect: function () {
  24828. return this._viewRect;
  24829. },
  24830. /**
  24831. * Get view rect after roam transform
  24832. * @return {module:zrender/core/BoundingRect}
  24833. */
  24834. getViewRectAfterRoam: function () {
  24835. var rect = this.getBoundingRect().clone();
  24836. rect.applyTransform(this.transform);
  24837. return rect;
  24838. },
  24839. /**
  24840. * Convert a single (lon, lat) data item to (x, y) point.
  24841. * @param {Array.<number>} data
  24842. * @return {Array.<number>}
  24843. */
  24844. dataToPoint: function (data) {
  24845. var transform = this.transform;
  24846. return transform
  24847. ? v2ApplyTransform([], data, transform)
  24848. : [data[0], data[1]];
  24849. },
  24850. /**
  24851. * Convert a (x, y) point to (lon, lat) data
  24852. * @param {Array.<number>} point
  24853. * @return {Array.<number>}
  24854. */
  24855. pointToData: function (point) {
  24856. var invTransform = this.invTransform;
  24857. return invTransform
  24858. ? v2ApplyTransform([], point, invTransform)
  24859. : [point[0], point[1]];
  24860. }
  24861. /**
  24862. * @return {number}
  24863. */
  24864. // getScalarScale: function () {
  24865. // // Use determinant square root of transform to mutiply scalar
  24866. // var m = this.transform;
  24867. // var det = Math.sqrt(Math.abs(m[0] * m[3] - m[2] * m[1]));
  24868. // return det;
  24869. // }
  24870. };
  24871. zrUtil.mixin(View, Transformable);
  24872. module.exports = View;
  24873. /***/ },
  24874. /* 164 */
  24875. /***/ function(module, exports, __webpack_require__) {
  24876. // Fix for 南海诸岛
  24877. var Region = __webpack_require__(161);
  24878. var geoCoord = [126, 25];
  24879. var points = [
  24880. [[0,3.5],[7,11.2],[15,11.9],[30,7],[42,0.7],[52,0.7],
  24881. [56,7.7],[59,0.7],[64,0.7],[64,0],[5,0],[0,3.5]],
  24882. [[13,16.1],[19,14.7],[16,21.7],[11,23.1],[13,16.1]],
  24883. [[12,32.2],[14,38.5],[15,38.5],[13,32.2],[12,32.2]],
  24884. [[16,47.6],[12,53.2],[13,53.2],[18,47.6],[16,47.6]],
  24885. [[6,64.4],[8,70],[9,70],[8,64.4],[6,64.4]],
  24886. [[23,82.6],[29,79.8],[30,79.8],[25,82.6],[23,82.6]],
  24887. [[37,70.7],[43,62.3],[44,62.3],[39,70.7],[37,70.7]],
  24888. [[48,51.1],[51,45.5],[53,45.5],[50,51.1],[48,51.1]],
  24889. [[51,35],[51,28.7],[53,28.7],[53,35],[51,35]],
  24890. [[52,22.4],[55,17.5],[56,17.5],[53,22.4],[52,22.4]],
  24891. [[58,12.6],[62,7],[63,7],[60,12.6],[58,12.6]],
  24892. [[0,3.5],[0,93.1],[64,93.1],[64,0],[63,0],[63,92.4],
  24893. [1,92.4],[1,3.5],[0,3.5]]
  24894. ];
  24895. for (var i = 0; i < points.length; i++) {
  24896. for (var k = 0; k < points[i].length; k++) {
  24897. points[i][k][0] /= 10.5;
  24898. points[i][k][1] /= -10.5 / 0.75;
  24899. points[i][k][0] += geoCoord[0];
  24900. points[i][k][1] += geoCoord[1];
  24901. }
  24902. }
  24903. module.exports = function (geo) {
  24904. if (geo.map === 'china') {
  24905. geo.regions.push(new Region(
  24906. '南海诸岛', points, geoCoord
  24907. ));
  24908. }
  24909. };
  24910. /***/ },
  24911. /* 165 */
  24912. /***/ function(module, exports, __webpack_require__) {
  24913. var zrUtil = __webpack_require__(3);
  24914. var coordsOffsetMap = {
  24915. '南海诸岛' : [32, 80],
  24916. // 全国
  24917. '广东': [0, -10],
  24918. '香港': [10, 5],
  24919. '澳门': [-10, 10],
  24920. //'北京': [-10, 0],
  24921. '天津': [5, 5]
  24922. };
  24923. module.exports = function (geo) {
  24924. zrUtil.each(geo.regions, function (region) {
  24925. var coordFix = coordsOffsetMap[region.name];
  24926. if (coordFix) {
  24927. var cp = region.center;
  24928. cp[0] += coordFix[0] / 10.5;
  24929. cp[1] += -coordFix[1] / (10.5 / 0.75);
  24930. }
  24931. });
  24932. };
  24933. /***/ },
  24934. /* 166 */
  24935. /***/ function(module, exports, __webpack_require__) {
  24936. var zrUtil = __webpack_require__(3);
  24937. var geoCoordMap = {
  24938. 'Russia': [100, 60],
  24939. 'United States of America': [-99, 38]
  24940. };
  24941. module.exports = function (geo) {
  24942. zrUtil.each(geo.regions, function (region) {
  24943. var geoCoord = geoCoordMap[region.name];
  24944. if (geoCoord) {
  24945. var cp = region.center;
  24946. cp[0] = geoCoord[0];
  24947. cp[1] = geoCoord[1];
  24948. }
  24949. });
  24950. };
  24951. /***/ },
  24952. /* 167 */
  24953. /***/ function(module, exports, __webpack_require__) {
  24954. // var zrUtil = require('zrender/lib/core/util');
  24955. var graphic = __webpack_require__(42);
  24956. var MapDraw = __webpack_require__(168);
  24957. __webpack_require__(1).extendChartView({
  24958. type: 'map',
  24959. render: function (mapModel, ecModel, api, payload) {
  24960. // Not render if it is an toggleSelect action from self
  24961. if (payload && payload.type === 'mapToggleSelect'
  24962. && payload.from === this.uid
  24963. ) {
  24964. return;
  24965. }
  24966. var group = this.group;
  24967. group.removeAll();
  24968. // Not update map if it is an roam action from self
  24969. if (!(payload && payload.type === 'geoRoam'
  24970. && payload.component === 'series'
  24971. && payload.name === mapModel.name)) {
  24972. if (mapModel.needsDrawMap) {
  24973. var mapDraw = this._mapDraw || new MapDraw(api, true);
  24974. group.add(mapDraw.group);
  24975. mapDraw.draw(mapModel, ecModel, api, this, payload);
  24976. this._mapDraw = mapDraw;
  24977. }
  24978. else {
  24979. // Remove drawed map
  24980. this._mapDraw && this._mapDraw.remove();
  24981. this._mapDraw = null;
  24982. }
  24983. }
  24984. else {
  24985. var mapDraw = this._mapDraw;
  24986. mapDraw && group.add(mapDraw.group);
  24987. }
  24988. mapModel.get('showLegendSymbol') && ecModel.getComponent('legend')
  24989. && this._renderSymbols(mapModel, ecModel, api);
  24990. },
  24991. remove: function () {
  24992. this._mapDraw && this._mapDraw.remove();
  24993. this._mapDraw = null;
  24994. this.group.removeAll();
  24995. },
  24996. _renderSymbols: function (mapModel, ecModel, api) {
  24997. var data = mapModel.getData();
  24998. var group = this.group;
  24999. data.each('value', function (value, idx) {
  25000. if (isNaN(value)) {
  25001. return;
  25002. }
  25003. var layout = data.getItemLayout(idx);
  25004. if (!layout || !layout.point) {
  25005. // Not exists in map
  25006. return;
  25007. }
  25008. var point = layout.point;
  25009. var offset = layout.offset;
  25010. var circle = new graphic.Circle({
  25011. style: {
  25012. fill: data.getVisual('color')
  25013. },
  25014. shape: {
  25015. cx: point[0] + offset * 9,
  25016. cy: point[1],
  25017. r: 3
  25018. },
  25019. silent: true,
  25020. z2: 10
  25021. });
  25022. // First data on the same region
  25023. if (!offset) {
  25024. var labelText = data.getName(idx);
  25025. var itemModel = data.getItemModel(idx);
  25026. var labelModel = itemModel.getModel('label.normal');
  25027. var hoverLabelModel = itemModel.getModel('label.emphasis');
  25028. var textStyleModel = labelModel.getModel('textStyle');
  25029. var hoverTextStyleModel = hoverLabelModel.getModel('textStyle');
  25030. var polygonGroups = data.getItemGraphicEl(idx);
  25031. circle.setStyle({
  25032. textPosition: 'bottom'
  25033. });
  25034. var onEmphasis = function () {
  25035. circle.setStyle({
  25036. text: hoverLabelModel.get('show') ? labelText : '',
  25037. textFill: hoverTextStyleModel.getTextColor(),
  25038. textFont: hoverTextStyleModel.getFont()
  25039. });
  25040. };
  25041. var onNormal = function () {
  25042. circle.setStyle({
  25043. text: labelModel.get('show') ? labelText : '',
  25044. textFill: textStyleModel.getTextColor(),
  25045. textFont: textStyleModel.getFont()
  25046. });
  25047. };
  25048. polygonGroups.on('mouseover', onEmphasis)
  25049. .on('mouseout', onNormal)
  25050. .on('emphasis', onEmphasis)
  25051. .on('normal', onNormal);
  25052. onNormal();
  25053. }
  25054. group.add(circle);
  25055. });
  25056. }
  25057. });
  25058. /***/ },
  25059. /* 168 */
  25060. /***/ function(module, exports, __webpack_require__) {
  25061. /**
  25062. * @module echarts/component/helper/MapDraw
  25063. */
  25064. var RoamController = __webpack_require__(169);
  25065. var graphic = __webpack_require__(42);
  25066. var zrUtil = __webpack_require__(3);
  25067. function getFixedItemStyle(model, scale) {
  25068. var itemStyle = model.getItemStyle();
  25069. var areaColor = model.get('areaColor');
  25070. if (areaColor) {
  25071. itemStyle.fill = areaColor;
  25072. }
  25073. return itemStyle;
  25074. }
  25075. function updateMapSelectHandler(mapOrGeoModel, group, api, fromView) {
  25076. group.off('click');
  25077. mapOrGeoModel.get('selectedMode')
  25078. && group.on('click', function (e) {
  25079. var el = e.target;
  25080. while (!el.__region) {
  25081. el = el.parent;
  25082. }
  25083. if (!el) {
  25084. return;
  25085. }
  25086. var region = el.__region;
  25087. var action = {
  25088. type: (mapOrGeoModel.mainType === 'geo' ? 'geo' : 'map') + 'ToggleSelect',
  25089. name: region.name,
  25090. from: fromView.uid
  25091. };
  25092. action[mapOrGeoModel.mainType + 'Id'] = mapOrGeoModel.id;
  25093. api.dispatchAction(action);
  25094. updateMapSelected(mapOrGeoModel, group);
  25095. });
  25096. }
  25097. function updateMapSelected(mapOrGeoModel, group) {
  25098. // FIXME
  25099. group.eachChild(function (otherRegionEl) {
  25100. if (otherRegionEl.__region) {
  25101. otherRegionEl.trigger(mapOrGeoModel.isSelected(otherRegionEl.__region.name) ? 'emphasis' : 'normal');
  25102. }
  25103. });
  25104. }
  25105. /**
  25106. * @alias module:echarts/component/helper/MapDraw
  25107. * @param {module:echarts/ExtensionAPI} api
  25108. * @param {boolean} updateGroup
  25109. */
  25110. function MapDraw(api, updateGroup) {
  25111. var group = new graphic.Group();
  25112. /**
  25113. * @type {module:echarts/component/helper/RoamController}
  25114. * @private
  25115. */
  25116. this._controller = new RoamController(
  25117. api.getZr(), updateGroup ? group : null, null
  25118. );
  25119. /**
  25120. * @type {module:zrender/container/Group}
  25121. * @readOnly
  25122. */
  25123. this.group = group;
  25124. /**
  25125. * @type {boolean}
  25126. * @private
  25127. */
  25128. this._updateGroup = updateGroup;
  25129. }
  25130. MapDraw.prototype = {
  25131. constructor: MapDraw,
  25132. draw: function (mapOrGeoModel, ecModel, api, fromView, payload) {
  25133. // geoModel has no data
  25134. var data = mapOrGeoModel.getData && mapOrGeoModel.getData();
  25135. var geo = mapOrGeoModel.coordinateSystem;
  25136. var group = this.group;
  25137. var scale = geo.scale;
  25138. var groupNewProp = {
  25139. position: geo.position,
  25140. scale: scale
  25141. };
  25142. // No animation when first draw or in action
  25143. if (!group.childAt(0) || payload) {
  25144. group.attr(groupNewProp);
  25145. }
  25146. else {
  25147. graphic.updateProps(group, groupNewProp, mapOrGeoModel);
  25148. }
  25149. group.removeAll();
  25150. var itemStyleAccessPath = ['itemStyle', 'normal'];
  25151. var hoverItemStyleAccessPath = ['itemStyle', 'emphasis'];
  25152. var labelAccessPath = ['label', 'normal'];
  25153. var hoverLabelAccessPath = ['label', 'emphasis'];
  25154. zrUtil.each(geo.regions, function (region) {
  25155. var regionGroup = new graphic.Group();
  25156. var compoundPath = new graphic.CompoundPath({
  25157. shape: {
  25158. paths: []
  25159. }
  25160. });
  25161. regionGroup.add(compoundPath);
  25162. var regionModel = mapOrGeoModel.getRegionModel(region.name) || mapOrGeoModel;
  25163. var itemStyleModel = regionModel.getModel(itemStyleAccessPath);
  25164. var hoverItemStyleModel = regionModel.getModel(hoverItemStyleAccessPath);
  25165. var itemStyle = getFixedItemStyle(itemStyleModel, scale);
  25166. var hoverItemStyle = getFixedItemStyle(hoverItemStyleModel, scale);
  25167. var labelModel = regionModel.getModel(labelAccessPath);
  25168. var hoverLabelModel = regionModel.getModel(hoverLabelAccessPath);
  25169. var dataIdx;
  25170. // Use the itemStyle in data if has data
  25171. if (data) {
  25172. dataIdx = data.indexOfName(region.name);
  25173. // Only visual color of each item will be used. It can be encoded by dataRange
  25174. // But visual color of series is used in symbol drawing
  25175. //
  25176. // Visual color for each series is for the symbol draw
  25177. var visualColor = data.getItemVisual(dataIdx, 'color', true);
  25178. if (visualColor) {
  25179. itemStyle.fill = visualColor;
  25180. }
  25181. }
  25182. var textStyleModel = labelModel.getModel('textStyle');
  25183. var hoverTextStyleModel = hoverLabelModel.getModel('textStyle');
  25184. zrUtil.each(region.contours, function (contour) {
  25185. var polygon = new graphic.Polygon({
  25186. shape: {
  25187. points: contour
  25188. }
  25189. });
  25190. compoundPath.shape.paths.push(polygon);
  25191. });
  25192. compoundPath.setStyle(itemStyle);
  25193. compoundPath.style.strokeNoScale = true;
  25194. compoundPath.culling = true;
  25195. // Label
  25196. var showLabel = labelModel.get('show');
  25197. var hoverShowLabel = hoverLabelModel.get('show');
  25198. var isDataNaN = data && isNaN(data.get('value', dataIdx));
  25199. var itemLayout = data && data.getItemLayout(dataIdx);
  25200. // In the following cases label will be drawn
  25201. // 1. In map series and data value is NaN
  25202. // 2. In geo component
  25203. // 4. Region has no series legendSymbol, which will be add a showLabel flag in mapSymbolLayout
  25204. if (
  25205. (!data || isDataNaN && (showLabel || hoverShowLabel))
  25206. || (itemLayout && itemLayout.showLabel)
  25207. ) {
  25208. var query = data ? dataIdx : region.name;
  25209. var formattedStr = mapOrGeoModel.getFormattedLabel(query, 'normal');
  25210. var hoverFormattedStr = mapOrGeoModel.getFormattedLabel(query, 'emphasis');
  25211. var text = new graphic.Text({
  25212. style: {
  25213. text: showLabel ? (formattedStr || region.name) : '',
  25214. fill: textStyleModel.getTextColor(),
  25215. textFont: textStyleModel.getFont(),
  25216. textAlign: 'center',
  25217. textVerticalAlign: 'middle'
  25218. },
  25219. hoverStyle: {
  25220. text: hoverShowLabel ? (hoverFormattedStr || region.name) : '',
  25221. fill: hoverTextStyleModel.getTextColor(),
  25222. textFont: hoverTextStyleModel.getFont()
  25223. },
  25224. position: region.center.slice(),
  25225. scale: [1 / scale[0], 1 / scale[1]],
  25226. z2: 10,
  25227. silent: true
  25228. });
  25229. regionGroup.add(text);
  25230. }
  25231. // setItemGraphicEl, setHoverStyle after all polygons and labels
  25232. // are added to the rigionGroup
  25233. if (data) {
  25234. data.setItemGraphicEl(dataIdx, regionGroup);
  25235. }
  25236. else {
  25237. var regionModel = mapOrGeoModel.getRegionModel(region.name);
  25238. // Package custom mouse event for geo component
  25239. compoundPath.eventData = {
  25240. componentType: 'geo',
  25241. geoIndex: mapOrGeoModel.componentIndex,
  25242. name: region.name,
  25243. region: (regionModel && regionModel.option) || {}
  25244. };
  25245. }
  25246. regionGroup.__region = region;
  25247. graphic.setHoverStyle(regionGroup, hoverItemStyle);
  25248. group.add(regionGroup);
  25249. });
  25250. this._updateController(mapOrGeoModel, ecModel, api);
  25251. updateMapSelectHandler(mapOrGeoModel, group, api, fromView);
  25252. updateMapSelected(mapOrGeoModel, group);
  25253. },
  25254. remove: function () {
  25255. this.group.removeAll();
  25256. this._controller.dispose();
  25257. },
  25258. _updateController: function (mapOrGeoModel, ecModel, api) {
  25259. var geo = mapOrGeoModel.coordinateSystem;
  25260. var controller = this._controller;
  25261. controller.zoomLimit = mapOrGeoModel.get('scaleLimit');
  25262. // Update zoom from model
  25263. controller.zoom = geo.getZoom();
  25264. // roamType is will be set default true if it is null
  25265. controller.enable(mapOrGeoModel.get('roam') || false);
  25266. var mainType = mapOrGeoModel.mainType;
  25267. function makeActionBase() {
  25268. var action = {
  25269. type: 'geoRoam',
  25270. componentType: mainType
  25271. };
  25272. action[mainType + 'Id'] = mapOrGeoModel.id;
  25273. return action;
  25274. }
  25275. controller.off('pan')
  25276. .on('pan', function (dx, dy) {
  25277. api.dispatchAction(zrUtil.extend(makeActionBase(), {
  25278. dx: dx,
  25279. dy: dy
  25280. }));
  25281. });
  25282. controller.off('zoom')
  25283. .on('zoom', function (zoom, mouseX, mouseY) {
  25284. api.dispatchAction(zrUtil.extend(makeActionBase(), {
  25285. zoom: zoom,
  25286. originX: mouseX,
  25287. originY: mouseY
  25288. }));
  25289. if (this._updateGroup) {
  25290. var group = this.group;
  25291. var scale = group.scale;
  25292. group.traverse(function (el) {
  25293. if (el.type === 'text') {
  25294. el.attr('scale', [1 / scale[0], 1 / scale[1]]);
  25295. }
  25296. });
  25297. }
  25298. }, this);
  25299. controller.rectProvider = function () {
  25300. return geo.getViewRectAfterRoam();
  25301. };
  25302. }
  25303. };
  25304. module.exports = MapDraw;
  25305. /***/ },
  25306. /* 169 */
  25307. /***/ function(module, exports, __webpack_require__) {
  25308. /**
  25309. * @module echarts/component/helper/RoamController
  25310. */
  25311. var Eventful = __webpack_require__(32);
  25312. var zrUtil = __webpack_require__(3);
  25313. var eventTool = __webpack_require__(81);
  25314. var interactionMutex = __webpack_require__(170);
  25315. function mousedown(e) {
  25316. if (e.target && e.target.draggable) {
  25317. return;
  25318. }
  25319. var x = e.offsetX;
  25320. var y = e.offsetY;
  25321. var rect = this.rectProvider && this.rectProvider();
  25322. if (rect && rect.contain(x, y)) {
  25323. this._x = x;
  25324. this._y = y;
  25325. this._dragging = true;
  25326. }
  25327. }
  25328. function mousemove(e) {
  25329. if (!this._dragging) {
  25330. return;
  25331. }
  25332. eventTool.stop(e.event);
  25333. if (e.gestureEvent !== 'pinch') {
  25334. if (interactionMutex.isTaken('globalPan', this._zr)) {
  25335. return;
  25336. }
  25337. var x = e.offsetX;
  25338. var y = e.offsetY;
  25339. var dx = x - this._x;
  25340. var dy = y - this._y;
  25341. this._x = x;
  25342. this._y = y;
  25343. var target = this.target;
  25344. if (target) {
  25345. var pos = target.position;
  25346. pos[0] += dx;
  25347. pos[1] += dy;
  25348. target.dirty();
  25349. }
  25350. eventTool.stop(e.event);
  25351. this.trigger('pan', dx, dy);
  25352. }
  25353. }
  25354. function mouseup(e) {
  25355. this._dragging = false;
  25356. }
  25357. function mousewheel(e) {
  25358. // Convenience:
  25359. // Mac and VM Windows on Mac: scroll up: zoom out.
  25360. // Windows: scroll up: zoom in.
  25361. var zoomDelta = e.wheelDelta > 0 ? 1.1 : 1 / 1.1;
  25362. zoom.call(this, e, zoomDelta, e.offsetX, e.offsetY);
  25363. }
  25364. function pinch(e) {
  25365. if (interactionMutex.isTaken('globalPan', this._zr)) {
  25366. return;
  25367. }
  25368. var zoomDelta = e.pinchScale > 1 ? 1.1 : 1 / 1.1;
  25369. zoom.call(this, e, zoomDelta, e.pinchX, e.pinchY);
  25370. }
  25371. function zoom(e, zoomDelta, zoomX, zoomY) {
  25372. var rect = this.rectProvider && this.rectProvider();
  25373. if (rect && rect.contain(zoomX, zoomY)) {
  25374. // When mouse is out of roamController rect,
  25375. // default befavoius should be be disabled, otherwise
  25376. // page sliding is disabled, contrary to expectation.
  25377. eventTool.stop(e.event);
  25378. var target = this.target;
  25379. var zoomLimit = this.zoomLimit;
  25380. if (target) {
  25381. var pos = target.position;
  25382. var scale = target.scale;
  25383. var newZoom = this.zoom = this.zoom || 1;
  25384. newZoom *= zoomDelta;
  25385. if (zoomLimit) {
  25386. var zoomMin = zoomLimit.min || 0;
  25387. var zoomMax = zoomLimit.max || Infinity;
  25388. newZoom = Math.max(
  25389. Math.min(zoomMax, newZoom),
  25390. zoomMin
  25391. );
  25392. }
  25393. var zoomScale = newZoom / this.zoom;
  25394. this.zoom = newZoom;
  25395. // Keep the mouse center when scaling
  25396. pos[0] -= (zoomX - pos[0]) * (zoomScale - 1);
  25397. pos[1] -= (zoomY - pos[1]) * (zoomScale - 1);
  25398. scale[0] *= zoomScale;
  25399. scale[1] *= zoomScale;
  25400. target.dirty();
  25401. }
  25402. this.trigger('zoom', zoomDelta, zoomX, zoomY);
  25403. }
  25404. }
  25405. /**
  25406. * @alias module:echarts/component/helper/RoamController
  25407. * @constructor
  25408. * @mixin {module:zrender/mixin/Eventful}
  25409. *
  25410. * @param {module:zrender/zrender~ZRender} zr
  25411. * @param {module:zrender/Element} target
  25412. * @param {Function} rectProvider
  25413. */
  25414. function RoamController(zr, target, rectProvider) {
  25415. /**
  25416. * @type {module:zrender/Element}
  25417. */
  25418. this.target = target;
  25419. /**
  25420. * @type {Function}
  25421. */
  25422. this.rectProvider = rectProvider;
  25423. /**
  25424. * { min: 1, max: 2 }
  25425. * @type {Object}
  25426. */
  25427. this.zoomLimit;
  25428. /**
  25429. * @type {number}
  25430. */
  25431. this.zoom;
  25432. /**
  25433. * @type {module:zrender}
  25434. */
  25435. this._zr = zr;
  25436. // Avoid two roamController bind the same handler
  25437. var bind = zrUtil.bind;
  25438. var mousedownHandler = bind(mousedown, this);
  25439. var mousemoveHandler = bind(mousemove, this);
  25440. var mouseupHandler = bind(mouseup, this);
  25441. var mousewheelHandler = bind(mousewheel, this);
  25442. var pinchHandler = bind(pinch, this);
  25443. Eventful.call(this);
  25444. /**
  25445. * Notice: only enable needed types. For example, if 'zoom'
  25446. * is not needed, 'zoom' should not be enabled, otherwise
  25447. * default mousewheel behaviour (scroll page) will be disabled.
  25448. *
  25449. * @param {boolean|string} [controlType=true] Specify the control type,
  25450. * which can be null/undefined or true/false
  25451. * or 'pan/move' or 'zoom'/'scale'
  25452. */
  25453. this.enable = function (controlType) {
  25454. // Disable previous first
  25455. this.disable();
  25456. if (controlType == null) {
  25457. controlType = true;
  25458. }
  25459. if (controlType === true || (controlType === 'move' || controlType === 'pan')) {
  25460. zr.on('mousedown', mousedownHandler);
  25461. zr.on('mousemove', mousemoveHandler);
  25462. zr.on('mouseup', mouseupHandler);
  25463. }
  25464. if (controlType === true || (controlType === 'scale' || controlType === 'zoom')) {
  25465. zr.on('mousewheel', mousewheelHandler);
  25466. zr.on('pinch', pinchHandler);
  25467. }
  25468. };
  25469. this.disable = function () {
  25470. zr.off('mousedown', mousedownHandler);
  25471. zr.off('mousemove', mousemoveHandler);
  25472. zr.off('mouseup', mouseupHandler);
  25473. zr.off('mousewheel', mousewheelHandler);
  25474. zr.off('pinch', pinchHandler);
  25475. };
  25476. this.dispose = this.disable;
  25477. this.isDragging = function () {
  25478. return this._dragging;
  25479. };
  25480. this.isPinching = function () {
  25481. return this._pinching;
  25482. };
  25483. }
  25484. zrUtil.mixin(RoamController, Eventful);
  25485. module.exports = RoamController;
  25486. /***/ },
  25487. /* 170 */
  25488. /***/ function(module, exports) {
  25489. var ATTR = '\0_ec_interaction_mutex';
  25490. var interactionMutex = {
  25491. take: function (key, zr) {
  25492. getStore(zr)[key] = true;
  25493. },
  25494. release: function (key, zr) {
  25495. getStore(zr)[key] = false;
  25496. },
  25497. isTaken: function (key, zr) {
  25498. return !!getStore(zr)[key];
  25499. }
  25500. };
  25501. function getStore(zr) {
  25502. return zr[ATTR] || (zr[ATTR] = {});
  25503. }
  25504. module.exports = interactionMutex;
  25505. /***/ },
  25506. /* 171 */
  25507. /***/ function(module, exports, __webpack_require__) {
  25508. var zrUtil = __webpack_require__(3);
  25509. var roamHelper = __webpack_require__(172);
  25510. var echarts = __webpack_require__(1);
  25511. /**
  25512. * @payload
  25513. * @property {string} [componentType=series]
  25514. * @property {number} [dx]
  25515. * @property {number} [dy]
  25516. * @property {number} [zoom]
  25517. * @property {number} [originX]
  25518. * @property {number} [originY]
  25519. */
  25520. echarts.registerAction({
  25521. type: 'geoRoam',
  25522. event: 'geoRoam',
  25523. update: 'updateLayout'
  25524. }, function (payload, ecModel) {
  25525. var componentType = payload.componentType || 'series';
  25526. ecModel.eachComponent(
  25527. { mainType: componentType, query: payload },
  25528. function (componentModel) {
  25529. var geo = componentModel.coordinateSystem;
  25530. if (geo.type !== 'geo') {
  25531. return;
  25532. }
  25533. var res = roamHelper.updateCenterAndZoom(
  25534. geo, payload, componentModel.get('scaleLimit')
  25535. );
  25536. componentModel.setCenter
  25537. && componentModel.setCenter(res.center);
  25538. componentModel.setZoom
  25539. && componentModel.setZoom(res.zoom);
  25540. // All map series with same `map` use the same geo coordinate system
  25541. // So the center and zoom must be in sync. Include the series not selected by legend
  25542. if (componentType === 'series') {
  25543. zrUtil.each(componentModel.seriesGroup, function (seriesModel) {
  25544. seriesModel.setCenter(res.center);
  25545. seriesModel.setZoom(res.zoom);
  25546. });
  25547. }
  25548. }
  25549. );
  25550. });
  25551. /***/ },
  25552. /* 172 */
  25553. /***/ function(module, exports) {
  25554. var roamHelper = {};
  25555. /**
  25556. * @param {module:echarts/coord/View} view
  25557. * @param {Object} payload
  25558. * @param {Object} [zoomLimit]
  25559. */
  25560. roamHelper.updateCenterAndZoom = function (
  25561. view, payload, zoomLimit
  25562. ) {
  25563. var previousZoom = view.getZoom();
  25564. var center = view.getCenter();
  25565. var zoom = payload.zoom;
  25566. var point = view.dataToPoint(center);
  25567. if (payload.dx != null && payload.dy != null) {
  25568. point[0] -= payload.dx;
  25569. point[1] -= payload.dy;
  25570. var center = view.pointToData(point);
  25571. view.setCenter(center);
  25572. }
  25573. if (zoom != null) {
  25574. if (zoomLimit) {
  25575. var zoomMin = zoomLimit.min || 0;
  25576. var zoomMax = zoomLimit.max || Infinity;
  25577. zoom = Math.max(
  25578. Math.min(previousZoom * zoom, zoomMax),
  25579. zoomMin
  25580. ) / previousZoom;
  25581. }
  25582. // Zoom on given point(originX, originY)
  25583. view.scale[0] *= zoom;
  25584. view.scale[1] *= zoom;
  25585. var position = view.position;
  25586. var fixX = (payload.originX - position[0]) * (zoom - 1);
  25587. var fixY = (payload.originY - position[1]) * (zoom - 1);
  25588. position[0] -= fixX;
  25589. position[1] -= fixY;
  25590. view.updateTransform();
  25591. // Get the new center
  25592. var center = view.pointToData(point);
  25593. view.setCenter(center);
  25594. view.setZoom(zoom * previousZoom);
  25595. }
  25596. return {
  25597. center: view.getCenter(),
  25598. zoom: view.getZoom()
  25599. };
  25600. };
  25601. module.exports = roamHelper;
  25602. /***/ },
  25603. /* 173 */
  25604. /***/ function(module, exports, __webpack_require__) {
  25605. var zrUtil = __webpack_require__(3);
  25606. module.exports = function (ecModel) {
  25607. var processedMapType = {};
  25608. ecModel.eachSeriesByType('map', function (mapSeries) {
  25609. var mapType = mapSeries.get('map');
  25610. if (processedMapType[mapType]) {
  25611. return;
  25612. }
  25613. var mapSymbolOffsets = {};
  25614. zrUtil.each(mapSeries.seriesGroup, function (subMapSeries) {
  25615. var geo = subMapSeries.coordinateSystem;
  25616. var data = subMapSeries.getData();
  25617. if (subMapSeries.get('showLegendSymbol') && ecModel.getComponent('legend')) {
  25618. data.each('value', function (value, idx) {
  25619. var name = data.getName(idx);
  25620. var region = geo.getRegion(name);
  25621. // No region or no value
  25622. // In MapSeries data regions will be filled with NaN
  25623. // If they are not in the series.data array.
  25624. // So here must validate if value is NaN
  25625. if (!region || isNaN(value)) {
  25626. return;
  25627. }
  25628. var offset = mapSymbolOffsets[name] || 0;
  25629. var point = geo.dataToPoint(region.center);
  25630. mapSymbolOffsets[name] = offset + 1;
  25631. data.setItemLayout(idx, {
  25632. point: point,
  25633. offset: offset
  25634. });
  25635. });
  25636. }
  25637. });
  25638. // Show label of those region not has legendSymbol(which is offset 0)
  25639. var data = mapSeries.getData();
  25640. data.each(function (idx) {
  25641. var name = data.getName(idx);
  25642. var layout = data.getItemLayout(idx) || {};
  25643. layout.showLabel = !mapSymbolOffsets[name];
  25644. data.setItemLayout(idx, layout);
  25645. });
  25646. processedMapType[mapType] = true;
  25647. });
  25648. };
  25649. /***/ },
  25650. /* 174 */
  25651. /***/ function(module, exports) {
  25652. module.exports = function (ecModel) {
  25653. ecModel.eachSeriesByType('map', function (seriesModel) {
  25654. var colorList = seriesModel.get('color');
  25655. var itemStyleModel = seriesModel.getModel('itemStyle.normal');
  25656. var areaColor = itemStyleModel.get('areaColor');
  25657. var color = itemStyleModel.get('color')
  25658. || colorList[seriesModel.seriesIndex % colorList.length];
  25659. seriesModel.getData().setVisual({
  25660. 'areaColor': areaColor,
  25661. 'color': color
  25662. });
  25663. });
  25664. };
  25665. /***/ },
  25666. /* 175 */
  25667. /***/ function(module, exports, __webpack_require__) {
  25668. var zrUtil = __webpack_require__(3);
  25669. // FIXME 公用?
  25670. /**
  25671. * @param {Array.<module:echarts/data/List>} datas
  25672. * @param {string} statisticsType 'average' 'sum'
  25673. * @inner
  25674. */
  25675. function dataStatistics(datas, statisticsType) {
  25676. var dataNameMap = {};
  25677. var dims = ['value'];
  25678. for (var i = 0; i < datas.length; i++) {
  25679. datas[i].each(dims, function (value, idx) {
  25680. var name = datas[i].getName(idx);
  25681. dataNameMap[name] = dataNameMap[name] || [];
  25682. if (!isNaN(value)) {
  25683. dataNameMap[name].push(value);
  25684. }
  25685. });
  25686. }
  25687. return datas[0].map(dims, function (value, idx) {
  25688. var name = datas[0].getName(idx);
  25689. var sum = 0;
  25690. var min = Infinity;
  25691. var max = -Infinity;
  25692. var len = dataNameMap[name].length;
  25693. for (var i = 0; i < len; i++) {
  25694. min = Math.min(min, dataNameMap[name][i]);
  25695. max = Math.max(max, dataNameMap[name][i]);
  25696. sum += dataNameMap[name][i];
  25697. }
  25698. var result;
  25699. if (statisticsType === 'min') {
  25700. result = min;
  25701. }
  25702. else if (statisticsType === 'max') {
  25703. result = max;
  25704. }
  25705. else if (statisticsType === 'average') {
  25706. result = sum / len;
  25707. }
  25708. else {
  25709. result = sum;
  25710. }
  25711. return len === 0 ? NaN : result;
  25712. });
  25713. }
  25714. module.exports = function (ecModel) {
  25715. var seriesGroupByMapType = {};
  25716. ecModel.eachSeriesByType('map', function (seriesModel) {
  25717. var mapType = seriesModel.get('map');
  25718. seriesGroupByMapType[mapType] = seriesGroupByMapType[mapType] || [];
  25719. seriesGroupByMapType[mapType].push(seriesModel);
  25720. });
  25721. zrUtil.each(seriesGroupByMapType, function (seriesList, mapType) {
  25722. var data = dataStatistics(
  25723. zrUtil.map(seriesList, function (seriesModel) {
  25724. return seriesModel.getData();
  25725. }),
  25726. seriesList[0].get('mapValueCalculation')
  25727. );
  25728. seriesList[0].seriesGroup = [];
  25729. seriesList[0].setData(data);
  25730. // FIXME Put where?
  25731. for (var i = 0; i < seriesList.length; i++) {
  25732. seriesList[i].seriesGroup = seriesList;
  25733. seriesList[i].needsDrawMap = i === 0;
  25734. }
  25735. });
  25736. };
  25737. /***/ },
  25738. /* 176 */
  25739. /***/ function(module, exports, __webpack_require__) {
  25740. var zrUtil = __webpack_require__(3);
  25741. var geoProps = [
  25742. 'x', 'y', 'x2', 'y2', 'width', 'height', 'map', 'roam', 'center', 'zoom', 'scaleLimit', 'label', 'itemStyle'
  25743. ];
  25744. var geoCoordsMap = {};
  25745. function createGeoFromMap(mapSeriesOpt) {
  25746. var geoOpt = {};
  25747. zrUtil.each(geoProps, function (propName) {
  25748. if (mapSeriesOpt[propName] != null) {
  25749. geoOpt[propName] = mapSeriesOpt[propName];
  25750. }
  25751. });
  25752. return geoOpt;
  25753. }
  25754. module.exports = function (option) {
  25755. // Save geoCoord
  25756. var mapSeries = [];
  25757. zrUtil.each(option.series, function (seriesOpt) {
  25758. if (seriesOpt.type === 'map') {
  25759. mapSeries.push(seriesOpt);
  25760. }
  25761. zrUtil.extend(geoCoordsMap, seriesOpt.geoCoord);
  25762. });
  25763. var newCreatedGeoOptMap = {};
  25764. zrUtil.each(mapSeries, function (seriesOpt) {
  25765. seriesOpt.map = seriesOpt.map || seriesOpt.mapType;
  25766. // Put x, y, width, height, x2, y2 in the top level
  25767. zrUtil.defaults(seriesOpt, seriesOpt.mapLocation);
  25768. if (seriesOpt.markPoint) {
  25769. var markPoint = seriesOpt.markPoint;
  25770. // Convert name or geoCoord in markPoint to lng and lat
  25771. // For example
  25772. // { name: 'xxx', value: 10} Or
  25773. // { geoCoord: [lng, lat], value: 10} to
  25774. // { name: 'xxx', value: [lng, lat, 10]}
  25775. markPoint.data = zrUtil.map(markPoint.data, function (dataOpt) {
  25776. if (!zrUtil.isArray(dataOpt.value)) {
  25777. var geoCoord;
  25778. if (dataOpt.geoCoord) {
  25779. geoCoord = dataOpt.geoCoord;
  25780. }
  25781. else if (dataOpt.name) {
  25782. geoCoord = geoCoordsMap[dataOpt.name];
  25783. }
  25784. var newValue = geoCoord ? [geoCoord[0], geoCoord[1]] : [NaN, NaN];
  25785. if (dataOpt.value != null) {
  25786. newValue.push(dataOpt.value);
  25787. }
  25788. dataOpt.value = newValue;
  25789. }
  25790. return dataOpt;
  25791. });
  25792. // Convert map series which only has markPoint without data to scatter series
  25793. // FIXME
  25794. if (!(seriesOpt.data && seriesOpt.data.length)) {
  25795. if (!option.geo) {
  25796. option.geo = [];
  25797. }
  25798. else if (!zrUtil.isArray(option.geo)) {
  25799. option.geo = [option.geo];
  25800. }
  25801. // Use same geo if multiple map series has same map type
  25802. var geoOpt = newCreatedGeoOptMap[seriesOpt.map];
  25803. if (!geoOpt) {
  25804. geoOpt = newCreatedGeoOptMap[seriesOpt.map] = createGeoFromMap(seriesOpt);
  25805. option.geo.push(geoOpt);
  25806. }
  25807. var scatterSeries = seriesOpt.markPoint;
  25808. scatterSeries.type = option.effect && option.effect.show ? 'effectScatter' : 'scatter';
  25809. scatterSeries.coordinateSystem = 'geo';
  25810. scatterSeries.geoIndex = zrUtil.indexOf(option.geo, geoOpt);
  25811. scatterSeries.name = seriesOpt.name;
  25812. option.series.splice(zrUtil.indexOf(option.series, seriesOpt), 1, scatterSeries);
  25813. }
  25814. }
  25815. });
  25816. };
  25817. /***/ },
  25818. /* 177 */
  25819. /***/ function(module, exports, __webpack_require__) {
  25820. var echarts = __webpack_require__(1);
  25821. __webpack_require__(178);
  25822. __webpack_require__(181);
  25823. __webpack_require__(185);
  25824. echarts.registerVisualCoding('chart', __webpack_require__(186));
  25825. echarts.registerLayout(__webpack_require__(188));
  25826. /***/ },
  25827. /* 178 */
  25828. /***/ function(module, exports, __webpack_require__) {
  25829. var SeriesModel = __webpack_require__(27);
  25830. var Tree = __webpack_require__(179);
  25831. var zrUtil = __webpack_require__(3);
  25832. var Model = __webpack_require__(8);
  25833. var formatUtil = __webpack_require__(6);
  25834. var encodeHTML = formatUtil.encodeHTML;
  25835. var addCommas = formatUtil.addCommas;
  25836. module.exports = SeriesModel.extend({
  25837. type: 'series.treemap',
  25838. dependencies: ['grid', 'polar'],
  25839. /**
  25840. * @type {module:echarts/data/Tree~Node}
  25841. */
  25842. _viewRoot: null,
  25843. defaultOption: {
  25844. // center: ['50%', '50%'], // not supported in ec3.
  25845. // size: ['80%', '80%'], // deprecated, compatible with ec2.
  25846. left: 'center',
  25847. top: 'middle',
  25848. right: null,
  25849. bottom: null,
  25850. width: '80%',
  25851. height: '80%',
  25852. sort: true, // Can be null or false or true
  25853. // (order by desc default, asc not supported yet (strange effect))
  25854. clipWindow: 'origin', // Size of clipped window when zooming. 'origin' or 'fullscreen'
  25855. squareRatio: 0.5 * (1 + Math.sqrt(5)), // golden ratio
  25856. leafDepth: null, // Nodes on depth from root are regarded as leaves.
  25857. // Count from zero (zero represents only view root).
  25858. drillDownIcon: '▶', // Use html character temporarily because it is complicated
  25859. // to align specialized icon. ▷▶❒❐▼✚
  25860. visualDimension: 0, // Can be 0, 1, 2, 3.
  25861. zoomToNodeRatio: 0.32 * 0.32, // Be effective when using zoomToNode. Specify the proportion of the
  25862. // target node area in the view area.
  25863. roam: true, // true, false, 'scale' or 'zoom', 'move'.
  25864. nodeClick: 'zoomToNode', // Leaf node click behaviour: 'zoomToNode', 'link', false.
  25865. // If leafDepth is set and clicking a node which has children but
  25866. // be on left depth, the behaviour would be changing root. Otherwise
  25867. // use behavious defined above.
  25868. animation: true,
  25869. animationDurationUpdate: 900,
  25870. animationEasing: 'quinticInOut',
  25871. breadcrumb: {
  25872. show: true,
  25873. height: 22,
  25874. left: 'center',
  25875. top: 'bottom',
  25876. // right
  25877. // bottom
  25878. emptyItemWidth: 25, // Width of empty node.
  25879. itemStyle: {
  25880. normal: {
  25881. color: 'rgba(0,0,0,0.7)', //'#5793f3',
  25882. borderColor: 'rgba(255,255,255,0.7)',
  25883. borderWidth: 1,
  25884. shadowColor: 'rgba(150,150,150,1)',
  25885. shadowBlur: 3,
  25886. shadowOffsetX: 0,
  25887. shadowOffsetY: 0,
  25888. textStyle: {
  25889. color: '#fff'
  25890. }
  25891. },
  25892. emphasis: {
  25893. textStyle: {}
  25894. }
  25895. }
  25896. },
  25897. label: {
  25898. normal: {
  25899. show: true,
  25900. position: 'inside', // Can be [5, '5%'] or position stirng like 'insideTopLeft', ...
  25901. textStyle: {
  25902. color: '#fff',
  25903. ellipsis: true
  25904. }
  25905. }
  25906. },
  25907. itemStyle: {
  25908. normal: {
  25909. color: null, // Can be 'none' if not necessary.
  25910. colorAlpha: null, // Can be 'none' if not necessary.
  25911. colorSaturation: null, // Can be 'none' if not necessary.
  25912. borderWidth: 0,
  25913. gapWidth: 0,
  25914. borderColor: '#fff',
  25915. borderColorSaturation: null // If specified, borderColor will be ineffective, and the
  25916. // border color is evaluated by color of current node and
  25917. // borderColorSaturation.
  25918. },
  25919. emphasis: {
  25920. }
  25921. },
  25922. color: 'none', // Array. Specify color list of each level.
  25923. // level[0].color would be global color list.
  25924. colorAlpha: null, // Array. Specify color alpha range of each level, like [0.2, 0.8]
  25925. colorSaturation: null, // Array. Specify color saturation of each level, like [0.2, 0.5]
  25926. colorMappingBy: 'index', // 'value' or 'index' or 'id'.
  25927. visibleMin: 10, // If area less than this threshold (unit: pixel^2), node will not
  25928. // be rendered. Only works when sort is 'asc' or 'desc'.
  25929. childrenVisibleMin: null, // If area of a node less than this threshold (unit: pixel^2),
  25930. // grandchildren will not show.
  25931. // Why grandchildren? If not grandchildren but children,
  25932. // some siblings show children and some not,
  25933. // the appearance may be mess and not consistent,
  25934. levels: [] // Each item: {
  25935. // visibleMin, itemStyle, visualDimension, label
  25936. // }
  25937. // data: {
  25938. // value: [],
  25939. // children: [],
  25940. // link: 'http://xxx.xxx.xxx',
  25941. // target: 'blank' or 'self'
  25942. // }
  25943. },
  25944. /**
  25945. * @override
  25946. */
  25947. getInitialData: function (option, ecModel) {
  25948. var data = option.data || [];
  25949. var rootName = option.name;
  25950. rootName == null && (rootName = option.name);
  25951. // Create a virtual root.
  25952. var root = {name: rootName, children: option.data};
  25953. var value0 = (data[0] || {}).value;
  25954. completeTreeValue(root, zrUtil.isArray(value0) ? value0.length : -1);
  25955. // FIXME
  25956. // sereis.mergeOption 的 getInitData是否放在merge后,从而能直接获取merege后的结果而非手动判断。
  25957. var levels = option.levels || [];
  25958. levels = option.levels = setDefault(levels, ecModel);
  25959. // Make sure always a new tree is created when setOption,
  25960. // in TreemapView, we check whether oldTree === newTree
  25961. // to choose mappings approach among old shapes and new shapes.
  25962. return Tree.createTree(root, this, levels).data;
  25963. },
  25964. optionUpdated: function () {
  25965. this.resetViewRoot();
  25966. },
  25967. /**
  25968. * @override
  25969. * @param {number} dataIndex
  25970. * @param {boolean} [mutipleSeries=false]
  25971. */
  25972. formatTooltip: function (dataIndex) {
  25973. var data = this.getData();
  25974. var value = this.getRawValue(dataIndex);
  25975. var formattedValue = zrUtil.isArray(value)
  25976. ? addCommas(value[0]) : addCommas(value);
  25977. var name = data.getName(dataIndex);
  25978. return encodeHTML(name) + ': ' + formattedValue;
  25979. },
  25980. /**
  25981. * Add tree path to tooltip param
  25982. *
  25983. * @override
  25984. * @param {number} dataIndex
  25985. * @return {Object}
  25986. */
  25987. getDataParams: function (dataIndex) {
  25988. var params = SeriesModel.prototype.getDataParams.apply(this, arguments);
  25989. var data = this.getData();
  25990. var node = data.tree.getNodeByDataIndex(dataIndex);
  25991. var treePathInfo = params.treePathInfo = [];
  25992. while (node) {
  25993. var nodeDataIndex = node.dataIndex;
  25994. treePathInfo.push({
  25995. name: node.name,
  25996. dataIndex: nodeDataIndex,
  25997. value: this.getRawValue(nodeDataIndex)
  25998. });
  25999. node = node.parentNode;
  26000. }
  26001. treePathInfo.reverse();
  26002. return params;
  26003. },
  26004. /**
  26005. * @public
  26006. * @param {Object} layoutInfo {
  26007. * x: containerGroup x
  26008. * y: containerGroup y
  26009. * width: containerGroup width
  26010. * height: containerGroup height
  26011. * }
  26012. */
  26013. setLayoutInfo: function (layoutInfo) {
  26014. /**
  26015. * @readOnly
  26016. * @type {Object}
  26017. */
  26018. this.layoutInfo = this.layoutInfo || {};
  26019. zrUtil.extend(this.layoutInfo, layoutInfo);
  26020. },
  26021. /**
  26022. * @param {string} id
  26023. * @return {number} index
  26024. */
  26025. mapIdToIndex: function (id) {
  26026. // A feature is implemented:
  26027. // index is monotone increasing with the sequence of
  26028. // input id at the first time.
  26029. // This feature can make sure that each data item and its
  26030. // mapped color have the same index between data list and
  26031. // color list at the beginning, which is useful for user
  26032. // to adjust data-color mapping.
  26033. /**
  26034. * @private
  26035. * @type {Object}
  26036. */
  26037. var idIndexMap = this._idIndexMap;
  26038. if (!idIndexMap) {
  26039. idIndexMap = this._idIndexMap = {};
  26040. /**
  26041. * @private
  26042. * @type {number}
  26043. */
  26044. this._idIndexMapCount = 0;
  26045. }
  26046. var index = idIndexMap[id];
  26047. if (index == null) {
  26048. idIndexMap[id] = index = this._idIndexMapCount++;
  26049. }
  26050. return index;
  26051. },
  26052. getViewRoot: function () {
  26053. return this._viewRoot;
  26054. },
  26055. /**
  26056. * @param {module:echarts/data/Tree~Node} [viewRoot]
  26057. */
  26058. resetViewRoot: function (viewRoot) {
  26059. viewRoot
  26060. ? (this._viewRoot = viewRoot)
  26061. : (viewRoot = this._viewRoot);
  26062. var root = this.getData().tree.root;
  26063. if (!viewRoot
  26064. || (viewRoot !== root && !root.contains(viewRoot))
  26065. ) {
  26066. this._viewRoot = root;
  26067. }
  26068. }
  26069. });
  26070. /**
  26071. * @param {Object} dataNode
  26072. */
  26073. function completeTreeValue(dataNode, arrValueLength) {
  26074. // Postorder travel tree.
  26075. // If value of none-leaf node is not set,
  26076. // calculate it by suming up the value of all children.
  26077. var sum = 0;
  26078. zrUtil.each(dataNode.children, function (child) {
  26079. completeTreeValue(child, arrValueLength);
  26080. var childValue = child.value;
  26081. zrUtil.isArray(childValue) && (childValue = childValue[0]);
  26082. sum += childValue;
  26083. });
  26084. var thisValue = dataNode.value;
  26085. if (arrValueLength >= 0) {
  26086. if (!zrUtil.isArray(thisValue)) {
  26087. dataNode.value = new Array(arrValueLength);
  26088. }
  26089. else {
  26090. thisValue = thisValue[0];
  26091. }
  26092. }
  26093. if (thisValue == null || isNaN(thisValue)) {
  26094. thisValue = sum;
  26095. }
  26096. // Value should not less than 0.
  26097. if (thisValue < 0) {
  26098. thisValue = 0;
  26099. }
  26100. arrValueLength >= 0
  26101. ? (dataNode.value[0] = thisValue)
  26102. : (dataNode.value = thisValue);
  26103. }
  26104. /**
  26105. * set default to level configuration
  26106. */
  26107. function setDefault(levels, ecModel) {
  26108. var globalColorList = ecModel.get('color');
  26109. if (!globalColorList) {
  26110. return;
  26111. }
  26112. levels = levels || [];
  26113. var hasColorDefine;
  26114. zrUtil.each(levels, function (levelDefine) {
  26115. var model = new Model(levelDefine);
  26116. var modelColor = model.get('color');
  26117. if (model.get('itemStyle.normal.color')
  26118. || (modelColor && modelColor !== 'none')
  26119. ) {
  26120. hasColorDefine = true;
  26121. }
  26122. });
  26123. if (!hasColorDefine) {
  26124. var level0 = levels[0] || (levels[0] = {});
  26125. level0.color = globalColorList.slice();
  26126. }
  26127. return levels;
  26128. }
  26129. /***/ },
  26130. /* 179 */
  26131. /***/ function(module, exports, __webpack_require__) {
  26132. /**
  26133. * Tree data structure
  26134. *
  26135. * @module echarts/data/Tree
  26136. */
  26137. var zrUtil = __webpack_require__(3);
  26138. var Model = __webpack_require__(8);
  26139. var List = __webpack_require__(95);
  26140. var linkList = __webpack_require__(180);
  26141. var completeDimensions = __webpack_require__(97);
  26142. /**
  26143. * @constructor module:echarts/data/Tree~TreeNode
  26144. * @param {string} name
  26145. * @param {module:echarts/data/Tree} hostTree
  26146. */
  26147. var TreeNode = function (name, hostTree) {
  26148. /**
  26149. * @type {string}
  26150. */
  26151. this.name = name || '';
  26152. /**
  26153. * Depth of node
  26154. *
  26155. * @type {number}
  26156. * @readOnly
  26157. */
  26158. this.depth = 0;
  26159. /**
  26160. * Height of the subtree rooted at this node.
  26161. * @type {number}
  26162. * @readOnly
  26163. */
  26164. this.height = 0;
  26165. /**
  26166. * @type {module:echarts/data/Tree~TreeNode}
  26167. * @readOnly
  26168. */
  26169. this.parentNode = null;
  26170. /**
  26171. * Reference to list item.
  26172. * Do not persistent dataIndex outside,
  26173. * besause it may be changed by list.
  26174. * If dataIndex -1,
  26175. * this node is logical deleted (filtered) in list.
  26176. *
  26177. * @type {Object}
  26178. * @readOnly
  26179. */
  26180. this.dataIndex = -1;
  26181. /**
  26182. * @type {Array.<module:echarts/data/Tree~TreeNode>}
  26183. * @readOnly
  26184. */
  26185. this.children = [];
  26186. /**
  26187. * @type {Array.<module:echarts/data/Tree~TreeNode>}
  26188. * @pubilc
  26189. */
  26190. this.viewChildren = [];
  26191. /**
  26192. * @type {moduel:echarts/data/Tree}
  26193. * @readOnly
  26194. */
  26195. this.hostTree = hostTree;
  26196. };
  26197. TreeNode.prototype = {
  26198. constructor: TreeNode,
  26199. /**
  26200. * The node is removed.
  26201. * @return {boolean} is removed.
  26202. */
  26203. isRemoved: function () {
  26204. return this.dataIndex < 0;
  26205. },
  26206. /**
  26207. * Travel this subtree (include this node).
  26208. * Usage:
  26209. * node.eachNode(function () { ... }); // preorder
  26210. * node.eachNode('preorder', function () { ... }); // preorder
  26211. * node.eachNode('postorder', function () { ... }); // postorder
  26212. * node.eachNode(
  26213. * {order: 'postorder', attr: 'viewChildren'},
  26214. * function () { ... }
  26215. * ); // postorder
  26216. *
  26217. * @param {(Object|string)} options If string, means order.
  26218. * @param {string=} options.order 'preorder' or 'postorder'
  26219. * @param {string=} options.attr 'children' or 'viewChildren'
  26220. * @param {Function} cb If in preorder and return false,
  26221. * its subtree will not be visited.
  26222. * @param {Object} [context]
  26223. */
  26224. eachNode: function (options, cb, context) {
  26225. if (typeof options === 'function') {
  26226. context = cb;
  26227. cb = options;
  26228. options = null;
  26229. }
  26230. options = options || {};
  26231. if (zrUtil.isString(options)) {
  26232. options = {order: options};
  26233. }
  26234. var order = options.order || 'preorder';
  26235. var children = this[options.attr || 'children'];
  26236. var suppressVisitSub;
  26237. order === 'preorder' && (suppressVisitSub = cb.call(context, this));
  26238. for (var i = 0; !suppressVisitSub && i < children.length; i++) {
  26239. children[i].eachNode(options, cb, context);
  26240. }
  26241. order === 'postorder' && cb.call(context, this);
  26242. },
  26243. /**
  26244. * Update depth and height of this subtree.
  26245. *
  26246. * @param {number} depth
  26247. */
  26248. updateDepthAndHeight: function (depth) {
  26249. var height = 0;
  26250. this.depth = depth;
  26251. for (var i = 0; i < this.children.length; i++) {
  26252. var child = this.children[i];
  26253. child.updateDepthAndHeight(depth + 1);
  26254. if (child.height > height) {
  26255. height = child.height;
  26256. }
  26257. }
  26258. this.height = height + 1;
  26259. },
  26260. /**
  26261. * @param {string} id
  26262. * @return {module:echarts/data/Tree~TreeNode}
  26263. */
  26264. getNodeById: function (id) {
  26265. if (this.getId() === id) {
  26266. return this;
  26267. }
  26268. for (var i = 0, children = this.children, len = children.length; i < len; i++) {
  26269. var res = children[i].getNodeById(id);
  26270. if (res) {
  26271. return res;
  26272. }
  26273. }
  26274. },
  26275. /**
  26276. * @param {module:echarts/data/Tree~TreeNode} node
  26277. * @return {boolean}
  26278. */
  26279. contains: function (node) {
  26280. if (node === this) {
  26281. return true;
  26282. }
  26283. for (var i = 0, children = this.children, len = children.length; i < len; i++) {
  26284. var res = children[i].contains(node);
  26285. if (res) {
  26286. return res;
  26287. }
  26288. }
  26289. },
  26290. /**
  26291. * @param {boolean} includeSelf Default false.
  26292. * @return {Array.<module:echarts/data/Tree~TreeNode>} order: [root, child, grandchild, ...]
  26293. */
  26294. getAncestors: function (includeSelf) {
  26295. var ancestors = [];
  26296. var node = includeSelf ? this : this.parentNode;
  26297. while (node) {
  26298. ancestors.push(node);
  26299. node = node.parentNode;
  26300. }
  26301. ancestors.reverse();
  26302. return ancestors;
  26303. },
  26304. /**
  26305. * @param {string|Array=} [dimension='value'] Default 'value'. can be 0, 1, 2, 3
  26306. * @return {number} Value.
  26307. */
  26308. getValue: function (dimension) {
  26309. var data = this.hostTree.data;
  26310. return data.get(data.getDimension(dimension || 'value'), this.dataIndex);
  26311. },
  26312. /**
  26313. * @param {Object} layout
  26314. * @param {boolean=} [merge=false]
  26315. */
  26316. setLayout: function (layout, merge) {
  26317. this.dataIndex >= 0
  26318. && this.hostTree.data.setItemLayout(this.dataIndex, layout, merge);
  26319. },
  26320. /**
  26321. * @return {Object} layout
  26322. */
  26323. getLayout: function () {
  26324. return this.hostTree.data.getItemLayout(this.dataIndex);
  26325. },
  26326. /**
  26327. * @param {string} path
  26328. * @return {module:echarts/model/Model}
  26329. */
  26330. getModel: function (path) {
  26331. if (this.dataIndex < 0) {
  26332. return;
  26333. }
  26334. var hostTree = this.hostTree;
  26335. var itemModel = hostTree.data.getItemModel(this.dataIndex);
  26336. var levelModel = this.getLevelModel();
  26337. return itemModel.getModel(path, (levelModel || hostTree.hostModel).getModel(path));
  26338. },
  26339. /**
  26340. * @return {module:echarts/model/Model}
  26341. */
  26342. getLevelModel: function () {
  26343. return (this.hostTree.levelModels || [])[this.depth];
  26344. },
  26345. /**
  26346. * @example
  26347. * setItemVisual('color', color);
  26348. * setItemVisual({
  26349. * 'color': color
  26350. * });
  26351. */
  26352. setVisual: function (key, value) {
  26353. this.dataIndex >= 0
  26354. && this.hostTree.data.setItemVisual(this.dataIndex, key, value);
  26355. },
  26356. /**
  26357. * Get item visual
  26358. */
  26359. getVisual: function (key, ignoreParent) {
  26360. return this.hostTree.data.getItemVisual(this.dataIndex, key, ignoreParent);
  26361. },
  26362. /**
  26363. * @public
  26364. * @return {number}
  26365. */
  26366. getRawIndex: function () {
  26367. return this.hostTree.data.getRawIndex(this.dataIndex);
  26368. },
  26369. /**
  26370. * @public
  26371. * @return {string}
  26372. */
  26373. getId: function () {
  26374. return this.hostTree.data.getId(this.dataIndex);
  26375. }
  26376. };
  26377. /**
  26378. * @constructor
  26379. * @alias module:echarts/data/Tree
  26380. * @param {module:echarts/model/Model} hostModel
  26381. * @param {Array.<Object>} levelOptions
  26382. */
  26383. function Tree(hostModel, levelOptions) {
  26384. /**
  26385. * @type {module:echarts/data/Tree~TreeNode}
  26386. * @readOnly
  26387. */
  26388. this.root;
  26389. /**
  26390. * @type {module:echarts/data/List}
  26391. * @readOnly
  26392. */
  26393. this.data;
  26394. /**
  26395. * Index of each item is the same as the raw index of coresponding list item.
  26396. * @private
  26397. * @type {Array.<module:echarts/data/Tree~TreeNode}
  26398. */
  26399. this._nodes = [];
  26400. /**
  26401. * @private
  26402. * @readOnly
  26403. * @type {module:echarts/model/Model}
  26404. */
  26405. this.hostModel = hostModel;
  26406. /**
  26407. * @private
  26408. * @readOnly
  26409. * @type {Array.<module:echarts/model/Model}
  26410. */
  26411. this.levelModels = zrUtil.map(levelOptions || [], function (levelDefine) {
  26412. return new Model(levelDefine, hostModel, hostModel.ecModel);
  26413. });
  26414. }
  26415. Tree.prototype = {
  26416. constructor: Tree,
  26417. type: 'tree',
  26418. /**
  26419. * Travel this subtree (include this node).
  26420. * Usage:
  26421. * node.eachNode(function () { ... }); // preorder
  26422. * node.eachNode('preorder', function () { ... }); // preorder
  26423. * node.eachNode('postorder', function () { ... }); // postorder
  26424. * node.eachNode(
  26425. * {order: 'postorder', attr: 'viewChildren'},
  26426. * function () { ... }
  26427. * ); // postorder
  26428. *
  26429. * @param {(Object|string)} options If string, means order.
  26430. * @param {string=} options.order 'preorder' or 'postorder'
  26431. * @param {string=} options.attr 'children' or 'viewChildren'
  26432. * @param {Function} cb
  26433. * @param {Object} [context]
  26434. */
  26435. eachNode: function(options, cb, context) {
  26436. this.root.eachNode(options, cb, context);
  26437. },
  26438. /**
  26439. * @param {number} dataIndex
  26440. * @return {module:echarts/data/Tree~TreeNode}
  26441. */
  26442. getNodeByDataIndex: function (dataIndex) {
  26443. var rawIndex = this.data.getRawIndex(dataIndex);
  26444. return this._nodes[rawIndex];
  26445. },
  26446. /**
  26447. * @param {string} name
  26448. * @return {module:echarts/data/Tree~TreeNode}
  26449. */
  26450. getNodeByName: function (name) {
  26451. return this.root.getNodeByName(name);
  26452. },
  26453. /**
  26454. * Update item available by list,
  26455. * when list has been performed options like 'filterSelf' or 'map'.
  26456. */
  26457. update: function () {
  26458. var data = this.data;
  26459. var nodes = this._nodes;
  26460. for (var i = 0, len = nodes.length; i < len; i++) {
  26461. nodes[i].dataIndex = -1;
  26462. }
  26463. for (var i = 0, len = data.count(); i < len; i++) {
  26464. nodes[data.getRawIndex(i)].dataIndex = i;
  26465. }
  26466. },
  26467. /**
  26468. * Clear all layouts
  26469. */
  26470. clearLayouts: function () {
  26471. this.data.clearItemLayouts();
  26472. }
  26473. };
  26474. /**
  26475. * data node format:
  26476. * {
  26477. * name: ...
  26478. * value: ...
  26479. * children: [
  26480. * {
  26481. * name: ...
  26482. * value: ...
  26483. * children: ...
  26484. * },
  26485. * ...
  26486. * ]
  26487. * }
  26488. *
  26489. * @static
  26490. * @param {Objec} dataRoot Root node.
  26491. * @param {module:echarts/model/Model} hostModel
  26492. * @param {Array.<Object>} levelOptions
  26493. * @return module:echarts/data/Tree
  26494. */
  26495. Tree.createTree = function (dataRoot, hostModel, levelOptions) {
  26496. var tree = new Tree(hostModel, levelOptions);
  26497. var listData = [];
  26498. buildHierarchy(dataRoot);
  26499. function buildHierarchy(dataNode, parentNode) {
  26500. listData.push(dataNode);
  26501. var node = new TreeNode(dataNode.name, tree);
  26502. parentNode
  26503. ? addChild(node, parentNode)
  26504. : (tree.root = node);
  26505. tree._nodes.push(node);
  26506. var children = dataNode.children;
  26507. if (children) {
  26508. for (var i = 0; i < children.length; i++) {
  26509. buildHierarchy(children[i], node);
  26510. }
  26511. }
  26512. }
  26513. tree.root.updateDepthAndHeight(0);
  26514. var dimensions = completeDimensions([{name: 'value'}], listData);
  26515. var list = new List(dimensions, hostModel);
  26516. list.initData(listData);
  26517. linkList({
  26518. mainData: list,
  26519. struct: tree,
  26520. structAttr: 'tree'
  26521. });
  26522. tree.update();
  26523. return tree;
  26524. };
  26525. /**
  26526. * It is needed to consider the mess of 'list', 'hostModel' when creating a TreeNote,
  26527. * so this function is not ready and not necessary to be public.
  26528. *
  26529. * @param {(module:echarts/data/Tree~TreeNode|Object)} child
  26530. */
  26531. function addChild(child, node) {
  26532. var children = node.children;
  26533. if (child.parentNode === node) {
  26534. return;
  26535. }
  26536. children.push(child);
  26537. child.parentNode = node;
  26538. }
  26539. module.exports = Tree;
  26540. /***/ },
  26541. /* 180 */
  26542. /***/ function(module, exports, __webpack_require__) {
  26543. /**
  26544. * Link lists and struct (graph or tree)
  26545. */
  26546. var zrUtil = __webpack_require__(3);
  26547. var each = zrUtil.each;
  26548. var DATAS = '\0__link_datas';
  26549. var MAIN_DATA = '\0__link_mainData';
  26550. // Caution:
  26551. // In most case, either list or its shallow clones (see list.cloneShallow)
  26552. // is active in echarts process. So considering heap memory consumption,
  26553. // we do not clone tree or graph, but share them among list and its shallow clones.
  26554. // But in some rare case, we have to keep old list (like do animation in chart). So
  26555. // please take care that both the old list and the new list share the same tree/graph.
  26556. /**
  26557. * @param {Object} opt
  26558. * @param {module:echarts/data/List} opt.mainData
  26559. * @param {Object} [opt.struct] For example, instance of Graph or Tree.
  26560. * @param {string} [opt.structAttr] designation: list[structAttr] = struct;
  26561. * @param {Object} [opt.datas] {dataType: data},
  26562. * like: {node: nodeList, edge: edgeList}.
  26563. * Should contain mainData.
  26564. * @param {Object} [opt.datasAttr] {dataType: attr},
  26565. * designation: struct[datasAttr[dataType]] = list;
  26566. */
  26567. function linkList(opt) {
  26568. var mainData = opt.mainData;
  26569. var datas = opt.datas;
  26570. if (!datas) {
  26571. datas = {main: mainData};
  26572. opt.datasAttr = {main: 'data'};
  26573. }
  26574. opt.datas = opt.mainData = null;
  26575. linkAll(mainData, datas, opt);
  26576. // Porxy data original methods.
  26577. each(datas, function (data) {
  26578. each(mainData.TRANSFERABLE_METHODS, function (methodName) {
  26579. data.wrapMethod(methodName, zrUtil.curry(transferInjection, opt));
  26580. });
  26581. });
  26582. // Beyond transfer, additional features should be added to `cloneShallow`.
  26583. mainData.wrapMethod('cloneShallow', zrUtil.curry(cloneShallowInjection, opt));
  26584. // Only mainData trigger change, because struct.update may trigger
  26585. // another changable methods, which may bring about dead lock.
  26586. each(mainData.CHANGABLE_METHODS, function (methodName) {
  26587. mainData.wrapMethod(methodName, zrUtil.curry(changeInjection, opt));
  26588. });
  26589. // Make sure datas contains mainData.
  26590. zrUtil.assert(datas[mainData.dataType] === mainData);
  26591. }
  26592. function transferInjection(opt, res) {
  26593. if (isMainData(this)) {
  26594. // Transfer datas to new main data.
  26595. var datas = zrUtil.extend({}, this[DATAS]);
  26596. datas[this.dataType] = res;
  26597. linkAll(res, datas, opt);
  26598. }
  26599. else {
  26600. // Modify the reference in main data to point newData.
  26601. linkSingle(res, this.dataType, this[MAIN_DATA], opt);
  26602. }
  26603. return res;
  26604. }
  26605. function changeInjection(opt, res) {
  26606. opt.struct && opt.struct.update(this);
  26607. return res;
  26608. }
  26609. function cloneShallowInjection(opt, res) {
  26610. // cloneShallow, which brings about some fragilities, may be inappropriate
  26611. // to be exposed as an API. So for implementation simplicity we can make
  26612. // the restriction that cloneShallow of not-mainData should not be invoked
  26613. // outside, but only be invoked here.
  26614. each(res[DATAS], function (data, dataType) {
  26615. data !== res && linkSingle(data.cloneShallow(), dataType, res, opt);
  26616. });
  26617. return res;
  26618. }
  26619. /**
  26620. * Supplement method to List.
  26621. *
  26622. * @public
  26623. * @param {string} [dataType] If not specified, return mainData.
  26624. * @return {module:echarts/data/List}
  26625. */
  26626. function getLinkedData(dataType) {
  26627. var mainData = this[MAIN_DATA];
  26628. return (dataType == null || mainData == null)
  26629. ? mainData
  26630. : mainData[DATAS][dataType];
  26631. }
  26632. function isMainData(data) {
  26633. return data[MAIN_DATA] === data;
  26634. }
  26635. function linkAll(mainData, datas, opt) {
  26636. mainData[DATAS] = {};
  26637. each(datas, function (data, dataType) {
  26638. linkSingle(data, dataType, mainData, opt);
  26639. });
  26640. }
  26641. function linkSingle(data, dataType, mainData, opt) {
  26642. mainData[DATAS][dataType] = data;
  26643. data[MAIN_DATA] = mainData;
  26644. data.dataType = dataType;
  26645. if (opt.struct) {
  26646. data[opt.structAttr] = opt.struct;
  26647. opt.struct[opt.datasAttr[dataType]] = data;
  26648. }
  26649. // Supplement method.
  26650. data.getLinkedData = getLinkedData;
  26651. }
  26652. module.exports = linkList;
  26653. /***/ },
  26654. /* 181 */
  26655. /***/ function(module, exports, __webpack_require__) {
  26656. var zrUtil = __webpack_require__(3);
  26657. var graphic = __webpack_require__(42);
  26658. var DataDiffer = __webpack_require__(96);
  26659. var helper = __webpack_require__(182);
  26660. var Breadcrumb = __webpack_require__(183);
  26661. var RoamController = __webpack_require__(169);
  26662. var BoundingRect = __webpack_require__(15);
  26663. var matrix = __webpack_require__(17);
  26664. var animationUtil = __webpack_require__(184);
  26665. var bind = zrUtil.bind;
  26666. var Group = graphic.Group;
  26667. var Rect = graphic.Rect;
  26668. var each = zrUtil.each;
  26669. var DRAG_THRESHOLD = 3;
  26670. var PATH_LABEL_NORMAL = ['label', 'normal'];
  26671. var PATH_LABEL_EMPHASIS = ['label', 'emphasis'];
  26672. var Z_BASE = 10; // Should bigger than every z.
  26673. var Z_BG = 1;
  26674. var Z_CONTENT = 2;
  26675. module.exports = __webpack_require__(1).extendChartView({
  26676. type: 'treemap',
  26677. /**
  26678. * @override
  26679. */
  26680. init: function (o, api) {
  26681. /**
  26682. * @private
  26683. * @type {module:zrender/container/Group}
  26684. */
  26685. this._containerGroup;
  26686. /**
  26687. * @private
  26688. * @type {Object.<string, Array.<module:zrender/container/Group>>}
  26689. */
  26690. this._storage = createStorage();
  26691. /**
  26692. * @private
  26693. * @type {module:echarts/data/Tree}
  26694. */
  26695. this._oldTree;
  26696. /**
  26697. * @private
  26698. * @type {module:echarts/chart/treemap/Breadcrumb}
  26699. */
  26700. this._breadcrumb;
  26701. /**
  26702. * @private
  26703. * @type {module:echarts/component/helper/RoamController}
  26704. */
  26705. this._controller;
  26706. /**
  26707. * 'ready', 'animating'
  26708. * @private
  26709. */
  26710. this._state = 'ready';
  26711. /**
  26712. * @private
  26713. * @type {boolean}
  26714. */
  26715. this._mayClick;
  26716. },
  26717. /**
  26718. * @override
  26719. */
  26720. render: function (seriesModel, ecModel, api, payload) {
  26721. var models = ecModel.findComponents({
  26722. mainType: 'series', subType: 'treemap', query: payload
  26723. });
  26724. if (zrUtil.indexOf(models, seriesModel) < 0) {
  26725. return;
  26726. }
  26727. this.seriesModel = seriesModel;
  26728. this.api = api;
  26729. this.ecModel = ecModel;
  26730. var targetInfo = helper.retrieveTargetInfo(payload, seriesModel);
  26731. var payloadType = payload && payload.type;
  26732. var layoutInfo = seriesModel.layoutInfo;
  26733. var isInit = !this._oldTree;
  26734. var thisStorage = this._storage;
  26735. // Mark new root when action is treemapRootToNode.
  26736. var reRoot = (payloadType === 'treemapRootToNode' && targetInfo && thisStorage)
  26737. ? {
  26738. rootNodeGroup: thisStorage.nodeGroup[targetInfo.node.getRawIndex()],
  26739. direction: payload.direction
  26740. }
  26741. : null;
  26742. var containerGroup = this._giveContainerGroup(layoutInfo);
  26743. var renderResult = this._doRender(containerGroup, seriesModel, reRoot);
  26744. (
  26745. !isInit && (
  26746. !payloadType
  26747. || payloadType === 'treemapZoomToNode'
  26748. || payloadType === 'treemapRootToNode'
  26749. )
  26750. )
  26751. ? this._doAnimation(containerGroup, renderResult, seriesModel, reRoot)
  26752. : renderResult.renderFinally();
  26753. this._resetController(api);
  26754. this._renderBreadcrumb(seriesModel, api, targetInfo);
  26755. },
  26756. /**
  26757. * @private
  26758. */
  26759. _giveContainerGroup: function (layoutInfo) {
  26760. var containerGroup = this._containerGroup;
  26761. if (!containerGroup) {
  26762. // FIXME
  26763. // 加一层containerGroup是为了clip,但是现在clip功能并没有实现。
  26764. containerGroup = this._containerGroup = new Group();
  26765. this._initEvents(containerGroup);
  26766. this.group.add(containerGroup);
  26767. }
  26768. containerGroup.position = [layoutInfo.x, layoutInfo.y];
  26769. return containerGroup;
  26770. },
  26771. /**
  26772. * @private
  26773. */
  26774. _doRender: function (containerGroup, seriesModel, reRoot) {
  26775. var thisTree = seriesModel.getData().tree;
  26776. var oldTree = this._oldTree;
  26777. // Clear last shape records.
  26778. var lastsForAnimation = createStorage();
  26779. var thisStorage = createStorage();
  26780. var oldStorage = this._storage;
  26781. var willInvisibleEls = [];
  26782. var doRenderNode = zrUtil.curry(
  26783. renderNode, seriesModel,
  26784. thisStorage, oldStorage, reRoot,
  26785. lastsForAnimation, willInvisibleEls
  26786. );
  26787. // Notice: when thisTree and oldTree are the same tree (see list.cloneShadow),
  26788. // the oldTree is actually losted, so we can not find all of the old graphic
  26789. // elements from tree. So we use this stragegy: make element storage, move
  26790. // from old storage to new storage, clear old storage.
  26791. dualTravel(
  26792. thisTree.root ? [thisTree.root] : [],
  26793. (oldTree && oldTree.root) ? [oldTree.root] : [],
  26794. containerGroup,
  26795. thisTree === oldTree || !oldTree,
  26796. 0
  26797. );
  26798. // Process all removing.
  26799. var willDeleteEls = clearStorage(oldStorage);
  26800. this._oldTree = thisTree;
  26801. this._storage = thisStorage;
  26802. return {
  26803. lastsForAnimation: lastsForAnimation,
  26804. willDeleteEls: willDeleteEls,
  26805. renderFinally: renderFinally
  26806. };
  26807. function dualTravel(thisViewChildren, oldViewChildren, parentGroup, sameTree, depth) {
  26808. // When 'render' is triggered by action,
  26809. // 'this' and 'old' may be the same tree,
  26810. // we use rawIndex in that case.
  26811. if (sameTree) {
  26812. oldViewChildren = thisViewChildren;
  26813. each(thisViewChildren, function (child, index) {
  26814. !child.isRemoved() && processNode(index, index);
  26815. });
  26816. }
  26817. // Diff hierarchically (diff only in each subtree, but not whole).
  26818. // because, consistency of view is important.
  26819. else {
  26820. (new DataDiffer(oldViewChildren, thisViewChildren, getKey, getKey))
  26821. .add(processNode)
  26822. .update(processNode)
  26823. .remove(zrUtil.curry(processNode, null))
  26824. .execute();
  26825. }
  26826. function getKey(node) {
  26827. // Identify by name or raw index.
  26828. return node.getId();
  26829. }
  26830. function processNode(newIndex, oldIndex) {
  26831. var thisNode = newIndex != null ? thisViewChildren[newIndex] : null;
  26832. var oldNode = oldIndex != null ? oldViewChildren[oldIndex] : null;
  26833. var group = doRenderNode(thisNode, oldNode, parentGroup, depth);
  26834. group && dualTravel(
  26835. thisNode && thisNode.viewChildren || [],
  26836. oldNode && oldNode.viewChildren || [],
  26837. group,
  26838. sameTree,
  26839. depth + 1
  26840. );
  26841. }
  26842. }
  26843. function clearStorage(storage) {
  26844. var willDeleteEls = createStorage();
  26845. storage && each(storage, function (store, storageName) {
  26846. var delEls = willDeleteEls[storageName];
  26847. each(store, function (el) {
  26848. el && (delEls.push(el), el.__tmWillDelete = 1);
  26849. });
  26850. });
  26851. return willDeleteEls;
  26852. }
  26853. function renderFinally() {
  26854. each(willDeleteEls, function (els) {
  26855. each(els, function (el) {
  26856. el.parent && el.parent.remove(el);
  26857. });
  26858. });
  26859. each(willInvisibleEls, function (el) {
  26860. el.invisible = true;
  26861. // Setting invisible is for optimizing, so no need to set dirty,
  26862. // just mark as invisible.
  26863. el.dirty();
  26864. });
  26865. }
  26866. },
  26867. /**
  26868. * @private
  26869. */
  26870. _doAnimation: function (containerGroup, renderResult, seriesModel, reRoot) {
  26871. if (!seriesModel.get('animation')) {
  26872. return;
  26873. }
  26874. var duration = seriesModel.get('animationDurationUpdate');
  26875. var easing = seriesModel.get('animationEasing');
  26876. var animationWrap = animationUtil.createWrap();
  26877. // Make delete animations.
  26878. each(renderResult.willDeleteEls, function (store, storageName) {
  26879. each(store, function (el, rawIndex) {
  26880. if (el.invisible) {
  26881. return;
  26882. }
  26883. var parent = el.parent; // Always has parent, and parent is nodeGroup.
  26884. var target;
  26885. if (reRoot && reRoot.direction === 'drillDown') {
  26886. target = parent === reRoot.rootNodeGroup
  26887. // This is the content element of view root.
  26888. // Only `content` will enter this branch, because
  26889. // `background` and `nodeGroup` will not be deleted.
  26890. ? {
  26891. shape: {
  26892. x: 0,
  26893. y: 0,
  26894. width: parent.__tmNodeWidth,
  26895. height: parent.__tmNodeHeight
  26896. },
  26897. style: {
  26898. opacity: 0
  26899. }
  26900. }
  26901. // Others.
  26902. : {style: {opacity: 0}};
  26903. }
  26904. else {
  26905. var targetX = 0;
  26906. var targetY = 0;
  26907. if (!parent.__tmWillDelete) {
  26908. // Let node animate to right-bottom corner, cooperating with fadeout,
  26909. // which is appropriate for user understanding.
  26910. // Divided by 2 for reRoot rolling up effect.
  26911. targetX = parent.__tmNodeWidth / 2;
  26912. targetY = parent.__tmNodeHeight / 2;
  26913. }
  26914. target = storageName === 'nodeGroup'
  26915. ? {position: [targetX, targetY], style: {opacity: 0}}
  26916. : {
  26917. shape: {x: targetX, y: targetY, width: 0, height: 0},
  26918. style: {opacity: 0}
  26919. };
  26920. }
  26921. target && animationWrap.add(el, target, duration, easing);
  26922. });
  26923. });
  26924. // Make other animations
  26925. each(this._storage, function (store, storageName) {
  26926. each(store, function (el, rawIndex) {
  26927. var last = renderResult.lastsForAnimation[storageName][rawIndex];
  26928. var target = {};
  26929. if (!last) {
  26930. return;
  26931. }
  26932. if (storageName === 'nodeGroup') {
  26933. if (last.old) {
  26934. target.position = el.position.slice();
  26935. el.position = last.old;
  26936. }
  26937. }
  26938. else {
  26939. if (last.old) {
  26940. target.shape = zrUtil.extend({}, el.shape);
  26941. el.setShape(last.old);
  26942. }
  26943. if (last.fadein) {
  26944. el.setStyle('opacity', 0);
  26945. target.style = {opacity: 1};
  26946. }
  26947. // When animation is stopped for succedent animation starting,
  26948. // el.style.opacity might not be 1
  26949. else if (el.style.opacity !== 1) {
  26950. target.style = {opacity: 1};
  26951. }
  26952. }
  26953. animationWrap.add(el, target, duration, easing);
  26954. });
  26955. }, this);
  26956. this._state = 'animating';
  26957. animationWrap
  26958. .done(bind(function () {
  26959. this._state = 'ready';
  26960. renderResult.renderFinally();
  26961. }, this))
  26962. .start();
  26963. },
  26964. /**
  26965. * @private
  26966. */
  26967. _resetController: function (api) {
  26968. var controller = this._controller;
  26969. // Init controller.
  26970. if (!controller) {
  26971. controller = this._controller = new RoamController(api.getZr());
  26972. controller.enable(this.seriesModel.get('roam'));
  26973. controller.on('pan', bind(this._onPan, this));
  26974. controller.on('zoom', bind(this._onZoom, this));
  26975. }
  26976. var rect = new BoundingRect(0, 0, api.getWidth(), api.getHeight());
  26977. controller.rectProvider = function () {
  26978. return rect;
  26979. };
  26980. },
  26981. /**
  26982. * @private
  26983. */
  26984. _clearController: function () {
  26985. var controller = this._controller;
  26986. if (controller) {
  26987. controller.off('pan').off('zoom');
  26988. controller = null;
  26989. }
  26990. },
  26991. /**
  26992. * @private
  26993. */
  26994. _onPan: function (dx, dy) {
  26995. this._mayClick = false;
  26996. if (this._state !== 'animating'
  26997. && (Math.abs(dx) > DRAG_THRESHOLD || Math.abs(dy) > DRAG_THRESHOLD)
  26998. ) {
  26999. // These param must not be cached.
  27000. var root = this.seriesModel.getData().tree.root;
  27001. if (!root) {
  27002. return;
  27003. }
  27004. var rootLayout = root.getLayout();
  27005. if (!rootLayout) {
  27006. return;
  27007. }
  27008. this.api.dispatchAction({
  27009. type: 'treemapMove',
  27010. from: this.uid,
  27011. seriesId: this.seriesModel.id,
  27012. rootRect: {
  27013. x: rootLayout.x + dx, y: rootLayout.y + dy,
  27014. width: rootLayout.width, height: rootLayout.height
  27015. }
  27016. });
  27017. }
  27018. },
  27019. /**
  27020. * @private
  27021. */
  27022. _onZoom: function (scale, mouseX, mouseY) {
  27023. this._mayClick = false;
  27024. if (this._state !== 'animating') {
  27025. // These param must not be cached.
  27026. var root = this.seriesModel.getData().tree.root;
  27027. if (!root) {
  27028. return;
  27029. }
  27030. var rootLayout = root.getLayout();
  27031. if (!rootLayout) {
  27032. return;
  27033. }
  27034. var rect = new BoundingRect(
  27035. rootLayout.x, rootLayout.y, rootLayout.width, rootLayout.height
  27036. );
  27037. var layoutInfo = this.seriesModel.layoutInfo;
  27038. // Transform mouse coord from global to containerGroup.
  27039. mouseX -= layoutInfo.x;
  27040. mouseY -= layoutInfo.y;
  27041. // Scale root bounding rect.
  27042. var m = matrix.create();
  27043. matrix.translate(m, m, [-mouseX, -mouseY]);
  27044. matrix.scale(m, m, [scale, scale]);
  27045. matrix.translate(m, m, [mouseX, mouseY]);
  27046. rect.applyTransform(m);
  27047. this.api.dispatchAction({
  27048. type: 'treemapRender',
  27049. from: this.uid,
  27050. seriesId: this.seriesModel.id,
  27051. rootRect: {
  27052. x: rect.x, y: rect.y,
  27053. width: rect.width, height: rect.height
  27054. }
  27055. });
  27056. }
  27057. },
  27058. /**
  27059. * @private
  27060. */
  27061. _initEvents: function (containerGroup) {
  27062. // FIXME
  27063. // 不用click以及silent的原因是,animate时视图设置silent true来避免click生效,
  27064. // 但是animate中,按下鼠标,animate结束后(silent设回为false)松开鼠标,
  27065. // 还是会触发click,期望是不触发。
  27066. // Mousedown occurs when drag start, and mouseup occurs when drag end,
  27067. // click event should not be triggered in that case.
  27068. containerGroup.on('mousedown', function (e) {
  27069. this._state === 'ready' && (this._mayClick = true);
  27070. }, this);
  27071. containerGroup.on('mouseup', function (e) {
  27072. if (this._mayClick) {
  27073. this._mayClick = false;
  27074. this._state === 'ready' && onClick.call(this, e);
  27075. }
  27076. }, this);
  27077. function onClick(e) {
  27078. var nodeClick = this.seriesModel.get('nodeClick', true);
  27079. if (!nodeClick) {
  27080. return;
  27081. }
  27082. var targetInfo = this.findTarget(e.offsetX, e.offsetY);
  27083. if (!targetInfo) {
  27084. return;
  27085. }
  27086. var node = targetInfo.node;
  27087. if (node.getLayout().isLeafRoot) {
  27088. this._rootToNode(targetInfo);
  27089. }
  27090. else {
  27091. if (nodeClick === 'zoomToNode') {
  27092. this._zoomToNode(targetInfo);
  27093. }
  27094. else if (nodeClick === 'link') {
  27095. var itemModel = node.hostTree.data.getItemModel(node.dataIndex);
  27096. var link = itemModel.get('link', true);
  27097. var linkTarget = itemModel.get('target', true) || 'blank';
  27098. link && window.open(link, linkTarget);
  27099. }
  27100. }
  27101. }
  27102. },
  27103. /**
  27104. * @private
  27105. */
  27106. _renderBreadcrumb: function (seriesModel, api, targetInfo) {
  27107. if (!targetInfo) {
  27108. // Find breadcrumb tail on center of containerGroup.
  27109. targetInfo = this.findTarget(api.getWidth() / 2, api.getHeight() / 2);
  27110. if (!targetInfo) {
  27111. targetInfo = {node: seriesModel.getData().tree.root};
  27112. }
  27113. }
  27114. (this._breadcrumb || (this._breadcrumb = new Breadcrumb(this.group, bind(onSelect, this))))
  27115. .render(seriesModel, api, targetInfo.node);
  27116. function onSelect(node) {
  27117. if (this._state !== 'animating') {
  27118. helper.aboveViewRoot(seriesModel.getViewRoot(), node)
  27119. ? this._rootToNode({node: node})
  27120. : this._zoomToNode({node: node});
  27121. }
  27122. }
  27123. },
  27124. /**
  27125. * @override
  27126. */
  27127. remove: function () {
  27128. this._clearController();
  27129. this._containerGroup && this._containerGroup.removeAll();
  27130. this._storage = createStorage();
  27131. this._state = 'ready';
  27132. this._breadcrumb && this._breadcrumb.remove();
  27133. },
  27134. dispose: function () {
  27135. this._clearController();
  27136. },
  27137. /**
  27138. * @private
  27139. */
  27140. _zoomToNode: function (targetInfo) {
  27141. this.api.dispatchAction({
  27142. type: 'treemapZoomToNode',
  27143. from: this.uid,
  27144. seriesId: this.seriesModel.id,
  27145. targetNode: targetInfo.node
  27146. });
  27147. },
  27148. /**
  27149. * @private
  27150. */
  27151. _rootToNode: function (targetInfo) {
  27152. this.api.dispatchAction({
  27153. type: 'treemapRootToNode',
  27154. from: this.uid,
  27155. seriesId: this.seriesModel.id,
  27156. targetNode: targetInfo.node
  27157. });
  27158. },
  27159. /**
  27160. * @public
  27161. * @param {number} x Global coord x.
  27162. * @param {number} y Global coord y.
  27163. * @return {Object} info If not found, return undefined;
  27164. * @return {number} info.node Target node.
  27165. * @return {number} info.offsetX x refer to target node.
  27166. * @return {number} info.offsetY y refer to target node.
  27167. */
  27168. findTarget: function (x, y) {
  27169. var targetInfo;
  27170. var viewRoot = this.seriesModel.getViewRoot();
  27171. viewRoot.eachNode({attr: 'viewChildren', order: 'preorder'}, function (node) {
  27172. var bgEl = this._storage.background[node.getRawIndex()];
  27173. // If invisible, there might be no element.
  27174. if (bgEl) {
  27175. var point = bgEl.transformCoordToLocal(x, y);
  27176. var shape = bgEl.shape;
  27177. // For performance consideration, dont use 'getBoundingRect'.
  27178. if (shape.x <= point[0]
  27179. && point[0] <= shape.x + shape.width
  27180. && shape.y <= point[1]
  27181. && point[1] <= shape.y + shape.height
  27182. ) {
  27183. targetInfo = {node: node, offsetX: point[0], offsetY: point[1]};
  27184. }
  27185. else {
  27186. return false; // Suppress visit subtree.
  27187. }
  27188. }
  27189. }, this);
  27190. return targetInfo;
  27191. }
  27192. });
  27193. /**
  27194. * @inner
  27195. */
  27196. function createStorage() {
  27197. return {nodeGroup: [], background: [], content: []};
  27198. }
  27199. /**
  27200. * @inner
  27201. * @return Return undefined means do not travel further.
  27202. */
  27203. function renderNode(
  27204. seriesModel, thisStorage, oldStorage, reRoot,
  27205. lastsForAnimation, willInvisibleEls,
  27206. thisNode, oldNode, parentGroup, depth
  27207. ) {
  27208. // Whether under viewRoot.
  27209. if (!thisNode) {
  27210. // Deleting nodes will be performed finally. This method just find
  27211. // element from old storage, or create new element, set them to new
  27212. // storage, and set styles.
  27213. return;
  27214. }
  27215. var thisLayout = thisNode.getLayout();
  27216. if (!thisLayout || !thisLayout.isInView) {
  27217. return;
  27218. }
  27219. var thisWidth = thisLayout.width;
  27220. var thisHeight = thisLayout.height;
  27221. var thisInvisible = thisLayout.invisible;
  27222. var thisRawIndex = thisNode.getRawIndex();
  27223. var oldRawIndex = oldNode && oldNode.getRawIndex();
  27224. // Node group
  27225. var group = giveGraphic('nodeGroup', Group);
  27226. if (!group) {
  27227. return;
  27228. }
  27229. parentGroup.add(group);
  27230. // x,y are not set when el is above view root.
  27231. group.position = [thisLayout.x || 0, thisLayout.y || 0];
  27232. group.__tmNodeWidth = thisWidth;
  27233. group.__tmNodeHeight = thisHeight;
  27234. if (thisLayout.isAboveViewRoot) {
  27235. return group;
  27236. }
  27237. // Background
  27238. var bg = giveGraphic('background', Rect, depth, Z_BG);
  27239. if (bg) {
  27240. bg.setShape({x: 0, y: 0, width: thisWidth, height: thisHeight});
  27241. updateStyle(bg, function () {
  27242. bg.setStyle('fill', thisNode.getVisual('borderColor', true));
  27243. });
  27244. group.add(bg);
  27245. }
  27246. var thisViewChildren = thisNode.viewChildren;
  27247. // No children, render content.
  27248. if (!thisViewChildren || !thisViewChildren.length) {
  27249. var content = giveGraphic('content', Rect, depth, Z_CONTENT);
  27250. content && renderContent(group);
  27251. }
  27252. return group;
  27253. // ----------------------------
  27254. // | Procedures in renderNode |
  27255. // ----------------------------
  27256. function renderContent(group) {
  27257. // For tooltip.
  27258. content.dataIndex = thisNode.dataIndex;
  27259. content.seriesIndex = seriesModel.seriesIndex;
  27260. var borderWidth = thisLayout.borderWidth;
  27261. var contentWidth = Math.max(thisWidth - 2 * borderWidth, 0);
  27262. var contentHeight = Math.max(thisHeight - 2 * borderWidth, 0);
  27263. content.culling = true;
  27264. content.setShape({
  27265. x: borderWidth,
  27266. y: borderWidth,
  27267. width: contentWidth,
  27268. height: contentHeight
  27269. });
  27270. var visualColor = thisNode.getVisual('color', true);
  27271. updateStyle(content, function () {
  27272. var normalStyle = {fill: visualColor};
  27273. var emphasisStyle = thisNode.getModel('itemStyle.emphasis').getItemStyle();
  27274. prepareText(normalStyle, emphasisStyle, visualColor, contentWidth, contentHeight);
  27275. content.setStyle(normalStyle);
  27276. graphic.setHoverStyle(content, emphasisStyle);
  27277. });
  27278. group.add(content);
  27279. }
  27280. function updateStyle(element, cb) {
  27281. if (!thisInvisible) {
  27282. // If invisible, do not set visual, otherwise the element will
  27283. // change immediately before animation. We think it is OK to
  27284. // remain its origin color when moving out of the view window.
  27285. cb();
  27286. if (!element.__tmWillVisible) {
  27287. element.invisible = false;
  27288. }
  27289. }
  27290. else {
  27291. // Delay invisible setting utill animation finished,
  27292. // avoid element vanish suddenly before animation.
  27293. !element.invisible && willInvisibleEls.push(element);
  27294. }
  27295. }
  27296. function prepareText(normalStyle, emphasisStyle, visualColor, contentWidth, contentHeight) {
  27297. var nodeModel = thisNode.getModel();
  27298. var text = nodeModel.get('name');
  27299. if (thisLayout.isLeafRoot) {
  27300. var iconChar = seriesModel.get('drillDownIcon', true);
  27301. text += iconChar ? ' ' + iconChar : '';
  27302. }
  27303. setText(
  27304. text, normalStyle, nodeModel, PATH_LABEL_NORMAL,
  27305. visualColor, contentWidth, contentHeight
  27306. );
  27307. setText(
  27308. text, emphasisStyle, nodeModel, PATH_LABEL_EMPHASIS,
  27309. visualColor, contentWidth, contentHeight
  27310. );
  27311. }
  27312. function setText(text, style, nodeModel, labelPath, visualColor, contentWidth, contentHeight) {
  27313. var labelModel = nodeModel.getModel(labelPath);
  27314. var labelTextStyleModel = labelModel.getModel('textStyle');
  27315. graphic.setText(style, labelModel, visualColor);
  27316. // text.align and text.baseline is not included by graphic.setText,
  27317. // because in most cases the two attributes are not exposed to user,
  27318. // except in treemap.
  27319. style.textAlign = labelTextStyleModel.get('align');
  27320. style.textVerticalAlign = labelTextStyleModel.get('baseline');
  27321. var textRect = labelTextStyleModel.getTextRect(text);
  27322. if (!labelModel.getShallow('show') || textRect.height > contentHeight) {
  27323. style.text = '';
  27324. }
  27325. else if (textRect.width > contentWidth) {
  27326. style.text = labelTextStyleModel.get('ellipsis')
  27327. ? labelTextStyleModel.ellipsis(text, contentWidth) : '';
  27328. }
  27329. else {
  27330. style.text = text;
  27331. }
  27332. }
  27333. function giveGraphic(storageName, Ctor, depth, z) {
  27334. var element = oldRawIndex != null && oldStorage[storageName][oldRawIndex];
  27335. var lasts = lastsForAnimation[storageName];
  27336. if (element) {
  27337. // Remove from oldStorage
  27338. oldStorage[storageName][oldRawIndex] = null;
  27339. prepareAnimationWhenHasOld(lasts, element, storageName);
  27340. }
  27341. // If invisible and no old element, do not create new element (for optimizing).
  27342. else if (!thisInvisible) {
  27343. element = new Ctor({z: calculateZ(depth, z)});
  27344. element.__tmDepth = depth;
  27345. element.__tmStorageName = storageName;
  27346. prepareAnimationWhenNoOld(lasts, element, storageName);
  27347. }
  27348. // Set to thisStorage
  27349. return (thisStorage[storageName][thisRawIndex] = element);
  27350. }
  27351. function prepareAnimationWhenHasOld(lasts, element, storageName) {
  27352. var lastCfg = lasts[thisRawIndex] = {};
  27353. lastCfg.old = storageName === 'nodeGroup'
  27354. ? element.position.slice()
  27355. : zrUtil.extend({}, element.shape);
  27356. }
  27357. // If a element is new, we need to find the animation start point carefully,
  27358. // otherwise it will looks strange when 'zoomToNode'.
  27359. function prepareAnimationWhenNoOld(lasts, element, storageName) {
  27360. var lastCfg = lasts[thisRawIndex] = {};
  27361. var parentNode = thisNode.parentNode;
  27362. if (parentNode && (!reRoot || reRoot.direction === 'drillDown')) {
  27363. var parentOldX = 0;
  27364. var parentOldY = 0;
  27365. // New nodes appear from right-bottom corner in 'zoomToNode' animation.
  27366. // For convenience, get old bounding rect from background.
  27367. var parentOldBg = lastsForAnimation.background[parentNode.getRawIndex()];
  27368. if (!reRoot && parentOldBg && parentOldBg.old) {
  27369. parentOldX = parentOldBg.old.width;
  27370. parentOldY = parentOldBg.old.height;
  27371. }
  27372. // When no parent old shape found, its parent is new too,
  27373. // so we can just use {x:0, y:0}.
  27374. lastCfg.old = storageName === 'nodeGroup'
  27375. ? [0, parentOldY]
  27376. : {x: parentOldX, y: parentOldY, width: 0, height: 0};
  27377. }
  27378. // Fade in, user can be aware that these nodes are new.
  27379. lastCfg.fadein = storageName !== 'nodeGroup';
  27380. }
  27381. }
  27382. // We can not set all backgroud with the same z, Because the behaviour of
  27383. // drill down and roll up differ background creation sequence from tree
  27384. // hierarchy sequence, which cause that lowser background element overlap
  27385. // upper ones. So we calculate z based on depth.
  27386. // Moreover, we try to shrink down z interval to [0, 1] to avoid that
  27387. // treemap with large z overlaps other components.
  27388. function calculateZ(depth, zInLevel) {
  27389. var zb = depth * Z_BASE + zInLevel;
  27390. return (zb - 1) / zb;
  27391. }
  27392. /***/ },
  27393. /* 182 */
  27394. /***/ function(module, exports, __webpack_require__) {
  27395. var zrUtil = __webpack_require__(3);
  27396. var helper = {
  27397. retrieveTargetInfo: function (payload, seriesModel) {
  27398. if (payload
  27399. && (
  27400. payload.type === 'treemapZoomToNode'
  27401. || payload.type === 'treemapRootToNode'
  27402. )
  27403. ) {
  27404. var root = seriesModel.getData().tree.root;
  27405. var targetNode = payload.targetNode;
  27406. if (targetNode && root.contains(targetNode)) {
  27407. return {node: targetNode};
  27408. }
  27409. var targetNodeId = payload.targetNodeId;
  27410. if (targetNodeId != null && (targetNode = root.getNodeById(targetNodeId))) {
  27411. return {node: targetNode};
  27412. }
  27413. }
  27414. },
  27415. // Not includes the given node at the last item.
  27416. getPathToRoot: function (node) {
  27417. var path = [];
  27418. while (node) {
  27419. node = node.parentNode;
  27420. node && path.push(node);
  27421. }
  27422. return path.reverse();
  27423. },
  27424. aboveViewRoot: function (viewRoot, node) {
  27425. var viewPath = helper.getPathToRoot(viewRoot);
  27426. return zrUtil.indexOf(viewPath, node) >= 0;
  27427. }
  27428. };
  27429. module.exports = helper;
  27430. /***/ },
  27431. /* 183 */
  27432. /***/ function(module, exports, __webpack_require__) {
  27433. var graphic = __webpack_require__(42);
  27434. var layout = __webpack_require__(21);
  27435. var zrUtil = __webpack_require__(3);
  27436. var TEXT_PADDING = 8;
  27437. var ITEM_GAP = 8;
  27438. var ARRAY_LENGTH = 5;
  27439. function Breadcrumb(containerGroup, onSelect) {
  27440. /**
  27441. * @private
  27442. * @type {module:zrender/container/Group}
  27443. */
  27444. this.group = new graphic.Group();
  27445. containerGroup.add(this.group);
  27446. /**
  27447. * @private
  27448. * @type {Function}
  27449. */
  27450. this._onSelect = onSelect || zrUtil.noop;
  27451. }
  27452. Breadcrumb.prototype = {
  27453. constructor: Breadcrumb,
  27454. render: function (seriesModel, api, targetNode) {
  27455. var model = seriesModel.getModel('breadcrumb');
  27456. var thisGroup = this.group;
  27457. thisGroup.removeAll();
  27458. if (!model.get('show') || !targetNode) {
  27459. return;
  27460. }
  27461. var normalStyleModel = model.getModel('itemStyle.normal');
  27462. // var emphasisStyleModel = model.getModel('itemStyle.emphasis');
  27463. var textStyleModel = normalStyleModel.getModel('textStyle');
  27464. var layoutParam = {
  27465. pos: {
  27466. left: model.get('left'),
  27467. right: model.get('right'),
  27468. top: model.get('top'),
  27469. bottom: model.get('bottom')
  27470. },
  27471. box: {
  27472. width: api.getWidth(),
  27473. height: api.getHeight()
  27474. },
  27475. emptyItemWidth: model.get('emptyItemWidth'),
  27476. totalWidth: 0,
  27477. renderList: []
  27478. };
  27479. this._prepare(
  27480. model, targetNode, layoutParam, textStyleModel
  27481. );
  27482. this._renderContent(
  27483. model, targetNode, layoutParam, normalStyleModel, textStyleModel
  27484. );
  27485. layout.positionGroup(thisGroup, layoutParam.pos, layoutParam.box);
  27486. },
  27487. /**
  27488. * Prepare render list and total width
  27489. * @private
  27490. */
  27491. _prepare: function (model, targetNode, layoutParam, textStyleModel) {
  27492. for (var node = targetNode; node; node = node.parentNode) {
  27493. var text = node.getModel().get('name');
  27494. var textRect = textStyleModel.getTextRect(text);
  27495. var itemWidth = Math.max(
  27496. textRect.width + TEXT_PADDING * 2,
  27497. layoutParam.emptyItemWidth
  27498. );
  27499. layoutParam.totalWidth += itemWidth + ITEM_GAP;
  27500. layoutParam.renderList.push({node: node, text: text, width: itemWidth});
  27501. }
  27502. },
  27503. /**
  27504. * @private
  27505. */
  27506. _renderContent: function (
  27507. model, targetNode, layoutParam, normalStyleModel, textStyleModel
  27508. ) {
  27509. // Start rendering.
  27510. var lastX = 0;
  27511. var emptyItemWidth = layoutParam.emptyItemWidth;
  27512. var height = model.get('height');
  27513. var availableSize = layout.getAvailableSize(layoutParam.pos, layoutParam.box);
  27514. var totalWidth = layoutParam.totalWidth;
  27515. var renderList = layoutParam.renderList;
  27516. for (var i = renderList.length - 1; i >= 0; i--) {
  27517. var item = renderList[i];
  27518. var itemWidth = item.width;
  27519. var text = item.text;
  27520. // Hdie text and shorten width if necessary.
  27521. if (totalWidth > availableSize.width) {
  27522. totalWidth -= itemWidth - emptyItemWidth;
  27523. itemWidth = emptyItemWidth;
  27524. text = '';
  27525. }
  27526. this.group.add(new graphic.Polygon({
  27527. shape: {
  27528. points: makeItemPoints(
  27529. lastX, 0, itemWidth, height,
  27530. i === renderList.length - 1, i === 0
  27531. )
  27532. },
  27533. style: zrUtil.defaults(
  27534. normalStyleModel.getItemStyle(),
  27535. {
  27536. lineJoin: 'bevel',
  27537. text: text,
  27538. textFill: textStyleModel.getTextColor(),
  27539. textFont: textStyleModel.getFont()
  27540. }
  27541. ),
  27542. z: 10,
  27543. onclick: zrUtil.bind(this._onSelect, this, item.node)
  27544. }));
  27545. lastX += itemWidth + ITEM_GAP;
  27546. }
  27547. },
  27548. /**
  27549. * @override
  27550. */
  27551. remove: function () {
  27552. this.group.removeAll();
  27553. }
  27554. };
  27555. function makeItemPoints(x, y, itemWidth, itemHeight, head, tail) {
  27556. var points = [
  27557. [head ? x : x - ARRAY_LENGTH, y],
  27558. [x + itemWidth, y],
  27559. [x + itemWidth, y + itemHeight],
  27560. [head ? x : x - ARRAY_LENGTH, y + itemHeight]
  27561. ];
  27562. !tail && points.splice(2, 0, [x + itemWidth + ARRAY_LENGTH, y + itemHeight / 2]);
  27563. !head && points.push([x, y + itemHeight / 2]);
  27564. return points;
  27565. }
  27566. module.exports = Breadcrumb;
  27567. /***/ },
  27568. /* 184 */
  27569. /***/ function(module, exports, __webpack_require__) {
  27570. var zrUtil = __webpack_require__(3);
  27571. /**
  27572. * @param {number} [time=500] Time in ms
  27573. * @param {string} [easing='linear']
  27574. * @param {number} [delay=0]
  27575. * @param {Function} [callback]
  27576. *
  27577. * @example
  27578. * // Animate position
  27579. * animation
  27580. * .createWrap()
  27581. * .add(el1, {position: [10, 10]})
  27582. * .add(el2, {shape: {width: 500}, style: {fill: 'red'}}, 400)
  27583. * .done(function () { // done })
  27584. * .start('cubicOut');
  27585. */
  27586. function createWrap() {
  27587. var storage = [];
  27588. var elExistsMap = {};
  27589. var doneCallback;
  27590. return {
  27591. /**
  27592. * Caution: a el can only be added once, otherwise 'done'
  27593. * might not be called. This method checks this (by el.id),
  27594. * suppresses adding and returns false when existing el found.
  27595. *
  27596. * @param {modele:zrender/Element} el
  27597. * @param {Object} target
  27598. * @param {number} [time=500]
  27599. * @param {number} [delay=0]
  27600. * @param {string} [easing='linear']
  27601. * @return {boolean} Whether adding succeeded.
  27602. *
  27603. * @example
  27604. * add(el, target, time, delay, easing);
  27605. * add(el, target, time, easing);
  27606. * add(el, target, time);
  27607. * add(el, target);
  27608. */
  27609. add: function (el, target, time, delay, easing) {
  27610. if (zrUtil.isString(delay)) {
  27611. easing = delay;
  27612. delay = 0;
  27613. }
  27614. if (elExistsMap[el.id]) {
  27615. return false;
  27616. }
  27617. elExistsMap[el.id] = 1;
  27618. storage.push(
  27619. {el: el, target: target, time: time, delay: delay, easing: easing}
  27620. );
  27621. return true;
  27622. },
  27623. /**
  27624. * Only execute when animation finished. Will not execute when any
  27625. * of 'stop' or 'stopAnimation' called.
  27626. *
  27627. * @param {Function} callback
  27628. */
  27629. done: function (callback) {
  27630. doneCallback = callback;
  27631. return this;
  27632. },
  27633. /**
  27634. * Will stop exist animation firstly.
  27635. */
  27636. start: function () {
  27637. var count = storage.length;
  27638. for (var i = 0, len = storage.length; i < len; i++) {
  27639. var item = storage[i];
  27640. item.el.animateTo(item.target, item.time, item.delay, item.easing, done);
  27641. }
  27642. return this;
  27643. function done() {
  27644. count--;
  27645. if (!count) {
  27646. storage.length = 0;
  27647. elExistsMap = {};
  27648. doneCallback && doneCallback();
  27649. }
  27650. }
  27651. }
  27652. };
  27653. }
  27654. module.exports = {createWrap: createWrap};
  27655. /***/ },
  27656. /* 185 */
  27657. /***/ function(module, exports, __webpack_require__) {
  27658. /**
  27659. * @file Treemap action
  27660. */
  27661. var echarts = __webpack_require__(1);
  27662. var helper = __webpack_require__(182);
  27663. var noop = function () {};
  27664. var actionTypes = [
  27665. 'treemapZoomToNode',
  27666. 'treemapRender',
  27667. 'treemapMove'
  27668. ];
  27669. for (var i = 0; i < actionTypes.length; i++) {
  27670. echarts.registerAction({type: actionTypes[i], update: 'updateView'}, noop);
  27671. }
  27672. echarts.registerAction(
  27673. {type: 'treemapRootToNode', update: 'updateView'},
  27674. function (payload, ecModel) {
  27675. ecModel.eachComponent(
  27676. {mainType: 'series', subType: 'treemap', query: payload},
  27677. handleRootToNode
  27678. );
  27679. function handleRootToNode(model, index) {
  27680. var targetInfo = helper.retrieveTargetInfo(payload, model);
  27681. if (targetInfo) {
  27682. var originViewRoot = model.getViewRoot();
  27683. if (originViewRoot) {
  27684. payload.direction = helper.aboveViewRoot(originViewRoot, targetInfo.node)
  27685. ? 'rollUp' : 'drillDown';
  27686. }
  27687. model.resetViewRoot(targetInfo.node);
  27688. }
  27689. }
  27690. }
  27691. );
  27692. /***/ },
  27693. /* 186 */
  27694. /***/ function(module, exports, __webpack_require__) {
  27695. var VisualMapping = __webpack_require__(187);
  27696. var zrColor = __webpack_require__(38);
  27697. var zrUtil = __webpack_require__(3);
  27698. var isArray = zrUtil.isArray;
  27699. var ITEM_STYLE_NORMAL = 'itemStyle.normal';
  27700. module.exports = function (ecModel, payload) {
  27701. var condition = {mainType: 'series', subType: 'treemap', query: payload};
  27702. ecModel.eachComponent(condition, function (seriesModel) {
  27703. var tree = seriesModel.getData().tree;
  27704. var root = tree.root;
  27705. var seriesItemStyleModel = seriesModel.getModel(ITEM_STYLE_NORMAL);
  27706. if (root.isRemoved()) {
  27707. return;
  27708. }
  27709. var levelItemStyles = zrUtil.map(tree.levelModels, function (levelModel) {
  27710. return levelModel ? levelModel.get(ITEM_STYLE_NORMAL) : null;
  27711. });
  27712. travelTree(
  27713. root, // Visual should calculate from tree root but not view root.
  27714. {},
  27715. levelItemStyles,
  27716. seriesItemStyleModel,
  27717. seriesModel.getViewRoot().getAncestors(),
  27718. seriesModel
  27719. );
  27720. });
  27721. };
  27722. function travelTree(
  27723. node, designatedVisual, levelItemStyles, seriesItemStyleModel,
  27724. viewRootAncestors, seriesModel
  27725. ) {
  27726. var nodeModel = node.getModel();
  27727. var nodeLayout = node.getLayout();
  27728. // Optimize
  27729. if (!nodeLayout || nodeLayout.invisible || !nodeLayout.isInView) {
  27730. return;
  27731. }
  27732. var nodeItemStyleModel = node.getModel(ITEM_STYLE_NORMAL);
  27733. var levelItemStyle = levelItemStyles[node.depth];
  27734. var visuals = buildVisuals(
  27735. nodeItemStyleModel, designatedVisual, levelItemStyle, seriesItemStyleModel
  27736. );
  27737. // calculate border color
  27738. var borderColor = nodeItemStyleModel.get('borderColor');
  27739. var borderColorSaturation = nodeItemStyleModel.get('borderColorSaturation');
  27740. var thisNodeColor;
  27741. if (borderColorSaturation != null) {
  27742. // For performance, do not always execute 'calculateColor'.
  27743. thisNodeColor = calculateColor(visuals, node);
  27744. borderColor = calculateBorderColor(borderColorSaturation, thisNodeColor);
  27745. }
  27746. node.setVisual('borderColor', borderColor);
  27747. var viewChildren = node.viewChildren;
  27748. if (!viewChildren || !viewChildren.length) {
  27749. thisNodeColor = calculateColor(visuals, node);
  27750. // Apply visual to this node.
  27751. node.setVisual('color', thisNodeColor);
  27752. }
  27753. else {
  27754. var mapping = buildVisualMapping(
  27755. node, nodeModel, nodeLayout, nodeItemStyleModel, visuals, viewChildren
  27756. );
  27757. // Designate visual to children.
  27758. zrUtil.each(viewChildren, function (child, index) {
  27759. // If higher than viewRoot, only ancestors of viewRoot is needed to visit.
  27760. if (child.depth >= viewRootAncestors.length
  27761. || child === viewRootAncestors[child.depth]
  27762. ) {
  27763. var childVisual = mapVisual(
  27764. nodeModel, visuals, child, index, mapping, seriesModel
  27765. );
  27766. travelTree(
  27767. child, childVisual, levelItemStyles, seriesItemStyleModel,
  27768. viewRootAncestors, seriesModel
  27769. );
  27770. }
  27771. });
  27772. }
  27773. }
  27774. function buildVisuals(
  27775. nodeItemStyleModel, designatedVisual, levelItemStyle, seriesItemStyleModel
  27776. ) {
  27777. var visuals = zrUtil.extend({}, designatedVisual);
  27778. zrUtil.each(['color', 'colorAlpha', 'colorSaturation'], function (visualName) {
  27779. // Priority: thisNode > thisLevel > parentNodeDesignated > seriesModel
  27780. var val = nodeItemStyleModel.get(visualName, true); // Ignore parent
  27781. val == null && levelItemStyle && (val = levelItemStyle[visualName]);
  27782. val == null && (val = designatedVisual[visualName]);
  27783. val == null && (val = seriesItemStyleModel.get(visualName));
  27784. val != null && (visuals[visualName] = val);
  27785. });
  27786. return visuals;
  27787. }
  27788. function calculateColor(visuals) {
  27789. var color = getValueVisualDefine(visuals, 'color');
  27790. if (color) {
  27791. var colorAlpha = getValueVisualDefine(visuals, 'colorAlpha');
  27792. var colorSaturation = getValueVisualDefine(visuals, 'colorSaturation');
  27793. if (colorSaturation) {
  27794. color = zrColor.modifyHSL(color, null, null, colorSaturation);
  27795. }
  27796. if (colorAlpha) {
  27797. color = zrColor.modifyAlpha(color, colorAlpha);
  27798. }
  27799. return color;
  27800. }
  27801. }
  27802. function calculateBorderColor(borderColorSaturation, thisNodeColor) {
  27803. return thisNodeColor != null
  27804. ? zrColor.modifyHSL(thisNodeColor, null, null, borderColorSaturation)
  27805. : null;
  27806. }
  27807. function getValueVisualDefine(visuals, name) {
  27808. var value = visuals[name];
  27809. if (value != null && value !== 'none') {
  27810. return value;
  27811. }
  27812. }
  27813. function buildVisualMapping(
  27814. node, nodeModel, nodeLayout, nodeItemStyleModel, visuals, viewChildren
  27815. ) {
  27816. if (!viewChildren || !viewChildren.length) {
  27817. return;
  27818. }
  27819. var rangeVisual = getRangeVisual(nodeModel, 'color')
  27820. || (
  27821. visuals.color != null
  27822. && visuals.color !== 'none'
  27823. && (
  27824. getRangeVisual(nodeModel, 'colorAlpha')
  27825. || getRangeVisual(nodeModel, 'colorSaturation')
  27826. )
  27827. );
  27828. if (!rangeVisual) {
  27829. return;
  27830. }
  27831. var colorMappingBy = nodeModel.get('colorMappingBy');
  27832. var opt = {
  27833. type: rangeVisual.name,
  27834. dataExtent: nodeLayout.dataExtent,
  27835. visual: rangeVisual.range
  27836. };
  27837. if (opt.type === 'color'
  27838. && (colorMappingBy === 'index' || colorMappingBy === 'id')
  27839. ) {
  27840. opt.mappingMethod = 'category';
  27841. opt.loop = true;
  27842. // categories is ordinal, so do not set opt.categories.
  27843. }
  27844. else {
  27845. opt.mappingMethod = 'linear';
  27846. }
  27847. var mapping = new VisualMapping(opt);
  27848. mapping.__drColorMappingBy = colorMappingBy;
  27849. return mapping;
  27850. }
  27851. // Notice: If we dont have the attribute 'colorRange', but only use
  27852. // attribute 'color' to represent both concepts of 'colorRange' and 'color',
  27853. // (It means 'colorRange' when 'color' is Array, means 'color' when not array),
  27854. // this problem will be encountered:
  27855. // If a level-1 node dont have children, and its siblings has children,
  27856. // and colorRange is set on level-1, then the node can not be colored.
  27857. // So we separate 'colorRange' and 'color' to different attributes.
  27858. function getRangeVisual(nodeModel, name) {
  27859. // 'colorRange', 'colorARange', 'colorSRange'.
  27860. // If not exsits on this node, fetch from levels and series.
  27861. var range = nodeModel.get(name);
  27862. return (isArray(range) && range.length) ? {name: name, range: range} : null;
  27863. }
  27864. function mapVisual(nodeModel, visuals, child, index, mapping, seriesModel) {
  27865. var childVisuals = zrUtil.extend({}, visuals);
  27866. if (mapping) {
  27867. var mappingType = mapping.type;
  27868. var colorMappingBy = mappingType === 'color' && mapping.__drColorMappingBy;
  27869. var value =
  27870. colorMappingBy === 'index'
  27871. ? index
  27872. : colorMappingBy === 'id'
  27873. ? seriesModel.mapIdToIndex(child.getId())
  27874. : child.getValue(nodeModel.get('visualDimension'));
  27875. childVisuals[mappingType] = mapping.mapValueToVisual(value);
  27876. }
  27877. return childVisuals;
  27878. }
  27879. /***/ },
  27880. /* 187 */
  27881. /***/ function(module, exports, __webpack_require__) {
  27882. /**
  27883. * @file Visual mapping.
  27884. */
  27885. var zrUtil = __webpack_require__(3);
  27886. var zrColor = __webpack_require__(38);
  27887. var linearMap = __webpack_require__(7).linearMap;
  27888. var each = zrUtil.each;
  27889. var isObject = zrUtil.isObject;
  27890. var CATEGORY_DEFAULT_VISUAL_INDEX = -1;
  27891. /**
  27892. * @param {Object} option
  27893. * @param {string} [option.type] See visualHandlers.
  27894. * @param {string} [option.mappingMethod] 'linear' or 'piecewise' or 'category'
  27895. * @param {Array.<number>=} [option.dataExtent] [minExtent, maxExtent],
  27896. * required when mappingMethod is 'linear'
  27897. * @param {Array.<Object>=} [option.pieceList] [
  27898. * {value: someValue},
  27899. * {interval: [min1, max1], visual: {...}},
  27900. * {interval: [min2, max2]}
  27901. * ],
  27902. * required when mappingMethod is 'piecewise'.
  27903. * Visual for only each piece can be specified.
  27904. * @param {Array.<string|Object>=} [option.categories] ['cate1', 'cate2']
  27905. * required when mappingMethod is 'category'.
  27906. * If no option.categories, it represents
  27907. * categories is [0, 1, 2, ...].
  27908. * @param {boolean} [option.loop=false] Whether loop mapping when mappingMethod is 'category'.
  27909. * @param {(Array|Object|*)} [option.visual] Visual data.
  27910. * when mappingMethod is 'category',
  27911. * visual data can be array or object
  27912. * (like: {cate1: '#222', none: '#fff'})
  27913. * or primary types (which represents
  27914. * defualt category visual), otherwise visual
  27915. * can be array or primary (which will be
  27916. * normalized to array).
  27917. *
  27918. */
  27919. var VisualMapping = function (option) {
  27920. var mappingMethod = option.mappingMethod;
  27921. var visualType = option.type;
  27922. /**
  27923. * @readOnly
  27924. * @type {Object}
  27925. */
  27926. var thisOption = this.option = zrUtil.clone(option);
  27927. /**
  27928. * @readOnly
  27929. * @type {string}
  27930. */
  27931. this.type = visualType;
  27932. /**
  27933. * @readOnly
  27934. * @type {string}
  27935. */
  27936. this.mappingMethod = mappingMethod;
  27937. /**
  27938. * @private
  27939. * @type {Function}
  27940. */
  27941. this._normalizeData = normalizers[mappingMethod];
  27942. /**
  27943. * @private
  27944. * @type {Function}
  27945. */
  27946. this._getSpecifiedVisual = zrUtil.bind(
  27947. specifiedVisualGetters[mappingMethod], this, visualType
  27948. );
  27949. zrUtil.extend(this, visualHandlers[visualType]);
  27950. if (mappingMethod === 'piecewise') {
  27951. normalizeVisualRange(thisOption);
  27952. preprocessForPiecewise(thisOption);
  27953. }
  27954. else if (mappingMethod === 'category') {
  27955. thisOption.categories
  27956. ? preprocessForSpecifiedCategory(thisOption)
  27957. // categories is ordinal when thisOption.categories not specified,
  27958. // which need no more preprocess except normalize visual.
  27959. : normalizeVisualRange(thisOption, true);
  27960. }
  27961. else { // mappingMethod === 'linear'
  27962. zrUtil.assert(thisOption.dataExtent);
  27963. normalizeVisualRange(thisOption);
  27964. }
  27965. };
  27966. VisualMapping.prototype = {
  27967. constructor: VisualMapping,
  27968. applyVisual: null,
  27969. isValueActive: null,
  27970. mapValueToVisual: null,
  27971. getNormalizer: function () {
  27972. return zrUtil.bind(this._normalizeData, this);
  27973. }
  27974. };
  27975. var visualHandlers = VisualMapping.visualHandlers = {
  27976. color: {
  27977. applyVisual: defaultApplyColor,
  27978. /**
  27979. * Create a mapper function
  27980. * @return {Function}
  27981. */
  27982. getColorMapper: function () {
  27983. var visual = isCategory(this)
  27984. ? this.option.visual
  27985. : zrUtil.map(this.option.visual, zrColor.parse);
  27986. return zrUtil.bind(
  27987. isCategory(this)
  27988. ? function (value, isNormalized) {
  27989. !isNormalized && (value = this._normalizeData(value));
  27990. return getVisualForCategory(this, visual, value);
  27991. }
  27992. : function (value, isNormalized, out) {
  27993. // If output rgb array
  27994. // which will be much faster and useful in pixel manipulation
  27995. var returnRGBArray = !!out;
  27996. !isNormalized && (value = this._normalizeData(value));
  27997. out = zrColor.fastMapToColor(value, visual, out);
  27998. return returnRGBArray ? out : zrUtil.stringify(out, 'rgba');
  27999. }, this);
  28000. },
  28001. mapValueToVisual: function (value) {
  28002. var visual = this.option.visual;
  28003. var normalized = this._normalizeData(value);
  28004. var result = this._getSpecifiedVisual(value);
  28005. if (result == null) {
  28006. result = isCategory(this)
  28007. ? getVisualForCategory(this, visual, normalized)
  28008. : zrColor.mapToColor(normalized, visual);
  28009. }
  28010. return result;
  28011. }
  28012. },
  28013. colorHue: makePartialColorVisualHandler(function (color, value) {
  28014. return zrColor.modifyHSL(color, value);
  28015. }),
  28016. colorSaturation: makePartialColorVisualHandler(function (color, value) {
  28017. return zrColor.modifyHSL(color, null, value);
  28018. }),
  28019. colorLightness: makePartialColorVisualHandler(function (color, value) {
  28020. return zrColor.modifyHSL(color, null, null, value);
  28021. }),
  28022. colorAlpha: makePartialColorVisualHandler(function (color, value) {
  28023. return zrColor.modifyAlpha(color, value);
  28024. }),
  28025. opacity: {
  28026. applyVisual: function (value, getter, setter) {
  28027. setter('opacity', this.mapValueToVisual(value));
  28028. },
  28029. mapValueToVisual: function (value) {
  28030. var normalized = this._normalizeData(value);
  28031. var result = this._getSpecifiedVisual(value);
  28032. var visual = this.option.visual;
  28033. if (result == null) {
  28034. result = isCategory(this)
  28035. ? getVisualForCategory(this, visual, normalized)
  28036. : linearMap(normalized, [0, 1], visual, true);
  28037. }
  28038. return result;
  28039. }
  28040. },
  28041. symbol: {
  28042. applyVisual: function (value, getter, setter) {
  28043. var symbolCfg = this.mapValueToVisual(value);
  28044. if (zrUtil.isString(symbolCfg)) {
  28045. setter('symbol', symbolCfg);
  28046. }
  28047. else if (isObject(symbolCfg)) {
  28048. for (var name in symbolCfg) {
  28049. if (symbolCfg.hasOwnProperty(name)) {
  28050. setter(name, symbolCfg[name]);
  28051. }
  28052. }
  28053. }
  28054. },
  28055. mapValueToVisual: function (value) {
  28056. var normalized = this._normalizeData(value);
  28057. var result = this._getSpecifiedVisual(value);
  28058. var visual = this.option.visual;
  28059. if (result == null) {
  28060. result = isCategory(this)
  28061. ? getVisualForCategory(this, visual, normalized)
  28062. : (arrayGetByNormalizedValue(visual, normalized) || {});
  28063. }
  28064. return result;
  28065. }
  28066. },
  28067. symbolSize: {
  28068. applyVisual: function (value, getter, setter) {
  28069. setter('symbolSize', this.mapValueToVisual(value));
  28070. },
  28071. mapValueToVisual: function (value) {
  28072. var normalized = this._normalizeData(value);
  28073. var result = this._getSpecifiedVisual(value);
  28074. var visual = this.option.visual;
  28075. if (result == null) {
  28076. result = isCategory(this)
  28077. ? getVisualForCategory(this, visual, normalized)
  28078. : linearMap(normalized, [0, 1], visual, true);
  28079. }
  28080. return result;
  28081. }
  28082. }
  28083. };
  28084. function preprocessForPiecewise(thisOption) {
  28085. var pieceList = thisOption.pieceList;
  28086. thisOption.hasSpecialVisual = false;
  28087. zrUtil.each(pieceList, function (piece, index) {
  28088. piece.originIndex = index;
  28089. // piece.visual is "result visual value" but not
  28090. // a visual range, so it does not need to be normalized.
  28091. if (piece.visual != null) {
  28092. thisOption.hasSpecialVisual = true;
  28093. }
  28094. });
  28095. }
  28096. function preprocessForSpecifiedCategory(thisOption) {
  28097. // Hash categories.
  28098. var categories = thisOption.categories;
  28099. var visual = thisOption.visual;
  28100. var categoryMap = thisOption.categoryMap = {};
  28101. each(categories, function (cate, index) {
  28102. categoryMap[cate] = index;
  28103. });
  28104. // Process visual map input.
  28105. if (!zrUtil.isArray(visual)) {
  28106. var visualArr = [];
  28107. if (zrUtil.isObject(visual)) {
  28108. each(visual, function (v, cate) {
  28109. var index = categoryMap[cate];
  28110. visualArr[index != null ? index : CATEGORY_DEFAULT_VISUAL_INDEX] = v;
  28111. });
  28112. }
  28113. else { // Is primary type, represents default visual.
  28114. visualArr[CATEGORY_DEFAULT_VISUAL_INDEX] = visual;
  28115. }
  28116. visual = thisOption.visual = visualArr;
  28117. }
  28118. // Remove categories that has no visual,
  28119. // then we can mapping them to CATEGORY_DEFAULT_VISUAL_INDEX.
  28120. for (var i = categories.length - 1; i >= 0; i--) {
  28121. if (visual[i] == null) {
  28122. delete categoryMap[categories[i]];
  28123. categories.pop();
  28124. }
  28125. }
  28126. }
  28127. function normalizeVisualRange(thisOption, isCategory) {
  28128. var visual = thisOption.visual;
  28129. var visualArr = [];
  28130. if (zrUtil.isObject(visual)) {
  28131. each(visual, function (v) {
  28132. visualArr.push(v);
  28133. });
  28134. }
  28135. else if (visual != null) {
  28136. visualArr.push(visual);
  28137. }
  28138. var doNotNeedPair = {'color': 1, 'symbol': 1};
  28139. if (!isCategory
  28140. && visualArr.length === 1
  28141. && !(thisOption.type in doNotNeedPair)
  28142. ) {
  28143. // Do not care visualArr.length === 0, which is illegal.
  28144. visualArr[1] = visualArr[0];
  28145. }
  28146. thisOption.visual = visualArr;
  28147. }
  28148. function makePartialColorVisualHandler(applyValue) {
  28149. return {
  28150. applyVisual: function (value, getter, setter) {
  28151. value = this.mapValueToVisual(value);
  28152. // Must not be array value
  28153. setter('color', applyValue(getter('color'), value));
  28154. },
  28155. mapValueToVisual: function (value) {
  28156. var normalized = this._normalizeData(value);
  28157. var result = this._getSpecifiedVisual(value);
  28158. var visual = this.option.visual;
  28159. if (result == null) {
  28160. result = isCategory(this)
  28161. ? getVisualForCategory(this, visual, normalized)
  28162. : linearMap(normalized, [0, 1], visual, true);
  28163. }
  28164. return result;
  28165. }
  28166. };
  28167. }
  28168. function arrayGetByNormalizedValue(arr, normalized) {
  28169. return arr[
  28170. Math.round(linearMap(normalized, [0, 1], [0, arr.length - 1], true))
  28171. ];
  28172. }
  28173. function defaultApplyColor(value, getter, setter) {
  28174. setter('color', this.mapValueToVisual(value));
  28175. }
  28176. function getVisualForCategory(me, visual, normalized) {
  28177. return visual[
  28178. (me.option.loop && normalized !== CATEGORY_DEFAULT_VISUAL_INDEX)
  28179. ? normalized % visual.length
  28180. : normalized
  28181. ];
  28182. }
  28183. function isCategory(me) {
  28184. return me.option.mappingMethod === 'category';
  28185. }
  28186. var normalizers = {
  28187. linear: function (value) {
  28188. return linearMap(value, this.option.dataExtent, [0, 1], true);
  28189. },
  28190. piecewise: function (value) {
  28191. var pieceList = this.option.pieceList;
  28192. var pieceIndex = VisualMapping.findPieceIndex(value, pieceList);
  28193. if (pieceIndex != null) {
  28194. return linearMap(pieceIndex, [0, pieceList.length - 1], [0, 1], true);
  28195. }
  28196. },
  28197. category: function (value) {
  28198. var index = this.option.categories
  28199. ? this.option.categoryMap[value]
  28200. : value; // ordinal
  28201. return index == null ? CATEGORY_DEFAULT_VISUAL_INDEX : index;
  28202. }
  28203. };
  28204. // FIXME
  28205. // refactor
  28206. var specifiedVisualGetters = {
  28207. // Linear do not support this feature.
  28208. linear: zrUtil.noop,
  28209. piecewise: function (visualType, value) {
  28210. var thisOption = this.option;
  28211. var pieceList = thisOption.pieceList;
  28212. if (thisOption.hasSpecialVisual) {
  28213. var pieceIndex = VisualMapping.findPieceIndex(value, pieceList);
  28214. var piece = pieceList[pieceIndex];
  28215. if (piece && piece.visual) {
  28216. return piece.visual[visualType];
  28217. }
  28218. }
  28219. },
  28220. // Category do not need to support this feature.
  28221. // Visual can be set in visualMap.inRange or
  28222. // visualMap.outOfRange directly.
  28223. category: zrUtil.noop
  28224. };
  28225. /**
  28226. * @public
  28227. */
  28228. VisualMapping.addVisualHandler = function (name, handler) {
  28229. visualHandlers[name] = handler;
  28230. };
  28231. /**
  28232. * @public
  28233. */
  28234. VisualMapping.isValidType = function (visualType) {
  28235. return visualHandlers.hasOwnProperty(visualType);
  28236. };
  28237. /**
  28238. * Convinent method.
  28239. * Visual can be Object or Array or primary type.
  28240. *
  28241. * @public
  28242. */
  28243. VisualMapping.eachVisual = function (visual, callback, context) {
  28244. if (zrUtil.isObject(visual)) {
  28245. zrUtil.each(visual, callback, context);
  28246. }
  28247. else {
  28248. callback.call(context, visual);
  28249. }
  28250. };
  28251. VisualMapping.mapVisual = function (visual, callback, context) {
  28252. var isPrimary;
  28253. var newVisual = zrUtil.isArray(visual)
  28254. ? []
  28255. : zrUtil.isObject(visual)
  28256. ? {}
  28257. : (isPrimary = true, null);
  28258. VisualMapping.eachVisual(visual, function (v, key) {
  28259. var newVal = callback.call(context, v, key);
  28260. isPrimary ? (newVisual = newVal) : (newVisual[key] = newVal);
  28261. });
  28262. return newVisual;
  28263. };
  28264. /**
  28265. * @public
  28266. * @param {Object} obj
  28267. * @return {Oject} new object containers visual values.
  28268. * If no visuals, return null.
  28269. */
  28270. VisualMapping.retrieveVisuals = function (obj) {
  28271. var ret = {};
  28272. var hasVisual;
  28273. obj && each(visualHandlers, function (h, visualType) {
  28274. if (obj.hasOwnProperty(visualType)) {
  28275. ret[visualType] = obj[visualType];
  28276. hasVisual = true;
  28277. }
  28278. });
  28279. return hasVisual ? ret : null;
  28280. };
  28281. /**
  28282. * Give order to visual types, considering colorSaturation, colorAlpha depends on color.
  28283. *
  28284. * @public
  28285. * @param {(Object|Array)} visualTypes If Object, like: {color: ..., colorSaturation: ...}
  28286. * IF Array, like: ['color', 'symbol', 'colorSaturation']
  28287. * @return {Array.<string>} Sorted visual types.
  28288. */
  28289. VisualMapping.prepareVisualTypes = function (visualTypes) {
  28290. if (isObject(visualTypes)) {
  28291. var types = [];
  28292. each(visualTypes, function (item, type) {
  28293. types.push(type);
  28294. });
  28295. visualTypes = types;
  28296. }
  28297. else if (zrUtil.isArray(visualTypes)) {
  28298. visualTypes = visualTypes.slice();
  28299. }
  28300. else {
  28301. return [];
  28302. }
  28303. visualTypes.sort(function (type1, type2) {
  28304. // color should be front of colorSaturation, colorAlpha, ...
  28305. // symbol and symbolSize do not matter.
  28306. return (type2 === 'color' && type1 !== 'color' && type1.indexOf('color') === 0)
  28307. ? 1 : -1;
  28308. });
  28309. return visualTypes;
  28310. };
  28311. /**
  28312. * 'color', 'colorSaturation', 'colorAlpha', ... are depends on 'color'.
  28313. * Other visuals are only depends on themself.
  28314. *
  28315. * @public
  28316. * @param {string} visualType1
  28317. * @param {string} visualType2
  28318. * @return {boolean}
  28319. */
  28320. VisualMapping.dependsOn = function (visualType1, visualType2) {
  28321. return visualType2 === 'color'
  28322. ? !!(visualType1 && visualType1.indexOf(visualType2) === 0)
  28323. : visualType1 === visualType2;
  28324. };
  28325. /**
  28326. * @public {Array.<Object>} [{value: ..., interval: [min, max]}, ...]
  28327. * @return {number} index
  28328. */
  28329. VisualMapping.findPieceIndex = function (value, pieceList) {
  28330. // value has high priority.
  28331. for (var i = 0, len = pieceList.length; i < len; i++) {
  28332. var piece = pieceList[i];
  28333. if (piece.value != null && piece.value === value) {
  28334. return i;
  28335. }
  28336. }
  28337. for (var i = 0, len = pieceList.length; i < len; i++) {
  28338. var piece = pieceList[i];
  28339. var interval = piece.interval;
  28340. if (interval) {
  28341. if (interval[0] === -Infinity) {
  28342. if (value < interval[1]) {
  28343. return i;
  28344. }
  28345. }
  28346. else if (interval[1] === Infinity) {
  28347. if (interval[0] < value) {
  28348. return i;
  28349. }
  28350. }
  28351. else if (
  28352. piece.interval[0] <= value
  28353. && value <= piece.interval[1]
  28354. ) {
  28355. return i;
  28356. }
  28357. }
  28358. }
  28359. };
  28360. module.exports = VisualMapping;
  28361. /***/ },
  28362. /* 188 */
  28363. /***/ function(module, exports, __webpack_require__) {
  28364. var zrUtil = __webpack_require__(3);
  28365. var numberUtil = __webpack_require__(7);
  28366. var layout = __webpack_require__(21);
  28367. var helper = __webpack_require__(182);
  28368. var BoundingRect = __webpack_require__(15);
  28369. var helper = __webpack_require__(182);
  28370. var mathMax = Math.max;
  28371. var mathMin = Math.min;
  28372. var parsePercent = numberUtil.parsePercent;
  28373. var retrieveValue = zrUtil.retrieve;
  28374. var each = zrUtil.each;
  28375. /**
  28376. * @public
  28377. */
  28378. function update(ecModel, api, payload) {
  28379. // Layout result in each node:
  28380. // {x, y, width, height, area, borderWidth}
  28381. var condition = {mainType: 'series', subType: 'treemap', query: payload};
  28382. ecModel.eachComponent(condition, function (seriesModel) {
  28383. var ecWidth = api.getWidth();
  28384. var ecHeight = api.getHeight();
  28385. var seriesOption = seriesModel.option;
  28386. var size = seriesOption.size || []; // Compatible with ec2.
  28387. var containerWidth = parsePercent(
  28388. retrieveValue(seriesOption.width, size[0]),
  28389. ecWidth
  28390. );
  28391. var containerHeight = parsePercent(
  28392. retrieveValue(seriesOption.height, size[1]),
  28393. ecHeight
  28394. );
  28395. var layoutInfo = layout.getLayoutRect(
  28396. seriesModel.getBoxLayoutParams(),
  28397. {
  28398. width: api.getWidth(),
  28399. height: api.getHeight()
  28400. }
  28401. );
  28402. // Fetch payload info.
  28403. var payloadType = payload && payload.type;
  28404. var targetInfo = helper.retrieveTargetInfo(payload, seriesModel);
  28405. var rootRect = (payloadType === 'treemapRender' || payloadType === 'treemapMove')
  28406. ? payload.rootRect : null;
  28407. var viewRoot = seriesModel.getViewRoot();
  28408. var viewAbovePath = helper.getPathToRoot(viewRoot);
  28409. if (payloadType !== 'treemapMove') {
  28410. var rootSize = payloadType === 'treemapZoomToNode'
  28411. ? estimateRootSize(
  28412. seriesModel, targetInfo, viewRoot, containerWidth, containerHeight
  28413. )
  28414. : rootRect
  28415. ? [rootRect.width, rootRect.height]
  28416. : [containerWidth, containerHeight];
  28417. var sort = seriesOption.sort;
  28418. if (sort && sort !== 'asc' && sort !== 'desc') {
  28419. sort = 'desc';
  28420. }
  28421. var options = {
  28422. squareRatio: seriesOption.squareRatio,
  28423. sort: sort,
  28424. leafDepth: seriesOption.leafDepth
  28425. };
  28426. // layout should be cleared because using updateView but not update.
  28427. viewRoot.hostTree.clearLayouts();
  28428. // TODO
  28429. // optimize: if out of view clip, do not layout.
  28430. // But take care that if do not render node out of view clip,
  28431. // how to calculate start po
  28432. var viewRootLayout = {
  28433. x: 0, y: 0,
  28434. width: rootSize[0], height: rootSize[1],
  28435. area: rootSize[0] * rootSize[1]
  28436. };
  28437. viewRoot.setLayout(viewRootLayout);
  28438. squarify(viewRoot, options, false, 0);
  28439. // Supplement layout.
  28440. var viewRootLayout = viewRoot.getLayout();
  28441. each(viewAbovePath, function (node, index) {
  28442. var childValue = (viewAbovePath[index + 1] || viewRoot).getValue();
  28443. node.setLayout(zrUtil.extend(
  28444. {dataExtent: [childValue, childValue], borderWidth: 0},
  28445. viewRootLayout
  28446. ));
  28447. });
  28448. }
  28449. var treeRoot = seriesModel.getData().tree.root;
  28450. treeRoot.setLayout(
  28451. calculateRootPosition(layoutInfo, rootRect, targetInfo),
  28452. true
  28453. );
  28454. seriesModel.setLayoutInfo(layoutInfo);
  28455. // FIXME
  28456. // 现在没有clip功能,暂时取ec高宽。
  28457. prunning(
  28458. treeRoot,
  28459. // Transform to base element coordinate system.
  28460. new BoundingRect(-layoutInfo.x, -layoutInfo.y, ecWidth, ecHeight),
  28461. viewAbovePath,
  28462. viewRoot,
  28463. 0
  28464. );
  28465. });
  28466. }
  28467. /**
  28468. * Layout treemap with squarify algorithm.
  28469. * @see https://graphics.ethz.ch/teaching/scivis_common/Literature/squarifiedTreeMaps.pdf
  28470. * @see https://github.com/mbostock/d3/blob/master/src/layout/treemap.js
  28471. *
  28472. * @protected
  28473. * @param {module:echarts/data/Tree~TreeNode} node
  28474. * @param {Object} options
  28475. * @param {string} options.sort 'asc' or 'desc'
  28476. * @param {number} options.squareRatio
  28477. * @param {boolean} hideChildren
  28478. * @param {number} depth
  28479. */
  28480. function squarify(node, options, hideChildren, depth) {
  28481. var width;
  28482. var height;
  28483. if (node.isRemoved()) {
  28484. return;
  28485. }
  28486. var thisLayout = node.getLayout();
  28487. width = thisLayout.width;
  28488. height = thisLayout.height;
  28489. // Considering border and gap
  28490. var itemStyleModel = node.getModel('itemStyle.normal');
  28491. var borderWidth = itemStyleModel.get('borderWidth');
  28492. var halfGapWidth = itemStyleModel.get('gapWidth') / 2;
  28493. var layoutOffset = borderWidth - halfGapWidth;
  28494. var nodeModel = node.getModel();
  28495. node.setLayout({borderWidth: borderWidth}, true);
  28496. width = mathMax(width - 2 * layoutOffset, 0);
  28497. height = mathMax(height - 2 * layoutOffset, 0);
  28498. var totalArea = width * height;
  28499. var viewChildren = initChildren(
  28500. node, nodeModel, totalArea, options, hideChildren, depth
  28501. );
  28502. if (!viewChildren.length) {
  28503. return;
  28504. }
  28505. var rect = {x: layoutOffset, y: layoutOffset, width: width, height: height};
  28506. var rowFixedLength = mathMin(width, height);
  28507. var best = Infinity; // the best row score so far
  28508. var row = [];
  28509. row.area = 0;
  28510. for (var i = 0, len = viewChildren.length; i < len;) {
  28511. var child = viewChildren[i];
  28512. row.push(child);
  28513. row.area += child.getLayout().area;
  28514. var score = worst(row, rowFixedLength, options.squareRatio);
  28515. // continue with this orientation
  28516. if (score <= best) {
  28517. i++;
  28518. best = score;
  28519. }
  28520. // abort, and try a different orientation
  28521. else {
  28522. row.area -= row.pop().getLayout().area;
  28523. position(row, rowFixedLength, rect, halfGapWidth, false);
  28524. rowFixedLength = mathMin(rect.width, rect.height);
  28525. row.length = row.area = 0;
  28526. best = Infinity;
  28527. }
  28528. }
  28529. if (row.length) {
  28530. position(row, rowFixedLength, rect, halfGapWidth, true);
  28531. }
  28532. if (!hideChildren) {
  28533. var childrenVisibleMin = nodeModel.get('childrenVisibleMin');
  28534. if (childrenVisibleMin != null && totalArea < childrenVisibleMin) {
  28535. hideChildren = true;
  28536. }
  28537. }
  28538. for (var i = 0, len = viewChildren.length; i < len; i++) {
  28539. squarify(viewChildren[i], options, hideChildren, depth + 1);
  28540. }
  28541. }
  28542. /**
  28543. * Set area to each child, and calculate data extent for visual coding.
  28544. */
  28545. function initChildren(node, nodeModel, totalArea, options, hideChildren, depth) {
  28546. var viewChildren = node.children || [];
  28547. var orderBy = options.sort;
  28548. orderBy !== 'asc' && orderBy !== 'desc' && (orderBy = null);
  28549. var overLeafDepth = options.leafDepth != null && options.leafDepth <= depth;
  28550. // leafDepth has higher priority.
  28551. if (hideChildren && !overLeafDepth) {
  28552. return (node.viewChildren = []);
  28553. }
  28554. // Sort children, order by desc.
  28555. viewChildren = zrUtil.filter(viewChildren, function (child) {
  28556. return !child.isRemoved();
  28557. });
  28558. sort(viewChildren, orderBy);
  28559. var info = statistic(nodeModel, viewChildren, orderBy);
  28560. if (info.sum === 0) {
  28561. return (node.viewChildren = []);
  28562. }
  28563. info.sum = filterByThreshold(nodeModel, totalArea, info.sum, orderBy, viewChildren);
  28564. if (info.sum === 0) {
  28565. return (node.viewChildren = []);
  28566. }
  28567. // Set area to each child.
  28568. for (var i = 0, len = viewChildren.length; i < len; i++) {
  28569. var area = viewChildren[i].getValue() / info.sum * totalArea;
  28570. // Do not use setLayout({...}, true), because it is needed to clear last layout.
  28571. viewChildren[i].setLayout({area: area});
  28572. }
  28573. if (overLeafDepth) {
  28574. viewChildren.length && node.setLayout({isLeafRoot: true}, true);
  28575. viewChildren.length = 0;
  28576. }
  28577. node.viewChildren = viewChildren;
  28578. node.setLayout({dataExtent: info.dataExtent}, true);
  28579. return viewChildren;
  28580. }
  28581. /**
  28582. * Consider 'visibleMin'. Modify viewChildren and get new sum.
  28583. */
  28584. function filterByThreshold(nodeModel, totalArea, sum, orderBy, orderedChildren) {
  28585. // visibleMin is not supported yet when no option.sort.
  28586. if (!orderBy) {
  28587. return sum;
  28588. }
  28589. var visibleMin = nodeModel.get('visibleMin');
  28590. var len = orderedChildren.length;
  28591. var deletePoint = len;
  28592. // Always travel from little value to big value.
  28593. for (var i = len - 1; i >= 0; i--) {
  28594. var value = orderedChildren[
  28595. orderBy === 'asc' ? len - i - 1 : i
  28596. ].getValue();
  28597. if (value / sum * totalArea < visibleMin) {
  28598. deletePoint = i;
  28599. sum -= value;
  28600. }
  28601. }
  28602. orderBy === 'asc'
  28603. ? orderedChildren.splice(0, len - deletePoint)
  28604. : orderedChildren.splice(deletePoint, len - deletePoint);
  28605. return sum;
  28606. }
  28607. /**
  28608. * Sort
  28609. */
  28610. function sort(viewChildren, orderBy) {
  28611. if (orderBy) {
  28612. viewChildren.sort(function (a, b) {
  28613. return orderBy === 'asc'
  28614. ? a.getValue() - b.getValue() : b.getValue() - a.getValue();
  28615. });
  28616. }
  28617. return viewChildren;
  28618. }
  28619. /**
  28620. * Statistic
  28621. */
  28622. function statistic(nodeModel, children, orderBy) {
  28623. // Calculate sum.
  28624. var sum = 0;
  28625. for (var i = 0, len = children.length; i < len; i++) {
  28626. sum += children[i].getValue();
  28627. }
  28628. // Statistic data extent for latter visual coding.
  28629. // Notice: data extent should be calculate based on raw children
  28630. // but not filtered view children, otherwise visual mapping will not
  28631. // be stable when zoom (where children is filtered by visibleMin).
  28632. var dimension = nodeModel.get('visualDimension');
  28633. var dataExtent;
  28634. // The same as area dimension.
  28635. if (!children || !children.length) {
  28636. dataExtent = [NaN, NaN];
  28637. }
  28638. else if (dimension === 'value' && orderBy) {
  28639. dataExtent = [
  28640. children[children.length - 1].getValue(),
  28641. children[0].getValue()
  28642. ];
  28643. orderBy === 'asc' && dataExtent.reverse();
  28644. }
  28645. // Other dimension.
  28646. else {
  28647. var dataExtent = [Infinity, -Infinity];
  28648. each(children, function (child) {
  28649. var value = child.getValue(dimension);
  28650. value < dataExtent[0] && (dataExtent[0] = value);
  28651. value > dataExtent[1] && (dataExtent[1] = value);
  28652. });
  28653. }
  28654. return {sum: sum, dataExtent: dataExtent};
  28655. }
  28656. /**
  28657. * Computes the score for the specified row,
  28658. * as the worst aspect ratio.
  28659. */
  28660. function worst(row, rowFixedLength, ratio) {
  28661. var areaMax = 0;
  28662. var areaMin = Infinity;
  28663. for (var i = 0, area, len = row.length; i < len; i++) {
  28664. area = row[i].getLayout().area;
  28665. if (area) {
  28666. area < areaMin && (areaMin = area);
  28667. area > areaMax && (areaMax = area);
  28668. }
  28669. }
  28670. var squareArea = row.area * row.area;
  28671. var f = rowFixedLength * rowFixedLength * ratio;
  28672. return squareArea
  28673. ? mathMax(
  28674. (f * areaMax) / squareArea,
  28675. squareArea / (f * areaMin)
  28676. )
  28677. : Infinity;
  28678. }
  28679. /**
  28680. * Positions the specified row of nodes. Modifies `rect`.
  28681. */
  28682. function position(row, rowFixedLength, rect, halfGapWidth, flush) {
  28683. // When rowFixedLength === rect.width,
  28684. // it is horizontal subdivision,
  28685. // rowFixedLength is the width of the subdivision,
  28686. // rowOtherLength is the height of the subdivision,
  28687. // and nodes will be positioned from left to right.
  28688. // wh[idx0WhenH] means: when horizontal,
  28689. // wh[idx0WhenH] => wh[0] => 'width'.
  28690. // xy[idx1WhenH] => xy[1] => 'y'.
  28691. var idx0WhenH = rowFixedLength === rect.width ? 0 : 1;
  28692. var idx1WhenH = 1 - idx0WhenH;
  28693. var xy = ['x', 'y'];
  28694. var wh = ['width', 'height'];
  28695. var last = rect[xy[idx0WhenH]];
  28696. var rowOtherLength = rowFixedLength
  28697. ? row.area / rowFixedLength : 0;
  28698. if (flush || rowOtherLength > rect[wh[idx1WhenH]]) {
  28699. rowOtherLength = rect[wh[idx1WhenH]]; // over+underflow
  28700. }
  28701. for (var i = 0, rowLen = row.length; i < rowLen; i++) {
  28702. var node = row[i];
  28703. var nodeLayout = {};
  28704. var step = rowOtherLength
  28705. ? node.getLayout().area / rowOtherLength : 0;
  28706. var wh1 = nodeLayout[wh[idx1WhenH]] = mathMax(rowOtherLength - 2 * halfGapWidth, 0);
  28707. // We use Math.max/min to avoid negative width/height when considering gap width.
  28708. var remain = rect[xy[idx0WhenH]] + rect[wh[idx0WhenH]] - last;
  28709. var modWH = (i === rowLen - 1 || remain < step) ? remain : step;
  28710. var wh0 = nodeLayout[wh[idx0WhenH]] = mathMax(modWH - 2 * halfGapWidth, 0);
  28711. nodeLayout[xy[idx1WhenH]] = rect[xy[idx1WhenH]] + mathMin(halfGapWidth, wh1 / 2);
  28712. nodeLayout[xy[idx0WhenH]] = last + mathMin(halfGapWidth, wh0 / 2);
  28713. last += modWH;
  28714. node.setLayout(nodeLayout, true);
  28715. }
  28716. rect[xy[idx1WhenH]] += rowOtherLength;
  28717. rect[wh[idx1WhenH]] -= rowOtherLength;
  28718. }
  28719. // Return [containerWidth, containerHeight] as defualt.
  28720. function estimateRootSize(seriesModel, targetInfo, viewRoot, containerWidth, containerHeight) {
  28721. // If targetInfo.node exists, we zoom to the node,
  28722. // so estimate whold width and heigth by target node.
  28723. var currNode = (targetInfo || {}).node;
  28724. var defaultSize = [containerWidth, containerHeight];
  28725. if (!currNode || currNode === viewRoot) {
  28726. return defaultSize;
  28727. }
  28728. var parent;
  28729. var viewArea = containerWidth * containerHeight;
  28730. var area = viewArea * seriesModel.option.zoomToNodeRatio;
  28731. while (parent = currNode.parentNode) { // jshint ignore:line
  28732. var sum = 0;
  28733. var siblings = parent.children;
  28734. for (var i = 0, len = siblings.length; i < len; i++) {
  28735. sum += siblings[i].getValue();
  28736. }
  28737. var currNodeValue = currNode.getValue();
  28738. if (currNodeValue === 0) {
  28739. return defaultSize;
  28740. }
  28741. area *= sum / currNodeValue;
  28742. var borderWidth = parent.getModel('itemStyle.normal').get('borderWidth');
  28743. if (isFinite(borderWidth)) {
  28744. // Considering border, suppose aspect ratio is 1.
  28745. area += 4 * borderWidth * borderWidth + 4 * borderWidth * Math.pow(area, 0.5);
  28746. }
  28747. area > numberUtil.MAX_SAFE_INTEGER && (area = numberUtil.MAX_SAFE_INTEGER);
  28748. currNode = parent;
  28749. }
  28750. area < viewArea && (area = viewArea);
  28751. var scale = Math.pow(area / viewArea, 0.5);
  28752. return [containerWidth * scale, containerHeight * scale];
  28753. }
  28754. // Root postion base on coord of containerGroup
  28755. function calculateRootPosition(layoutInfo, rootRect, targetInfo) {
  28756. if (rootRect) {
  28757. return {x: rootRect.x, y: rootRect.y};
  28758. }
  28759. var defaultPosition = {x: 0, y: 0};
  28760. if (!targetInfo) {
  28761. return defaultPosition;
  28762. }
  28763. // If targetInfo is fetched by 'retrieveTargetInfo',
  28764. // old tree and new tree are the same tree,
  28765. // so the node still exists and we can visit it.
  28766. var targetNode = targetInfo.node;
  28767. var layout = targetNode.getLayout();
  28768. if (!layout) {
  28769. return defaultPosition;
  28770. }
  28771. // Transform coord from local to container.
  28772. var targetCenter = [layout.width / 2, layout.height / 2];
  28773. var node = targetNode;
  28774. while (node) {
  28775. var nodeLayout = node.getLayout();
  28776. targetCenter[0] += nodeLayout.x;
  28777. targetCenter[1] += nodeLayout.y;
  28778. node = node.parentNode;
  28779. }
  28780. return {
  28781. x: layoutInfo.width / 2 - targetCenter[0],
  28782. y: layoutInfo.height / 2 - targetCenter[1]
  28783. };
  28784. }
  28785. // Mark nodes visible for prunning when visual coding and rendering.
  28786. // Prunning depends on layout and root position, so we have to do it after layout.
  28787. function prunning(node, clipRect, viewAbovePath, viewRoot, depth) {
  28788. var nodeLayout = node.getLayout();
  28789. var nodeInViewAbovePath = viewAbovePath[depth];
  28790. var isAboveViewRoot = nodeInViewAbovePath && nodeInViewAbovePath === node;
  28791. if (
  28792. (nodeInViewAbovePath && !isAboveViewRoot)
  28793. || (depth === viewAbovePath.length && node !== viewRoot)
  28794. ) {
  28795. return;
  28796. }
  28797. node.setLayout({
  28798. // isInView means: viewRoot sub tree + viewAbovePath
  28799. isInView: true,
  28800. // invisible only means: outside view clip so that the node can not
  28801. // see but still layout for animation preparation but not render.
  28802. invisible: !isAboveViewRoot && !clipRect.intersect(nodeLayout),
  28803. isAboveViewRoot: isAboveViewRoot
  28804. }, true);
  28805. // Transform to child coordinate.
  28806. var childClipRect = new BoundingRect(
  28807. clipRect.x - nodeLayout.x,
  28808. clipRect.y - nodeLayout.y,
  28809. clipRect.width,
  28810. clipRect.height
  28811. );
  28812. each(node.viewChildren || [], function (child) {
  28813. prunning(child, childClipRect, viewAbovePath, viewRoot, depth + 1);
  28814. });
  28815. }
  28816. module.exports = update;
  28817. /***/ },
  28818. /* 189 */
  28819. /***/ function(module, exports, __webpack_require__) {
  28820. var echarts = __webpack_require__(1);
  28821. var zrUtil = __webpack_require__(3);
  28822. __webpack_require__(190);
  28823. __webpack_require__(193);
  28824. __webpack_require__(198);
  28825. echarts.registerProcessor('filter', __webpack_require__(199));
  28826. echarts.registerVisualCoding('chart', zrUtil.curry(
  28827. __webpack_require__(104), 'graph', 'circle', null
  28828. ));
  28829. echarts.registerVisualCoding('chart', __webpack_require__(200));
  28830. echarts.registerVisualCoding('chart', __webpack_require__(201));
  28831. echarts.registerLayout(__webpack_require__(202));
  28832. echarts.registerLayout(__webpack_require__(205));
  28833. echarts.registerLayout(__webpack_require__(207));
  28834. // Graph view coordinate system
  28835. echarts.registerCoordinateSystem('graphView', {
  28836. create: __webpack_require__(209)
  28837. });
  28838. /***/ },
  28839. /* 190 */
  28840. /***/ function(module, exports, __webpack_require__) {
  28841. 'use strict';
  28842. var List = __webpack_require__(95);
  28843. var zrUtil = __webpack_require__(3);
  28844. var modelUtil = __webpack_require__(5);
  28845. var Model = __webpack_require__(8);
  28846. var createGraphFromNodeEdge = __webpack_require__(191);
  28847. var GraphSeries = __webpack_require__(1).extendSeriesModel({
  28848. type: 'series.graph',
  28849. init: function (option) {
  28850. GraphSeries.superApply(this, 'init', arguments);
  28851. // Provide data for legend select
  28852. this.legendDataProvider = function () {
  28853. return this._categoriesData;
  28854. };
  28855. this.fillDataTextStyle(option.edges || option.links);
  28856. this._updateCategoriesData();
  28857. },
  28858. mergeOption: function (option) {
  28859. GraphSeries.superApply(this, 'mergeOption', arguments);
  28860. this.fillDataTextStyle(option.edges || option.links);
  28861. this._updateCategoriesData();
  28862. },
  28863. mergeDefaultAndTheme: function (option) {
  28864. GraphSeries.superApply(this, 'mergeDefaultAndTheme', arguments);
  28865. modelUtil.defaultEmphasis(option.edgeLabel, modelUtil.LABEL_OPTIONS);
  28866. },
  28867. getInitialData: function (option, ecModel) {
  28868. var edges = option.edges || option.links || [];
  28869. var nodes = option.data || option.nodes || [];
  28870. var self = this;
  28871. if (nodes && edges) {
  28872. return createGraphFromNodeEdge(nodes, edges, this, true, beforeLink).data;
  28873. }
  28874. function beforeLink(nodeData, edgeData) {
  28875. // Overwrite nodeData.getItemModel to
  28876. nodeData.wrapMethod('getItemModel', function (model) {
  28877. var categoriesModels = self._categoriesModels;
  28878. var categoryIdx = model.getShallow('category');
  28879. var categoryModel = categoriesModels[categoryIdx];
  28880. if (categoryModel) {
  28881. categoryModel.parentModel = model.parentModel;
  28882. model.parentModel = categoryModel;
  28883. }
  28884. return model;
  28885. });
  28886. var edgeLabelModel = self.getModel('edgeLabel');
  28887. var wrappedGetEdgeModel = function (path, parentModel) {
  28888. var pathArr = (path || '').split('.');
  28889. if (pathArr[0] === 'label') {
  28890. parentModel = parentModel
  28891. || edgeLabelModel.getModel(pathArr.slice(1));
  28892. }
  28893. var model = Model.prototype.getModel.call(this, pathArr, parentModel);
  28894. model.getModel = wrappedGetEdgeModel;
  28895. return model;
  28896. };
  28897. edgeData.wrapMethod('getItemModel', function (model) {
  28898. // FIXME Wrap get method ?
  28899. model.getModel = wrappedGetEdgeModel;
  28900. return model;
  28901. });
  28902. }
  28903. },
  28904. /**
  28905. * @return {module:echarts/data/Graph}
  28906. */
  28907. getGraph: function () {
  28908. return this.getData().graph;
  28909. },
  28910. /**
  28911. * @return {module:echarts/data/List}
  28912. */
  28913. getEdgeData: function () {
  28914. return this.getGraph().edgeData;
  28915. },
  28916. /**
  28917. * @return {module:echarts/data/List}
  28918. */
  28919. getCategoriesData: function () {
  28920. return this._categoriesData;
  28921. },
  28922. /**
  28923. * @override
  28924. */
  28925. formatTooltip: function (dataIndex, multipleSeries, dataType) {
  28926. if (dataType === 'edge') {
  28927. var nodeData = this.getData();
  28928. var params = this.getDataParams(dataIndex, dataType);
  28929. var edge = nodeData.graph.getEdgeByIndex(dataIndex);
  28930. var sourceName = nodeData.getName(edge.node1.dataIndex);
  28931. var targetName = nodeData.getName(edge.node2.dataIndex);
  28932. var html = sourceName + ' > ' + targetName;
  28933. if (params.value) {
  28934. html += ' : ' + params.value;
  28935. }
  28936. return html;
  28937. }
  28938. else { // dataType === 'node' or empty
  28939. return GraphSeries.superApply(this, 'formatTooltip', arguments);
  28940. }
  28941. },
  28942. _updateCategoriesData: function () {
  28943. var categories = zrUtil.map(this.option.categories || [], function (category) {
  28944. // Data must has value
  28945. return category.value != null ? category : zrUtil.extend({
  28946. value: 0
  28947. }, category);
  28948. });
  28949. var categoriesData = new List(['value'], this);
  28950. categoriesData.initData(categories);
  28951. this._categoriesData = categoriesData;
  28952. this._categoriesModels = categoriesData.mapArray(function (idx) {
  28953. return categoriesData.getItemModel(idx, true);
  28954. });
  28955. },
  28956. setZoom: function (zoom) {
  28957. this.option.zoom = zoom;
  28958. },
  28959. setCenter: function (center) {
  28960. this.option.center = center;
  28961. },
  28962. defaultOption: {
  28963. zlevel: 0,
  28964. z: 2,
  28965. color: ['#61a0a8', '#d14a61', '#fd9c35', '#675bba', '#fec42c',
  28966. '#dd4444', '#fd9c35', '#cd4870'],
  28967. coordinateSystem: 'view',
  28968. // Default option for all coordinate systems
  28969. xAxisIndex: 0,
  28970. yAxisIndex: 0,
  28971. polarIndex: 0,
  28972. geoIndex: 0,
  28973. legendHoverLink: true,
  28974. hoverAnimation: true,
  28975. layout: null,
  28976. // Configuration of force
  28977. force: {
  28978. initLayout: null,
  28979. repulsion: 50,
  28980. gravity: 0.1,
  28981. edgeLength: 30,
  28982. layoutAnimation: true
  28983. },
  28984. left: 'center',
  28985. top: 'center',
  28986. // right: null,
  28987. // bottom: null,
  28988. // width: '80%',
  28989. // height: '80%',
  28990. symbol: 'circle',
  28991. symbolSize: 10,
  28992. edgeSymbol: ['none', 'none'],
  28993. edgeSymbolSize: 10,
  28994. edgeLabel: {
  28995. normal: {
  28996. position: 'middle'
  28997. },
  28998. emphasis: {}
  28999. },
  29000. draggable: false,
  29001. roam: false,
  29002. // Default on center of graph
  29003. center: null,
  29004. zoom: 1,
  29005. // Symbol size scale ratio in roam
  29006. nodeScaleRatio: 0.6,
  29007. // categories: [],
  29008. // data: []
  29009. // Or
  29010. // nodes: []
  29011. //
  29012. // links: []
  29013. // Or
  29014. // edges: []
  29015. label: {
  29016. normal: {
  29017. show: false,
  29018. formatter: '{b}'
  29019. },
  29020. emphasis: {
  29021. show: true
  29022. }
  29023. },
  29024. itemStyle: {
  29025. normal: {},
  29026. emphasis: {}
  29027. },
  29028. lineStyle: {
  29029. normal: {
  29030. color: '#aaa',
  29031. width: 1,
  29032. curveness: 0,
  29033. opacity: 0.5
  29034. },
  29035. emphasis: {}
  29036. }
  29037. }
  29038. });
  29039. module.exports = GraphSeries;
  29040. /***/ },
  29041. /* 191 */
  29042. /***/ function(module, exports, __webpack_require__) {
  29043. var List = __webpack_require__(95);
  29044. var Graph = __webpack_require__(192);
  29045. var linkList = __webpack_require__(180);
  29046. var completeDimensions = __webpack_require__(97);
  29047. var CoordinateSystem = __webpack_require__(25);
  29048. var zrUtil = __webpack_require__(3);
  29049. var createListFromArray = __webpack_require__(94);
  29050. module.exports = function (nodes, edges, hostModel, directed, beforeLink) {
  29051. var graph = new Graph(directed);
  29052. for (var i = 0; i < nodes.length; i++) {
  29053. graph.addNode(zrUtil.retrieve(
  29054. // Id, name, dataIndex
  29055. nodes[i].id, nodes[i].name, i
  29056. ), i);
  29057. }
  29058. var linkNameList = [];
  29059. var validEdges = [];
  29060. for (var i = 0; i < edges.length; i++) {
  29061. var link = edges[i];
  29062. var source = link.source;
  29063. var target = link.target;
  29064. // addEdge may fail when source or target not exists
  29065. if (graph.addEdge(source, target, i)) {
  29066. validEdges.push(link);
  29067. linkNameList.push(zrUtil.retrieve(link.id, source + ' > ' + target));
  29068. }
  29069. }
  29070. var coordSys = hostModel.get('coordinateSystem');
  29071. var nodeData;
  29072. if (coordSys === 'cartesian2d' || coordSys === 'polar') {
  29073. nodeData = createListFromArray(nodes, hostModel, hostModel.ecModel);
  29074. }
  29075. else {
  29076. // FIXME
  29077. var coordSysCtor = CoordinateSystem.get(coordSys);
  29078. // FIXME
  29079. var dimensionNames = completeDimensions(
  29080. ((coordSysCtor && coordSysCtor.type !== 'view') ? (coordSysCtor.dimensions || []) : []).concat(['value']),
  29081. nodes
  29082. );
  29083. nodeData = new List(dimensionNames, hostModel);
  29084. nodeData.initData(nodes);
  29085. }
  29086. var edgeData = new List(['value'], hostModel);
  29087. edgeData.initData(validEdges, linkNameList);
  29088. beforeLink && beforeLink(nodeData, edgeData);
  29089. linkList({
  29090. mainData: nodeData,
  29091. struct: graph,
  29092. structAttr: 'graph',
  29093. datas: {node: nodeData, edge: edgeData},
  29094. datasAttr: {node: 'data', edge: 'edgeData'}
  29095. });
  29096. // Update dataIndex of nodes and edges because invalid edge may be removed
  29097. graph.update();
  29098. return graph;
  29099. };
  29100. /***/ },
  29101. /* 192 */
  29102. /***/ function(module, exports, __webpack_require__) {
  29103. 'use strict';
  29104. /**
  29105. * Graph data structure
  29106. *
  29107. * @module echarts/data/Graph
  29108. * @author Yi Shen(https://www.github.com/pissang)
  29109. */
  29110. var zrUtil = __webpack_require__(3);
  29111. /**
  29112. * @alias module:echarts/data/Graph
  29113. * @constructor
  29114. * @param {boolean} directed
  29115. */
  29116. var Graph = function(directed) {
  29117. /**
  29118. * 是否是有向图
  29119. * @type {boolean}
  29120. * @private
  29121. */
  29122. this._directed = directed || false;
  29123. /**
  29124. * @type {Array.<module:echarts/data/Graph.Node>}
  29125. * @readOnly
  29126. */
  29127. this.nodes = [];
  29128. /**
  29129. * @type {Array.<module:echarts/data/Graph.Edge>}
  29130. * @readOnly
  29131. */
  29132. this.edges = [];
  29133. /**
  29134. * @type {Object.<string, module:echarts/data/Graph.Node>}
  29135. * @private
  29136. */
  29137. this._nodesMap = {};
  29138. /**
  29139. * @type {Object.<string, module:echarts/data/Graph.Edge>}
  29140. * @private
  29141. */
  29142. this._edgesMap = {};
  29143. /**
  29144. * @type {module:echarts/data/List}
  29145. * @readOnly
  29146. */
  29147. this.data;
  29148. /**
  29149. * @type {module:echarts/data/List}
  29150. * @readOnly
  29151. */
  29152. this.edgeData;
  29153. };
  29154. var graphProto = Graph.prototype;
  29155. /**
  29156. * @type {string}
  29157. */
  29158. graphProto.type = 'graph';
  29159. /**
  29160. * If is directed graph
  29161. * @return {boolean}
  29162. */
  29163. graphProto.isDirected = function () {
  29164. return this._directed;
  29165. };
  29166. /**
  29167. * Add a new node
  29168. * @param {string} id
  29169. * @param {number} [dataIndex]
  29170. */
  29171. graphProto.addNode = function (id, dataIndex) {
  29172. id = id || ('' + dataIndex);
  29173. var nodesMap = this._nodesMap;
  29174. if (nodesMap[id]) {
  29175. return;
  29176. }
  29177. var node = new Node(id, dataIndex);
  29178. node.hostGraph = this;
  29179. this.nodes.push(node);
  29180. nodesMap[id] = node;
  29181. return node;
  29182. };
  29183. /**
  29184. * Get node by data index
  29185. * @param {number} dataIndex
  29186. * @return {module:echarts/data/Graph~Node}
  29187. */
  29188. graphProto.getNodeByIndex = function (dataIndex) {
  29189. var rawIdx = this.data.getRawIndex(dataIndex);
  29190. return this.nodes[rawIdx];
  29191. };
  29192. /**
  29193. * Get node by id
  29194. * @param {string} id
  29195. * @return {module:echarts/data/Graph.Node}
  29196. */
  29197. graphProto.getNodeById = function (id) {
  29198. return this._nodesMap[id];
  29199. };
  29200. /**
  29201. * Add a new edge
  29202. * @param {number|string|module:echarts/data/Graph.Node} n1
  29203. * @param {number|string|module:echarts/data/Graph.Node} n2
  29204. * @param {number} [dataIndex=-1]
  29205. * @return {module:echarts/data/Graph.Edge}
  29206. */
  29207. graphProto.addEdge = function (n1, n2, dataIndex) {
  29208. var nodesMap = this._nodesMap;
  29209. var edgesMap = this._edgesMap;
  29210. // PNEDING
  29211. if (typeof n1 === 'number') {
  29212. n1 = this.nodes[n1];
  29213. }
  29214. if (typeof n2 === 'number') {
  29215. n2 = this.nodes[n2];
  29216. }
  29217. if (!(n1 instanceof Node)) {
  29218. n1 = nodesMap[n1];
  29219. }
  29220. if (!(n2 instanceof Node)) {
  29221. n2 = nodesMap[n2];
  29222. }
  29223. if (!n1 || !n2) {
  29224. return;
  29225. }
  29226. var key = n1.id + '-' + n2.id;
  29227. // PENDING
  29228. if (edgesMap[key]) {
  29229. return;
  29230. }
  29231. var edge = new Edge(n1, n2, dataIndex);
  29232. edge.hostGraph = this;
  29233. if (this._directed) {
  29234. n1.outEdges.push(edge);
  29235. n2.inEdges.push(edge);
  29236. }
  29237. n1.edges.push(edge);
  29238. if (n1 !== n2) {
  29239. n2.edges.push(edge);
  29240. }
  29241. this.edges.push(edge);
  29242. edgesMap[key] = edge;
  29243. return edge;
  29244. };
  29245. /**
  29246. * Get edge by data index
  29247. * @param {number} dataIndex
  29248. * @return {module:echarts/data/Graph~Node}
  29249. */
  29250. graphProto.getEdgeByIndex = function (dataIndex) {
  29251. var rawIdx = this.edgeData.getRawIndex(dataIndex);
  29252. return this.edges[rawIdx];
  29253. };
  29254. /**
  29255. * Get edge by two linked nodes
  29256. * @param {module:echarts/data/Graph.Node|string} n1
  29257. * @param {module:echarts/data/Graph.Node|string} n2
  29258. * @return {module:echarts/data/Graph.Edge}
  29259. */
  29260. graphProto.getEdge = function (n1, n2) {
  29261. if (n1 instanceof Node) {
  29262. n1 = n1.id;
  29263. }
  29264. if (n2 instanceof Node) {
  29265. n2 = n2.id;
  29266. }
  29267. var edgesMap = this._edgesMap;
  29268. if (this._directed) {
  29269. return edgesMap[n1 + '-' + n2];
  29270. } else {
  29271. return edgesMap[n1 + '-' + n2]
  29272. || edgesMap[n2 + '-' + n1];
  29273. }
  29274. };
  29275. /**
  29276. * Iterate all nodes
  29277. * @param {Function} cb
  29278. * @param {*} [context]
  29279. */
  29280. graphProto.eachNode = function (cb, context) {
  29281. var nodes = this.nodes;
  29282. var len = nodes.length;
  29283. for (var i = 0; i < len; i++) {
  29284. if (nodes[i].dataIndex >= 0) {
  29285. cb.call(context, nodes[i], i);
  29286. }
  29287. }
  29288. };
  29289. /**
  29290. * Iterate all edges
  29291. * @param {Function} cb
  29292. * @param {*} [context]
  29293. */
  29294. graphProto.eachEdge = function (cb, context) {
  29295. var edges = this.edges;
  29296. var len = edges.length;
  29297. for (var i = 0; i < len; i++) {
  29298. if (edges[i].dataIndex >= 0
  29299. && edges[i].node1.dataIndex >= 0
  29300. && edges[i].node2.dataIndex >= 0
  29301. ) {
  29302. cb.call(context, edges[i], i);
  29303. }
  29304. }
  29305. };
  29306. /**
  29307. * Breadth first traverse
  29308. * @param {Function} cb
  29309. * @param {module:echarts/data/Graph.Node} startNode
  29310. * @param {string} [direction='none'] 'none'|'in'|'out'
  29311. * @param {*} [context]
  29312. */
  29313. graphProto.breadthFirstTraverse = function (
  29314. cb, startNode, direction, context
  29315. ) {
  29316. if (!(startNode instanceof Node)) {
  29317. startNode = this._nodesMap[startNode];
  29318. }
  29319. if (!startNode) {
  29320. return;
  29321. }
  29322. var edgeType = direction === 'out'
  29323. ? 'outEdges' : (direction === 'in' ? 'inEdges' : 'edges');
  29324. for (var i = 0; i < this.nodes.length; i++) {
  29325. this.nodes[i].__visited = false;
  29326. }
  29327. if (cb.call(context, startNode, null)) {
  29328. return;
  29329. }
  29330. var queue = [startNode];
  29331. while (queue.length) {
  29332. var currentNode = queue.shift();
  29333. var edges = currentNode[edgeType];
  29334. for (var i = 0; i < edges.length; i++) {
  29335. var e = edges[i];
  29336. var otherNode = e.node1 === currentNode
  29337. ? e.node2 : e.node1;
  29338. if (!otherNode.__visited) {
  29339. if (cb.call(otherNode, otherNode, currentNode)) {
  29340. // Stop traversing
  29341. return;
  29342. }
  29343. queue.push(otherNode);
  29344. otherNode.__visited = true;
  29345. }
  29346. }
  29347. }
  29348. };
  29349. // TODO
  29350. // graphProto.depthFirstTraverse = function (
  29351. // cb, startNode, direction, context
  29352. // ) {
  29353. // };
  29354. // Filter update
  29355. graphProto.update = function () {
  29356. var data = this.data;
  29357. var edgeData = this.edgeData;
  29358. var nodes = this.nodes;
  29359. var edges = this.edges;
  29360. for (var i = 0, len = nodes.length; i < len; i++) {
  29361. nodes[i].dataIndex = -1;
  29362. }
  29363. for (var i = 0, len = data.count(); i < len; i++) {
  29364. nodes[data.getRawIndex(i)].dataIndex = i;
  29365. }
  29366. edgeData.filterSelf(function (idx) {
  29367. var edge = edges[edgeData.getRawIndex(idx)];
  29368. return edge.node1.dataIndex >= 0 && edge.node2.dataIndex >= 0;
  29369. });
  29370. // Update edge
  29371. for (var i = 0, len = edges.length; i < len; i++) {
  29372. edges[i].dataIndex = -1;
  29373. }
  29374. for (var i = 0, len = edgeData.count(); i < len; i++) {
  29375. edges[edgeData.getRawIndex(i)].dataIndex = i;
  29376. }
  29377. };
  29378. /**
  29379. * @return {module:echarts/data/Graph}
  29380. */
  29381. graphProto.clone = function () {
  29382. var graph = new Graph(this._directed);
  29383. var nodes = this.nodes;
  29384. var edges = this.edges;
  29385. for (var i = 0; i < nodes.length; i++) {
  29386. graph.addNode(nodes[i].id, nodes[i].dataIndex);
  29387. }
  29388. for (var i = 0; i < edges.length; i++) {
  29389. var e = edges[i];
  29390. graph.addEdge(e.node1.id, e.node2.id, e.dataIndex);
  29391. }
  29392. return graph;
  29393. };
  29394. /**
  29395. * @alias module:echarts/data/Graph.Node
  29396. */
  29397. function Node(id, dataIndex) {
  29398. /**
  29399. * @type {string}
  29400. */
  29401. this.id = id == null ? '' : id;
  29402. /**
  29403. * @type {Array.<module:echarts/data/Graph.Edge>}
  29404. */
  29405. this.inEdges = [];
  29406. /**
  29407. * @type {Array.<module:echarts/data/Graph.Edge>}
  29408. */
  29409. this.outEdges = [];
  29410. /**
  29411. * @type {Array.<module:echarts/data/Graph.Edge>}
  29412. */
  29413. this.edges = [];
  29414. /**
  29415. * @type {module:echarts/data/Graph}
  29416. */
  29417. this.hostGraph;
  29418. /**
  29419. * @type {number}
  29420. */
  29421. this.dataIndex = dataIndex == null ? -1 : dataIndex;
  29422. }
  29423. Node.prototype = {
  29424. constructor: Node,
  29425. /**
  29426. * @return {number}
  29427. */
  29428. degree: function () {
  29429. return this.edges.length;
  29430. },
  29431. /**
  29432. * @return {number}
  29433. */
  29434. inDegree: function () {
  29435. return this.inEdges.length;
  29436. },
  29437. /**
  29438. * @return {number}
  29439. */
  29440. outDegree: function () {
  29441. return this.outEdges.length;
  29442. },
  29443. /**
  29444. * @param {string} [path]
  29445. * @return {module:echarts/model/Model}
  29446. */
  29447. getModel: function (path) {
  29448. if (this.dataIndex < 0) {
  29449. return;
  29450. }
  29451. var graph = this.hostGraph;
  29452. var itemModel = graph.data.getItemModel(this.dataIndex);
  29453. return itemModel.getModel(path);
  29454. }
  29455. };
  29456. /**
  29457. * 图边
  29458. * @alias module:echarts/data/Graph.Edge
  29459. * @param {module:echarts/data/Graph.Node} n1
  29460. * @param {module:echarts/data/Graph.Node} n2
  29461. * @param {number} [dataIndex=-1]
  29462. */
  29463. function Edge(n1, n2, dataIndex) {
  29464. /**
  29465. * 节点1,如果是有向图则为源节点
  29466. * @type {module:echarts/data/Graph.Node}
  29467. */
  29468. this.node1 = n1;
  29469. /**
  29470. * 节点2,如果是有向图则为目标节点
  29471. * @type {module:echarts/data/Graph.Node}
  29472. */
  29473. this.node2 = n2;
  29474. this.dataIndex = dataIndex == null ? -1 : dataIndex;
  29475. }
  29476. /**
  29477. * @param {string} [path]
  29478. * @return {module:echarts/model/Model}
  29479. */
  29480. Edge.prototype.getModel = function (path) {
  29481. if (this.dataIndex < 0) {
  29482. return;
  29483. }
  29484. var graph = this.hostGraph;
  29485. var itemModel = graph.edgeData.getItemModel(this.dataIndex);
  29486. return itemModel.getModel(path);
  29487. };
  29488. var createGraphDataProxyMixin = function (hostName, dataName) {
  29489. return {
  29490. /**
  29491. * @param {string=} [dimension='value'] Default 'value'. can be 'a', 'b', 'c', 'd', 'e'.
  29492. * @return {number}
  29493. */
  29494. getValue: function (dimension) {
  29495. var data = this[hostName][dataName];
  29496. return data.get(data.getDimension(dimension || 'value'), this.dataIndex);
  29497. },
  29498. /**
  29499. * @param {Object|string} key
  29500. * @param {*} [value]
  29501. */
  29502. setVisual: function (key, value) {
  29503. this.dataIndex >= 0
  29504. && this[hostName][dataName].setItemVisual(this.dataIndex, key, value);
  29505. },
  29506. /**
  29507. * @param {string} key
  29508. * @return {boolean}
  29509. */
  29510. getVisual: function (key, ignoreParent) {
  29511. return this[hostName][dataName].getItemVisual(this.dataIndex, key, ignoreParent);
  29512. },
  29513. /**
  29514. * @param {Object} layout
  29515. * @return {boolean} [merge=false]
  29516. */
  29517. setLayout: function (layout, merge) {
  29518. this.dataIndex >= 0
  29519. && this[hostName][dataName].setItemLayout(this.dataIndex, layout, merge);
  29520. },
  29521. /**
  29522. * @return {Object}
  29523. */
  29524. getLayout: function () {
  29525. return this[hostName][dataName].getItemLayout(this.dataIndex);
  29526. },
  29527. /**
  29528. * @return {module:zrender/Element}
  29529. */
  29530. getGraphicEl: function () {
  29531. return this[hostName][dataName].getItemGraphicEl(this.dataIndex);
  29532. },
  29533. /**
  29534. * @return {number}
  29535. */
  29536. getRawIndex: function () {
  29537. return this[hostName][dataName].getRawIndex(this.dataIndex);
  29538. }
  29539. };
  29540. };
  29541. zrUtil.mixin(Node, createGraphDataProxyMixin('hostGraph', 'data'));
  29542. zrUtil.mixin(Edge, createGraphDataProxyMixin('hostGraph', 'edgeData'));
  29543. Graph.Node = Node;
  29544. Graph.Edge = Edge;
  29545. module.exports = Graph;
  29546. /***/ },
  29547. /* 193 */
  29548. /***/ function(module, exports, __webpack_require__) {
  29549. var SymbolDraw = __webpack_require__(99);
  29550. var LineDraw = __webpack_require__(194);
  29551. var RoamController = __webpack_require__(169);
  29552. var graphic = __webpack_require__(42);
  29553. var adjustEdge = __webpack_require__(197);
  29554. __webpack_require__(1).extendChartView({
  29555. type: 'graph',
  29556. init: function (ecModel, api) {
  29557. var symbolDraw = new SymbolDraw();
  29558. var lineDraw = new LineDraw();
  29559. var group = this.group;
  29560. var controller = new RoamController(api.getZr(), group);
  29561. group.add(symbolDraw.group);
  29562. group.add(lineDraw.group);
  29563. this._symbolDraw = symbolDraw;
  29564. this._lineDraw = lineDraw;
  29565. this._controller = controller;
  29566. this._firstRender = true;
  29567. },
  29568. render: function (seriesModel, ecModel, api) {
  29569. var coordSys = seriesModel.coordinateSystem;
  29570. // Only support view and geo coordinate system
  29571. // if (coordSys.type !== 'geo' && coordSys.type !== 'view') {
  29572. // return;
  29573. // }
  29574. this._model = seriesModel;
  29575. this._nodeScaleRatio = seriesModel.get('nodeScaleRatio');
  29576. var symbolDraw = this._symbolDraw;
  29577. var lineDraw = this._lineDraw;
  29578. var group = this.group;
  29579. if (coordSys.type === 'view') {
  29580. var groupNewProp = {
  29581. position: coordSys.position,
  29582. scale: coordSys.scale
  29583. };
  29584. if (this._firstRender) {
  29585. group.attr(groupNewProp);
  29586. }
  29587. else {
  29588. graphic.updateProps(group, groupNewProp, seriesModel);
  29589. }
  29590. }
  29591. // Fix edge contact point with node
  29592. adjustEdge(seriesModel.getGraph(), this._getNodeGlobalScale(seriesModel));
  29593. var data = seriesModel.getData();
  29594. symbolDraw.updateData(data);
  29595. var edgeData = seriesModel.getEdgeData();
  29596. lineDraw.updateData(edgeData);
  29597. this._updateNodeAndLinkScale();
  29598. this._updateController(seriesModel, api);
  29599. clearTimeout(this._layoutTimeout);
  29600. var forceLayout = seriesModel.forceLayout;
  29601. var layoutAnimation = seriesModel.get('force.layoutAnimation');
  29602. if (forceLayout) {
  29603. this._startForceLayoutIteration(forceLayout, layoutAnimation);
  29604. }
  29605. // Update draggable
  29606. data.eachItemGraphicEl(function (el, idx) {
  29607. var draggable = data.getItemModel(idx).get('draggable');
  29608. if (draggable) {
  29609. el.on('drag', function () {
  29610. if (forceLayout) {
  29611. forceLayout.warmUp();
  29612. !this._layouting
  29613. && this._startForceLayoutIteration(forceLayout, layoutAnimation);
  29614. forceLayout.setFixed(idx);
  29615. // Write position back to layout
  29616. data.setItemLayout(idx, el.position);
  29617. }
  29618. }, this).on('dragend', function () {
  29619. if (forceLayout) {
  29620. forceLayout.setUnfixed(idx);
  29621. }
  29622. }, this);
  29623. }
  29624. else {
  29625. el.off('drag');
  29626. }
  29627. el.setDraggable(draggable && forceLayout);
  29628. }, this);
  29629. this._firstRender = false;
  29630. },
  29631. _startForceLayoutIteration: function (forceLayout, layoutAnimation) {
  29632. var self = this;
  29633. (function step() {
  29634. forceLayout.step(function (stopped) {
  29635. self.updateLayout(self._model);
  29636. (self._layouting = !stopped) && (
  29637. layoutAnimation
  29638. ? (self._layoutTimeout = setTimeout(step, 16))
  29639. : step()
  29640. );
  29641. });
  29642. })();
  29643. },
  29644. _updateController: function (seriesModel, api) {
  29645. var controller = this._controller;
  29646. var group = this.group;
  29647. controller.rectProvider = function () {
  29648. var rect = group.getBoundingRect();
  29649. rect.applyTransform(group.transform);
  29650. return rect;
  29651. };
  29652. if (seriesModel.coordinateSystem.type !== 'view') {
  29653. controller.disable();
  29654. return;
  29655. }
  29656. controller.enable(seriesModel.get('roam'));
  29657. controller.zoomLimit = seriesModel.get('scaleLimit');
  29658. // Update zoom from model
  29659. controller.zoom = seriesModel.coordinateSystem.getZoom();
  29660. controller
  29661. .off('pan')
  29662. .off('zoom')
  29663. .on('pan', function (dx, dy) {
  29664. api.dispatchAction({
  29665. seriesId: seriesModel.id,
  29666. type: 'graphRoam',
  29667. dx: dx,
  29668. dy: dy
  29669. });
  29670. })
  29671. .on('zoom', function (zoom, mouseX, mouseY) {
  29672. api.dispatchAction({
  29673. seriesId: seriesModel.id,
  29674. type: 'graphRoam',
  29675. zoom: zoom,
  29676. originX: mouseX,
  29677. originY: mouseY
  29678. });
  29679. this._updateNodeAndLinkScale();
  29680. adjustEdge(seriesModel.getGraph(), this._getNodeGlobalScale(seriesModel));
  29681. this._lineDraw.updateLayout();
  29682. }, this);
  29683. },
  29684. _updateNodeAndLinkScale: function () {
  29685. var seriesModel = this._model;
  29686. var data = seriesModel.getData();
  29687. var nodeScale = this._getNodeGlobalScale(seriesModel);
  29688. var invScale = [nodeScale, nodeScale];
  29689. data.eachItemGraphicEl(function (el, idx) {
  29690. el.attr('scale', invScale);
  29691. });
  29692. },
  29693. _getNodeGlobalScale: function (seriesModel) {
  29694. var coordSys = seriesModel.coordinateSystem;
  29695. if (coordSys.type !== 'view') {
  29696. return 1;
  29697. }
  29698. var nodeScaleRatio = this._nodeScaleRatio;
  29699. var groupScale = this.group.scale;
  29700. var groupZoom = (groupScale && groupScale[0]) || 1;
  29701. // Scale node when zoom changes
  29702. var roamZoom = coordSys.getZoom();
  29703. var nodeScale = (roamZoom - 1) * nodeScaleRatio + 1;
  29704. return nodeScale / groupZoom;
  29705. },
  29706. updateLayout: function (seriesModel) {
  29707. this._symbolDraw.updateLayout();
  29708. this._lineDraw.updateLayout();
  29709. adjustEdge(seriesModel.getGraph(), this._getNodeGlobalScale(seriesModel));
  29710. },
  29711. remove: function (ecModel, api) {
  29712. this._symbolDraw && this._symbolDraw.remove();
  29713. this._lineDraw && this._lineDraw.remove();
  29714. }
  29715. });
  29716. /***/ },
  29717. /* 194 */
  29718. /***/ function(module, exports, __webpack_require__) {
  29719. /**
  29720. * @module echarts/chart/helper/LineDraw
  29721. */
  29722. var graphic = __webpack_require__(42);
  29723. var LineGroup = __webpack_require__(195);
  29724. function isPointNaN(pt) {
  29725. return isNaN(pt[0]) || isNaN(pt[1]);
  29726. }
  29727. function lineNeedsDraw(pts) {
  29728. return !isPointNaN(pts[0]) && !isPointNaN(pts[1]);
  29729. }
  29730. /**
  29731. * @alias module:echarts/component/marker/LineDraw
  29732. * @constructor
  29733. */
  29734. function LineDraw(ctor) {
  29735. this._ctor = ctor || LineGroup;
  29736. this.group = new graphic.Group();
  29737. }
  29738. var lineDrawProto = LineDraw.prototype;
  29739. /**
  29740. * @param {module:echarts/data/List} lineData
  29741. */
  29742. lineDrawProto.updateData = function (lineData) {
  29743. var oldLineData = this._lineData;
  29744. var group = this.group;
  29745. var LineCtor = this._ctor;
  29746. lineData.diff(oldLineData)
  29747. .add(function (idx) {
  29748. if (!lineNeedsDraw(lineData.getItemLayout(idx))) {
  29749. return;
  29750. }
  29751. var lineGroup = new LineCtor(lineData, idx);
  29752. lineData.setItemGraphicEl(idx, lineGroup);
  29753. group.add(lineGroup);
  29754. })
  29755. .update(function (newIdx, oldIdx) {
  29756. var lineGroup = oldLineData.getItemGraphicEl(oldIdx);
  29757. if (!lineNeedsDraw(lineData.getItemLayout(newIdx))) {
  29758. group.remove(lineGroup);
  29759. return;
  29760. }
  29761. if (!lineGroup) {
  29762. lineGroup = new LineCtor(lineData, newIdx);
  29763. }
  29764. else {
  29765. lineGroup.updateData(lineData, newIdx);
  29766. }
  29767. lineData.setItemGraphicEl(newIdx, lineGroup);
  29768. group.add(lineGroup);
  29769. })
  29770. .remove(function (idx) {
  29771. group.remove(oldLineData.getItemGraphicEl(idx));
  29772. })
  29773. .execute();
  29774. this._lineData = lineData;
  29775. };
  29776. lineDrawProto.updateLayout = function () {
  29777. var lineData = this._lineData;
  29778. lineData.eachItemGraphicEl(function (el, idx) {
  29779. el.updateLayout(lineData, idx);
  29780. }, this);
  29781. };
  29782. lineDrawProto.remove = function () {
  29783. this.group.removeAll();
  29784. };
  29785. module.exports = LineDraw;
  29786. /***/ },
  29787. /* 195 */
  29788. /***/ function(module, exports, __webpack_require__) {
  29789. /**
  29790. * @module echarts/chart/helper/Line
  29791. */
  29792. var symbolUtil = __webpack_require__(101);
  29793. var vector = __webpack_require__(16);
  29794. // var matrix = require('zrender/lib/core/matrix');
  29795. var LinePath = __webpack_require__(196);
  29796. var graphic = __webpack_require__(42);
  29797. var zrUtil = __webpack_require__(3);
  29798. var numberUtil = __webpack_require__(7);
  29799. var SYMBOL_CATEGORIES = ['fromSymbol', 'toSymbol'];
  29800. function makeSymbolTypeKey(symbolCategory) {
  29801. return '_' + symbolCategory + 'Type';
  29802. }
  29803. /**
  29804. * @inner
  29805. */
  29806. function createSymbol(name, lineData, idx) {
  29807. var color = lineData.getItemVisual(idx, 'color');
  29808. var symbolType = lineData.getItemVisual(idx, name);
  29809. var symbolSize = lineData.getItemVisual(idx, name + 'Size');
  29810. if (!symbolType || symbolType === 'none') {
  29811. return;
  29812. }
  29813. if (!zrUtil.isArray(symbolSize)) {
  29814. symbolSize = [symbolSize, symbolSize];
  29815. }
  29816. var symbolPath = symbolUtil.createSymbol(
  29817. symbolType, -symbolSize[0] / 2, -symbolSize[1] / 2,
  29818. symbolSize[0], symbolSize[1], color
  29819. );
  29820. symbolPath.name = name;
  29821. return symbolPath;
  29822. }
  29823. function createLine(points) {
  29824. var line = new LinePath({
  29825. name: 'line'
  29826. });
  29827. setLinePoints(line.shape, points);
  29828. return line;
  29829. }
  29830. function setLinePoints(targetShape, points) {
  29831. var p1 = points[0];
  29832. var p2 = points[1];
  29833. var cp1 = points[2];
  29834. targetShape.x1 = p1[0];
  29835. targetShape.y1 = p1[1];
  29836. targetShape.x2 = p2[0];
  29837. targetShape.y2 = p2[1];
  29838. targetShape.percent = 1;
  29839. if (cp1) {
  29840. targetShape.cpx1 = cp1[0];
  29841. targetShape.cpy1 = cp1[1];
  29842. }
  29843. }
  29844. function updateSymbolAndLabelBeforeLineUpdate () {
  29845. var lineGroup = this;
  29846. var symbolFrom = lineGroup.childOfName('fromSymbol');
  29847. var symbolTo = lineGroup.childOfName('toSymbol');
  29848. var label = lineGroup.childOfName('label');
  29849. // Quick reject
  29850. if (!symbolFrom && !symbolTo && label.ignore) {
  29851. return;
  29852. }
  29853. var invScale = 1;
  29854. var parentNode = this.parent;
  29855. while (parentNode) {
  29856. if (parentNode.scale) {
  29857. invScale /= parentNode.scale[0];
  29858. }
  29859. parentNode = parentNode.parent;
  29860. }
  29861. var line = lineGroup.childOfName('line');
  29862. // If line not changed
  29863. // FIXME Parent scale changed
  29864. if (!this.__dirty && !line.__dirty) {
  29865. return;
  29866. }
  29867. var percent = line.shape.percent;
  29868. var fromPos = line.pointAt(0);
  29869. var toPos = line.pointAt(percent);
  29870. var d = vector.sub([], toPos, fromPos);
  29871. vector.normalize(d, d);
  29872. if (symbolFrom) {
  29873. symbolFrom.attr('position', fromPos);
  29874. var tangent = line.tangentAt(0);
  29875. symbolFrom.attr('rotation', Math.PI / 2 - Math.atan2(
  29876. tangent[1], tangent[0]
  29877. ));
  29878. symbolFrom.attr('scale', [invScale * percent, invScale * percent]);
  29879. }
  29880. if (symbolTo) {
  29881. symbolTo.attr('position', toPos);
  29882. var tangent = line.tangentAt(1);
  29883. symbolTo.attr('rotation', -Math.PI / 2 - Math.atan2(
  29884. tangent[1], tangent[0]
  29885. ));
  29886. symbolTo.attr('scale', [invScale * percent, invScale * percent]);
  29887. }
  29888. if (!label.ignore) {
  29889. label.attr('position', toPos);
  29890. var textPosition;
  29891. var textAlign;
  29892. var textVerticalAlign;
  29893. var distance = 5 * invScale;
  29894. // End
  29895. if (label.__position === 'end') {
  29896. textPosition = [d[0] * distance + toPos[0], d[1] * distance + toPos[1]];
  29897. textAlign = d[0] > 0.8 ? 'left' : (d[0] < -0.8 ? 'right' : 'center');
  29898. textVerticalAlign = d[1] > 0.8 ? 'top' : (d[1] < -0.8 ? 'bottom' : 'middle');
  29899. }
  29900. // Middle
  29901. else if (label.__position === 'middle') {
  29902. var halfPercent = percent / 2;
  29903. var tangent = line.tangentAt(halfPercent);
  29904. var n = [tangent[1], -tangent[0]];
  29905. var cp = line.pointAt(halfPercent);
  29906. if (n[1] > 0) {
  29907. n[0] = -n[0];
  29908. n[1] = -n[1];
  29909. }
  29910. textPosition = [cp[0] + n[0] * distance, cp[1] + n[1] * distance];
  29911. textAlign = 'center';
  29912. textVerticalAlign = 'bottom';
  29913. var rotation = -Math.atan2(tangent[1], tangent[0]);
  29914. if (toPos[0] < fromPos[0]) {
  29915. rotation = Math.PI + rotation;
  29916. }
  29917. label.attr('rotation', rotation);
  29918. }
  29919. // Start
  29920. else {
  29921. textPosition = [-d[0] * distance + fromPos[0], -d[1] * distance + fromPos[1]];
  29922. textAlign = d[0] > 0.8 ? 'right' : (d[0] < -0.8 ? 'left' : 'center');
  29923. textVerticalAlign = d[1] > 0.8 ? 'bottom' : (d[1] < -0.8 ? 'top' : 'middle');
  29924. }
  29925. label.attr({
  29926. style: {
  29927. // Use the user specified text align and baseline first
  29928. textVerticalAlign: label.__verticalAlign || textVerticalAlign,
  29929. textAlign: label.__textAlign || textAlign
  29930. },
  29931. position: textPosition,
  29932. scale: [invScale, invScale]
  29933. });
  29934. }
  29935. }
  29936. /**
  29937. * @constructor
  29938. * @extends {module:zrender/graphic/Group}
  29939. * @alias {module:echarts/chart/helper/Line}
  29940. */
  29941. function Line(lineData, idx) {
  29942. graphic.Group.call(this);
  29943. this._createLine(lineData, idx);
  29944. }
  29945. var lineProto = Line.prototype;
  29946. // Update symbol position and rotation
  29947. lineProto.beforeUpdate = updateSymbolAndLabelBeforeLineUpdate;
  29948. lineProto._createLine = function (lineData, idx) {
  29949. var seriesModel = lineData.hostModel;
  29950. var linePoints = lineData.getItemLayout(idx);
  29951. var line = createLine(linePoints);
  29952. line.shape.percent = 0;
  29953. graphic.initProps(line, {
  29954. shape: {
  29955. percent: 1
  29956. }
  29957. }, seriesModel, idx);
  29958. this.add(line);
  29959. var label = new graphic.Text({
  29960. name: 'label'
  29961. });
  29962. this.add(label);
  29963. zrUtil.each(SYMBOL_CATEGORIES, function (symbolCategory) {
  29964. var symbol = createSymbol(symbolCategory, lineData, idx);
  29965. // symbols must added after line to make sure
  29966. // it will be updated after line#update.
  29967. // Or symbol position and rotation update in line#beforeUpdate will be one frame slow
  29968. this.add(symbol);
  29969. this[makeSymbolTypeKey(symbolCategory)] = lineData.getItemVisual(idx, symbolCategory);
  29970. }, this);
  29971. this._updateCommonStl(lineData, idx);
  29972. };
  29973. lineProto.updateData = function (lineData, idx) {
  29974. var seriesModel = lineData.hostModel;
  29975. var line = this.childOfName('line');
  29976. var linePoints = lineData.getItemLayout(idx);
  29977. var target = {
  29978. shape: {}
  29979. };
  29980. setLinePoints(target.shape, linePoints);
  29981. graphic.updateProps(line, target, seriesModel, idx);
  29982. zrUtil.each(SYMBOL_CATEGORIES, function (symbolCategory) {
  29983. var symbolType = lineData.getItemVisual(idx, symbolCategory);
  29984. var key = makeSymbolTypeKey(symbolCategory);
  29985. // Symbol changed
  29986. if (this[key] !== symbolType) {
  29987. var symbol = createSymbol(symbolCategory, lineData, idx);
  29988. this.remove(this.childOfName(symbolCategory));
  29989. this.add(symbol);
  29990. }
  29991. this[key] = symbolType;
  29992. }, this);
  29993. this._updateCommonStl(lineData, idx);
  29994. };
  29995. lineProto._updateCommonStl = function (lineData, idx) {
  29996. var seriesModel = lineData.hostModel;
  29997. var line = this.childOfName('line');
  29998. var itemModel = lineData.getItemModel(idx);
  29999. var labelModel = itemModel.getModel('label.normal');
  30000. var textStyleModel = labelModel.getModel('textStyle');
  30001. var labelHoverModel = itemModel.getModel('label.emphasis');
  30002. var textStyleHoverModel = labelHoverModel.getModel('textStyle');
  30003. var defaultText = numberUtil.round(seriesModel.getRawValue(idx));
  30004. if (isNaN(defaultText)) {
  30005. // Use name
  30006. defaultText = lineData.getName(idx);
  30007. }
  30008. line.useStyle(zrUtil.extend(
  30009. {
  30010. strokeNoScale: true,
  30011. fill: 'none',
  30012. stroke: lineData.getItemVisual(idx, 'color')
  30013. },
  30014. itemModel.getModel('lineStyle.normal').getLineStyle()
  30015. ));
  30016. line.hoverStyle = itemModel.getModel('lineStyle.emphasis').getLineStyle();
  30017. var defaultColor = lineData.getItemVisual(idx, 'color') || '#000';
  30018. var label = this.childOfName('label');
  30019. // label.afterUpdate = lineAfterUpdate;
  30020. label.setStyle({
  30021. text: labelModel.get('show')
  30022. ? zrUtil.retrieve(
  30023. seriesModel.getFormattedLabel(idx, 'normal', lineData.dataType),
  30024. defaultText
  30025. )
  30026. : '',
  30027. textFont: textStyleModel.getFont(),
  30028. fill: textStyleModel.getTextColor() || defaultColor
  30029. });
  30030. label.hoverStyle = {
  30031. text: labelHoverModel.get('show')
  30032. ? zrUtil.retrieve(
  30033. seriesModel.getFormattedLabel(idx, 'emphasis', lineData.dataType),
  30034. defaultText
  30035. )
  30036. : '',
  30037. textFont: textStyleHoverModel.getFont(),
  30038. fill: textStyleHoverModel.getTextColor() || defaultColor
  30039. };
  30040. label.__textAlign = textStyleModel.get('align');
  30041. label.__verticalAlign = textStyleModel.get('baseline');
  30042. label.__position = labelModel.get('position');
  30043. label.ignore = !label.style.text && !label.hoverStyle.text;
  30044. graphic.setHoverStyle(this);
  30045. };
  30046. lineProto.updateLayout = function (lineData, idx) {
  30047. var points = lineData.getItemLayout(idx);
  30048. var linePath = this.childOfName('line');
  30049. setLinePoints(linePath.shape, points);
  30050. linePath.dirty(true);
  30051. };
  30052. lineProto.setLinePoints = function (points) {
  30053. var linePath = this.childOfName('line');
  30054. setLinePoints(linePath.shape, points);
  30055. linePath.dirty();
  30056. };
  30057. zrUtil.inherits(Line, graphic.Group);
  30058. module.exports = Line;
  30059. /***/ },
  30060. /* 196 */
  30061. /***/ function(module, exports, __webpack_require__) {
  30062. /**
  30063. * Line path for bezier and straight line draw
  30064. */
  30065. var graphic = __webpack_require__(42);
  30066. var vec2 = __webpack_require__(16);
  30067. var straightLineProto = graphic.Line.prototype;
  30068. var bezierCurveProto = graphic.BezierCurve.prototype;
  30069. function isLine(shape) {
  30070. return shape.cpx1 == null || shape.cpy1 == null;
  30071. }
  30072. module.exports = graphic.extendShape({
  30073. type: 'ec-line',
  30074. style: {
  30075. stroke: '#000',
  30076. fill: null
  30077. },
  30078. shape: {
  30079. x1: 0,
  30080. y1: 0,
  30081. x2: 0,
  30082. y2: 0,
  30083. percent: 1,
  30084. cpx1: null,
  30085. cpy1: null
  30086. },
  30087. buildPath: function (ctx, shape) {
  30088. (isLine(shape) ? straightLineProto : bezierCurveProto).buildPath(ctx, shape);
  30089. },
  30090. pointAt: function (t) {
  30091. return isLine(this.shape)
  30092. ? straightLineProto.pointAt.call(this, t)
  30093. : bezierCurveProto.pointAt.call(this, t);
  30094. },
  30095. tangentAt: function (t) {
  30096. var shape = this.shape;
  30097. var p = isLine(shape)
  30098. ? [shape.x2 - shape.x1, shape.y2 - shape.y1]
  30099. : bezierCurveProto.tangentAt.call(this, t);
  30100. return vec2.normalize(p, p);
  30101. }
  30102. });
  30103. /***/ },
  30104. /* 197 */
  30105. /***/ function(module, exports, __webpack_require__) {
  30106. var curveTool = __webpack_require__(49);
  30107. var vec2 = __webpack_require__(16);
  30108. var v1 = [];
  30109. var v2 = [];
  30110. var v3 = [];
  30111. var quadraticAt = curveTool.quadraticAt;
  30112. var v2DistSquare = vec2.distSquare;
  30113. var mathAbs = Math.abs;
  30114. function intersectCurveCircle(curvePoints, center, radius) {
  30115. var p0 = curvePoints[0];
  30116. var p1 = curvePoints[1];
  30117. var p2 = curvePoints[2];
  30118. var d = Infinity;
  30119. var t;
  30120. var radiusSquare = radius * radius;
  30121. var interval = 0.1;
  30122. for (var _t = 0.1; _t <= 0.9; _t += 0.1) {
  30123. v1[0] = quadraticAt(p0[0], p1[0], p2[0], _t);
  30124. v1[1] = quadraticAt(p0[1], p1[1], p2[1], _t);
  30125. var diff = mathAbs(v2DistSquare(v1, center) - radiusSquare);
  30126. if (diff < d) {
  30127. d = diff;
  30128. t = _t;
  30129. }
  30130. }
  30131. // Assume the segment is monotone,Find root through Bisection method
  30132. // At most 32 iteration
  30133. for (var i = 0; i < 32; i++) {
  30134. // var prev = t - interval;
  30135. var next = t + interval;
  30136. // v1[0] = quadraticAt(p0[0], p1[0], p2[0], prev);
  30137. // v1[1] = quadraticAt(p0[1], p1[1], p2[1], prev);
  30138. v2[0] = quadraticAt(p0[0], p1[0], p2[0], t);
  30139. v2[1] = quadraticAt(p0[1], p1[1], p2[1], t);
  30140. v3[0] = quadraticAt(p0[0], p1[0], p2[0], next);
  30141. v3[1] = quadraticAt(p0[1], p1[1], p2[1], next);
  30142. var diff = v2DistSquare(v2, center) - radiusSquare;
  30143. if (mathAbs(diff) < 1e-2) {
  30144. break;
  30145. }
  30146. // var prevDiff = v2DistSquare(v1, center) - radiusSquare;
  30147. var nextDiff = v2DistSquare(v3, center) - radiusSquare;
  30148. interval /= 2;
  30149. if (diff < 0) {
  30150. if (nextDiff >= 0) {
  30151. t = t + interval;
  30152. }
  30153. else {
  30154. t = t - interval;
  30155. }
  30156. }
  30157. else {
  30158. if (nextDiff >= 0) {
  30159. t = t - interval;
  30160. }
  30161. else {
  30162. t = t + interval;
  30163. }
  30164. }
  30165. }
  30166. return t;
  30167. }
  30168. // Adjust edge to avoid
  30169. module.exports = function (graph, scale) {
  30170. var tmp0 = [];
  30171. var quadraticSubdivide = curveTool.quadraticSubdivide;
  30172. var pts = [[], [], []];
  30173. var pts2 = [[], []];
  30174. var v = [];
  30175. scale /= 2;
  30176. graph.eachEdge(function (edge) {
  30177. var linePoints = edge.getLayout();
  30178. var fromSymbol = edge.getVisual('fromSymbol');
  30179. var toSymbol = edge.getVisual('toSymbol');
  30180. if (!linePoints.__original) {
  30181. linePoints.__original = [
  30182. vec2.clone(linePoints[0]),
  30183. vec2.clone(linePoints[1])
  30184. ];
  30185. if (linePoints[2]) {
  30186. linePoints.__original.push(vec2.clone(linePoints[2]));
  30187. }
  30188. }
  30189. var originalPoints = linePoints.__original;
  30190. // Quadratic curve
  30191. if (linePoints[2] != null) {
  30192. vec2.copy(pts[0], originalPoints[0]);
  30193. vec2.copy(pts[1], originalPoints[2]);
  30194. vec2.copy(pts[2], originalPoints[1]);
  30195. if (fromSymbol && fromSymbol != 'none') {
  30196. var t = intersectCurveCircle(pts, originalPoints[0], edge.node1.getVisual('symbolSize') * scale);
  30197. // Subdivide and get the second
  30198. quadraticSubdivide(pts[0][0], pts[1][0], pts[2][0], t, tmp0);
  30199. pts[0][0] = tmp0[3];
  30200. pts[1][0] = tmp0[4];
  30201. quadraticSubdivide(pts[0][1], pts[1][1], pts[2][1], t, tmp0);
  30202. pts[0][1] = tmp0[3];
  30203. pts[1][1] = tmp0[4];
  30204. }
  30205. if (toSymbol && toSymbol != 'none') {
  30206. var t = intersectCurveCircle(pts, originalPoints[1], edge.node2.getVisual('symbolSize') * scale);
  30207. // Subdivide and get the first
  30208. quadraticSubdivide(pts[0][0], pts[1][0], pts[2][0], t, tmp0);
  30209. pts[1][0] = tmp0[1];
  30210. pts[2][0] = tmp0[2];
  30211. quadraticSubdivide(pts[0][1], pts[1][1], pts[2][1], t, tmp0);
  30212. pts[1][1] = tmp0[1];
  30213. pts[2][1] = tmp0[2];
  30214. }
  30215. // Copy back to layout
  30216. vec2.copy(linePoints[0], pts[0]);
  30217. vec2.copy(linePoints[1], pts[2]);
  30218. vec2.copy(linePoints[2], pts[1]);
  30219. }
  30220. // Line
  30221. else {
  30222. vec2.copy(pts2[0], originalPoints[0]);
  30223. vec2.copy(pts2[1], originalPoints[1]);
  30224. vec2.sub(v, pts2[1], pts2[0]);
  30225. vec2.normalize(v, v);
  30226. if (fromSymbol && fromSymbol != 'none') {
  30227. vec2.scaleAndAdd(pts2[0], pts2[0], v, edge.node1.getVisual('symbolSize') * scale);
  30228. }
  30229. if (toSymbol && toSymbol != 'none') {
  30230. vec2.scaleAndAdd(pts2[1], pts2[1], v, -edge.node2.getVisual('symbolSize') * scale);
  30231. }
  30232. vec2.copy(linePoints[0], pts2[0]);
  30233. vec2.copy(linePoints[1], pts2[1]);
  30234. }
  30235. });
  30236. };
  30237. /***/ },
  30238. /* 198 */
  30239. /***/ function(module, exports, __webpack_require__) {
  30240. var echarts = __webpack_require__(1);
  30241. var roamHelper = __webpack_require__(172);
  30242. var actionInfo = {
  30243. type: 'graphRoam',
  30244. event: 'graphRoam',
  30245. update: 'none'
  30246. };
  30247. /**
  30248. * @payload
  30249. * @property {string} name Series name
  30250. * @property {number} [dx]
  30251. * @property {number} [dy]
  30252. * @property {number} [zoom]
  30253. * @property {number} [originX]
  30254. * @property {number} [originY]
  30255. */
  30256. echarts.registerAction(actionInfo, function (payload, ecModel) {
  30257. ecModel.eachComponent({mainType: 'series', query: payload}, function (seriesModel) {
  30258. var coordSys = seriesModel.coordinateSystem;
  30259. var res = roamHelper.updateCenterAndZoom(coordSys, payload);
  30260. seriesModel.setCenter
  30261. && seriesModel.setCenter(res.center);
  30262. seriesModel.setZoom
  30263. && seriesModel.setZoom(res.zoom);
  30264. });
  30265. });
  30266. /***/ },
  30267. /* 199 */
  30268. /***/ function(module, exports) {
  30269. module.exports = function (ecModel) {
  30270. var legendModels = ecModel.findComponents({
  30271. mainType: 'legend'
  30272. });
  30273. if (!legendModels || !legendModels.length) {
  30274. return;
  30275. }
  30276. ecModel.eachSeriesByType('graph', function (graphSeries) {
  30277. var categoriesData = graphSeries.getCategoriesData();
  30278. var graph = graphSeries.getGraph();
  30279. var data = graph.data;
  30280. var categoryNames = categoriesData.mapArray(categoriesData.getName);
  30281. data.filterSelf(function (idx) {
  30282. var model = data.getItemModel(idx);
  30283. var category = model.getShallow('category');
  30284. if (category != null) {
  30285. if (typeof category === 'number') {
  30286. category = categoryNames[category];
  30287. }
  30288. // If in any legend component the status is not selected.
  30289. for (var i = 0; i < legendModels.length; i++) {
  30290. if (!legendModels[i].isSelected(category)) {
  30291. return false;
  30292. }
  30293. }
  30294. }
  30295. return true;
  30296. });
  30297. }, this);
  30298. };
  30299. /***/ },
  30300. /* 200 */
  30301. /***/ function(module, exports) {
  30302. module.exports = function (ecModel) {
  30303. ecModel.eachSeriesByType('graph', function (seriesModel) {
  30304. var colorList = seriesModel.get('color');
  30305. var categoriesData = seriesModel.getCategoriesData();
  30306. var data = seriesModel.getData();
  30307. var categoryNameIdxMap = {};
  30308. categoriesData.each(function (idx) {
  30309. categoryNameIdxMap[categoriesData.getName(idx)] = idx;
  30310. var itemModel = categoriesData.getItemModel(idx);
  30311. var rawIdx = categoriesData.getRawIndex(idx);
  30312. var color = itemModel.get('itemStyle.normal.color')
  30313. || colorList[rawIdx % colorList.length];
  30314. categoriesData.setItemVisual(idx, 'color', color);
  30315. });
  30316. // Assign category color to visual
  30317. if (categoriesData.count()) {
  30318. data.each(function (idx) {
  30319. var model = data.getItemModel(idx);
  30320. var category = model.getShallow('category');
  30321. if (category != null) {
  30322. if (typeof category === 'string') {
  30323. category = categoryNameIdxMap[category];
  30324. }
  30325. if (!data.getItemVisual(idx, 'color', true)) {
  30326. data.setItemVisual(
  30327. idx, 'color',
  30328. categoriesData.getItemVisual(category, 'color')
  30329. );
  30330. }
  30331. }
  30332. });
  30333. }
  30334. });
  30335. };
  30336. /***/ },
  30337. /* 201 */
  30338. /***/ function(module, exports) {
  30339. function normalize(a) {
  30340. if (!(a instanceof Array)) {
  30341. a = [a, a];
  30342. }
  30343. return a;
  30344. }
  30345. module.exports = function (ecModel) {
  30346. ecModel.eachSeriesByType('graph', function (seriesModel) {
  30347. var edgeData = seriesModel.getEdgeData();
  30348. var symbolType = normalize(seriesModel.get('edgeSymbol'));
  30349. var symbolSize = normalize(seriesModel.get('edgeSymbolSize'));
  30350. edgeData.setVisual('fromSymbol', symbolType && symbolType[0]);
  30351. edgeData.setVisual('toSymbol', symbolType && symbolType[1]);
  30352. edgeData.setVisual('fromSymbolSize', symbolSize && symbolSize[0]);
  30353. edgeData.setVisual('toSymbolSize', symbolSize && symbolSize[1]);
  30354. edgeData.setVisual('color', seriesModel.get('lineStyle.normal.color'));
  30355. edgeData.each(function (idx) {
  30356. var itemModel = edgeData.getItemModel(idx);
  30357. var symbolType = normalize(itemModel.getShallow('symbol', true));
  30358. var symbolSize = normalize(itemModel.getShallow('symbolSize', true));
  30359. symbolType[0] && edgeData.setItemVisual(idx, 'fromSymbol', symbolType[0]);
  30360. symbolType[1] && edgeData.setItemVisual(idx, 'toSymbol', symbolType[1]);
  30361. symbolSize[0] && edgeData.setItemVisual(idx, 'fromSymbolSize', symbolSize[0]);
  30362. symbolSize[1] && edgeData.setItemVisual(idx, 'toSymbolSize', symbolSize[1]);
  30363. });
  30364. });
  30365. };
  30366. /***/ },
  30367. /* 202 */
  30368. /***/ function(module, exports, __webpack_require__) {
  30369. var simpleLayoutHelper = __webpack_require__(203);
  30370. var simpleLayoutEdge = __webpack_require__(204);
  30371. module.exports = function (ecModel, api) {
  30372. ecModel.eachSeriesByType('graph', function (seriesModel) {
  30373. var layout = seriesModel.get('layout');
  30374. var coordSys = seriesModel.coordinateSystem;
  30375. if (coordSys && coordSys.type !== 'view') {
  30376. var data = seriesModel.getData();
  30377. data.each(coordSys.dimensions, function (x, y, idx) {
  30378. if (!isNaN(x) && !isNaN(y)) {
  30379. data.setItemLayout(idx, coordSys.dataToPoint([x, y]));
  30380. }
  30381. else {
  30382. // Also {Array.<number>}, not undefined to avoid if...else... statement
  30383. data.setItemLayout(idx, [NaN, NaN]);
  30384. }
  30385. });
  30386. simpleLayoutEdge(data.graph);
  30387. }
  30388. else if (!layout || layout === 'none') {
  30389. simpleLayoutHelper(seriesModel);
  30390. }
  30391. });
  30392. };
  30393. /***/ },
  30394. /* 203 */
  30395. /***/ function(module, exports, __webpack_require__) {
  30396. var simpleLayoutEdge = __webpack_require__(204);
  30397. module.exports = function (seriesModel) {
  30398. var coordSys = seriesModel.coordinateSystem;
  30399. if (coordSys && coordSys.type !== 'view') {
  30400. return;
  30401. }
  30402. var graph = seriesModel.getGraph();
  30403. graph.eachNode(function (node) {
  30404. var model = node.getModel();
  30405. node.setLayout([+model.get('x'), +model.get('y')]);
  30406. });
  30407. simpleLayoutEdge(graph);
  30408. };
  30409. /***/ },
  30410. /* 204 */
  30411. /***/ function(module, exports, __webpack_require__) {
  30412. var vec2 = __webpack_require__(16);
  30413. module.exports = function (graph) {
  30414. graph.eachEdge(function (edge) {
  30415. var curveness = edge.getModel().get('lineStyle.normal.curveness') || 0;
  30416. var p1 = vec2.clone(edge.node1.getLayout());
  30417. var p2 = vec2.clone(edge.node2.getLayout());
  30418. var points = [p1, p2];
  30419. if (curveness > 0) {
  30420. points.push([
  30421. (p1[0] + p2[0]) / 2 - (p1[1] - p2[1]) * curveness,
  30422. (p1[1] + p2[1]) / 2 - (p2[0] - p1[0]) * curveness
  30423. ]);
  30424. }
  30425. edge.setLayout(points);
  30426. });
  30427. };
  30428. /***/ },
  30429. /* 205 */
  30430. /***/ function(module, exports, __webpack_require__) {
  30431. var circularLayoutHelper = __webpack_require__(206);
  30432. module.exports = function (ecModel, api) {
  30433. ecModel.eachSeriesByType('graph', function (seriesModel) {
  30434. if (seriesModel.get('layout') === 'circular') {
  30435. circularLayoutHelper(seriesModel);
  30436. }
  30437. });
  30438. };
  30439. /***/ },
  30440. /* 206 */
  30441. /***/ function(module, exports, __webpack_require__) {
  30442. var vec2 = __webpack_require__(16);
  30443. module.exports = function (seriesModel) {
  30444. var coordSys = seriesModel.coordinateSystem;
  30445. if (coordSys && coordSys.type !== 'view') {
  30446. return;
  30447. }
  30448. var rect = coordSys.getBoundingRect();
  30449. var nodeData = seriesModel.getData();
  30450. var graph = nodeData.graph;
  30451. var angle = 0;
  30452. var sum = nodeData.getSum('value');
  30453. var unitAngle = Math.PI * 2 / (sum || nodeData.count());
  30454. var cx = rect.width / 2 + rect.x;
  30455. var cy = rect.height / 2 + rect.y;
  30456. var r = Math.min(rect.width, rect.height) / 2;
  30457. graph.eachNode(function (node) {
  30458. var value = node.getValue('value');
  30459. angle += unitAngle * (sum ? value : 2) / 2;
  30460. node.setLayout([
  30461. r * Math.cos(angle) + cx,
  30462. r * Math.sin(angle) + cy
  30463. ]);
  30464. angle += unitAngle * (sum ? value : 2) / 2;
  30465. });
  30466. graph.eachEdge(function (edge) {
  30467. var curveness = edge.getModel().get('lineStyle.normal.curveness') || 0;
  30468. var p1 = vec2.clone(edge.node1.getLayout());
  30469. var p2 = vec2.clone(edge.node2.getLayout());
  30470. var cp1;
  30471. var x12 = (p1[0] + p2[0]) / 2;
  30472. var y12 = (p1[1] + p2[1]) / 2;
  30473. if (curveness > 0) {
  30474. curveness *= 3;
  30475. cp1 = [
  30476. cx * curveness + x12 * (1 - curveness),
  30477. cy * curveness + y12 * (1 - curveness)
  30478. ];
  30479. }
  30480. edge.setLayout([p1, p2, cp1]);
  30481. });
  30482. };
  30483. /***/ },
  30484. /* 207 */
  30485. /***/ function(module, exports, __webpack_require__) {
  30486. var forceHelper = __webpack_require__(208);
  30487. var numberUtil = __webpack_require__(7);
  30488. var simpleLayoutHelper = __webpack_require__(203);
  30489. var circularLayoutHelper = __webpack_require__(206);
  30490. var vec2 = __webpack_require__(16);
  30491. module.exports = function (ecModel, api) {
  30492. ecModel.eachSeriesByType('graph', function (graphSeries) {
  30493. var coordSys = graphSeries.coordinateSystem;
  30494. if (coordSys && coordSys.type !== 'view') {
  30495. return;
  30496. }
  30497. if (graphSeries.get('layout') === 'force') {
  30498. var preservedPoints = graphSeries.preservedPoints || {};
  30499. var graph = graphSeries.getGraph();
  30500. var nodeData = graph.data;
  30501. var edgeData = graph.edgeData;
  30502. var forceModel = graphSeries.getModel('force');
  30503. var initLayout = forceModel.get('initLayout');
  30504. if (graphSeries.preservedPoints) {
  30505. nodeData.each(function (idx) {
  30506. var id = nodeData.getId(idx);
  30507. nodeData.setItemLayout(idx, preservedPoints[id] || [NaN, NaN]);
  30508. });
  30509. }
  30510. else if (!initLayout || initLayout === 'none') {
  30511. simpleLayoutHelper(graphSeries);
  30512. }
  30513. else if (initLayout === 'circular') {
  30514. circularLayoutHelper(graphSeries);
  30515. }
  30516. var nodeDataExtent = nodeData.getDataExtent('value');
  30517. // var edgeDataExtent = edgeData.getDataExtent('value');
  30518. var repulsion = forceModel.get('repulsion');
  30519. var edgeLength = forceModel.get('edgeLength');
  30520. var nodes = nodeData.mapArray('value', function (value, idx) {
  30521. var point = nodeData.getItemLayout(idx);
  30522. // var w = numberUtil.linearMap(value, nodeDataExtent, [0, 50]);
  30523. var rep = numberUtil.linearMap(value, nodeDataExtent, [0, repulsion]) || (repulsion / 2);
  30524. return {
  30525. w: rep,
  30526. rep: rep,
  30527. p: (!point || isNaN(point[0]) || isNaN(point[1])) ? null : point
  30528. };
  30529. });
  30530. var edges = edgeData.mapArray('value', function (value, idx) {
  30531. var edge = graph.getEdgeByIndex(idx);
  30532. // var w = numberUtil.linearMap(value, edgeDataExtent, [0, 100]);
  30533. return {
  30534. n1: nodes[edge.node1.dataIndex],
  30535. n2: nodes[edge.node2.dataIndex],
  30536. d: edgeLength,
  30537. curveness: edge.getModel().get('lineStyle.normal.curveness') || 0
  30538. };
  30539. });
  30540. var coordSys = graphSeries.coordinateSystem;
  30541. var rect = coordSys.getBoundingRect();
  30542. var forceInstance = forceHelper(nodes, edges, {
  30543. rect: rect,
  30544. gravity: forceModel.get('gravity')
  30545. });
  30546. var oldStep = forceInstance.step;
  30547. forceInstance.step = function (cb) {
  30548. for (var i = 0, l = nodes.length; i < l; i++) {
  30549. if (nodes[i].fixed) {
  30550. // Write back to layout instance
  30551. vec2.copy(nodes[i].p, graph.getNodeByIndex(i).getLayout());
  30552. }
  30553. }
  30554. oldStep(function (nodes, edges, stopped) {
  30555. for (var i = 0, l = nodes.length; i < l; i++) {
  30556. if (!nodes[i].fixed) {
  30557. graph.getNodeByIndex(i).setLayout(nodes[i].p);
  30558. }
  30559. preservedPoints[nodeData.getId(i)] = nodes[i].p;
  30560. }
  30561. for (var i = 0, l = edges.length; i < l; i++) {
  30562. var e = edges[i];
  30563. var p1 = e.n1.p;
  30564. var p2 = e.n2.p;
  30565. var points = [p1, p2];
  30566. if (e.curveness > 0) {
  30567. points.push([
  30568. (p1[0] + p2[0]) / 2 - (p1[1] - p2[1]) * e.curveness,
  30569. (p1[1] + p2[1]) / 2 - (p2[0] - p1[0]) * e.curveness
  30570. ]);
  30571. }
  30572. graph.getEdgeByIndex(i).setLayout(points);
  30573. }
  30574. // Update layout
  30575. cb && cb(stopped);
  30576. });
  30577. };
  30578. graphSeries.forceLayout = forceInstance;
  30579. graphSeries.preservedPoints = preservedPoints;
  30580. // Step to get the layout
  30581. forceInstance.step();
  30582. }
  30583. else {
  30584. // Remove prev injected forceLayout instance
  30585. graphSeries.forceLayout = null;
  30586. }
  30587. });
  30588. };
  30589. /***/ },
  30590. /* 208 */
  30591. /***/ function(module, exports, __webpack_require__) {
  30592. var vec2 = __webpack_require__(16);
  30593. var scaleAndAdd = vec2.scaleAndAdd;
  30594. // function adjacentNode(n, e) {
  30595. // return e.n1 === n ? e.n2 : e.n1;
  30596. // }
  30597. module.exports = function (nodes, edges, opts) {
  30598. var rect = opts.rect;
  30599. var width = rect.width;
  30600. var height = rect.height;
  30601. var center = [rect.x + width / 2, rect.y + height / 2];
  30602. // var scale = opts.scale || 1;
  30603. var gravity = opts.gravity == null ? 0.1 : opts.gravity;
  30604. // for (var i = 0; i < edges.length; i++) {
  30605. // var e = edges[i];
  30606. // var n1 = e.n1;
  30607. // var n2 = e.n2;
  30608. // n1.edges = n1.edges || [];
  30609. // n2.edges = n2.edges || [];
  30610. // n1.edges.push(e);
  30611. // n2.edges.push(e);
  30612. // }
  30613. // Init position
  30614. for (var i = 0; i < nodes.length; i++) {
  30615. var n = nodes[i];
  30616. if (!n.p) {
  30617. // Use the position from first adjecent node with defined position
  30618. // Or use a random position
  30619. // From d3
  30620. // if (n.edges) {
  30621. // var j = -1;
  30622. // while (++j < n.edges.length) {
  30623. // var e = n.edges[j];
  30624. // var other = adjacentNode(n, e);
  30625. // if (other.p) {
  30626. // n.p = vec2.clone(other.p);
  30627. // break;
  30628. // }
  30629. // }
  30630. // }
  30631. // if (!n.p) {
  30632. n.p = vec2.create(
  30633. width * (Math.random() - 0.5) + center[0],
  30634. height * (Math.random() - 0.5) + center[1]
  30635. );
  30636. // }
  30637. }
  30638. n.pp = vec2.clone(n.p);
  30639. n.edges = null;
  30640. }
  30641. // Formula in 'Graph Drawing by Force-directed Placement'
  30642. // var k = scale * Math.sqrt(width * height / nodes.length);
  30643. // var k2 = k * k;
  30644. var friction = 0.6;
  30645. return {
  30646. warmUp: function () {
  30647. friction = 0.5;
  30648. },
  30649. setFixed: function (idx) {
  30650. nodes[idx].fixed = true;
  30651. },
  30652. setUnfixed: function (idx) {
  30653. nodes[idx].fixed = false;
  30654. },
  30655. step: function (cb) {
  30656. var v12 = [];
  30657. var nLen = nodes.length;
  30658. for (var i = 0; i < edges.length; i++) {
  30659. var e = edges[i];
  30660. var n1 = e.n1;
  30661. var n2 = e.n2;
  30662. vec2.sub(v12, n2.p, n1.p);
  30663. var d = vec2.len(v12) - e.d;
  30664. var w = n2.w / (n1.w + n2.w);
  30665. vec2.normalize(v12, v12);
  30666. !n1.fixed && scaleAndAdd(n1.p, n1.p, v12, w * d * friction);
  30667. !n2.fixed && scaleAndAdd(n2.p, n2.p, v12, -(1 - w) * d * friction);
  30668. }
  30669. // Gravity
  30670. for (var i = 0; i < nLen; i++) {
  30671. var n = nodes[i];
  30672. if (!n.fixed) {
  30673. vec2.sub(v12, center, n.p);
  30674. // var d = vec2.len(v12);
  30675. // vec2.scale(v12, v12, 1 / d);
  30676. // var gravityFactor = gravity;
  30677. vec2.scaleAndAdd(n.p, n.p, v12, gravity * friction);
  30678. }
  30679. }
  30680. // Repulsive
  30681. // PENDING
  30682. for (var i = 0; i < nLen; i++) {
  30683. var n1 = nodes[i];
  30684. for (var j = i + 1; j < nLen; j++) {
  30685. var n2 = nodes[j];
  30686. vec2.sub(v12, n2.p, n1.p);
  30687. var d = vec2.len(v12);
  30688. if (d === 0) {
  30689. // Random repulse
  30690. vec2.set(v12, Math.random() - 0.5, Math.random() - 0.5);
  30691. d = 1;
  30692. }
  30693. var repFact = (n1.rep + n2.rep) / d / d;
  30694. !n1.fixed && scaleAndAdd(n1.pp, n1.pp, v12, repFact);
  30695. !n2.fixed && scaleAndAdd(n2.pp, n2.pp, v12, -repFact);
  30696. }
  30697. }
  30698. var v = [];
  30699. for (var i = 0; i < nLen; i++) {
  30700. var n = nodes[i];
  30701. if (!n.fixed) {
  30702. vec2.sub(v, n.p, n.pp);
  30703. vec2.scaleAndAdd(n.p, n.p, v, friction);
  30704. vec2.copy(n.pp, n.p);
  30705. }
  30706. }
  30707. friction = friction * 0.992;
  30708. cb && cb(nodes, edges, friction < 0.01);
  30709. }
  30710. };
  30711. };
  30712. /***/ },
  30713. /* 209 */
  30714. /***/ function(module, exports, __webpack_require__) {
  30715. // FIXME Where to create the simple view coordinate system
  30716. var View = __webpack_require__(163);
  30717. var layout = __webpack_require__(21);
  30718. var bbox = __webpack_require__(50);
  30719. function getViewRect(seriesModel, api, aspect) {
  30720. var option = seriesModel.getBoxLayoutParams();
  30721. option.aspect = aspect;
  30722. return layout.getLayoutRect(option, {
  30723. width: api.getWidth(),
  30724. height: api.getHeight()
  30725. });
  30726. }
  30727. module.exports = function (ecModel, api) {
  30728. var viewList = [];
  30729. ecModel.eachSeriesByType('graph', function (seriesModel) {
  30730. var coordSysType = seriesModel.get('coordinateSystem');
  30731. if (!coordSysType || coordSysType === 'view') {
  30732. var viewCoordSys = new View();
  30733. viewList.push(viewCoordSys);
  30734. var data = seriesModel.getData();
  30735. var positions = data.mapArray(function (idx) {
  30736. var itemModel = data.getItemModel(idx);
  30737. return [+itemModel.get('x'), +itemModel.get('y')];
  30738. });
  30739. var min = [];
  30740. var max = [];
  30741. bbox.fromPoints(positions, min, max);
  30742. // If width or height is 0
  30743. if (max[0] - min[0] === 0) {
  30744. max[0] += 1;
  30745. min[0] -= 1;
  30746. }
  30747. if (max[1] - min[1] === 0) {
  30748. max[1] += 1;
  30749. min[1] -= 1;
  30750. }
  30751. var aspect = (max[0] - min[0]) / (max[1] - min[1]);
  30752. // FIXME If get view rect after data processed?
  30753. var viewRect = getViewRect(seriesModel, api, aspect);
  30754. // Position may be NaN, use view rect instead
  30755. if (isNaN(aspect)) {
  30756. min = [viewRect.x, viewRect.y];
  30757. max = [viewRect.x + viewRect.width, viewRect.y + viewRect.height];
  30758. }
  30759. var bbWidth = max[0] - min[0];
  30760. var bbHeight = max[1] - min[1];
  30761. var viewWidth = viewRect.width;
  30762. var viewHeight = viewRect.height;
  30763. viewCoordSys = seriesModel.coordinateSystem = new View();
  30764. viewCoordSys.zoomLimit = seriesModel.get('scaleLimit');
  30765. viewCoordSys.setBoundingRect(
  30766. min[0], min[1], bbWidth, bbHeight
  30767. );
  30768. viewCoordSys.setViewRect(
  30769. viewRect.x, viewRect.y, viewWidth, viewHeight
  30770. );
  30771. // Update roam info
  30772. viewCoordSys.setCenter(seriesModel.get('center'));
  30773. viewCoordSys.setZoom(seriesModel.get('zoom'));
  30774. }
  30775. });
  30776. return viewList;
  30777. };
  30778. /***/ },
  30779. /* 210 */
  30780. /***/ function(module, exports, __webpack_require__) {
  30781. __webpack_require__(211);
  30782. __webpack_require__(212);
  30783. /***/ },
  30784. /* 211 */
  30785. /***/ function(module, exports, __webpack_require__) {
  30786. var List = __webpack_require__(95);
  30787. var SeriesModel = __webpack_require__(27);
  30788. var zrUtil = __webpack_require__(3);
  30789. var GaugeSeries = SeriesModel.extend({
  30790. type: 'series.gauge',
  30791. getInitialData: function (option, ecModel) {
  30792. var list = new List(['value'], this);
  30793. var dataOpt = option.data || [];
  30794. if (!zrUtil.isArray(dataOpt)) {
  30795. dataOpt = [dataOpt];
  30796. }
  30797. // Only use the first data item
  30798. list.initData(dataOpt);
  30799. return list;
  30800. },
  30801. defaultOption: {
  30802. zlevel: 0,
  30803. z: 2,
  30804. // 默认全局居中
  30805. center: ['50%', '50%'],
  30806. legendHoverLink: true,
  30807. radius: '75%',
  30808. startAngle: 225,
  30809. endAngle: -45,
  30810. clockwise: true,
  30811. // 最小值
  30812. min: 0,
  30813. // 最大值
  30814. max: 100,
  30815. // 分割段数,默认为10
  30816. splitNumber: 10,
  30817. // 坐标轴线
  30818. axisLine: {
  30819. // 默认显示,属性show控制显示与否
  30820. show: true,
  30821. lineStyle: { // 属性lineStyle控制线条样式
  30822. color: [[0.2, '#91c7ae'], [0.8, '#63869e'], [1, '#c23531']],
  30823. width: 30
  30824. }
  30825. },
  30826. // 分隔线
  30827. splitLine: {
  30828. // 默认显示,属性show控制显示与否
  30829. show: true,
  30830. // 属性length控制线长
  30831. length: 30,
  30832. // 属性lineStyle(详见lineStyle)控制线条样式
  30833. lineStyle: {
  30834. color: '#eee',
  30835. width: 2,
  30836. type: 'solid'
  30837. }
  30838. },
  30839. // 坐标轴小标记
  30840. axisTick: {
  30841. // 属性show控制显示与否,默认不显示
  30842. show: true,
  30843. // 每份split细分多少段
  30844. splitNumber: 5,
  30845. // 属性length控制线长
  30846. length: 8,
  30847. // 属性lineStyle控制线条样式
  30848. lineStyle: {
  30849. color: '#eee',
  30850. width: 1,
  30851. type: 'solid'
  30852. }
  30853. },
  30854. axisLabel: {
  30855. show: true,
  30856. // formatter: null,
  30857. textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  30858. color: 'auto'
  30859. }
  30860. },
  30861. pointer: {
  30862. show: true,
  30863. length: '80%',
  30864. width: 8
  30865. },
  30866. itemStyle: {
  30867. normal: {
  30868. color: 'auto'
  30869. }
  30870. },
  30871. title: {
  30872. show: true,
  30873. // x, y,单位px
  30874. offsetCenter: [0, '-40%'],
  30875. // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  30876. textStyle: {
  30877. color: '#333',
  30878. fontSize: 15
  30879. }
  30880. },
  30881. detail: {
  30882. show: true,
  30883. backgroundColor: 'rgba(0,0,0,0)',
  30884. borderWidth: 0,
  30885. borderColor: '#ccc',
  30886. width: 100,
  30887. height: 40,
  30888. // x, y,单位px
  30889. offsetCenter: [0, '40%'],
  30890. // formatter: null,
  30891. // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  30892. textStyle: {
  30893. color: 'auto',
  30894. fontSize: 30
  30895. }
  30896. }
  30897. }
  30898. });
  30899. module.exports = GaugeSeries;
  30900. /***/ },
  30901. /* 212 */
  30902. /***/ function(module, exports, __webpack_require__) {
  30903. var PointerPath = __webpack_require__(213);
  30904. var graphic = __webpack_require__(42);
  30905. var numberUtil = __webpack_require__(7);
  30906. var parsePercent = numberUtil.parsePercent;
  30907. function parsePosition(seriesModel, api) {
  30908. var center = seriesModel.get('center');
  30909. var width = api.getWidth();
  30910. var height = api.getHeight();
  30911. var size = Math.min(width, height);
  30912. var cx = parsePercent(center[0], api.getWidth());
  30913. var cy = parsePercent(center[1], api.getHeight());
  30914. var r = parsePercent(seriesModel.get('radius'), size / 2);
  30915. return {
  30916. cx: cx,
  30917. cy: cy,
  30918. r: r
  30919. };
  30920. }
  30921. function formatLabel(label, labelFormatter) {
  30922. if (labelFormatter) {
  30923. if (typeof labelFormatter === 'string') {
  30924. label = labelFormatter.replace('{value}', label);
  30925. }
  30926. else if (typeof labelFormatter === 'function') {
  30927. label = labelFormatter(label);
  30928. }
  30929. }
  30930. return label;
  30931. }
  30932. var PI2 = Math.PI * 2;
  30933. var GaugeView = __webpack_require__(41).extend({
  30934. type: 'gauge',
  30935. render: function (seriesModel, ecModel, api) {
  30936. this.group.removeAll();
  30937. var colorList = seriesModel.get('axisLine.lineStyle.color');
  30938. var posInfo = parsePosition(seriesModel, api);
  30939. this._renderMain(
  30940. seriesModel, ecModel, api, colorList, posInfo
  30941. );
  30942. },
  30943. _renderMain: function (seriesModel, ecModel, api, colorList, posInfo) {
  30944. var group = this.group;
  30945. var axisLineModel = seriesModel.getModel('axisLine');
  30946. var lineStyleModel = axisLineModel.getModel('lineStyle');
  30947. var clockwise = seriesModel.get('clockwise');
  30948. var startAngle = -seriesModel.get('startAngle') / 180 * Math.PI;
  30949. var endAngle = -seriesModel.get('endAngle') / 180 * Math.PI;
  30950. var angleRangeSpan = (endAngle - startAngle) % PI2;
  30951. var prevEndAngle = startAngle;
  30952. var axisLineWidth = lineStyleModel.get('width');
  30953. for (var i = 0; i < colorList.length; i++) {
  30954. // Clamp
  30955. var percent = Math.min(Math.max(colorList[i][0], 0), 1);
  30956. var endAngle = startAngle + angleRangeSpan * percent;
  30957. var sector = new graphic.Sector({
  30958. shape: {
  30959. startAngle: prevEndAngle,
  30960. endAngle: endAngle,
  30961. cx: posInfo.cx,
  30962. cy: posInfo.cy,
  30963. clockwise: clockwise,
  30964. r0: posInfo.r - axisLineWidth,
  30965. r: posInfo.r
  30966. },
  30967. silent: true
  30968. });
  30969. sector.setStyle({
  30970. fill: colorList[i][1]
  30971. });
  30972. sector.setStyle(lineStyleModel.getLineStyle(
  30973. // Because we use sector to simulate arc
  30974. // so the properties for stroking are useless
  30975. ['color', 'borderWidth', 'borderColor']
  30976. ));
  30977. group.add(sector);
  30978. prevEndAngle = endAngle;
  30979. }
  30980. var getColor = function (percent) {
  30981. // Less than 0
  30982. if (percent <= 0) {
  30983. return colorList[0][1];
  30984. }
  30985. for (var i = 0; i < colorList.length; i++) {
  30986. if (colorList[i][0] >= percent
  30987. && (i === 0 ? 0 : colorList[i - 1][0]) < percent
  30988. ) {
  30989. return colorList[i][1];
  30990. }
  30991. }
  30992. // More than 1
  30993. return colorList[i - 1][1];
  30994. };
  30995. if (!clockwise) {
  30996. var tmp = startAngle;
  30997. startAngle = endAngle;
  30998. endAngle = tmp;
  30999. }
  31000. this._renderTicks(
  31001. seriesModel, ecModel, api, getColor, posInfo,
  31002. startAngle, endAngle, clockwise
  31003. );
  31004. this._renderPointer(
  31005. seriesModel, ecModel, api, getColor, posInfo,
  31006. startAngle, endAngle, clockwise
  31007. );
  31008. this._renderTitle(
  31009. seriesModel, ecModel, api, getColor, posInfo
  31010. );
  31011. this._renderDetail(
  31012. seriesModel, ecModel, api, getColor, posInfo
  31013. );
  31014. },
  31015. _renderTicks: function (
  31016. seriesModel, ecModel, api, getColor, posInfo,
  31017. startAngle, endAngle, clockwise
  31018. ) {
  31019. var group = this.group;
  31020. var cx = posInfo.cx;
  31021. var cy = posInfo.cy;
  31022. var r = posInfo.r;
  31023. var minVal = seriesModel.get('min');
  31024. var maxVal = seriesModel.get('max');
  31025. var splitLineModel = seriesModel.getModel('splitLine');
  31026. var tickModel = seriesModel.getModel('axisTick');
  31027. var labelModel = seriesModel.getModel('axisLabel');
  31028. var splitNumber = seriesModel.get('splitNumber');
  31029. var subSplitNumber = tickModel.get('splitNumber');
  31030. var splitLineLen = parsePercent(
  31031. splitLineModel.get('length'), r
  31032. );
  31033. var tickLen = parsePercent(
  31034. tickModel.get('length'), r
  31035. );
  31036. var angle = startAngle;
  31037. var step = (endAngle - startAngle) / splitNumber;
  31038. var subStep = step / subSplitNumber;
  31039. var splitLineStyle = splitLineModel.getModel('lineStyle').getLineStyle();
  31040. var tickLineStyle = tickModel.getModel('lineStyle').getLineStyle();
  31041. var textStyleModel = labelModel.getModel('textStyle');
  31042. for (var i = 0; i <= splitNumber; i++) {
  31043. var unitX = Math.cos(angle);
  31044. var unitY = Math.sin(angle);
  31045. // Split line
  31046. if (splitLineModel.get('show')) {
  31047. var splitLine = new graphic.Line({
  31048. shape: {
  31049. x1: unitX * r + cx,
  31050. y1: unitY * r + cy,
  31051. x2: unitX * (r - splitLineLen) + cx,
  31052. y2: unitY * (r - splitLineLen) + cy
  31053. },
  31054. style: splitLineStyle,
  31055. silent: true
  31056. });
  31057. if (splitLineStyle.stroke === 'auto') {
  31058. splitLine.setStyle({
  31059. stroke: getColor(i / splitNumber)
  31060. });
  31061. }
  31062. group.add(splitLine);
  31063. }
  31064. // Label
  31065. if (labelModel.get('show')) {
  31066. var label = formatLabel(
  31067. numberUtil.round(i / splitNumber * (maxVal - minVal) + minVal),
  31068. labelModel.get('formatter')
  31069. );
  31070. var text = new graphic.Text({
  31071. style: {
  31072. text: label,
  31073. x: unitX * (r - splitLineLen - 5) + cx,
  31074. y: unitY * (r - splitLineLen - 5) + cy,
  31075. fill: textStyleModel.getTextColor(),
  31076. textFont: textStyleModel.getFont(),
  31077. textVerticalAlign: unitY < -0.4 ? 'top' : (unitY > 0.4 ? 'bottom' : 'middle'),
  31078. textAlign: unitX < -0.4 ? 'left' : (unitX > 0.4 ? 'right' : 'center')
  31079. },
  31080. silent: true
  31081. });
  31082. if (text.style.fill === 'auto') {
  31083. text.setStyle({
  31084. fill: getColor(i / splitNumber)
  31085. });
  31086. }
  31087. group.add(text);
  31088. }
  31089. // Axis tick
  31090. if (tickModel.get('show') && i !== splitNumber) {
  31091. for (var j = 0; j <= subSplitNumber; j++) {
  31092. var unitX = Math.cos(angle);
  31093. var unitY = Math.sin(angle);
  31094. var tickLine = new graphic.Line({
  31095. shape: {
  31096. x1: unitX * r + cx,
  31097. y1: unitY * r + cy,
  31098. x2: unitX * (r - tickLen) + cx,
  31099. y2: unitY * (r - tickLen) + cy
  31100. },
  31101. silent: true,
  31102. style: tickLineStyle
  31103. });
  31104. if (tickLineStyle.stroke === 'auto') {
  31105. tickLine.setStyle({
  31106. stroke: getColor((i + j / subSplitNumber) / splitNumber)
  31107. });
  31108. }
  31109. group.add(tickLine);
  31110. angle += subStep;
  31111. }
  31112. angle -= subStep;
  31113. }
  31114. else {
  31115. angle += step;
  31116. }
  31117. }
  31118. },
  31119. _renderPointer: function (
  31120. seriesModel, ecModel, api, getColor, posInfo,
  31121. startAngle, endAngle, clockwise
  31122. ) {
  31123. var valueExtent = [+seriesModel.get('min'), +seriesModel.get('max')];
  31124. var angleExtent = [startAngle, endAngle];
  31125. if (!clockwise) {
  31126. angleExtent = angleExtent.reverse();
  31127. }
  31128. var data = seriesModel.getData();
  31129. var oldData = this._data;
  31130. var group = this.group;
  31131. data.diff(oldData)
  31132. .add(function (idx) {
  31133. var pointer = new PointerPath({
  31134. shape: {
  31135. angle: startAngle
  31136. }
  31137. });
  31138. graphic.updateProps(pointer, {
  31139. shape: {
  31140. angle: numberUtil.linearMap(data.get('value', idx), valueExtent, angleExtent, true)
  31141. }
  31142. }, seriesModel);
  31143. group.add(pointer);
  31144. data.setItemGraphicEl(idx, pointer);
  31145. })
  31146. .update(function (newIdx, oldIdx) {
  31147. var pointer = oldData.getItemGraphicEl(oldIdx);
  31148. graphic.updateProps(pointer, {
  31149. shape: {
  31150. angle: numberUtil.linearMap(data.get('value', newIdx), valueExtent, angleExtent, true)
  31151. }
  31152. }, seriesModel);
  31153. group.add(pointer);
  31154. data.setItemGraphicEl(newIdx, pointer);
  31155. })
  31156. .remove(function (idx) {
  31157. var pointer = oldData.getItemGraphicEl(idx);
  31158. group.remove(pointer);
  31159. })
  31160. .execute();
  31161. data.eachItemGraphicEl(function (pointer, idx) {
  31162. var itemModel = data.getItemModel(idx);
  31163. var pointerModel = itemModel.getModel('pointer');
  31164. pointer.setShape({
  31165. x: posInfo.cx,
  31166. y: posInfo.cy,
  31167. width: parsePercent(
  31168. pointerModel.get('width'), posInfo.r
  31169. ),
  31170. r: parsePercent(pointerModel.get('length'), posInfo.r)
  31171. });
  31172. pointer.useStyle(itemModel.getModel('itemStyle.normal').getItemStyle());
  31173. if (pointer.style.fill === 'auto') {
  31174. pointer.setStyle('fill', getColor(
  31175. (data.get('value', idx) - valueExtent[0]) / (valueExtent[1] - valueExtent[0])
  31176. ));
  31177. }
  31178. graphic.setHoverStyle(
  31179. pointer, itemModel.getModel('itemStyle.emphasis').getItemStyle()
  31180. );
  31181. });
  31182. this._data = data;
  31183. },
  31184. _renderTitle: function (
  31185. seriesModel, ecModel, api, getColor, posInfo
  31186. ) {
  31187. var titleModel = seriesModel.getModel('title');
  31188. if (titleModel.get('show')) {
  31189. var textStyleModel = titleModel.getModel('textStyle');
  31190. var offsetCenter = titleModel.get('offsetCenter');
  31191. var x = posInfo.cx + parsePercent(offsetCenter[0], posInfo.r);
  31192. var y = posInfo.cy + parsePercent(offsetCenter[1], posInfo.r);
  31193. var text = new graphic.Text({
  31194. style: {
  31195. x: x,
  31196. y: y,
  31197. // FIXME First data name ?
  31198. text: seriesModel.getData().getName(0),
  31199. fill: textStyleModel.getTextColor(),
  31200. textFont: textStyleModel.getFont(),
  31201. textAlign: 'center',
  31202. textVerticalAlign: 'middle'
  31203. }
  31204. });
  31205. this.group.add(text);
  31206. }
  31207. },
  31208. _renderDetail: function (
  31209. seriesModel, ecModel, api, getColor, posInfo
  31210. ) {
  31211. var detailModel = seriesModel.getModel('detail');
  31212. var minVal = seriesModel.get('min');
  31213. var maxVal = seriesModel.get('max');
  31214. if (detailModel.get('show')) {
  31215. var textStyleModel = detailModel.getModel('textStyle');
  31216. var offsetCenter = detailModel.get('offsetCenter');
  31217. var x = posInfo.cx + parsePercent(offsetCenter[0], posInfo.r);
  31218. var y = posInfo.cy + parsePercent(offsetCenter[1], posInfo.r);
  31219. var width = parsePercent(detailModel.get('width'), posInfo.r);
  31220. var height = parsePercent(detailModel.get('height'), posInfo.r);
  31221. var value = seriesModel.getData().get('value', 0);
  31222. var rect = new graphic.Rect({
  31223. shape: {
  31224. x: x - width / 2,
  31225. y: y - height / 2,
  31226. width: width,
  31227. height: height
  31228. },
  31229. style: {
  31230. text: formatLabel(
  31231. // FIXME First data name ?
  31232. value, detailModel.get('formatter')
  31233. ),
  31234. fill: detailModel.get('backgroundColor'),
  31235. textFill: textStyleModel.getTextColor(),
  31236. textFont: textStyleModel.getFont()
  31237. }
  31238. });
  31239. if (rect.style.textFill === 'auto') {
  31240. rect.setStyle('textFill', getColor(
  31241. numberUtil.linearMap(value, [minVal, maxVal], [0, 1], true)
  31242. ));
  31243. }
  31244. rect.setStyle(detailModel.getItemStyle(['color']));
  31245. this.group.add(rect);
  31246. }
  31247. }
  31248. });
  31249. module.exports = GaugeView;
  31250. /***/ },
  31251. /* 213 */
  31252. /***/ function(module, exports, __webpack_require__) {
  31253. module.exports = __webpack_require__(44).extend({
  31254. type: 'echartsGaugePointer',
  31255. shape: {
  31256. angle: 0,
  31257. width: 10,
  31258. r: 10,
  31259. x: 0,
  31260. y: 0
  31261. },
  31262. buildPath: function (ctx, shape) {
  31263. var mathCos = Math.cos;
  31264. var mathSin = Math.sin;
  31265. var r = shape.r;
  31266. var width = shape.width;
  31267. var angle = shape.angle;
  31268. var x = shape.x - mathCos(angle) * width * (width >= r / 3 ? 1 : 2);
  31269. var y = shape.y - mathSin(angle) * width * (width >= r / 3 ? 1 : 2);
  31270. angle = shape.angle - Math.PI / 2;
  31271. ctx.moveTo(x, y);
  31272. ctx.lineTo(
  31273. shape.x + mathCos(angle) * width,
  31274. shape.y + mathSin(angle) * width
  31275. );
  31276. ctx.lineTo(
  31277. shape.x + mathCos(shape.angle) * r,
  31278. shape.y + mathSin(shape.angle) * r
  31279. );
  31280. ctx.lineTo(
  31281. shape.x - mathCos(angle) * width,
  31282. shape.y - mathSin(angle) * width
  31283. );
  31284. ctx.lineTo(x, y);
  31285. return;
  31286. }
  31287. });
  31288. /***/ },
  31289. /* 214 */
  31290. /***/ function(module, exports, __webpack_require__) {
  31291. var zrUtil = __webpack_require__(3);
  31292. var echarts = __webpack_require__(1);
  31293. __webpack_require__(215);
  31294. __webpack_require__(216);
  31295. echarts.registerVisualCoding(
  31296. 'chart', zrUtil.curry(__webpack_require__(138), 'funnel')
  31297. );
  31298. echarts.registerLayout(__webpack_require__(217));
  31299. echarts.registerProcessor(
  31300. 'filter', zrUtil.curry(__webpack_require__(141), 'funnel')
  31301. );
  31302. /***/ },
  31303. /* 215 */
  31304. /***/ function(module, exports, __webpack_require__) {
  31305. 'use strict';
  31306. var List = __webpack_require__(95);
  31307. var modelUtil = __webpack_require__(5);
  31308. var completeDimensions = __webpack_require__(97);
  31309. var FunnelSeries = __webpack_require__(1).extendSeriesModel({
  31310. type: 'series.funnel',
  31311. init: function (option) {
  31312. FunnelSeries.superApply(this, 'init', arguments);
  31313. // Enable legend selection for each data item
  31314. // Use a function instead of direct access because data reference may changed
  31315. this.legendDataProvider = function () {
  31316. return this._dataBeforeProcessed;
  31317. };
  31318. // Extend labelLine emphasis
  31319. this._defaultLabelLine(option);
  31320. },
  31321. getInitialData: function (option, ecModel) {
  31322. var dimensions = completeDimensions(['value'], option.data);
  31323. var list = new List(dimensions, this);
  31324. list.initData(option.data);
  31325. return list;
  31326. },
  31327. _defaultLabelLine: function (option) {
  31328. // Extend labelLine emphasis
  31329. modelUtil.defaultEmphasis(option.labelLine, ['show']);
  31330. var labelLineNormalOpt = option.labelLine.normal;
  31331. var labelLineEmphasisOpt = option.labelLine.emphasis;
  31332. // Not show label line if `label.normal.show = false`
  31333. labelLineNormalOpt.show = labelLineNormalOpt.show
  31334. && option.label.normal.show;
  31335. labelLineEmphasisOpt.show = labelLineEmphasisOpt.show
  31336. && option.label.emphasis.show;
  31337. },
  31338. defaultOption: {
  31339. zlevel: 0, // 一级层叠
  31340. z: 2, // 二级层叠
  31341. legendHoverLink: true,
  31342. left: 80,
  31343. top: 60,
  31344. right: 80,
  31345. bottom: 60,
  31346. // width: {totalWidth} - left - right,
  31347. // height: {totalHeight} - top - bottom,
  31348. // 默认取数据最小最大值
  31349. // min: 0,
  31350. // max: 100,
  31351. minSize: '0%',
  31352. maxSize: '100%',
  31353. sort: 'descending', // 'ascending', 'descending'
  31354. gap: 0,
  31355. funnelAlign: 'center',
  31356. label: {
  31357. normal: {
  31358. show: true,
  31359. position: 'outer'
  31360. // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  31361. // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
  31362. },
  31363. emphasis: {
  31364. show: true
  31365. }
  31366. },
  31367. labelLine: {
  31368. normal: {
  31369. show: true,
  31370. length: 20,
  31371. lineStyle: {
  31372. // color: 各异,
  31373. width: 1,
  31374. type: 'solid'
  31375. }
  31376. },
  31377. emphasis: {}
  31378. },
  31379. itemStyle: {
  31380. normal: {
  31381. // color: 各异,
  31382. borderColor: '#fff',
  31383. borderWidth: 1
  31384. },
  31385. emphasis: {
  31386. // color: 各异,
  31387. }
  31388. }
  31389. }
  31390. });
  31391. module.exports = FunnelSeries;
  31392. /***/ },
  31393. /* 216 */
  31394. /***/ function(module, exports, __webpack_require__) {
  31395. var graphic = __webpack_require__(42);
  31396. var zrUtil = __webpack_require__(3);
  31397. /**
  31398. * Piece of pie including Sector, Label, LabelLine
  31399. * @constructor
  31400. * @extends {module:zrender/graphic/Group}
  31401. */
  31402. function FunnelPiece(data, idx) {
  31403. graphic.Group.call(this);
  31404. var polygon = new graphic.Polygon();
  31405. var labelLine = new graphic.Polyline();
  31406. var text = new graphic.Text();
  31407. this.add(polygon);
  31408. this.add(labelLine);
  31409. this.add(text);
  31410. this.updateData(data, idx, true);
  31411. // Hover to change label and labelLine
  31412. function onEmphasis() {
  31413. labelLine.ignore = labelLine.hoverIgnore;
  31414. text.ignore = text.hoverIgnore;
  31415. }
  31416. function onNormal() {
  31417. labelLine.ignore = labelLine.normalIgnore;
  31418. text.ignore = text.normalIgnore;
  31419. }
  31420. this.on('emphasis', onEmphasis)
  31421. .on('normal', onNormal)
  31422. .on('mouseover', onEmphasis)
  31423. .on('mouseout', onNormal);
  31424. }
  31425. var funnelPieceProto = FunnelPiece.prototype;
  31426. function getLabelStyle(data, idx, state, labelModel) {
  31427. var textStyleModel = labelModel.getModel('textStyle');
  31428. var position = labelModel.get('position');
  31429. var isLabelInside = position === 'inside' || position === 'inner' || position === 'center';
  31430. return {
  31431. fill: textStyleModel.getTextColor()
  31432. || (isLabelInside ? '#fff' : data.getItemVisual(idx, 'color')),
  31433. textFont: textStyleModel.getFont(),
  31434. text: zrUtil.retrieve(
  31435. data.hostModel.getFormattedLabel(idx, state),
  31436. data.getName(idx)
  31437. )
  31438. };
  31439. }
  31440. var opacityAccessPath = ['itemStyle', 'normal', 'opacity'];
  31441. funnelPieceProto.updateData = function (data, idx, firstCreate) {
  31442. var polygon = this.childAt(0);
  31443. var seriesModel = data.hostModel;
  31444. var itemModel = data.getItemModel(idx);
  31445. var layout = data.getItemLayout(idx);
  31446. var opacity = data.getItemModel(idx).get(opacityAccessPath);
  31447. opacity = opacity == null ? 1 : opacity;
  31448. // Reset style
  31449. polygon.useStyle({});
  31450. if (firstCreate) {
  31451. polygon.setShape({
  31452. points: layout.points
  31453. });
  31454. polygon.setStyle({ opacity : 0 });
  31455. graphic.initProps(polygon, {
  31456. style: {
  31457. opacity: opacity
  31458. }
  31459. }, seriesModel, idx);
  31460. }
  31461. else {
  31462. graphic.updateProps(polygon, {
  31463. style: {
  31464. opacity: opacity
  31465. },
  31466. shape: {
  31467. points: layout.points
  31468. }
  31469. }, seriesModel, idx);
  31470. }
  31471. // Update common style
  31472. var itemStyleModel = itemModel.getModel('itemStyle');
  31473. var visualColor = data.getItemVisual(idx, 'color');
  31474. polygon.setStyle(
  31475. zrUtil.defaults(
  31476. {
  31477. fill: visualColor
  31478. },
  31479. itemStyleModel.getModel('normal').getItemStyle(['opacity'])
  31480. )
  31481. );
  31482. polygon.hoverStyle = itemStyleModel.getModel('emphasis').getItemStyle();
  31483. this._updateLabel(data, idx);
  31484. graphic.setHoverStyle(this);
  31485. };
  31486. funnelPieceProto._updateLabel = function (data, idx) {
  31487. var labelLine = this.childAt(1);
  31488. var labelText = this.childAt(2);
  31489. var seriesModel = data.hostModel;
  31490. var itemModel = data.getItemModel(idx);
  31491. var layout = data.getItemLayout(idx);
  31492. var labelLayout = layout.label;
  31493. var visualColor = data.getItemVisual(idx, 'color');
  31494. graphic.updateProps(labelLine, {
  31495. shape: {
  31496. points: labelLayout.linePoints || labelLayout.linePoints
  31497. }
  31498. }, seriesModel, idx);
  31499. graphic.updateProps(labelText, {
  31500. style: {
  31501. x: labelLayout.x,
  31502. y: labelLayout.y
  31503. }
  31504. }, seriesModel, idx);
  31505. labelText.attr({
  31506. style: {
  31507. textAlign: labelLayout.textAlign,
  31508. textVerticalAlign: labelLayout.verticalAlign,
  31509. textFont: labelLayout.font
  31510. },
  31511. rotation: labelLayout.rotation,
  31512. origin: [labelLayout.x, labelLayout.y],
  31513. z2: 10
  31514. });
  31515. var labelModel = itemModel.getModel('label.normal');
  31516. var labelHoverModel = itemModel.getModel('label.emphasis');
  31517. var labelLineModel = itemModel.getModel('labelLine.normal');
  31518. var labelLineHoverModel = itemModel.getModel('labelLine.emphasis');
  31519. labelText.setStyle(getLabelStyle(data, idx, 'normal', labelModel));
  31520. labelText.ignore = labelText.normalIgnore = !labelModel.get('show');
  31521. labelText.hoverIgnore = !labelHoverModel.get('show');
  31522. labelLine.ignore = labelLine.normalIgnore = !labelLineModel.get('show');
  31523. labelLine.hoverIgnore = !labelLineHoverModel.get('show');
  31524. // Default use item visual color
  31525. labelLine.setStyle({
  31526. stroke: visualColor
  31527. });
  31528. labelLine.setStyle(labelLineModel.getModel('lineStyle').getLineStyle());
  31529. labelText.hoverStyle = getLabelStyle(data, idx, 'emphasis', labelHoverModel);
  31530. labelLine.hoverStyle = labelLineHoverModel.getModel('lineStyle').getLineStyle();
  31531. };
  31532. zrUtil.inherits(FunnelPiece, graphic.Group);
  31533. var Funnel = __webpack_require__(41).extend({
  31534. type: 'funnel',
  31535. render: function (seriesModel, ecModel, api) {
  31536. var data = seriesModel.getData();
  31537. var oldData = this._data;
  31538. var group = this.group;
  31539. data.diff(oldData)
  31540. .add(function (idx) {
  31541. var funnelPiece = new FunnelPiece(data, idx);
  31542. data.setItemGraphicEl(idx, funnelPiece);
  31543. group.add(funnelPiece);
  31544. })
  31545. .update(function (newIdx, oldIdx) {
  31546. var piePiece = oldData.getItemGraphicEl(oldIdx);
  31547. piePiece.updateData(data, newIdx);
  31548. group.add(piePiece);
  31549. data.setItemGraphicEl(newIdx, piePiece);
  31550. })
  31551. .remove(function (idx) {
  31552. var piePiece = oldData.getItemGraphicEl(idx);
  31553. group.remove(piePiece);
  31554. })
  31555. .execute();
  31556. this._data = data;
  31557. },
  31558. remove: function () {
  31559. this.group.removeAll();
  31560. this._data = null;
  31561. }
  31562. });
  31563. module.exports = Funnel;
  31564. /***/ },
  31565. /* 217 */
  31566. /***/ function(module, exports, __webpack_require__) {
  31567. var layout = __webpack_require__(21);
  31568. var number = __webpack_require__(7);
  31569. var parsePercent = number.parsePercent;
  31570. function getViewRect(seriesModel, api) {
  31571. return layout.getLayoutRect(
  31572. seriesModel.getBoxLayoutParams(), {
  31573. width: api.getWidth(),
  31574. height: api.getHeight()
  31575. }
  31576. );
  31577. }
  31578. function getSortedIndices(data, sort) {
  31579. var valueArr = data.mapArray('value', function (val) {
  31580. return val;
  31581. });
  31582. var indices = [];
  31583. var isAscending = sort === 'ascending';
  31584. for (var i = 0, len = data.count(); i < len; i++) {
  31585. indices[i] = i;
  31586. }
  31587. indices.sort(function (a, b) {
  31588. return isAscending ? valueArr[a] - valueArr[b] : valueArr[b] - valueArr[a];
  31589. });
  31590. return indices;
  31591. }
  31592. function labelLayout (data) {
  31593. data.each(function (idx) {
  31594. var itemModel = data.getItemModel(idx);
  31595. var labelModel = itemModel.getModel('label.normal');
  31596. var labelPosition = labelModel.get('position');
  31597. var labelLineModel = itemModel.getModel('labelLine.normal');
  31598. var layout = data.getItemLayout(idx);
  31599. var points = layout.points;
  31600. var isLabelInside = labelPosition === 'inner'
  31601. || labelPosition === 'inside' || labelPosition === 'center';
  31602. var textAlign;
  31603. var textX;
  31604. var textY;
  31605. var linePoints;
  31606. if (isLabelInside) {
  31607. textX = (points[0][0] + points[1][0] + points[2][0] + points[3][0]) / 4;
  31608. textY = (points[0][1] + points[1][1] + points[2][1] + points[3][1]) / 4;
  31609. textAlign = 'center';
  31610. linePoints = [
  31611. [textX, textY], [textX, textY]
  31612. ];
  31613. }
  31614. else {
  31615. var x1;
  31616. var y1;
  31617. var x2;
  31618. var labelLineLen = labelLineModel.get('length');
  31619. if (labelPosition === 'left') {
  31620. // Left side
  31621. x1 = (points[3][0] + points[0][0]) / 2;
  31622. y1 = (points[3][1] + points[0][1]) / 2;
  31623. x2 = x1 - labelLineLen;
  31624. textX = x2 - 5;
  31625. textAlign = 'right';
  31626. }
  31627. else {
  31628. // Right side
  31629. x1 = (points[1][0] + points[2][0]) / 2;
  31630. y1 = (points[1][1] + points[2][1]) / 2;
  31631. x2 = x1 + labelLineLen;
  31632. textX = x2 + 5;
  31633. textAlign = 'left';
  31634. }
  31635. var y2 = y1;
  31636. linePoints = [[x1, y1], [x2, y2]];
  31637. textY = y2;
  31638. }
  31639. layout.label = {
  31640. linePoints: linePoints,
  31641. x: textX,
  31642. y: textY,
  31643. verticalAlign: 'middle',
  31644. textAlign: textAlign,
  31645. inside: isLabelInside
  31646. };
  31647. });
  31648. }
  31649. module.exports = function (ecModel, api) {
  31650. ecModel.eachSeriesByType('funnel', function (seriesModel) {
  31651. var data = seriesModel.getData();
  31652. var sort = seriesModel.get('sort');
  31653. var viewRect = getViewRect(seriesModel, api);
  31654. var indices = getSortedIndices(data, sort);
  31655. var sizeExtent = [
  31656. parsePercent(seriesModel.get('minSize'), viewRect.width),
  31657. parsePercent(seriesModel.get('maxSize'), viewRect.width)
  31658. ];
  31659. var dataExtent = data.getDataExtent('value');
  31660. var min = seriesModel.get('min');
  31661. var max = seriesModel.get('max');
  31662. if (min == null) {
  31663. min = Math.min(dataExtent[0], 0);
  31664. }
  31665. if (max == null) {
  31666. max = dataExtent[1];
  31667. }
  31668. var funnelAlign = seriesModel.get('funnelAlign');
  31669. var gap = seriesModel.get('gap');
  31670. var itemHeight = (viewRect.height - gap * (data.count() - 1)) / data.count();
  31671. var y = viewRect.y;
  31672. var getLinePoints = function (idx, offY) {
  31673. // End point index is data.count() and we assign it 0
  31674. var val = data.get('value', idx) || 0;
  31675. var itemWidth = number.linearMap(val, [min, max], sizeExtent, true);
  31676. var x0;
  31677. switch (funnelAlign) {
  31678. case 'left':
  31679. x0 = viewRect.x;
  31680. break;
  31681. case 'center':
  31682. x0 = viewRect.x + (viewRect.width - itemWidth) / 2;
  31683. break;
  31684. case 'right':
  31685. x0 = viewRect.x + viewRect.width - itemWidth;
  31686. break;
  31687. }
  31688. return [
  31689. [x0, offY],
  31690. [x0 + itemWidth, offY]
  31691. ];
  31692. };
  31693. if (sort === 'ascending') {
  31694. // From bottom to top
  31695. itemHeight = -itemHeight;
  31696. gap = -gap;
  31697. y += viewRect.height;
  31698. indices = indices.reverse();
  31699. }
  31700. for (var i = 0; i < indices.length; i++) {
  31701. var idx = indices[i];
  31702. var nextIdx = indices[i + 1];
  31703. var start = getLinePoints(idx, y);
  31704. var end = getLinePoints(nextIdx, y + itemHeight);
  31705. y += itemHeight + gap;
  31706. data.setItemLayout(idx, {
  31707. points: start.concat(end.slice().reverse())
  31708. });
  31709. }
  31710. labelLayout(data);
  31711. });
  31712. };
  31713. /***/ },
  31714. /* 218 */
  31715. /***/ function(module, exports, __webpack_require__) {
  31716. var echarts = __webpack_require__(1);
  31717. __webpack_require__(219);
  31718. __webpack_require__(230);
  31719. __webpack_require__(231);
  31720. echarts.registerVisualCoding('chart', __webpack_require__(232));
  31721. /***/ },
  31722. /* 219 */
  31723. /***/ function(module, exports, __webpack_require__) {
  31724. __webpack_require__(220);
  31725. __webpack_require__(223);
  31726. __webpack_require__(225);
  31727. var echarts = __webpack_require__(1);
  31728. // Parallel view
  31729. echarts.extendComponentView({
  31730. type: 'parallel'
  31731. });
  31732. echarts.registerPreprocessor(
  31733. __webpack_require__(229)
  31734. );
  31735. /***/ },
  31736. /* 220 */
  31737. /***/ function(module, exports, __webpack_require__) {
  31738. /**
  31739. * Parallel coordinate system creater.
  31740. */
  31741. var Parallel = __webpack_require__(221);
  31742. function create(ecModel, api) {
  31743. var coordSysList = [];
  31744. ecModel.eachComponent('parallel', function (parallelModel, idx) {
  31745. var coordSys = new Parallel(parallelModel, ecModel, api);
  31746. coordSys.name = 'parallel_' + idx;
  31747. coordSys.resize(parallelModel, api);
  31748. parallelModel.coordinateSystem = coordSys;
  31749. coordSys.model = parallelModel;
  31750. coordSysList.push(coordSys);
  31751. });
  31752. // Inject the coordinateSystems into seriesModel
  31753. ecModel.eachSeries(function (seriesModel) {
  31754. if (seriesModel.get('coordinateSystem') === 'parallel') {
  31755. var parallelIndex = seriesModel.get('parallelIndex');
  31756. seriesModel.coordinateSystem = coordSysList[parallelIndex];
  31757. }
  31758. });
  31759. return coordSysList;
  31760. }
  31761. __webpack_require__(25).register('parallel', {create: create});
  31762. /***/ },
  31763. /* 221 */
  31764. /***/ function(module, exports, __webpack_require__) {
  31765. /**
  31766. * Parallel Coordinates
  31767. * <https://en.wikipedia.org/wiki/Parallel_coordinates>
  31768. */
  31769. var layout = __webpack_require__(21);
  31770. var axisHelper = __webpack_require__(109);
  31771. var zrUtil = __webpack_require__(3);
  31772. var ParallelAxis = __webpack_require__(222);
  31773. var matrix = __webpack_require__(17);
  31774. var vector = __webpack_require__(16);
  31775. var each = zrUtil.each;
  31776. var PI = Math.PI;
  31777. function Parallel(parallelModel, ecModel, api) {
  31778. /**
  31779. * key: dimension
  31780. * @type {Object.<string, module:echarts/coord/parallel/Axis>}
  31781. * @private
  31782. */
  31783. this._axesMap = {};
  31784. /**
  31785. * key: dimension
  31786. * value: {position: [], rotation, }
  31787. * @type {Object.<string, Object>}
  31788. * @private
  31789. */
  31790. this._axesLayout = {};
  31791. /**
  31792. * Always follow axis order.
  31793. * @type {Array.<string>}
  31794. * @readOnly
  31795. */
  31796. this.dimensions = parallelModel.dimensions;
  31797. /**
  31798. * @type {module:zrender/core/BoundingRect}
  31799. */
  31800. this._rect;
  31801. /**
  31802. * @type {module:echarts/coord/parallel/ParallelModel}
  31803. */
  31804. this._model = parallelModel;
  31805. this._init(parallelModel, ecModel, api);
  31806. }
  31807. Parallel.prototype = {
  31808. type: 'parallel',
  31809. constructor: Parallel,
  31810. /**
  31811. * Initialize cartesian coordinate systems
  31812. * @private
  31813. */
  31814. _init: function (parallelModel, ecModel, api) {
  31815. var dimensions = parallelModel.dimensions;
  31816. var parallelAxisIndex = parallelModel.parallelAxisIndex;
  31817. each(dimensions, function (dim, idx) {
  31818. var axisIndex = parallelAxisIndex[idx];
  31819. var axisModel = ecModel.getComponent('parallelAxis', axisIndex);
  31820. var axis = this._axesMap[dim] = new ParallelAxis(
  31821. dim,
  31822. axisHelper.createScaleByModel(axisModel),
  31823. [0, 0],
  31824. axisModel.get('type'),
  31825. axisIndex
  31826. );
  31827. var isCategory = axis.type === 'category';
  31828. axis.onBand = isCategory && axisModel.get('boundaryGap');
  31829. axis.inverse = axisModel.get('inverse');
  31830. // Inject axis into axisModel
  31831. axisModel.axis = axis;
  31832. // Inject axisModel into axis
  31833. axis.model = axisModel;
  31834. }, this);
  31835. },
  31836. /**
  31837. * Update axis scale after data processed
  31838. * @param {module:echarts/model/Global} ecModel
  31839. * @param {module:echarts/ExtensionAPI} api
  31840. */
  31841. update: function (ecModel, api) {
  31842. this._updateAxesFromSeries(this._model, ecModel);
  31843. },
  31844. /**
  31845. * Update properties from series
  31846. * @private
  31847. */
  31848. _updateAxesFromSeries: function (parallelModel, ecModel) {
  31849. ecModel.eachSeries(function (seriesModel) {
  31850. if (!parallelModel.contains(seriesModel, ecModel)) {
  31851. return;
  31852. }
  31853. var data = seriesModel.getData();
  31854. each(this.dimensions, function (dim) {
  31855. var axis = this._axesMap[dim];
  31856. axis.scale.unionExtent(data.getDataExtent(dim));
  31857. axisHelper.niceScaleExtent(axis, axis.model);
  31858. }, this);
  31859. }, this);
  31860. },
  31861. /**
  31862. * Resize the parallel coordinate system.
  31863. * @param {module:echarts/coord/parallel/ParallelModel} parallelModel
  31864. * @param {module:echarts/ExtensionAPI} api
  31865. */
  31866. resize: function (parallelModel, api) {
  31867. this._rect = layout.getLayoutRect(
  31868. parallelModel.getBoxLayoutParams(),
  31869. {
  31870. width: api.getWidth(),
  31871. height: api.getHeight()
  31872. }
  31873. );
  31874. this._layoutAxes(parallelModel);
  31875. },
  31876. /**
  31877. * @return {module:zrender/core/BoundingRect}
  31878. */
  31879. getRect: function () {
  31880. return this._rect;
  31881. },
  31882. /**
  31883. * @private
  31884. */
  31885. _layoutAxes: function (parallelModel) {
  31886. var rect = this._rect;
  31887. var layout = parallelModel.get('layout');
  31888. var axes = this._axesMap;
  31889. var dimensions = this.dimensions;
  31890. var size = [rect.width, rect.height];
  31891. var sizeIdx = layout === 'horizontal' ? 0 : 1;
  31892. var layoutLength = size[sizeIdx];
  31893. var axisLength = size[1 - sizeIdx];
  31894. var axisExtent = [0, axisLength];
  31895. each(axes, function (axis) {
  31896. var idx = axis.inverse ? 1 : 0;
  31897. axis.setExtent(axisExtent[idx], axisExtent[1 - idx]);
  31898. });
  31899. each(dimensions, function (dim, idx) {
  31900. var pos = layoutLength * idx / (dimensions.length - 1);
  31901. var positionTable = {
  31902. horizontal: {
  31903. x: pos,
  31904. y: axisLength
  31905. },
  31906. vertical: {
  31907. x: 0,
  31908. y: pos
  31909. }
  31910. };
  31911. var rotationTable = {
  31912. horizontal: PI / 2,
  31913. vertical: 0
  31914. };
  31915. var position = [
  31916. positionTable[layout].x + rect.x,
  31917. positionTable[layout].y + rect.y
  31918. ];
  31919. var rotation = rotationTable[layout];
  31920. var transform = matrix.create();
  31921. matrix.rotate(transform, transform, rotation);
  31922. matrix.translate(transform, transform, position);
  31923. // TODO
  31924. // tick等排布信息。
  31925. // TODO
  31926. // 根据axis order 更新 dimensions顺序。
  31927. this._axesLayout[dim] = {
  31928. position: position,
  31929. rotation: rotation,
  31930. transform: transform,
  31931. tickDirection: 1,
  31932. labelDirection: 1
  31933. };
  31934. }, this);
  31935. },
  31936. /**
  31937. * Get axis by dim.
  31938. * @param {string} dim
  31939. * @return {module:echarts/coord/parallel/ParallelAxis} [description]
  31940. */
  31941. getAxis: function (dim) {
  31942. return this._axesMap[dim];
  31943. },
  31944. /**
  31945. * Convert a dim value of a single item of series data to Point.
  31946. * @param {*} value
  31947. * @param {string} dim
  31948. * @return {Array}
  31949. */
  31950. dataToPoint: function (value, dim) {
  31951. return this.axisCoordToPoint(
  31952. this._axesMap[dim].dataToCoord(value),
  31953. dim
  31954. );
  31955. },
  31956. /**
  31957. * @param {module:echarts/data/List} data
  31958. * @param {Functio} cb param: {string} activeState 'active' or 'inactive' or 'normal'
  31959. * {number} dataIndex
  31960. * @param {Object} context
  31961. */
  31962. eachActiveState: function (data, callback, context) {
  31963. var dimensions = this.dimensions;
  31964. var axesMap = this._axesMap;
  31965. var hasActiveSet = false;
  31966. for (var j = 0, lenj = dimensions.length; j < lenj; j++) {
  31967. if (axesMap[dimensions[j]].model.getActiveState() !== 'normal') {
  31968. hasActiveSet = true;
  31969. }
  31970. }
  31971. for (var i = 0, len = data.count(); i < len; i++) {
  31972. var values = data.getValues(dimensions, i);
  31973. var activeState;
  31974. if (!hasActiveSet) {
  31975. activeState = 'normal';
  31976. }
  31977. else {
  31978. activeState = 'active';
  31979. for (var j = 0, lenj = dimensions.length; j < lenj; j++) {
  31980. var dimName = dimensions[j];
  31981. var state = axesMap[dimName].model.getActiveState(values[j], j);
  31982. if (state === 'inactive') {
  31983. activeState = 'inactive';
  31984. break;
  31985. }
  31986. }
  31987. }
  31988. callback.call(context, activeState, i);
  31989. }
  31990. },
  31991. /**
  31992. * Convert coords of each axis to Point.
  31993. * Return point. For example: [10, 20]
  31994. * @param {Array.<number>} coords
  31995. * @param {string} dim
  31996. * @return {Array.<number>}
  31997. */
  31998. axisCoordToPoint: function (coord, dim) {
  31999. var axisLayout = this._axesLayout[dim];
  32000. var point = [coord, 0];
  32001. vector.applyTransform(point, point, axisLayout.transform);
  32002. return point;
  32003. },
  32004. /**
  32005. * Get axis layout.
  32006. */
  32007. getAxisLayout: function (dim) {
  32008. return zrUtil.clone(this._axesLayout[dim]);
  32009. }
  32010. };
  32011. module.exports = Parallel;
  32012. /***/ },
  32013. /* 222 */
  32014. /***/ function(module, exports, __webpack_require__) {
  32015. var zrUtil = __webpack_require__(3);
  32016. var Axis = __webpack_require__(118);
  32017. /**
  32018. * @constructor module:echarts/coord/parallel/ParallelAxis
  32019. * @extends {module:echarts/coord/Axis}
  32020. * @param {string} dim
  32021. * @param {*} scale
  32022. * @param {Array.<number>} coordExtent
  32023. * @param {string} axisType
  32024. */
  32025. var ParallelAxis = function (dim, scale, coordExtent, axisType, axisIndex) {
  32026. Axis.call(this, dim, scale, coordExtent);
  32027. /**
  32028. * Axis type
  32029. * - 'category'
  32030. * - 'value'
  32031. * - 'time'
  32032. * - 'log'
  32033. * @type {string}
  32034. */
  32035. this.type = axisType || 'value';
  32036. /**
  32037. * @type {number}
  32038. * @readOnly
  32039. */
  32040. this.axisIndex = axisIndex;
  32041. };
  32042. ParallelAxis.prototype = {
  32043. constructor: ParallelAxis,
  32044. /**
  32045. * Axis model
  32046. * @param {module:echarts/coord/parallel/AxisModel}
  32047. */
  32048. model: null
  32049. };
  32050. zrUtil.inherits(ParallelAxis, Axis);
  32051. module.exports = ParallelAxis;
  32052. /***/ },
  32053. /* 223 */
  32054. /***/ function(module, exports, __webpack_require__) {
  32055. var zrUtil = __webpack_require__(3);
  32056. var Component = __webpack_require__(19);
  32057. __webpack_require__(224);
  32058. Component.extend({
  32059. type: 'parallel',
  32060. dependencies: ['parallelAxis'],
  32061. /**
  32062. * @type {module:echarts/coord/parallel/Parallel}
  32063. */
  32064. coordinateSystem: null,
  32065. /**
  32066. * Each item like: 'dim0', 'dim1', 'dim2', ...
  32067. * @type {Array.<string>}
  32068. * @readOnly
  32069. */
  32070. dimensions: null,
  32071. /**
  32072. * Coresponding to dimensions.
  32073. * @type {Array.<number>}
  32074. * @readOnly
  32075. */
  32076. parallelAxisIndex: null,
  32077. defaultOption: {
  32078. zlevel: 0, // 一级层叠
  32079. z: 0, // 二级层叠
  32080. left: 80,
  32081. top: 60,
  32082. right: 80,
  32083. bottom: 60,
  32084. // width: {totalWidth} - left - right,
  32085. // height: {totalHeight} - top - bottom,
  32086. layout: 'horizontal', // 'horizontal' or 'vertical'
  32087. parallelAxisDefault: null
  32088. },
  32089. /**
  32090. * @override
  32091. */
  32092. init: function () {
  32093. Component.prototype.init.apply(this, arguments);
  32094. this.mergeOption({});
  32095. },
  32096. /**
  32097. * @override
  32098. */
  32099. mergeOption: function (newOption) {
  32100. var thisOption = this.option;
  32101. newOption && zrUtil.merge(thisOption, newOption, true);
  32102. this._initDimensions();
  32103. },
  32104. /**
  32105. * Whether series or axis is in this coordinate system.
  32106. * @param {module:echarts/model/Series|module:echarts/coord/parallel/AxisModel} model
  32107. * @param {module:echarts/model/Global} ecModel
  32108. */
  32109. contains: function (model, ecModel) {
  32110. var parallelIndex = model.get('parallelIndex');
  32111. return parallelIndex != null
  32112. && ecModel.getComponent('parallel', parallelIndex) === this;
  32113. },
  32114. /**
  32115. * @private
  32116. */
  32117. _initDimensions: function () {
  32118. var dimensions = this.dimensions = [];
  32119. var parallelAxisIndex = this.parallelAxisIndex = [];
  32120. var axisModels = zrUtil.filter(this.dependentModels.parallelAxis, function (axisModel) {
  32121. // Can not use this.contains here, because
  32122. // initialization has not been completed yet.
  32123. return axisModel.get('parallelIndex') === this.componentIndex;
  32124. });
  32125. zrUtil.each(axisModels, function (axisModel) {
  32126. dimensions.push('dim' + axisModel.get('dim'));
  32127. parallelAxisIndex.push(axisModel.componentIndex);
  32128. });
  32129. }
  32130. });
  32131. /***/ },
  32132. /* 224 */
  32133. /***/ function(module, exports, __webpack_require__) {
  32134. var ComponentModel = __webpack_require__(19);
  32135. var zrUtil = __webpack_require__(3);
  32136. var makeStyleMapper = __webpack_require__(11);
  32137. var axisModelCreator = __webpack_require__(122);
  32138. var numberUtil = __webpack_require__(7);
  32139. var AxisModel = ComponentModel.extend({
  32140. type: 'baseParallelAxis',
  32141. /**
  32142. * @type {module:echarts/coord/parallel/Axis}
  32143. */
  32144. axis: null,
  32145. /**
  32146. * @type {Array.<Array.<number>}
  32147. * @readOnly
  32148. */
  32149. activeIntervals: [],
  32150. /**
  32151. * @return {Object}
  32152. */
  32153. getAreaSelectStyle: function () {
  32154. return makeStyleMapper(
  32155. [
  32156. ['fill', 'color'],
  32157. ['lineWidth', 'borderWidth'],
  32158. ['stroke', 'borderColor'],
  32159. ['width', 'width'],
  32160. ['opacity', 'opacity']
  32161. ]
  32162. ).call(this.getModel('areaSelectStyle'));
  32163. },
  32164. /**
  32165. * The code of this feature is put on AxisModel but not ParallelAxis,
  32166. * because axisModel can be alive after echarts updating but instance of
  32167. * ParallelAxis having been disposed. this._activeInterval should be kept
  32168. * when action dispatched (i.e. legend click).
  32169. *
  32170. * @param {Array.<Array<number>>} intervals interval.length === 0
  32171. * means set all active.
  32172. * @public
  32173. */
  32174. setActiveIntervals: function (intervals) {
  32175. var activeIntervals = this.activeIntervals = zrUtil.clone(intervals);
  32176. // Normalize
  32177. if (activeIntervals) {
  32178. for (var i = activeIntervals.length - 1; i >= 0; i--) {
  32179. numberUtil.asc(activeIntervals[i]);
  32180. }
  32181. }
  32182. },
  32183. /**
  32184. * @param {number|string} [value] When attempting to detect 'no activeIntervals set',
  32185. * value can not be input.
  32186. * @return {string} 'normal': no activeIntervals set,
  32187. * 'active',
  32188. * 'inactive'.
  32189. * @public
  32190. */
  32191. getActiveState: function (value) {
  32192. var activeIntervals = this.activeIntervals;
  32193. if (!activeIntervals.length) {
  32194. return 'normal';
  32195. }
  32196. if (value == null) {
  32197. return 'inactive';
  32198. }
  32199. for (var i = 0, len = activeIntervals.length; i < len; i++) {
  32200. if (activeIntervals[i][0] <= value && value <= activeIntervals[i][1]) {
  32201. return 'active';
  32202. }
  32203. }
  32204. return 'inactive';
  32205. }
  32206. });
  32207. var defaultOption = {
  32208. type: 'value',
  32209. /**
  32210. * @type {Array.<number>}
  32211. */
  32212. dim: null, // 0, 1, 2, ...
  32213. parallelIndex: null,
  32214. areaSelectStyle: {
  32215. width: 20,
  32216. borderWidth: 1,
  32217. borderColor: 'rgba(160,197,232)',
  32218. color: 'rgba(160,197,232)',
  32219. opacity: 0.3
  32220. },
  32221. z: 10
  32222. };
  32223. zrUtil.merge(AxisModel.prototype, __webpack_require__(124));
  32224. function getAxisType(axisName, option) {
  32225. return option.type || (option.data ? 'category' : 'value');
  32226. }
  32227. axisModelCreator('parallel', AxisModel, getAxisType, defaultOption);
  32228. module.exports = AxisModel;
  32229. /***/ },
  32230. /* 225 */
  32231. /***/ function(module, exports, __webpack_require__) {
  32232. __webpack_require__(220);
  32233. __webpack_require__(226);
  32234. __webpack_require__(227);
  32235. /***/ },
  32236. /* 226 */
  32237. /***/ function(module, exports, __webpack_require__) {
  32238. var echarts = __webpack_require__(1);
  32239. var actionInfo = {
  32240. type: 'axisAreaSelect',
  32241. event: 'axisAreaSelected',
  32242. update: 'updateVisual'
  32243. };
  32244. /**
  32245. * @payload
  32246. * @property {string} parallelAxisId
  32247. * @property {Array.<Array.<number>>} intervals
  32248. */
  32249. echarts.registerAction(actionInfo, function (payload, ecModel) {
  32250. ecModel.eachComponent(
  32251. {mainType: 'parallelAxis', query: payload},
  32252. function (parallelAxisModel) {
  32253. parallelAxisModel.axis.model.setActiveIntervals(payload.intervals);
  32254. }
  32255. );
  32256. });
  32257. /***/ },
  32258. /* 227 */
  32259. /***/ function(module, exports, __webpack_require__) {
  32260. var zrUtil = __webpack_require__(3);
  32261. var AxisBuilder = __webpack_require__(127);
  32262. var SelectController = __webpack_require__(228);
  32263. var elementList = ['axisLine', 'axisLabel', 'axisTick', 'axisName'];
  32264. var AxisView = __webpack_require__(1).extendComponentView({
  32265. type: 'parallelAxis',
  32266. /**
  32267. * @type {module:echarts/component/helper/SelectController}
  32268. */
  32269. _selectController: null,
  32270. /**
  32271. * @override
  32272. */
  32273. render: function (axisModel, ecModel, api, payload) {
  32274. if (fromAxisAreaSelect(axisModel, ecModel, payload)) {
  32275. return;
  32276. }
  32277. this.axisModel = axisModel;
  32278. this.api = api;
  32279. this.group.removeAll();
  32280. if (!axisModel.get('show')) {
  32281. return;
  32282. }
  32283. var coordSys = ecModel.getComponent(
  32284. 'parallel', axisModel.get('parallelIndex')
  32285. ).coordinateSystem;
  32286. var areaSelectStyle = axisModel.getAreaSelectStyle();
  32287. var areaWidth = areaSelectStyle.width;
  32288. var axisLayout = coordSys.getAxisLayout(axisModel.axis.dim);
  32289. var builderOpt = zrUtil.extend(
  32290. {
  32291. strokeContainThreshold: areaWidth,
  32292. // lineWidth === 0 or no value.
  32293. axisLineSilent: !(areaWidth > 0) // jshint ignore:line
  32294. },
  32295. axisLayout
  32296. );
  32297. var axisBuilder = new AxisBuilder(axisModel, builderOpt);
  32298. zrUtil.each(elementList, axisBuilder.add, axisBuilder);
  32299. var axisGroup = axisBuilder.getGroup();
  32300. this.group.add(axisGroup);
  32301. this._buildSelectController(
  32302. axisGroup, areaSelectStyle, axisModel, api
  32303. );
  32304. },
  32305. _buildSelectController: function (axisGroup, areaSelectStyle, axisModel, api) {
  32306. var axis = axisModel.axis;
  32307. var selectController = this._selectController;
  32308. if (!selectController) {
  32309. selectController = this._selectController = new SelectController(
  32310. 'line',
  32311. api.getZr(),
  32312. areaSelectStyle
  32313. );
  32314. selectController.on('selected', zrUtil.bind(this._onSelected, this));
  32315. }
  32316. selectController.enable(axisGroup);
  32317. // After filtering, axis may change, select area needs to be update.
  32318. var ranges = zrUtil.map(axisModel.activeIntervals, function (interval) {
  32319. return [
  32320. axis.dataToCoord(interval[0], true),
  32321. axis.dataToCoord(interval[1], true)
  32322. ];
  32323. });
  32324. selectController.update(ranges);
  32325. },
  32326. _onSelected: function (ranges) {
  32327. // Do not cache these object, because the mey be changed.
  32328. var axisModel = this.axisModel;
  32329. var axis = axisModel.axis;
  32330. var intervals = zrUtil.map(ranges, function (range) {
  32331. return [
  32332. axis.coordToData(range[0], true),
  32333. axis.coordToData(range[1], true)
  32334. ];
  32335. });
  32336. this.api.dispatchAction({
  32337. type: 'axisAreaSelect',
  32338. parallelAxisId: axisModel.id,
  32339. intervals: intervals
  32340. });
  32341. },
  32342. /**
  32343. * @override
  32344. */
  32345. remove: function () {
  32346. this._selectController && this._selectController.disable();
  32347. },
  32348. /**
  32349. * @override
  32350. */
  32351. dispose: function () {
  32352. if (this._selectController) {
  32353. this._selectController.dispose();
  32354. this._selectController = null;
  32355. }
  32356. }
  32357. });
  32358. function fromAxisAreaSelect(axisModel, ecModel, payload) {
  32359. return payload
  32360. && payload.type === 'axisAreaSelect'
  32361. && ecModel.findComponents(
  32362. {mainType: 'parallelAxis', query: payload}
  32363. )[0] === axisModel;
  32364. }
  32365. module.exports = AxisView;
  32366. /***/ },
  32367. /* 228 */
  32368. /***/ function(module, exports, __webpack_require__) {
  32369. /**
  32370. * Box selection tool.
  32371. *
  32372. * @module echarts/component/helper/SelectController
  32373. */
  32374. var Eventful = __webpack_require__(32);
  32375. var zrUtil = __webpack_require__(3);
  32376. var graphic = __webpack_require__(42);
  32377. var bind = zrUtil.bind;
  32378. var each = zrUtil.each;
  32379. var mathMin = Math.min;
  32380. var mathMax = Math.max;
  32381. var mathPow = Math.pow;
  32382. var COVER_Z = 10000;
  32383. var UNSELECT_THRESHOLD = 2;
  32384. var EVENTS = ['mousedown', 'mousemove', 'mouseup'];
  32385. /**
  32386. * @alias module:echarts/component/helper/SelectController
  32387. * @constructor
  32388. * @mixin {module:zrender/mixin/Eventful}
  32389. *
  32390. * @param {string} type 'line', 'rect'
  32391. * @param {module:zrender/zrender~ZRender} zr
  32392. * @param {Object} [opt]
  32393. * @param {number} [opt.width]
  32394. * @param {number} [opt.lineWidth]
  32395. * @param {string} [opt.stroke]
  32396. * @param {string} [opt.fill]
  32397. */
  32398. function SelectController(type, zr, opt) {
  32399. Eventful.call(this);
  32400. /**
  32401. * @type {string}
  32402. * @readOnly
  32403. */
  32404. this.type = type;
  32405. /**
  32406. * @type {module:zrender/zrender~ZRender}
  32407. */
  32408. this.zr = zr;
  32409. /**
  32410. * @type {Object}
  32411. * @readOnly
  32412. */
  32413. this.opt = zrUtil.clone(opt);
  32414. /**
  32415. * @type {module:zrender/container/Group}
  32416. * @readOnly
  32417. */
  32418. this.group = new graphic.Group();
  32419. /**
  32420. * @type {module:zrender/core/BoundingRect}
  32421. */
  32422. this._containerRect = null;
  32423. /**
  32424. * @type {Array.<nubmer>}
  32425. * @private
  32426. */
  32427. this._track = [];
  32428. /**
  32429. * @type {boolean}
  32430. */
  32431. this._dragging;
  32432. /**
  32433. * @type {module:zrender/Element}
  32434. * @private
  32435. */
  32436. this._cover;
  32437. /**
  32438. * @type {boolean}
  32439. * @private
  32440. */
  32441. this._disabled = true;
  32442. /**
  32443. * @type {Object}
  32444. * @private
  32445. */
  32446. this._handlers = {
  32447. mousedown: bind(mousedown, this),
  32448. mousemove: bind(mousemove, this),
  32449. mouseup: bind(mouseup, this)
  32450. };
  32451. each(EVENTS, function (eventName) {
  32452. this.zr.on(eventName, this._handlers[eventName]);
  32453. }, this);
  32454. }
  32455. SelectController.prototype = {
  32456. constructor: SelectController,
  32457. /**
  32458. * @param {module:zrender/mixin/Transformable} container
  32459. * @param {module:zrender/core/BoundingRect|boolean} [rect] If not specified,
  32460. * use container.getBoundingRect().
  32461. * If false, do not use containerRect.
  32462. */
  32463. enable: function (container, rect) {
  32464. this._disabled = false;
  32465. // Remove from old container.
  32466. removeGroup.call(this);
  32467. // boundingRect will change when dragging, so we have
  32468. // to keep initial boundingRect.
  32469. this._containerRect = rect !== false
  32470. ? (rect || container.getBoundingRect()) : null;
  32471. // Add to new container.
  32472. container.add(this.group);
  32473. },
  32474. /**
  32475. * Update cover location.
  32476. * @param {Array.<number>|Object} ranges If null/undefined, remove cover.
  32477. */
  32478. update: function (ranges) {
  32479. // TODO
  32480. // Only support one interval yet.
  32481. renderCover.call(this, ranges && zrUtil.clone(ranges));
  32482. },
  32483. disable: function () {
  32484. this._disabled = true;
  32485. removeGroup.call(this);
  32486. },
  32487. dispose: function () {
  32488. this.disable();
  32489. each(EVENTS, function (eventName) {
  32490. this.zr.off(eventName, this._handlers[eventName]);
  32491. }, this);
  32492. }
  32493. };
  32494. zrUtil.mixin(SelectController, Eventful);
  32495. function updateZ(group) {
  32496. group.traverse(function (el) {
  32497. el.z = COVER_Z;
  32498. });
  32499. }
  32500. function isInContainer(x, y) {
  32501. var localPos = this.group.transformCoordToLocal(x, y);
  32502. return !this._containerRect
  32503. || this._containerRect.contain(localPos[0], localPos[1]);
  32504. }
  32505. function preventDefault(e) {
  32506. var rawE = e.event;
  32507. rawE.preventDefault && rawE.preventDefault();
  32508. }
  32509. function mousedown(e) {
  32510. if (this._disabled || (e.target && e.target.draggable)) {
  32511. return;
  32512. }
  32513. preventDefault(e);
  32514. var x = e.offsetX;
  32515. var y = e.offsetY;
  32516. if (isInContainer.call(this, x, y)) {
  32517. this._dragging = true;
  32518. this._track = [[x, y]];
  32519. }
  32520. }
  32521. function mousemove(e) {
  32522. if (!this._dragging || this._disabled) {
  32523. return;
  32524. }
  32525. preventDefault(e);
  32526. updateViewByCursor.call(this, e);
  32527. }
  32528. function mouseup(e) {
  32529. if (!this._dragging || this._disabled) {
  32530. return;
  32531. }
  32532. preventDefault(e);
  32533. updateViewByCursor.call(this, e, true);
  32534. this._dragging = false;
  32535. this._track = [];
  32536. }
  32537. function updateViewByCursor(e, isEnd) {
  32538. var x = e.offsetX;
  32539. var y = e.offsetY;
  32540. if (isInContainer.call(this, x, y)) {
  32541. this._track.push([x, y]);
  32542. // Create or update cover.
  32543. var ranges = shouldShowCover.call(this)
  32544. ? coverRenderers[this.type].getRanges.call(this)
  32545. // Remove cover.
  32546. : [];
  32547. renderCover.call(this, ranges);
  32548. this.trigger('selected', zrUtil.clone(ranges));
  32549. if (isEnd) {
  32550. this.trigger('selectEnd', zrUtil.clone(ranges));
  32551. }
  32552. }
  32553. }
  32554. function shouldShowCover() {
  32555. var track = this._track;
  32556. if (!track.length) {
  32557. return false;
  32558. }
  32559. var p2 = track[track.length - 1];
  32560. var p1 = track[0];
  32561. var dx = p2[0] - p1[0];
  32562. var dy = p2[1] - p1[1];
  32563. var dist = mathPow(dx * dx + dy * dy, 0.5);
  32564. return dist > UNSELECT_THRESHOLD;
  32565. }
  32566. function renderCover(ranges) {
  32567. var coverRenderer = coverRenderers[this.type];
  32568. if (ranges && ranges.length) {
  32569. if (!this._cover) {
  32570. this._cover = coverRenderer.create.call(this);
  32571. this.group.add(this._cover);
  32572. }
  32573. coverRenderer.update.call(this, ranges);
  32574. }
  32575. else {
  32576. this.group.remove(this._cover);
  32577. this._cover = null;
  32578. }
  32579. updateZ(this.group);
  32580. }
  32581. function removeGroup() {
  32582. // container may 'removeAll' outside.
  32583. var group = this.group;
  32584. var container = group.parent;
  32585. if (container) {
  32586. container.remove(group);
  32587. }
  32588. }
  32589. function createRectCover() {
  32590. var opt = this.opt;
  32591. return new graphic.Rect({
  32592. // FIXME
  32593. // customize style.
  32594. style: {
  32595. stroke: opt.stroke,
  32596. fill: opt.fill,
  32597. lineWidth: opt.lineWidth,
  32598. opacity: opt.opacity
  32599. }
  32600. });
  32601. }
  32602. function getLocalTrack() {
  32603. return zrUtil.map(this._track, function (point) {
  32604. return this.group.transformCoordToLocal(point[0], point[1]);
  32605. }, this);
  32606. }
  32607. function getLocalTrackEnds() {
  32608. var localTrack = getLocalTrack.call(this);
  32609. var tail = localTrack.length - 1;
  32610. tail < 0 && (tail = 0);
  32611. return [localTrack[0], localTrack[tail]];
  32612. }
  32613. /**
  32614. * key: this.type
  32615. * @type {Object}
  32616. */
  32617. var coverRenderers = {
  32618. line: {
  32619. create: createRectCover,
  32620. getRanges: function () {
  32621. var ends = getLocalTrackEnds.call(this);
  32622. var min = mathMin(ends[0][0], ends[1][0]);
  32623. var max = mathMax(ends[0][0], ends[1][0]);
  32624. return [[min, max]];
  32625. },
  32626. update: function (ranges) {
  32627. var range = ranges[0];
  32628. var width = this.opt.width;
  32629. this._cover.setShape({
  32630. x: range[0],
  32631. y: -width / 2,
  32632. width: range[1] - range[0],
  32633. height: width
  32634. });
  32635. }
  32636. },
  32637. rect: {
  32638. create: createRectCover,
  32639. getRanges: function () {
  32640. var ends = getLocalTrackEnds.call(this);
  32641. var min = [
  32642. mathMin(ends[1][0], ends[0][0]),
  32643. mathMin(ends[1][1], ends[0][1])
  32644. ];
  32645. var max = [
  32646. mathMax(ends[1][0], ends[0][0]),
  32647. mathMax(ends[1][1], ends[0][1])
  32648. ];
  32649. return [[
  32650. [min[0], max[0]], // x range
  32651. [min[1], max[1]] // y range
  32652. ]];
  32653. },
  32654. update: function (ranges) {
  32655. var range = ranges[0];
  32656. this._cover.setShape({
  32657. x: range[0][0],
  32658. y: range[1][0],
  32659. width: range[0][1] - range[0][0],
  32660. height: range[1][1] - range[1][0]
  32661. });
  32662. }
  32663. }
  32664. };
  32665. module.exports = SelectController;
  32666. /***/ },
  32667. /* 229 */
  32668. /***/ function(module, exports, __webpack_require__) {
  32669. var zrUtil = __webpack_require__(3);
  32670. var modelUtil = __webpack_require__(5);
  32671. module.exports = function (option) {
  32672. createParallelIfNeeded(option);
  32673. mergeAxisOptionFromParallel(option);
  32674. };
  32675. /**
  32676. * Create a parallel coordinate if not exists.
  32677. * @inner
  32678. */
  32679. function createParallelIfNeeded(option) {
  32680. if (option.parallel) {
  32681. return;
  32682. }
  32683. var hasParallelSeries = false;
  32684. zrUtil.each(option.series, function (seriesOpt) {
  32685. if (seriesOpt && seriesOpt.type === 'parallel') {
  32686. hasParallelSeries = true;
  32687. }
  32688. });
  32689. if (hasParallelSeries) {
  32690. option.parallel = [{}];
  32691. }
  32692. }
  32693. /**
  32694. * Merge aixs definition from parallel option (if exists) to axis option.
  32695. * @inner
  32696. */
  32697. function mergeAxisOptionFromParallel(option) {
  32698. var axes = modelUtil.normalizeToArray(option.parallelAxis);
  32699. zrUtil.each(axes, function (axisOption) {
  32700. if (!zrUtil.isObject(axisOption)) {
  32701. return;
  32702. }
  32703. var parallelIndex = axisOption.parallelIndex || 0;
  32704. var parallelOption = modelUtil.normalizeToArray(option.parallel)[parallelIndex];
  32705. if (parallelOption && parallelOption.parallelAxisDefault) {
  32706. zrUtil.merge(axisOption, parallelOption.parallelAxisDefault, false);
  32707. }
  32708. });
  32709. }
  32710. /***/ },
  32711. /* 230 */
  32712. /***/ function(module, exports, __webpack_require__) {
  32713. var List = __webpack_require__(95);
  32714. var zrUtil = __webpack_require__(3);
  32715. var SeriesModel = __webpack_require__(27);
  32716. module.exports = SeriesModel.extend({
  32717. type: 'series.parallel',
  32718. dependencies: ['parallel'],
  32719. getInitialData: function (option, ecModel) {
  32720. var parallelModel = ecModel.getComponent(
  32721. 'parallel', this.get('parallelIndex')
  32722. );
  32723. var dimensions = parallelModel.dimensions;
  32724. var parallelAxisIndices = parallelModel.parallelAxisIndex;
  32725. var rawData = option.data;
  32726. var dimensionsInfo = zrUtil.map(dimensions, function (dim, index) {
  32727. var axisModel = ecModel.getComponent(
  32728. 'parallelAxis', parallelAxisIndices[index]
  32729. );
  32730. if (axisModel.get('type') === 'category') {
  32731. translateCategoryValue(axisModel, dim, rawData);
  32732. return {name: dim, type: 'ordinal'};
  32733. }
  32734. else {
  32735. return dim;
  32736. }
  32737. });
  32738. var list = new List(dimensionsInfo, this);
  32739. list.initData(rawData);
  32740. return list;
  32741. },
  32742. /**
  32743. * User can get data raw indices on 'axisAreaSelected' event received.
  32744. *
  32745. * @public
  32746. * @param {string} activeState 'active' or 'inactive' or 'normal'
  32747. * @return {Array.<number>} Raw indices
  32748. */
  32749. getRawIndicesByActiveState: function (activeState) {
  32750. var coordSys = this.coordinateSystem;
  32751. var data = this.getData();
  32752. var indices = [];
  32753. coordSys.eachActiveState(data, function (theActiveState, dataIndex) {
  32754. if (activeState === theActiveState) {
  32755. indices.push(data.getRawIndex(dataIndex));
  32756. }
  32757. });
  32758. return indices;
  32759. },
  32760. defaultOption: {
  32761. zlevel: 0, // 一级层叠
  32762. z: 2, // 二级层叠
  32763. coordinateSystem: 'parallel',
  32764. parallelIndex: 0,
  32765. // FIXME 尚无用
  32766. label: {
  32767. normal: {
  32768. show: false
  32769. // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  32770. // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为
  32771. // 'inside'|'left'|'right'|'top'|'bottom'
  32772. // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
  32773. },
  32774. emphasis: {
  32775. show: false
  32776. // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  32777. // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为
  32778. // 'inside'|'left'|'right'|'top'|'bottom'
  32779. // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
  32780. }
  32781. },
  32782. inactiveOpacity: 0.05,
  32783. activeOpacity: 1,
  32784. lineStyle: {
  32785. normal: {
  32786. width: 2,
  32787. opacity: 0.45,
  32788. type: 'solid'
  32789. }
  32790. },
  32791. // smooth: false
  32792. animationEasing: 'linear'
  32793. }
  32794. });
  32795. function translateCategoryValue(axisModel, dim, rawData) {
  32796. var axisData = axisModel.get('data');
  32797. var numberDim = +dim.replace('dim', '');
  32798. if (axisData && axisData.length) {
  32799. zrUtil.each(rawData, function (dataItem) {
  32800. if (!dataItem) {
  32801. return;
  32802. }
  32803. var index = zrUtil.indexOf(axisData, dataItem[numberDim]);
  32804. dataItem[numberDim] = index >= 0 ? index : NaN;
  32805. });
  32806. }
  32807. // FIXME
  32808. // 如果没有设置axis data, 应自动算出,或者提示。
  32809. }
  32810. /***/ },
  32811. /* 231 */
  32812. /***/ function(module, exports, __webpack_require__) {
  32813. var graphic = __webpack_require__(42);
  32814. var zrUtil = __webpack_require__(3);
  32815. var ParallelView = __webpack_require__(41).extend({
  32816. type: 'parallel',
  32817. init: function () {
  32818. /**
  32819. * @type {module:zrender/container/Group}
  32820. * @private
  32821. */
  32822. this._dataGroup = new graphic.Group();
  32823. this.group.add(this._dataGroup);
  32824. /**
  32825. * @type {module:echarts/data/List}
  32826. */
  32827. this._data;
  32828. },
  32829. /**
  32830. * @override
  32831. */
  32832. render: function (seriesModel, ecModel, api, payload) {
  32833. var dataGroup = this._dataGroup;
  32834. var data = seriesModel.getData();
  32835. var oldData = this._data;
  32836. var coordSys = seriesModel.coordinateSystem;
  32837. var dimensions = coordSys.dimensions;
  32838. data.diff(oldData)
  32839. .add(add)
  32840. .update(update)
  32841. .remove(remove)
  32842. .execute();
  32843. // Update style
  32844. data.eachItemGraphicEl(function (elGroup, idx) {
  32845. var itemModel = data.getItemModel(idx);
  32846. var lineStyleModel = itemModel.getModel('lineStyle.normal');
  32847. elGroup.eachChild(function (child) {
  32848. child.useStyle(zrUtil.extend(
  32849. lineStyleModel.getLineStyle(),
  32850. {
  32851. fill: null,
  32852. stroke: data.getItemVisual(idx, 'color'),
  32853. opacity: data.getItemVisual(idx, 'opacity')
  32854. }
  32855. ));
  32856. });
  32857. });
  32858. // First create
  32859. if (!this._data) {
  32860. dataGroup.setClipPath(createGridClipShape(
  32861. coordSys, seriesModel, function () {
  32862. dataGroup.removeClipPath();
  32863. }
  32864. ));
  32865. }
  32866. this._data = data;
  32867. function add(newDataIndex) {
  32868. var values = data.getValues(dimensions, newDataIndex);
  32869. var elGroup = new graphic.Group();
  32870. dataGroup.add(elGroup);
  32871. eachAxisPair(
  32872. values, dimensions, coordSys,
  32873. function (pointPair, pairIndex) {
  32874. // FIXME
  32875. // init animation
  32876. if (pointPair) {
  32877. elGroup.add(createEl(pointPair));
  32878. }
  32879. }
  32880. );
  32881. data.setItemGraphicEl(newDataIndex, elGroup);
  32882. }
  32883. function update(newDataIndex, oldDataIndex) {
  32884. var values = data.getValues(dimensions, newDataIndex);
  32885. var elGroup = oldData.getItemGraphicEl(oldDataIndex);
  32886. var newEls = [];
  32887. var elGroupIndex = 0;
  32888. eachAxisPair(
  32889. values, dimensions, coordSys,
  32890. function (pointPair, pairIndex) {
  32891. var el = elGroup.childAt(elGroupIndex++);
  32892. if (pointPair && !el) {
  32893. newEls.push(createEl(pointPair));
  32894. }
  32895. else if (pointPair) {
  32896. graphic.updateProps(el, {
  32897. shape: {
  32898. points: pointPair
  32899. }
  32900. }, seriesModel, newDataIndex);
  32901. }
  32902. }
  32903. );
  32904. // Remove redundent els
  32905. for (var i = elGroup.childCount() - 1; i >= elGroupIndex; i--) {
  32906. elGroup.remove(elGroup.childAt(i));
  32907. }
  32908. // Add new els
  32909. for (var i = 0, len = newEls.length; i < len; i++) {
  32910. elGroup.add(newEls[i]);
  32911. }
  32912. data.setItemGraphicEl(newDataIndex, elGroup);
  32913. }
  32914. function remove(oldDataIndex) {
  32915. var elGroup = oldData.getItemGraphicEl(oldDataIndex);
  32916. dataGroup.remove(elGroup);
  32917. }
  32918. },
  32919. /**
  32920. * @override
  32921. */
  32922. remove: function () {
  32923. this._dataGroup && this._dataGroup.removeAll();
  32924. this._data = null;
  32925. }
  32926. });
  32927. function createGridClipShape(coordSys, seriesModel, cb) {
  32928. var parallelModel = coordSys.model;
  32929. var rect = coordSys.getRect();
  32930. var rectEl = new graphic.Rect({
  32931. shape: {
  32932. x: rect.x,
  32933. y: rect.y,
  32934. width: rect.width,
  32935. height: rect.height
  32936. }
  32937. });
  32938. var dim = parallelModel.get('layout') === 'horizontal' ? 'width' : 'height';
  32939. rectEl.setShape(dim, 0);
  32940. graphic.initProps(rectEl, {
  32941. shape: {
  32942. width: rect.width,
  32943. height: rect.height
  32944. }
  32945. }, seriesModel, cb);
  32946. return rectEl;
  32947. }
  32948. function eachAxisPair(values, dimensions, coordSys, cb) {
  32949. for (var i = 0, len = dimensions.length - 1; i < len; i++) {
  32950. var dimA = dimensions[i];
  32951. var dimB = dimensions[i + 1];
  32952. var valueA = values[i];
  32953. var valueB = values[i + 1];
  32954. cb(
  32955. (isEmptyValue(valueA, coordSys.getAxis(dimA).type)
  32956. || isEmptyValue(valueB, coordSys.getAxis(dimB).type)
  32957. )
  32958. ? null
  32959. : [
  32960. coordSys.dataToPoint(valueA, dimA),
  32961. coordSys.dataToPoint(valueB, dimB)
  32962. ],
  32963. i
  32964. );
  32965. }
  32966. }
  32967. function createEl(pointPair) {
  32968. return new graphic.Polyline({
  32969. shape: {points: pointPair},
  32970. silent: true
  32971. });
  32972. }
  32973. // FIXME
  32974. // 公用方法?
  32975. function isEmptyValue(val, axisType) {
  32976. return axisType === 'category'
  32977. ? val == null
  32978. : (val == null || isNaN(val)); // axisType === 'value'
  32979. }
  32980. module.exports = ParallelView;
  32981. /***/ },
  32982. /* 232 */
  32983. /***/ function(module, exports) {
  32984. /**
  32985. * @payload
  32986. * @property {string} parallelAxisId
  32987. * @property {Array.<number>} extent
  32988. */
  32989. module.exports = function (ecModel, payload) {
  32990. ecModel.eachSeriesByType('parallel', function (seriesModel) {
  32991. var itemStyleModel = seriesModel.getModel('itemStyle.normal');
  32992. var globalColors = ecModel.get('color');
  32993. var color = itemStyleModel.get('color')
  32994. || globalColors[seriesModel.seriesIndex % globalColors.length];
  32995. var inactiveOpacity = seriesModel.get('inactiveOpacity');
  32996. var activeOpacity = seriesModel.get('activeOpacity');
  32997. var lineStyle = seriesModel.getModel('lineStyle.normal').getLineStyle();
  32998. var coordSys = seriesModel.coordinateSystem;
  32999. var data = seriesModel.getData();
  33000. var opacityMap = {
  33001. normal: lineStyle.opacity,
  33002. active: activeOpacity,
  33003. inactive: inactiveOpacity
  33004. };
  33005. coordSys.eachActiveState(data, function (activeState, dataIndex) {
  33006. data.setItemVisual(dataIndex, 'opacity', opacityMap[activeState]);
  33007. });
  33008. data.setVisual('color', color);
  33009. });
  33010. };
  33011. /***/ },
  33012. /* 233 */
  33013. /***/ function(module, exports, __webpack_require__) {
  33014. var echarts = __webpack_require__(1);
  33015. __webpack_require__(234);
  33016. __webpack_require__(235);
  33017. echarts.registerLayout(__webpack_require__(236));
  33018. echarts.registerVisualCoding('chart', __webpack_require__(238));
  33019. /***/ },
  33020. /* 234 */
  33021. /***/ function(module, exports, __webpack_require__) {
  33022. 'use strict';
  33023. var SeriesModel = __webpack_require__(27);
  33024. var createGraphFromNodeEdge = __webpack_require__(191);
  33025. var SankeySeries = SeriesModel.extend({
  33026. type: 'series.sankey',
  33027. layoutInfo: null,
  33028. getInitialData: function (option, ecModel) {
  33029. var links = option.edges || option.links;
  33030. var nodes = option.data || option.nodes;
  33031. if (nodes && links) {
  33032. var graph = createGraphFromNodeEdge(nodes, links, this, true);
  33033. return graph.data;
  33034. }
  33035. },
  33036. /**
  33037. * @return {module:echarts/data/Graph}
  33038. */
  33039. getGraph: function () {
  33040. return this.getData().graph;
  33041. },
  33042. /**
  33043. * return {module:echarts/data/List}
  33044. */
  33045. getEdgeData: function() {
  33046. return this.getGraph().edgeData;
  33047. },
  33048. /**
  33049. * @override
  33050. */
  33051. formatTooltip: function (dataIndex, multipleSeries, dataType) {
  33052. if (dataType === 'edge') {
  33053. var params = this.getDataParams(dataIndex, dataType);
  33054. var rawDataOpt = params.data;
  33055. var html = rawDataOpt.source + ' -- ' + rawDataOpt.target;
  33056. if (params.value) {
  33057. html += ' : ' + params.value;
  33058. }
  33059. return html;
  33060. }
  33061. else {
  33062. return SankeySeries.superCall(this, 'formatTooltip', dataIndex, multipleSeries);
  33063. }
  33064. // dataType === 'node' or empty do not show tooltip by default.
  33065. },
  33066. defaultOption: {
  33067. zlevel: 0,
  33068. z: 2,
  33069. coordinateSystem: 'view',
  33070. layout : null,
  33071. // the position of the whole view
  33072. left: '5%',
  33073. top: '5%',
  33074. right: '20%',
  33075. bottom: '5%',
  33076. // the dx of the node
  33077. nodeWidth: 20,
  33078. // the distance between two nodes
  33079. nodeGap: 8,
  33080. // the number of iterations to change the position of the node
  33081. layoutIterations: 32,
  33082. label: {
  33083. normal: {
  33084. show: true,
  33085. position: 'right',
  33086. textStyle: {
  33087. color: '#000',
  33088. fontSize: 12
  33089. }
  33090. },
  33091. emphasis: {
  33092. show: true
  33093. }
  33094. },
  33095. itemStyle: {
  33096. normal: {
  33097. borderWidth: 1,
  33098. borderColor: '#333'
  33099. }
  33100. },
  33101. lineStyle: {
  33102. normal: {
  33103. color: '#314656',
  33104. opacity: 0.2,
  33105. curveness: 0.5
  33106. },
  33107. emphasis: {
  33108. opacity: 0.6
  33109. }
  33110. },
  33111. animationEasing: 'linear',
  33112. animationDuration: 1000
  33113. }
  33114. });
  33115. module.exports = SankeySeries;
  33116. /***/ },
  33117. /* 235 */
  33118. /***/ function(module, exports, __webpack_require__) {
  33119. var graphic = __webpack_require__(42);
  33120. var zrUtil = __webpack_require__(3);
  33121. var SankeyShape = graphic.extendShape({
  33122. shape: {
  33123. x1: 0, y1: 0,
  33124. x2: 0, y2: 0,
  33125. cpx1: 0, cpy1: 0,
  33126. cpx2: 0, cpy2: 0,
  33127. extent: 0
  33128. },
  33129. buildPath: function (ctx, shape) {
  33130. var halfExtent = shape.extent / 2;
  33131. ctx.moveTo(shape.x1, shape.y1 - halfExtent);
  33132. ctx.bezierCurveTo(
  33133. shape.cpx1, shape.cpy1 - halfExtent,
  33134. shape.cpx2, shape.cpy2 - halfExtent,
  33135. shape.x2, shape.y2 - halfExtent
  33136. );
  33137. ctx.lineTo(shape.x2, shape.y2 + halfExtent);
  33138. ctx.bezierCurveTo(
  33139. shape.cpx2, shape.cpy2 + halfExtent,
  33140. shape.cpx1, shape.cpy1 + halfExtent,
  33141. shape.x1, shape.y1 + halfExtent
  33142. );
  33143. ctx.closePath();
  33144. }
  33145. });
  33146. module.exports = __webpack_require__(1).extendChartView({
  33147. type: 'sankey',
  33148. /**
  33149. * @private
  33150. * @type {module:echarts/chart/sankey/SankeySeries}
  33151. */
  33152. _model: null,
  33153. render: function(seriesModel, ecModel, api) {
  33154. var graph = seriesModel.getGraph();
  33155. var group = this.group;
  33156. var layoutInfo = seriesModel.layoutInfo;
  33157. var nodeData = seriesModel.getData();
  33158. var edgeData = seriesModel.getData('edge');
  33159. this._model = seriesModel;
  33160. group.removeAll();
  33161. group.position = [layoutInfo.x, layoutInfo.y];
  33162. // generate a rect for each node
  33163. graph.eachNode(function (node) {
  33164. var layout = node.getLayout();
  33165. var itemModel = node.getModel();
  33166. var labelModel = itemModel.getModel('label.normal');
  33167. var textStyleModel = labelModel.getModel('textStyle');
  33168. var labelHoverModel = itemModel.getModel('label.emphasis');
  33169. var textStyleHoverModel = labelHoverModel.getModel('textStyle');
  33170. var rect = new graphic.Rect({
  33171. shape: {
  33172. x: layout.x,
  33173. y: layout.y,
  33174. width: node.getLayout().dx,
  33175. height: node.getLayout().dy
  33176. },
  33177. style: {
  33178. // Get formatted label in label.normal option. Use node id if it is not specified
  33179. text: labelModel.get('show')
  33180. ? seriesModel.getFormattedLabel(node.dataIndex, 'normal') || node.id
  33181. // Use empty string to hide the label
  33182. : '',
  33183. textFont: textStyleModel.getFont(),
  33184. textFill: textStyleModel.getTextColor(),
  33185. textPosition: labelModel.get('position')
  33186. }
  33187. });
  33188. rect.setStyle(zrUtil.defaults(
  33189. {
  33190. fill: node.getVisual('color')
  33191. },
  33192. itemModel.getModel('itemStyle.normal').getItemStyle()
  33193. ));
  33194. graphic.setHoverStyle(rect, zrUtil.extend(
  33195. node.getModel('itemStyle.emphasis'),
  33196. {
  33197. text: labelHoverModel.get('show')
  33198. ? seriesModel.getFormattedLabel(node.dataIndex, 'emphasis') || node.id
  33199. : '',
  33200. textFont: textStyleHoverModel.getFont(),
  33201. textFill: textStyleHoverModel.getTextColor(),
  33202. textPosition: labelHoverModel.get('position')
  33203. }
  33204. ));
  33205. group.add(rect);
  33206. nodeData.setItemGraphicEl(node.dataIndex, rect);
  33207. rect.dataType = 'node';
  33208. });
  33209. // generate a bezire Curve for each edge
  33210. graph.eachEdge(function (edge) {
  33211. var curve = new SankeyShape();
  33212. curve.dataIndex = edge.dataIndex;
  33213. curve.seriesIndex = seriesModel.seriesIndex;
  33214. curve.dataType = 'edge';
  33215. var lineStyleModel = edge.getModel('lineStyle.normal');
  33216. var curvature = lineStyleModel.get('curveness');
  33217. var n1Layout = edge.node1.getLayout();
  33218. var n2Layout = edge.node2.getLayout();
  33219. var edgeLayout = edge.getLayout();
  33220. curve.shape.extent = Math.max(1, edgeLayout.dy);
  33221. var x1 = n1Layout.x + n1Layout.dx;
  33222. var y1 = n1Layout.y + edgeLayout.sy + edgeLayout.dy / 2;
  33223. var x2 = n2Layout.x;
  33224. var y2 = n2Layout.y + edgeLayout.ty + edgeLayout.dy /2;
  33225. var cpx1 = x1 * (1 - curvature) + x2 * curvature;
  33226. var cpy1 = y1;
  33227. var cpx2 = x1 * curvature + x2 * (1 - curvature);
  33228. var cpy2 = y2;
  33229. curve.setShape({
  33230. x1: x1,
  33231. y1: y1,
  33232. x2: x2,
  33233. y2: y2,
  33234. cpx1: cpx1,
  33235. cpy1: cpy1,
  33236. cpx2: cpx2,
  33237. cpy2: cpy2
  33238. });
  33239. curve.setStyle(lineStyleModel.getItemStyle());
  33240. graphic.setHoverStyle(curve, edge.getModel('lineStyle.emphasis').getItemStyle());
  33241. group.add(curve);
  33242. edgeData.setItemGraphicEl(edge.dataIndex, curve);
  33243. });
  33244. if (!this._data && seriesModel.get('animation')) {
  33245. group.setClipPath(createGridClipShape(group.getBoundingRect(), seriesModel, function () {
  33246. group.removeClipPath();
  33247. }));
  33248. }
  33249. this._data = seriesModel.getData();
  33250. }
  33251. });
  33252. //add animation to the view
  33253. function createGridClipShape(rect, seriesModel, cb) {
  33254. var rectEl = new graphic.Rect({
  33255. shape: {
  33256. x: rect.x - 10,
  33257. y: rect.y - 10,
  33258. width: 0,
  33259. height: rect.height + 20
  33260. }
  33261. });
  33262. graphic.initProps(rectEl, {
  33263. shape: {
  33264. width: rect.width + 20,
  33265. height: rect.height + 20
  33266. }
  33267. }, seriesModel, cb);
  33268. return rectEl;
  33269. }
  33270. /***/ },
  33271. /* 236 */
  33272. /***/ function(module, exports, __webpack_require__) {
  33273. var layout = __webpack_require__(21);
  33274. var nest = __webpack_require__(237);
  33275. var zrUtil = __webpack_require__(3);
  33276. module.exports = function (ecModel, api) {
  33277. ecModel.eachSeriesByType('sankey', function (seriesModel) {
  33278. var nodeWidth = seriesModel.get('nodeWidth');
  33279. var nodeGap = seriesModel.get('nodeGap');
  33280. var layoutInfo = getViewRect(seriesModel, api);
  33281. seriesModel.layoutInfo = layoutInfo;
  33282. var width = layoutInfo.width;
  33283. var height = layoutInfo.height;
  33284. var graph = seriesModel.getGraph();
  33285. var nodes = graph.nodes;
  33286. var edges = graph.edges;
  33287. computeNodeValues(nodes);
  33288. var filteredNodes = nodes.filter(function (node) {
  33289. return node.getLayout().value === 0;
  33290. });
  33291. var iterations = filteredNodes.length !== 0
  33292. ? 0 : seriesModel.get('layoutIterations');
  33293. layoutSankey(nodes, edges, nodeWidth, nodeGap, width, height, iterations);
  33294. });
  33295. };
  33296. /**
  33297. * get the layout position of the whole view.
  33298. */
  33299. function getViewRect(seriesModel, api) {
  33300. return layout.getLayoutRect(
  33301. seriesModel.getBoxLayoutParams(), {
  33302. width: api.getWidth(),
  33303. height: api.getHeight()
  33304. }
  33305. );
  33306. }
  33307. function layoutSankey(nodes, edges, nodeWidth, nodeGap, width, height, iterations) {
  33308. computeNodeBreadths(nodes, nodeWidth, width);
  33309. computeNodeDepths(nodes, edges, height, nodeGap, iterations);
  33310. computeEdgeDepths(nodes);
  33311. }
  33312. /**
  33313. * compute the value of each node by summing the associated edge's value.
  33314. * @param {module:echarts/data/Graph~Node} nodes
  33315. */
  33316. function computeNodeValues(nodes) {
  33317. zrUtil.each(nodes, function (node) {
  33318. var value1 = sum(node.outEdges, getEdgeValue);
  33319. var value2 = sum(node.inEdges, getEdgeValue);
  33320. var value = Math.max(value1, value2);
  33321. node.setLayout({value: value}, true);
  33322. });
  33323. }
  33324. /**
  33325. * compute the x-position for each node.
  33326. * @param {module:echarts/data/Graph~Node} nodes
  33327. * @param {number} nodeWidth
  33328. * @param {number} width
  33329. */
  33330. function computeNodeBreadths(nodes, nodeWidth, width) {
  33331. var remainNodes = nodes;
  33332. var nextNode = null;
  33333. var x = 0;
  33334. var kx = 0;
  33335. while (remainNodes.length) {
  33336. nextNode = [];
  33337. for (var i = 0, len = remainNodes.length; i < len; i++) {
  33338. var node = remainNodes[i];
  33339. node.setLayout({x: x}, true);
  33340. node.setLayout({dx: nodeWidth}, true);
  33341. for (var j = 0, lenj = node.outEdges.length; j < lenj; j++) {
  33342. nextNode.push(node.outEdges[j].node2);
  33343. }
  33344. }
  33345. remainNodes = nextNode;
  33346. ++x;
  33347. }
  33348. moveSinksRight(nodes, x);
  33349. kx = (width - nodeWidth) / (x - 1);
  33350. scaleNodeBreadths(nodes, kx);
  33351. }
  33352. /**
  33353. * all the node without outEgdes are assigned maximum breadth and
  33354. * be aligned in the last column.
  33355. * @param {module:echarts/data/Graph~Node} nodes
  33356. * @param {number} x
  33357. */
  33358. function moveSinksRight(nodes, x) {
  33359. zrUtil.each(nodes, function (node) {
  33360. if(!node.outEdges.length) {
  33361. node.setLayout({x: x-1}, true);
  33362. }
  33363. });
  33364. }
  33365. /**
  33366. * scale node x-position to the width.
  33367. * @param {module:echarts/data/Graph~Node} nodes
  33368. * @param {number} kx
  33369. */
  33370. function scaleNodeBreadths(nodes, kx) {
  33371. zrUtil.each(nodes, function(node) {
  33372. var nodeX = node.getLayout().x * kx;
  33373. node.setLayout({x: nodeX}, true);
  33374. });
  33375. }
  33376. /**
  33377. * using Gauss-Seidel iterations method to compute the node depth(y-position).
  33378. * @param {module:echarts/data/Graph~Node} nodes
  33379. * @param {module:echarts/data/Graph~Edge} edges
  33380. * @param {number} height
  33381. * @param {numbber} nodeGap
  33382. * @param {number} iterations
  33383. */
  33384. function computeNodeDepths(nodes, edges, height, nodeGap, iterations) {
  33385. var nodesByBreadth = nest()
  33386. .key(function (d) {
  33387. return d.getLayout().x;
  33388. })
  33389. .sortKeys(ascending)
  33390. .entries(nodes)
  33391. .map(function (d) {
  33392. return d.values;
  33393. });
  33394. initializeNodeDepth(nodes, nodesByBreadth, edges, height, nodeGap);
  33395. resolveCollisions(nodesByBreadth, nodeGap, height);
  33396. for (var alpha = 1; iterations > 0; iterations--) {
  33397. alpha *= 0.99;
  33398. relaxRightToLeft(nodesByBreadth, alpha);
  33399. resolveCollisions(nodesByBreadth, nodeGap, height);
  33400. relaxLeftToRight(nodesByBreadth, alpha);
  33401. resolveCollisions(nodesByBreadth, nodeGap, height);
  33402. }
  33403. }
  33404. /**
  33405. * compute the original y-position for each node.
  33406. * @param {module:echarts/data/Graph~Node} nodes
  33407. * @param {Array.<Array.<module:echarts/data/Graph~Node>>} nodesByBreadth
  33408. * @param {module:echarts/data/Graph~Edge} edges
  33409. * @param {number} height
  33410. * @param {number} nodeGap
  33411. */
  33412. function initializeNodeDepth(nodes, nodesByBreadth, edges, height, nodeGap) {
  33413. var kyArray = [];
  33414. zrUtil.each(nodesByBreadth, function (nodes) {
  33415. var n = nodes.length;
  33416. var sum = 0;
  33417. zrUtil.each(nodes, function (node) {
  33418. sum += node.getLayout().value;
  33419. });
  33420. var ky = (height - (n-1) * nodeGap) / sum;
  33421. kyArray.push(ky);
  33422. });
  33423. kyArray.sort(function (a, b) {
  33424. return a - b;
  33425. });
  33426. var ky0 = kyArray[0];
  33427. zrUtil.each(nodesByBreadth, function (nodes) {
  33428. zrUtil.each(nodes, function (node, i) {
  33429. node.setLayout({y: i}, true);
  33430. var nodeDy = node.getLayout().value * ky0;
  33431. node.setLayout({dy: nodeDy}, true);
  33432. });
  33433. });
  33434. zrUtil.each(edges, function (edge) {
  33435. var edgeDy = +edge.getValue() * ky0;
  33436. edge.setLayout({dy: edgeDy}, true);
  33437. });
  33438. }
  33439. /**
  33440. * resolve the collision of initialized depth.
  33441. * @param {Array.<Array.<module:echarts/data/Graph~Node>>} nodesByBreadth
  33442. * @param {number} nodeGap
  33443. * @param {number} height
  33444. */
  33445. function resolveCollisions(nodesByBreadth, nodeGap, height) {
  33446. zrUtil.each(nodesByBreadth, function (nodes) {
  33447. var node;
  33448. var dy;
  33449. var y0 = 0;
  33450. var n = nodes.length;
  33451. var i;
  33452. nodes.sort(ascendingDepth);
  33453. for (i = 0; i < n; i++) {
  33454. node = nodes[i];
  33455. dy = y0 - node.getLayout().y;
  33456. if(dy > 0) {
  33457. var nodeY = node.getLayout().y + dy;
  33458. node.setLayout({y: nodeY}, true);
  33459. }
  33460. y0 = node.getLayout().y + node.getLayout().dy + nodeGap;
  33461. }
  33462. // if the bottommost node goes outside the biunds, push it back up
  33463. dy = y0 - nodeGap - height;
  33464. if (dy > 0) {
  33465. var nodeY = node.getLayout().y -dy;
  33466. node.setLayout({y: nodeY}, true);
  33467. y0 = node.getLayout().y;
  33468. for (i = n - 2; i >= 0; --i) {
  33469. node = nodes[i];
  33470. dy = node.getLayout().y + node.getLayout().dy + nodeGap - y0;
  33471. if (dy > 0) {
  33472. nodeY = node.getLayout().y - dy;
  33473. node.setLayout({y: nodeY}, true);
  33474. }
  33475. y0 = node.getLayout().y;
  33476. }
  33477. }
  33478. });
  33479. }
  33480. /**
  33481. * change the y-position of the nodes, except most the right side nodes.
  33482. * @param {Array.<Array.<module:echarts/data/Graph~Node>>} nodesByBreadth
  33483. * @param {number} alpha
  33484. */
  33485. function relaxRightToLeft(nodesByBreadth, alpha) {
  33486. zrUtil.each(nodesByBreadth.slice().reverse(), function (nodes) {
  33487. zrUtil.each(nodes, function (node) {
  33488. if (node.outEdges.length) {
  33489. var y = sum(node.outEdges, weightedTarget) / sum(node.outEdges, getEdgeValue);
  33490. var nodeY = node.getLayout().y + (y - center(node)) * alpha;
  33491. node.setLayout({y: nodeY}, true);
  33492. }
  33493. });
  33494. });
  33495. }
  33496. function weightedTarget(edge) {
  33497. return center(edge.node2) * edge.getValue();
  33498. }
  33499. /**
  33500. * change the y-position of the nodes, except most the left side nodes.
  33501. * @param {Array.<Array.<module:echarts/data/Graph~Node>>} nodesByBreadth
  33502. * @param {number} alpha
  33503. */
  33504. function relaxLeftToRight(nodesByBreadth, alpha) {
  33505. zrUtil.each(nodesByBreadth, function (nodes) {
  33506. zrUtil.each(nodes, function (node) {
  33507. if (node.inEdges.length) {
  33508. var y = sum(node.inEdges, weightedSource) / sum(node.inEdges, getEdgeValue);
  33509. var nodeY = node.getLayout().y + (y - center(node)) * alpha;
  33510. node.setLayout({y: nodeY}, true);
  33511. }
  33512. });
  33513. });
  33514. }
  33515. function weightedSource(edge) {
  33516. return center(edge.node1) * edge.getValue();
  33517. }
  33518. /**
  33519. * compute the depth(y-position) of each edge.
  33520. * @param {module:echarts/data/Graph~Node} nodes
  33521. */
  33522. function computeEdgeDepths(nodes) {
  33523. zrUtil.each(nodes, function (node) {
  33524. node.outEdges.sort(ascendingTargetDepth);
  33525. node.inEdges.sort(ascendingSourceDepth);
  33526. });
  33527. zrUtil.each(nodes, function (node) {
  33528. var sy = 0;
  33529. var ty = 0;
  33530. zrUtil.each(node.outEdges, function (edge) {
  33531. edge.setLayout({sy: sy}, true);
  33532. sy += edge.getLayout().dy;
  33533. });
  33534. zrUtil.each(node.inEdges, function (edge) {
  33535. edge.setLayout({ty: ty}, true);
  33536. ty += edge.getLayout().dy;
  33537. });
  33538. });
  33539. }
  33540. function ascendingTargetDepth(a, b) {
  33541. return a.node2.getLayout().y - b.node2.getLayout().y;
  33542. }
  33543. function ascendingSourceDepth(a, b) {
  33544. return a.node1.getLayout().y - b.node1.getLayout().y;
  33545. }
  33546. function sum(array, f) {
  33547. var s = 0;
  33548. var n = array.length;
  33549. var a;
  33550. var i = -1;
  33551. if (arguments.length === 1) {
  33552. while (++i < n) {
  33553. a = +array[i];
  33554. if (!isNaN(a)) {
  33555. s += a;
  33556. }
  33557. }
  33558. }
  33559. else {
  33560. while (++i < n) {
  33561. a = +f.call(array, array[i], i);
  33562. if(!isNaN(a)) {
  33563. s += a;
  33564. }
  33565. }
  33566. }
  33567. return s;
  33568. }
  33569. function center(node) {
  33570. return node.getLayout().y + node.getLayout().dy / 2;
  33571. }
  33572. function ascendingDepth(a, b) {
  33573. return a.getLayout().y - b.getLayout().y;
  33574. }
  33575. function ascending(a, b) {
  33576. return a < b ? -1 : a > b ? 1 : a == b ? 0 : NaN;
  33577. }
  33578. function getEdgeValue(edge) {
  33579. return edge.getValue();
  33580. }
  33581. /***/ },
  33582. /* 237 */
  33583. /***/ function(module, exports, __webpack_require__) {
  33584. var zrUtil = __webpack_require__(3);
  33585. /**
  33586. * nest helper used to group by the array.
  33587. * can specified the keys and sort the keys.
  33588. */
  33589. function nest() {
  33590. var keysFunction = [];
  33591. var sortKeysFunction = [];
  33592. /**
  33593. * map an Array into the mapObject.
  33594. * @param {Array} array
  33595. * @param {number} depth
  33596. */
  33597. function map(array, depth) {
  33598. if (depth >= keysFunction.length) {
  33599. return array;
  33600. }
  33601. var i = -1;
  33602. var n = array.length;
  33603. var keyFunction = keysFunction[depth++];
  33604. var mapObject = {};
  33605. var valuesByKey = {};
  33606. while (++i < n) {
  33607. var keyValue = keyFunction(array[i]);
  33608. var values = valuesByKey[keyValue];
  33609. if (values) {
  33610. values.push(array[i]);
  33611. }
  33612. else {
  33613. valuesByKey[keyValue] = [array[i]];
  33614. }
  33615. }
  33616. zrUtil.each(valuesByKey, function (value, key) {
  33617. mapObject[key] = map(value, depth);
  33618. });
  33619. return mapObject;
  33620. }
  33621. /**
  33622. * transform the Map Object to multidimensional Array
  33623. * @param {Object} map
  33624. * @param {number} depth
  33625. */
  33626. function entriesMap(mapObject, depth) {
  33627. if (depth >= keysFunction.length) {
  33628. return mapObject;
  33629. }
  33630. var array = [];
  33631. var sortKeyFunction = sortKeysFunction[depth++];
  33632. zrUtil.each(mapObject, function (value, key) {
  33633. array.push({
  33634. key: key, values: entriesMap(value, depth)
  33635. });
  33636. });
  33637. if (sortKeyFunction) {
  33638. return array.sort(function (a, b) {
  33639. return sortKeyFunction(a.key, b.key);
  33640. });
  33641. }
  33642. else {
  33643. return array;
  33644. }
  33645. }
  33646. return {
  33647. /**
  33648. * specified the key to groupby the arrays.
  33649. * users can specified one more keys.
  33650. * @param {Function} d
  33651. */
  33652. key: function (d) {
  33653. keysFunction.push(d);
  33654. return this;
  33655. },
  33656. /**
  33657. * specified the comparator to sort the keys
  33658. * @param {Function} order
  33659. */
  33660. sortKeys: function (order) {
  33661. sortKeysFunction[keysFunction.length - 1] = order;
  33662. return this;
  33663. },
  33664. /**
  33665. * the array to be grouped by.
  33666. * @param {Array} array
  33667. */
  33668. entries: function (array) {
  33669. return entriesMap(map(array, 0), 0);
  33670. }
  33671. };
  33672. }
  33673. module.exports = nest;
  33674. /***/ },
  33675. /* 238 */
  33676. /***/ function(module, exports, __webpack_require__) {
  33677. var VisualMapping = __webpack_require__(187);
  33678. module.exports = function (ecModel, payload) {
  33679. ecModel.eachSeriesByType('sankey', function (seriesModel) {
  33680. var graph = seriesModel.getGraph();
  33681. var nodes = graph.nodes;
  33682. nodes.sort(function (a, b) {
  33683. return a.getLayout().value - b.getLayout().value;
  33684. });
  33685. var minValue = nodes[0].getLayout().value;
  33686. var maxValue = nodes[nodes.length - 1].getLayout().value;
  33687. nodes.forEach(function (node) {
  33688. var mapping = new VisualMapping({
  33689. type: 'color',
  33690. mappingMethod: 'linear',
  33691. dataExtent: [minValue, maxValue],
  33692. visual: seriesModel.get('color')
  33693. });
  33694. var mapValueToColor = mapping.mapValueToVisual(node.getLayout().value);
  33695. node.setVisual('color', mapValueToColor);
  33696. // If set itemStyle.normal.color
  33697. var itemModel = node.getModel();
  33698. var customColor = itemModel.get('itemStyle.normal.color');
  33699. if (customColor != null) {
  33700. node.setVisual('color', customColor);
  33701. }
  33702. });
  33703. }) ;
  33704. };
  33705. /***/ },
  33706. /* 239 */
  33707. /***/ function(module, exports, __webpack_require__) {
  33708. var echarts = __webpack_require__(1);
  33709. __webpack_require__(240);
  33710. __webpack_require__(243);
  33711. echarts.registerVisualCoding('chart', __webpack_require__(244));
  33712. echarts.registerLayout(__webpack_require__(245));
  33713. /***/ },
  33714. /* 240 */
  33715. /***/ function(module, exports, __webpack_require__) {
  33716. 'use strict';
  33717. var zrUtil = __webpack_require__(3);
  33718. var SeriesModel = __webpack_require__(27);
  33719. var whiskerBoxCommon = __webpack_require__(241);
  33720. var BoxplotSeries = SeriesModel.extend({
  33721. type: 'series.boxplot',
  33722. dependencies: ['xAxis', 'yAxis', 'grid'],
  33723. // TODO
  33724. // box width represents group size, so dimension should have 'size'.
  33725. /**
  33726. * @see <https://en.wikipedia.org/wiki/Box_plot>
  33727. * The meanings of 'min' and 'max' depend on user,
  33728. * and echarts do not need to know it.
  33729. * @readOnly
  33730. */
  33731. valueDimensions: ['min', 'Q1', 'median', 'Q3', 'max'],
  33732. /**
  33733. * @type {Array.<string>}
  33734. * @readOnly
  33735. */
  33736. dimensions: null,
  33737. /**
  33738. * @override
  33739. */
  33740. defaultOption: {
  33741. zlevel: 0, // 一级层叠
  33742. z: 2, // 二级层叠
  33743. coordinateSystem: 'cartesian2d',
  33744. legendHoverLink: true,
  33745. hoverAnimation: true,
  33746. xAxisIndex: 0,
  33747. yAxisIndex: 0,
  33748. layout: null, // 'horizontal' or 'vertical'
  33749. boxWidth: [7, 50], // [min, max] can be percent of band width.
  33750. itemStyle: {
  33751. normal: {
  33752. color: '#fff',
  33753. borderWidth: 1
  33754. },
  33755. emphasis: {
  33756. borderWidth: 2,
  33757. shadowBlur: 5,
  33758. shadowOffsetX: 2,
  33759. shadowOffsetY: 2,
  33760. shadowColor: 'rgba(0,0,0,0.4)'
  33761. }
  33762. },
  33763. animationEasing: 'elasticOut',
  33764. animationDuration: 800
  33765. }
  33766. });
  33767. zrUtil.mixin(BoxplotSeries, whiskerBoxCommon.seriesModelMixin, true);
  33768. module.exports = BoxplotSeries;
  33769. /***/ },
  33770. /* 241 */
  33771. /***/ function(module, exports, __webpack_require__) {
  33772. 'use strict';
  33773. var List = __webpack_require__(95);
  33774. var completeDimensions = __webpack_require__(97);
  33775. var WhiskerBoxDraw = __webpack_require__(242);
  33776. var zrUtil = __webpack_require__(3);
  33777. function getItemValue(item) {
  33778. return item.value == null ? item : item.value;
  33779. }
  33780. var seriesModelMixin = {
  33781. /**
  33782. * @private
  33783. * @type {string}
  33784. */
  33785. _baseAxisDim: null,
  33786. /**
  33787. * @override
  33788. */
  33789. getInitialData: function (option, ecModel) {
  33790. // When both types of xAxis and yAxis are 'value', layout is
  33791. // needed to be specified by user. Otherwise, layout can be
  33792. // judged by which axis is category.
  33793. var categories;
  33794. var xAxisModel = ecModel.getComponent('xAxis', this.get('xAxisIndex'));
  33795. var yAxisModel = ecModel.getComponent('yAxis', this.get('yAxisIndex'));
  33796. var xAxisType = xAxisModel.get('type');
  33797. var yAxisType = yAxisModel.get('type');
  33798. var addOrdinal;
  33799. // FIXME
  33800. // 考虑时间轴
  33801. if (xAxisType === 'category') {
  33802. option.layout = 'horizontal';
  33803. categories = xAxisModel.getCategories();
  33804. addOrdinal = true;
  33805. }
  33806. else if (yAxisType === 'category') {
  33807. option.layout = 'vertical';
  33808. categories = yAxisModel.getCategories();
  33809. addOrdinal = true;
  33810. }
  33811. else {
  33812. option.layout = option.layout || 'horizontal';
  33813. }
  33814. this._baseAxisDim = option.layout === 'horizontal' ? 'x' : 'y';
  33815. var data = option.data;
  33816. var dimensions = this.dimensions = ['base'].concat(this.valueDimensions);
  33817. completeDimensions(dimensions, data);
  33818. var list = new List(dimensions, this);
  33819. list.initData(data, categories ? categories.slice() : null, function (dataItem, dimName, idx, dimIdx) {
  33820. var value = getItemValue(dataItem);
  33821. return addOrdinal ? (dimName === 'base' ? idx : value[dimIdx - 1]) : value[dimIdx];
  33822. });
  33823. return list;
  33824. },
  33825. /**
  33826. * Used by Gird.
  33827. * @param {string} axisDim 'x' or 'y'
  33828. * @return {Array.<string>} dimensions on the axis.
  33829. */
  33830. coordDimToDataDim: function (axisDim) {
  33831. var dims = this.valueDimensions.slice();
  33832. var baseDim = ['base'];
  33833. var map = {
  33834. horizontal: {x: baseDim, y: dims},
  33835. vertical: {x: dims, y: baseDim}
  33836. };
  33837. return map[this.get('layout')][axisDim];
  33838. },
  33839. /**
  33840. * @override
  33841. * @param {string|number} dataDim
  33842. * @return {string} coord dimension
  33843. */
  33844. dataDimToCoordDim: function (dataDim) {
  33845. var dim;
  33846. zrUtil.each(['x', 'y'], function (coordDim, index) {
  33847. var dataDims = this.coordDimToDataDim(coordDim);
  33848. if (zrUtil.indexOf(dataDims, dataDim) >= 0) {
  33849. dim = coordDim;
  33850. }
  33851. }, this);
  33852. return dim;
  33853. },
  33854. /**
  33855. * If horizontal, base axis is x, otherwise y.
  33856. * @override
  33857. */
  33858. getBaseAxis: function () {
  33859. var dim = this._baseAxisDim;
  33860. return this.ecModel.getComponent(dim + 'Axis', this.get(dim + 'AxisIndex')).axis;
  33861. }
  33862. };
  33863. var viewMixin = {
  33864. init: function () {
  33865. /**
  33866. * Old data.
  33867. * @private
  33868. * @type {module:echarts/chart/helper/WhiskerBoxDraw}
  33869. */
  33870. var whiskerBoxDraw = this._whiskerBoxDraw = new WhiskerBoxDraw(
  33871. this.getStyleUpdater()
  33872. );
  33873. this.group.add(whiskerBoxDraw.group);
  33874. },
  33875. render: function (seriesModel, ecModel, api) {
  33876. this._whiskerBoxDraw.updateData(seriesModel.getData());
  33877. },
  33878. remove: function (ecModel) {
  33879. this._whiskerBoxDraw.remove();
  33880. }
  33881. };
  33882. module.exports = {
  33883. seriesModelMixin: seriesModelMixin,
  33884. viewMixin: viewMixin
  33885. };
  33886. /***/ },
  33887. /* 242 */
  33888. /***/ function(module, exports, __webpack_require__) {
  33889. /**
  33890. * @module echarts/chart/helper/Symbol
  33891. */
  33892. var zrUtil = __webpack_require__(3);
  33893. var graphic = __webpack_require__(42);
  33894. var Path = __webpack_require__(44);
  33895. var WhiskerPath = Path.extend({
  33896. type: 'whiskerInBox',
  33897. shape: {},
  33898. buildPath: function (ctx, shape) {
  33899. for (var i in shape) {
  33900. if (i.indexOf('ends') === 0) {
  33901. var pts = shape[i];
  33902. ctx.moveTo(pts[0][0], pts[0][1]);
  33903. ctx.lineTo(pts[1][0], pts[1][1]);
  33904. }
  33905. }
  33906. }
  33907. });
  33908. /**
  33909. * @constructor
  33910. * @alias {module:echarts/chart/helper/WhiskerBox}
  33911. * @param {module:echarts/data/List} data
  33912. * @param {number} idx
  33913. * @param {Function} styleUpdater
  33914. * @param {boolean} isInit
  33915. * @extends {module:zrender/graphic/Group}
  33916. */
  33917. function WhiskerBox(data, idx, styleUpdater, isInit) {
  33918. graphic.Group.call(this);
  33919. /**
  33920. * @type {number}
  33921. * @readOnly
  33922. */
  33923. this.bodyIndex;
  33924. /**
  33925. * @type {number}
  33926. * @readOnly
  33927. */
  33928. this.whiskerIndex;
  33929. /**
  33930. * @type {Function}
  33931. */
  33932. this.styleUpdater = styleUpdater;
  33933. this._createContent(data, idx, isInit);
  33934. this.updateData(data, idx, isInit);
  33935. /**
  33936. * Last series model.
  33937. * @type {module:echarts/model/Series}
  33938. */
  33939. this._seriesModel;
  33940. }
  33941. var whiskerBoxProto = WhiskerBox.prototype;
  33942. whiskerBoxProto._createContent = function (data, idx, isInit) {
  33943. var itemLayout = data.getItemLayout(idx);
  33944. var constDim = itemLayout.chartLayout === 'horizontal' ? 1 : 0;
  33945. var count = 0;
  33946. // Whisker element.
  33947. this.add(new graphic.Polygon({
  33948. shape: {
  33949. points: isInit
  33950. ? transInit(itemLayout.bodyEnds, constDim, itemLayout)
  33951. : itemLayout.bodyEnds
  33952. },
  33953. style: {strokeNoScale: true},
  33954. z2: 100
  33955. }));
  33956. this.bodyIndex = count++;
  33957. // Box element.
  33958. var whiskerEnds = zrUtil.map(itemLayout.whiskerEnds, function (ends) {
  33959. return isInit ? transInit(ends, constDim, itemLayout) : ends;
  33960. });
  33961. this.add(new WhiskerPath({
  33962. shape: makeWhiskerEndsShape(whiskerEnds),
  33963. style: {strokeNoScale: true},
  33964. z2: 100
  33965. }));
  33966. this.whiskerIndex = count++;
  33967. };
  33968. function transInit(points, dim, itemLayout) {
  33969. return zrUtil.map(points, function (point) {
  33970. point = point.slice();
  33971. point[dim] = itemLayout.initBaseline;
  33972. return point;
  33973. });
  33974. }
  33975. function makeWhiskerEndsShape(whiskerEnds) {
  33976. // zr animation only support 2-dim array.
  33977. var shape = {};
  33978. zrUtil.each(whiskerEnds, function (ends, i) {
  33979. shape['ends' + i] = ends;
  33980. });
  33981. return shape;
  33982. }
  33983. /**
  33984. * Update symbol properties
  33985. * @param {module:echarts/data/List} data
  33986. * @param {number} idx
  33987. */
  33988. whiskerBoxProto.updateData = function (data, idx, isInit) {
  33989. var seriesModel = this._seriesModel = data.hostModel;
  33990. var itemLayout = data.getItemLayout(idx);
  33991. var updateMethod = graphic[isInit ? 'initProps' : 'updateProps'];
  33992. // this.childAt(this.bodyIndex).stopAnimation(true);
  33993. // this.childAt(this.whiskerIndex).stopAnimation(true);
  33994. updateMethod(
  33995. this.childAt(this.bodyIndex),
  33996. {shape: {points: itemLayout.bodyEnds}},
  33997. seriesModel, idx
  33998. );
  33999. updateMethod(
  34000. this.childAt(this.whiskerIndex),
  34001. {shape: makeWhiskerEndsShape(itemLayout.whiskerEnds)},
  34002. seriesModel, idx
  34003. );
  34004. this.styleUpdater.call(null, this, data, idx);
  34005. };
  34006. zrUtil.inherits(WhiskerBox, graphic.Group);
  34007. /**
  34008. * @constructor
  34009. * @alias module:echarts/chart/helper/WhiskerBoxDraw
  34010. */
  34011. function WhiskerBoxDraw(styleUpdater) {
  34012. this.group = new graphic.Group();
  34013. this.styleUpdater = styleUpdater;
  34014. }
  34015. var whiskerBoxDrawProto = WhiskerBoxDraw.prototype;
  34016. /**
  34017. * Update symbols draw by new data
  34018. * @param {module:echarts/data/List} data
  34019. */
  34020. whiskerBoxDrawProto.updateData = function (data) {
  34021. var group = this.group;
  34022. var oldData = this._data;
  34023. var styleUpdater = this.styleUpdater;
  34024. data.diff(oldData)
  34025. .add(function (newIdx) {
  34026. if (data.hasValue(newIdx)) {
  34027. var symbolEl = new WhiskerBox(data, newIdx, styleUpdater, true);
  34028. data.setItemGraphicEl(newIdx, symbolEl);
  34029. group.add(symbolEl);
  34030. }
  34031. })
  34032. .update(function (newIdx, oldIdx) {
  34033. var symbolEl = oldData.getItemGraphicEl(oldIdx);
  34034. // Empty data
  34035. if (!data.hasValue(newIdx)) {
  34036. group.remove(symbolEl);
  34037. return;
  34038. }
  34039. if (!symbolEl) {
  34040. symbolEl = new WhiskerBox(data, newIdx, styleUpdater);
  34041. }
  34042. else {
  34043. symbolEl.updateData(data, newIdx);
  34044. }
  34045. // Add back
  34046. group.add(symbolEl);
  34047. data.setItemGraphicEl(newIdx, symbolEl);
  34048. })
  34049. .remove(function (oldIdx) {
  34050. var el = oldData.getItemGraphicEl(oldIdx);
  34051. el && group.remove(el);
  34052. })
  34053. .execute();
  34054. this._data = data;
  34055. };
  34056. /**
  34057. * Remove symbols.
  34058. * @param {module:echarts/data/List} data
  34059. */
  34060. whiskerBoxDrawProto.remove = function () {
  34061. var group = this.group;
  34062. var data = this._data;
  34063. this._data = null;
  34064. data && data.eachItemGraphicEl(function (el) {
  34065. el && group.remove(el);
  34066. });
  34067. };
  34068. module.exports = WhiskerBoxDraw;
  34069. /***/ },
  34070. /* 243 */
  34071. /***/ function(module, exports, __webpack_require__) {
  34072. 'use strict';
  34073. var zrUtil = __webpack_require__(3);
  34074. var ChartView = __webpack_require__(41);
  34075. var graphic = __webpack_require__(42);
  34076. var whiskerBoxCommon = __webpack_require__(241);
  34077. var BoxplotView = ChartView.extend({
  34078. type: 'boxplot',
  34079. getStyleUpdater: function () {
  34080. return updateStyle;
  34081. }
  34082. });
  34083. zrUtil.mixin(BoxplotView, whiskerBoxCommon.viewMixin, true);
  34084. // Update common properties
  34085. var normalStyleAccessPath = ['itemStyle', 'normal'];
  34086. var emphasisStyleAccessPath = ['itemStyle', 'emphasis'];
  34087. function updateStyle(itemGroup, data, idx) {
  34088. var itemModel = data.getItemModel(idx);
  34089. var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath);
  34090. var borderColor = data.getItemVisual(idx, 'color');
  34091. // Exclude borderColor.
  34092. var itemStyle = normalItemStyleModel.getItemStyle(['borderColor']);
  34093. var whiskerEl = itemGroup.childAt(itemGroup.whiskerIndex);
  34094. whiskerEl.style.set(itemStyle);
  34095. whiskerEl.style.stroke = borderColor;
  34096. whiskerEl.dirty();
  34097. var bodyEl = itemGroup.childAt(itemGroup.bodyIndex);
  34098. bodyEl.style.set(itemStyle);
  34099. bodyEl.style.stroke = borderColor;
  34100. bodyEl.dirty();
  34101. var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle();
  34102. graphic.setHoverStyle(itemGroup, hoverStyle);
  34103. }
  34104. module.exports = BoxplotView;
  34105. /***/ },
  34106. /* 244 */
  34107. /***/ function(module, exports) {
  34108. var borderColorQuery = ['itemStyle', 'normal', 'borderColor'];
  34109. module.exports = function (ecModel, api) {
  34110. var globalColors = ecModel.get('color');
  34111. ecModel.eachRawSeriesByType('boxplot', function (seriesModel) {
  34112. var defaulColor = globalColors[seriesModel.seriesIndex % globalColors.length];
  34113. var data = seriesModel.getData();
  34114. data.setVisual({
  34115. legendSymbol: 'roundRect',
  34116. // Use name 'color' but not 'borderColor' for legend usage and
  34117. // visual coding from other component like dataRange.
  34118. color: seriesModel.get(borderColorQuery) || defaulColor
  34119. });
  34120. // Only visible series has each data be visual encoded
  34121. if (!ecModel.isSeriesFiltered(seriesModel)) {
  34122. data.each(function (idx) {
  34123. var itemModel = data.getItemModel(idx);
  34124. data.setItemVisual(
  34125. idx,
  34126. {color: itemModel.get(borderColorQuery, true)}
  34127. );
  34128. });
  34129. }
  34130. });
  34131. };
  34132. /***/ },
  34133. /* 245 */
  34134. /***/ function(module, exports, __webpack_require__) {
  34135. var zrUtil = __webpack_require__(3);
  34136. var numberUtil = __webpack_require__(7);
  34137. var parsePercent = numberUtil.parsePercent;
  34138. var each = zrUtil.each;
  34139. module.exports = function (ecModel, api) {
  34140. var groupResult = groupSeriesByAxis(ecModel);
  34141. each(groupResult, function (groupItem) {
  34142. var seriesModels = groupItem.seriesModels;
  34143. if (!seriesModels.length) {
  34144. return;
  34145. }
  34146. calculateBase(groupItem);
  34147. each(seriesModels, function (seriesModel, idx) {
  34148. layoutSingleSeries(
  34149. seriesModel,
  34150. groupItem.boxOffsetList[idx],
  34151. groupItem.boxWidthList[idx]
  34152. );
  34153. });
  34154. });
  34155. };
  34156. /**
  34157. * Group series by axis.
  34158. */
  34159. function groupSeriesByAxis(ecModel) {
  34160. var result = [];
  34161. var axisList = [];
  34162. ecModel.eachSeriesByType('boxplot', function (seriesModel) {
  34163. var baseAxis = seriesModel.getBaseAxis();
  34164. var idx = zrUtil.indexOf(axisList, baseAxis);
  34165. if (idx < 0) {
  34166. idx = axisList.length;
  34167. axisList[idx] = baseAxis;
  34168. result[idx] = {axis: baseAxis, seriesModels: []};
  34169. }
  34170. result[idx].seriesModels.push(seriesModel);
  34171. });
  34172. return result;
  34173. }
  34174. /**
  34175. * Calculate offset and box width for each series.
  34176. */
  34177. function calculateBase(groupItem) {
  34178. var extent;
  34179. var baseAxis = groupItem.axis;
  34180. var seriesModels = groupItem.seriesModels;
  34181. var seriesCount = seriesModels.length;
  34182. var boxWidthList = groupItem.boxWidthList = [];
  34183. var boxOffsetList = groupItem.boxOffsetList = [];
  34184. var boundList = [];
  34185. var bandWidth;
  34186. if (baseAxis.type === 'category') {
  34187. bandWidth = baseAxis.getBandWidth();
  34188. }
  34189. else {
  34190. var maxDataCount = 0;
  34191. each(seriesModels, function (seriesModel) {
  34192. maxDataCount = Math.max(maxDataCount, seriesModel.getData().count());
  34193. });
  34194. extent = baseAxis.getExtent(),
  34195. Math.abs(extent[1] - extent[0]) / maxDataCount;
  34196. }
  34197. each(seriesModels, function (seriesModel) {
  34198. var boxWidthBound = seriesModel.get('boxWidth');
  34199. if (!zrUtil.isArray(boxWidthBound)) {
  34200. boxWidthBound = [boxWidthBound, boxWidthBound];
  34201. }
  34202. boundList.push([
  34203. parsePercent(boxWidthBound[0], bandWidth) || 0,
  34204. parsePercent(boxWidthBound[1], bandWidth) || 0
  34205. ]);
  34206. });
  34207. var availableWidth = bandWidth * 0.8 - 2;
  34208. var boxGap = availableWidth / seriesCount * 0.3;
  34209. var boxWidth = (availableWidth - boxGap * (seriesCount - 1)) / seriesCount;
  34210. var base = boxWidth / 2 - availableWidth / 2;
  34211. each(seriesModels, function (seriesModel, idx) {
  34212. boxOffsetList.push(base);
  34213. base += boxGap + boxWidth;
  34214. boxWidthList.push(
  34215. Math.min(Math.max(boxWidth, boundList[idx][0]), boundList[idx][1])
  34216. );
  34217. });
  34218. }
  34219. /**
  34220. * Calculate points location for each series.
  34221. */
  34222. function layoutSingleSeries(seriesModel, offset, boxWidth) {
  34223. var coordSys = seriesModel.coordinateSystem;
  34224. var data = seriesModel.getData();
  34225. var dimensions = seriesModel.dimensions;
  34226. var chartLayout = seriesModel.get('layout');
  34227. var halfWidth = boxWidth / 2;
  34228. data.each(dimensions, function () {
  34229. var args = arguments;
  34230. var dimLen = dimensions.length;
  34231. var axisDimVal = args[0];
  34232. var idx = args[dimLen];
  34233. var variableDim = chartLayout === 'horizontal' ? 0 : 1;
  34234. var constDim = 1 - variableDim;
  34235. var median = getPoint(args[3]);
  34236. var end1 = getPoint(args[1]);
  34237. var end5 = getPoint(args[5]);
  34238. var whiskerEnds = [
  34239. [end1, getPoint(args[2])],
  34240. [end5, getPoint(args[4])]
  34241. ];
  34242. layEndLine(end1);
  34243. layEndLine(end5);
  34244. layEndLine(median);
  34245. var bodyEnds = [];
  34246. addBodyEnd(whiskerEnds[0][1], 0);
  34247. addBodyEnd(whiskerEnds[1][1], 1);
  34248. data.setItemLayout(idx, {
  34249. chartLayout: chartLayout,
  34250. initBaseline: median[constDim],
  34251. median: median,
  34252. bodyEnds: bodyEnds,
  34253. whiskerEnds: whiskerEnds
  34254. });
  34255. function getPoint(val) {
  34256. var p = [];
  34257. p[variableDim] = axisDimVal;
  34258. p[constDim] = val;
  34259. var point;
  34260. if (isNaN(axisDimVal) || isNaN(val)) {
  34261. point = [NaN, NaN];
  34262. }
  34263. else {
  34264. point = coordSys.dataToPoint(p);
  34265. point[variableDim] += offset;
  34266. }
  34267. return point;
  34268. }
  34269. function addBodyEnd(point, start) {
  34270. var point1 = point.slice();
  34271. var point2 = point.slice();
  34272. point1[variableDim] += halfWidth;
  34273. point2[variableDim] -= halfWidth;
  34274. start
  34275. ? bodyEnds.push(point1, point2)
  34276. : bodyEnds.push(point2, point1);
  34277. }
  34278. function layEndLine(endCenter) {
  34279. var line = [endCenter.slice(), endCenter.slice()];
  34280. line[0][variableDim] -= halfWidth;
  34281. line[1][variableDim] += halfWidth;
  34282. whiskerEnds.push(line);
  34283. }
  34284. });
  34285. }
  34286. /***/ },
  34287. /* 246 */
  34288. /***/ function(module, exports, __webpack_require__) {
  34289. var echarts = __webpack_require__(1);
  34290. __webpack_require__(247);
  34291. __webpack_require__(248);
  34292. echarts.registerPreprocessor(
  34293. __webpack_require__(249)
  34294. );
  34295. echarts.registerVisualCoding('chart', __webpack_require__(250));
  34296. echarts.registerLayout(__webpack_require__(251));
  34297. /***/ },
  34298. /* 247 */
  34299. /***/ function(module, exports, __webpack_require__) {
  34300. 'use strict';
  34301. var zrUtil = __webpack_require__(3);
  34302. var SeriesModel = __webpack_require__(27);
  34303. var whiskerBoxCommon = __webpack_require__(241);
  34304. var formatUtil = __webpack_require__(6);
  34305. var encodeHTML = formatUtil.encodeHTML;
  34306. var addCommas = formatUtil.addCommas;
  34307. var CandlestickSeries = SeriesModel.extend({
  34308. type: 'series.candlestick',
  34309. dependencies: ['xAxis', 'yAxis', 'grid'],
  34310. /**
  34311. * @readOnly
  34312. */
  34313. valueDimensions: ['open', 'close', 'lowest', 'highest'],
  34314. /**
  34315. * @type {Array.<string>}
  34316. * @readOnly
  34317. */
  34318. dimensions: null,
  34319. /**
  34320. * @override
  34321. */
  34322. defaultOption: {
  34323. zlevel: 0, // 一级层叠
  34324. z: 2, // 二级层叠
  34325. coordinateSystem: 'cartesian2d',
  34326. legendHoverLink: true,
  34327. hoverAnimation: true,
  34328. xAxisIndex: 0,
  34329. yAxisIndex: 0,
  34330. layout: null, // 'horizontal' or 'vertical'
  34331. itemStyle: {
  34332. normal: {
  34333. color: '#c23531', // 阳线 positive
  34334. color0: '#314656', // 阴线 negative '#c23531', '#314656'
  34335. borderWidth: 1,
  34336. // FIXME
  34337. // ec2中使用的是lineStyle.color 和 lineStyle.color0
  34338. borderColor: '#c23531',
  34339. borderColor0: '#314656'
  34340. },
  34341. emphasis: {
  34342. borderWidth: 2
  34343. }
  34344. },
  34345. animationUpdate: false,
  34346. animationEasing: 'linear',
  34347. animationDuration: 300
  34348. },
  34349. /**
  34350. * Get dimension for shadow in dataZoom
  34351. * @return {string} dimension name
  34352. */
  34353. getShadowDim: function () {
  34354. return 'open';
  34355. },
  34356. /**
  34357. * @override
  34358. */
  34359. formatTooltip: function (dataIndex, mutipleSeries) {
  34360. // It rearly use mutiple candlestick series in one cartesian,
  34361. // so only consider one series in this default tooltip.
  34362. var valueHTMLArr = zrUtil.map(this.valueDimensions, function (dim) {
  34363. return dim + ': ' + addCommas(this._data.get(dim, dataIndex));
  34364. }, this);
  34365. return encodeHTML(this.name) + '<br />' + valueHTMLArr.join('<br />');
  34366. }
  34367. });
  34368. zrUtil.mixin(CandlestickSeries, whiskerBoxCommon.seriesModelMixin, true);
  34369. module.exports = CandlestickSeries;
  34370. /***/ },
  34371. /* 248 */
  34372. /***/ function(module, exports, __webpack_require__) {
  34373. 'use strict';
  34374. var zrUtil = __webpack_require__(3);
  34375. var ChartView = __webpack_require__(41);
  34376. var graphic = __webpack_require__(42);
  34377. var whiskerBoxCommon = __webpack_require__(241);
  34378. var CandlestickView = ChartView.extend({
  34379. type: 'candlestick',
  34380. getStyleUpdater: function () {
  34381. return updateStyle;
  34382. }
  34383. });
  34384. zrUtil.mixin(CandlestickView, whiskerBoxCommon.viewMixin, true);
  34385. // Update common properties
  34386. var normalStyleAccessPath = ['itemStyle', 'normal'];
  34387. var emphasisStyleAccessPath = ['itemStyle', 'emphasis'];
  34388. function updateStyle(itemGroup, data, idx) {
  34389. var itemModel = data.getItemModel(idx);
  34390. var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath);
  34391. var color = data.getItemVisual(idx, 'color');
  34392. var borderColor = data.getItemVisual(idx, 'borderColor');
  34393. // Color must be excluded.
  34394. // Because symbol provide setColor individually to set fill and stroke
  34395. var itemStyle = normalItemStyleModel.getItemStyle(
  34396. ['color', 'color0', 'borderColor', 'borderColor0']
  34397. );
  34398. var whiskerEl = itemGroup.childAt(itemGroup.whiskerIndex);
  34399. whiskerEl.useStyle(itemStyle);
  34400. whiskerEl.style.stroke = borderColor;
  34401. var bodyEl = itemGroup.childAt(itemGroup.bodyIndex);
  34402. bodyEl.useStyle(itemStyle);
  34403. bodyEl.style.fill = color;
  34404. bodyEl.style.stroke = borderColor;
  34405. var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle();
  34406. graphic.setHoverStyle(itemGroup, hoverStyle);
  34407. }
  34408. module.exports = CandlestickView;
  34409. /***/ },
  34410. /* 249 */
  34411. /***/ function(module, exports, __webpack_require__) {
  34412. var zrUtil = __webpack_require__(3);
  34413. module.exports = function (option) {
  34414. if (!option || !zrUtil.isArray(option.series)) {
  34415. return;
  34416. }
  34417. // Translate 'k' to 'candlestick'.
  34418. zrUtil.each(option.series, function (seriesItem) {
  34419. if (zrUtil.isObject(seriesItem) && seriesItem.type === 'k') {
  34420. seriesItem.type = 'candlestick';
  34421. }
  34422. });
  34423. };
  34424. /***/ },
  34425. /* 250 */
  34426. /***/ function(module, exports) {
  34427. var positiveBorderColorQuery = ['itemStyle', 'normal', 'borderColor'];
  34428. var negativeBorderColorQuery = ['itemStyle', 'normal', 'borderColor0'];
  34429. var positiveColorQuery = ['itemStyle', 'normal', 'color'];
  34430. var negativeColorQuery = ['itemStyle', 'normal', 'color0'];
  34431. module.exports = function (ecModel, api) {
  34432. ecModel.eachRawSeriesByType('candlestick', function (seriesModel) {
  34433. var data = seriesModel.getData();
  34434. data.setVisual({
  34435. legendSymbol: 'roundRect'
  34436. });
  34437. // Only visible series has each data be visual encoded
  34438. if (!ecModel.isSeriesFiltered(seriesModel)) {
  34439. data.each(function (idx) {
  34440. var itemModel = data.getItemModel(idx);
  34441. var sign = data.getItemLayout(idx).sign;
  34442. data.setItemVisual(
  34443. idx,
  34444. {
  34445. color: itemModel.get(
  34446. sign > 0 ? positiveColorQuery : negativeColorQuery
  34447. ),
  34448. borderColor: itemModel.get(
  34449. sign > 0 ? positiveBorderColorQuery : negativeBorderColorQuery
  34450. )
  34451. }
  34452. );
  34453. });
  34454. }
  34455. });
  34456. };
  34457. /***/ },
  34458. /* 251 */
  34459. /***/ function(module, exports) {
  34460. var CANDLE_MIN_WIDTH = 2;
  34461. var CANDLE_MIN_NICE_WIDTH = 5;
  34462. var GPA_MIN = 4;
  34463. module.exports = function (ecModel, api) {
  34464. ecModel.eachSeriesByType('candlestick', function (seriesModel) {
  34465. var coordSys = seriesModel.coordinateSystem;
  34466. var data = seriesModel.getData();
  34467. var dimensions = seriesModel.dimensions;
  34468. var chartLayout = seriesModel.get('layout');
  34469. var candleWidth = calculateCandleWidth(seriesModel, data);
  34470. data.each(dimensions, function () {
  34471. var args = arguments;
  34472. var dimLen = dimensions.length;
  34473. var axisDimVal = args[0];
  34474. var idx = args[dimLen];
  34475. var variableDim = chartLayout === 'horizontal' ? 0 : 1;
  34476. var constDim = 1 - variableDim;
  34477. var openVal = args[1];
  34478. var closeVal = args[2];
  34479. var lowestVal = args[3];
  34480. var highestVal = args[4];
  34481. var ocLow = Math.min(openVal, closeVal);
  34482. var ocHigh = Math.max(openVal, closeVal);
  34483. var ocLowPoint = getPoint(ocLow);
  34484. var ocHighPoint = getPoint(ocHigh);
  34485. var lowestPoint = getPoint(lowestVal);
  34486. var highestPoint = getPoint(highestVal);
  34487. var whiskerEnds = [
  34488. [highestPoint, ocHighPoint],
  34489. [lowestPoint, ocLowPoint]
  34490. ];
  34491. var bodyEnds = [];
  34492. addBodyEnd(ocHighPoint, 0);
  34493. addBodyEnd(ocLowPoint, 1);
  34494. data.setItemLayout(idx, {
  34495. chartLayout: chartLayout,
  34496. sign: openVal > closeVal ? -1 : openVal < closeVal ? 1 : 0,
  34497. initBaseline: openVal > closeVal
  34498. ? ocHighPoint[constDim] : ocLowPoint[constDim], // open point.
  34499. bodyEnds: bodyEnds,
  34500. whiskerEnds: whiskerEnds
  34501. });
  34502. function getPoint(val) {
  34503. var p = [];
  34504. p[variableDim] = axisDimVal;
  34505. p[constDim] = val;
  34506. return (isNaN(axisDimVal) || isNaN(val))
  34507. ? [NaN, NaN]
  34508. : coordSys.dataToPoint(p);
  34509. }
  34510. function addBodyEnd(point, start) {
  34511. var point1 = point.slice();
  34512. var point2 = point.slice();
  34513. point1[variableDim] += candleWidth / 2;
  34514. point2[variableDim] -= candleWidth / 2;
  34515. start
  34516. ? bodyEnds.push(point1, point2)
  34517. : bodyEnds.push(point2, point1);
  34518. }
  34519. }, true);
  34520. });
  34521. };
  34522. function calculateCandleWidth(seriesModel, data) {
  34523. var baseAxis = seriesModel.getBaseAxis();
  34524. var extent;
  34525. var bandWidth = baseAxis.type === 'category'
  34526. ? baseAxis.getBandWidth()
  34527. : (
  34528. extent = baseAxis.getExtent(),
  34529. Math.abs(extent[1] - extent[0]) / data.count()
  34530. );
  34531. // Half band width is perfect when space is enouph, otherwise
  34532. // try not to be smaller than CANDLE_MIN_NICE_WIDTH (and only
  34533. // gap is compressed), otherwise ensure not to be smaller than
  34534. // CANDLE_MIN_WIDTH in spite of overlap.
  34535. return bandWidth / 2 - 2 > CANDLE_MIN_NICE_WIDTH // "- 2" is minus border width
  34536. ? bandWidth / 2 - 2
  34537. : bandWidth - CANDLE_MIN_NICE_WIDTH > GPA_MIN
  34538. ? CANDLE_MIN_NICE_WIDTH
  34539. : Math.max(bandWidth - GPA_MIN, CANDLE_MIN_WIDTH);
  34540. }
  34541. /***/ },
  34542. /* 252 */
  34543. /***/ function(module, exports, __webpack_require__) {
  34544. var zrUtil = __webpack_require__(3);
  34545. var echarts = __webpack_require__(1);
  34546. __webpack_require__(253);
  34547. __webpack_require__(254);
  34548. echarts.registerVisualCoding('chart', zrUtil.curry(
  34549. __webpack_require__(104), 'effectScatter', 'circle', null
  34550. ));
  34551. echarts.registerLayout(zrUtil.curry(
  34552. __webpack_require__(105), 'effectScatter'
  34553. ));
  34554. /***/ },
  34555. /* 253 */
  34556. /***/ function(module, exports, __webpack_require__) {
  34557. 'use strict';
  34558. var createListFromArray = __webpack_require__(94);
  34559. var SeriesModel = __webpack_require__(27);
  34560. module.exports = SeriesModel.extend({
  34561. type: 'series.effectScatter',
  34562. dependencies: ['grid', 'polar'],
  34563. getInitialData: function (option, ecModel) {
  34564. var list = createListFromArray(option.data, this, ecModel);
  34565. return list;
  34566. },
  34567. defaultOption: {
  34568. coordinateSystem: 'cartesian2d',
  34569. zlevel: 0,
  34570. z: 2,
  34571. legendHoverLink: true,
  34572. effectType: 'ripple',
  34573. // When to show the effect, option: 'render'|'emphasis'
  34574. showEffectOn: 'render',
  34575. // Ripple effect config
  34576. rippleEffect: {
  34577. period: 4,
  34578. // Scale of ripple
  34579. scale: 2.5,
  34580. // Brush type can be fill or stroke
  34581. brushType: 'fill'
  34582. },
  34583. // Cartesian coordinate system
  34584. xAxisIndex: 0,
  34585. yAxisIndex: 0,
  34586. // Polar coordinate system
  34587. polarIndex: 0,
  34588. // Geo coordinate system
  34589. geoIndex: 0,
  34590. // symbol: null, // 图形类型
  34591. symbolSize: 10 // 图形大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2
  34592. // symbolRotate: null, // 图形旋转控制
  34593. // large: false,
  34594. // Available when large is true
  34595. // largeThreshold: 2000,
  34596. // itemStyle: {
  34597. // normal: {
  34598. // opacity: 1
  34599. // }
  34600. // }
  34601. }
  34602. });
  34603. /***/ },
  34604. /* 254 */
  34605. /***/ function(module, exports, __webpack_require__) {
  34606. var SymbolDraw = __webpack_require__(99);
  34607. var EffectSymbol = __webpack_require__(255);
  34608. __webpack_require__(1).extendChartView({
  34609. type: 'effectScatter',
  34610. init: function () {
  34611. this._symbolDraw = new SymbolDraw(EffectSymbol);
  34612. },
  34613. render: function (seriesModel, ecModel, api) {
  34614. var data = seriesModel.getData();
  34615. var effectSymbolDraw = this._symbolDraw;
  34616. effectSymbolDraw.updateData(data);
  34617. this.group.add(effectSymbolDraw.group);
  34618. },
  34619. updateLayout: function () {
  34620. this._symbolDraw.updateLayout();
  34621. },
  34622. remove: function (ecModel, api) {
  34623. this._symbolDraw && this._symbolDraw.remove(api);
  34624. }
  34625. });
  34626. /***/ },
  34627. /* 255 */
  34628. /***/ function(module, exports, __webpack_require__) {
  34629. /**
  34630. * Symbol with ripple effect
  34631. * @module echarts/chart/helper/EffectSymbol
  34632. */
  34633. var zrUtil = __webpack_require__(3);
  34634. var symbolUtil = __webpack_require__(101);
  34635. var graphic = __webpack_require__(42);
  34636. var numberUtil = __webpack_require__(7);
  34637. var Symbol = __webpack_require__(100);
  34638. var Group = graphic.Group;
  34639. var EFFECT_RIPPLE_NUMBER = 3;
  34640. function normalizeSymbolSize(symbolSize) {
  34641. if (!zrUtil.isArray(symbolSize)) {
  34642. symbolSize = [+symbolSize, +symbolSize];
  34643. }
  34644. return symbolSize;
  34645. }
  34646. /**
  34647. * @constructor
  34648. * @param {module:echarts/data/List} data
  34649. * @param {number} idx
  34650. * @extends {module:zrender/graphic/Group}
  34651. */
  34652. function EffectSymbol(data, idx) {
  34653. Group.call(this);
  34654. var symbol = new Symbol(data, idx);
  34655. var rippleGroup = new Group();
  34656. this.add(symbol);
  34657. this.add(rippleGroup);
  34658. rippleGroup.beforeUpdate = function () {
  34659. this.attr(symbol.getScale());
  34660. };
  34661. this.updateData(data, idx);
  34662. }
  34663. var effectSymbolProto = EffectSymbol.prototype;
  34664. effectSymbolProto.stopEffectAnimation = function () {
  34665. this.childAt(1).removeAll();
  34666. };
  34667. effectSymbolProto.startEffectAnimation = function (
  34668. period, brushType, rippleScale, effectOffset, z, zlevel
  34669. ) {
  34670. var symbolType = this._symbolType;
  34671. var color = this._color;
  34672. var rippleGroup = this.childAt(1);
  34673. for (var i = 0; i < EFFECT_RIPPLE_NUMBER; i++) {
  34674. var ripplePath = symbolUtil.createSymbol(
  34675. symbolType, -0.5, -0.5, 1, 1, color
  34676. );
  34677. ripplePath.attr({
  34678. style: {
  34679. stroke: brushType === 'stroke' ? color : null,
  34680. fill: brushType === 'fill' ? color : null,
  34681. strokeNoScale: true
  34682. },
  34683. z2: 99,
  34684. silent: true,
  34685. scale: [1, 1],
  34686. z: z,
  34687. zlevel: zlevel
  34688. });
  34689. var delay = -i / EFFECT_RIPPLE_NUMBER * period + effectOffset;
  34690. // TODO Configurable period
  34691. ripplePath.animate('', true)
  34692. .when(period, {
  34693. scale: [rippleScale, rippleScale]
  34694. })
  34695. .delay(delay)
  34696. .start();
  34697. ripplePath.animateStyle(true)
  34698. .when(period, {
  34699. opacity: 0
  34700. })
  34701. .delay(delay)
  34702. .start();
  34703. rippleGroup.add(ripplePath);
  34704. }
  34705. };
  34706. /**
  34707. * Highlight symbol
  34708. */
  34709. effectSymbolProto.highlight = function () {
  34710. this.trigger('emphasis');
  34711. };
  34712. /**
  34713. * Downplay symbol
  34714. */
  34715. effectSymbolProto.downplay = function () {
  34716. this.trigger('normal');
  34717. };
  34718. /**
  34719. * Update symbol properties
  34720. * @param {module:echarts/data/List} data
  34721. * @param {number} idx
  34722. */
  34723. effectSymbolProto.updateData = function (data, idx) {
  34724. var seriesModel = data.hostModel;
  34725. this.childAt(0).updateData(data, idx);
  34726. var rippleGroup = this.childAt(1);
  34727. var itemModel = data.getItemModel(idx);
  34728. var symbolType = data.getItemVisual(idx, 'symbol');
  34729. var symbolSize = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'));
  34730. var color = data.getItemVisual(idx, 'color');
  34731. rippleGroup.attr('scale', symbolSize);
  34732. rippleGroup.traverse(function (ripplePath) {
  34733. ripplePath.attr({
  34734. fill: color
  34735. });
  34736. });
  34737. var symbolOffset = itemModel.getShallow('symbolOffset');
  34738. if (symbolOffset) {
  34739. var pos = rippleGroup.position;
  34740. pos[0] = numberUtil.parsePercent(symbolOffset[0], symbolSize[0]);
  34741. pos[1] = numberUtil.parsePercent(symbolOffset[1], symbolSize[1]);
  34742. }
  34743. rippleGroup.rotation = (itemModel.getShallow('symbolRotate') || 0) * Math.PI / 180 || 0;
  34744. this._symbolType = symbolType;
  34745. this._color = color;
  34746. var showEffectOn = seriesModel.get('showEffectOn');
  34747. var rippleScale = itemModel.get('rippleEffect.scale');
  34748. var brushType = itemModel.get('rippleEffect.brushType');
  34749. var effectPeriod = itemModel.get('rippleEffect.period') * 1000;
  34750. var effectOffset = idx / data.count();
  34751. var z = itemModel.getShallow('z') || 0;
  34752. var zlevel = itemModel.getShallow('zlevel') || 0;
  34753. this.stopEffectAnimation();
  34754. if (showEffectOn === 'render') {
  34755. this.startEffectAnimation(
  34756. effectPeriod, brushType, rippleScale, effectOffset, z, zlevel
  34757. );
  34758. }
  34759. var symbol = this.childAt(0);
  34760. function onEmphasis() {
  34761. symbol.trigger('emphasis');
  34762. if (showEffectOn !== 'render') {
  34763. this.startEffectAnimation(
  34764. effectPeriod, brushType, rippleScale, effectOffset, z, zlevel
  34765. );
  34766. }
  34767. }
  34768. function onNormal() {
  34769. symbol.trigger('normal');
  34770. if (showEffectOn !== 'render') {
  34771. this.stopEffectAnimation();
  34772. }
  34773. }
  34774. this.on('mouseover', onEmphasis, this)
  34775. .on('mouseout', onNormal, this)
  34776. .on('emphasis', onEmphasis, this)
  34777. .on('normal', onNormal, this);
  34778. };
  34779. effectSymbolProto.fadeOut = function (cb) {
  34780. this.off('mouseover').off('mouseout').off('emphasis').off('normal');
  34781. cb && cb();
  34782. };
  34783. zrUtil.inherits(EffectSymbol, Group);
  34784. module.exports = EffectSymbol;
  34785. /***/ },
  34786. /* 256 */
  34787. /***/ function(module, exports, __webpack_require__) {
  34788. __webpack_require__(257);
  34789. __webpack_require__(258);
  34790. var zrUtil = __webpack_require__(3);
  34791. var echarts = __webpack_require__(1);
  34792. echarts.registerLayout(
  34793. __webpack_require__(260)
  34794. );
  34795. echarts.registerVisualCoding(
  34796. 'chart', zrUtil.curry(__webpack_require__(89), 'lines', 'lineStyle')
  34797. );
  34798. /***/ },
  34799. /* 257 */
  34800. /***/ function(module, exports, __webpack_require__) {
  34801. 'use strict';
  34802. var SeriesModel = __webpack_require__(27);
  34803. var List = __webpack_require__(95);
  34804. var zrUtil = __webpack_require__(3);
  34805. var CoordinateSystem = __webpack_require__(25);
  34806. module.exports = SeriesModel.extend({
  34807. type: 'series.lines',
  34808. dependencies: ['grid', 'polar'],
  34809. getInitialData: function (option, ecModel) {
  34810. var fromDataArr = [];
  34811. var toDataArr = [];
  34812. var lineDataArr = [];
  34813. zrUtil.each(option.data, function (opt) {
  34814. fromDataArr.push(opt[0]);
  34815. toDataArr.push(opt[1]);
  34816. lineDataArr.push(zrUtil.extend(
  34817. zrUtil.extend({}, zrUtil.isArray(opt[0]) ? null : opt[0]),
  34818. zrUtil.isArray(opt[1]) ? null : opt[1]
  34819. ));
  34820. });
  34821. // var coordSys = option.coordinateSystem;
  34822. // if (coordSys !== 'cartesian2d' && coordSys !== 'geo') {
  34823. // throw new Error('Coordinate system can only be cartesian2d or geo in lines');
  34824. // }
  34825. // var dimensions = coordSys === 'geo' ? ['lng', 'lat'] : ['x', 'y'];
  34826. var coordSys = CoordinateSystem.get(option.coordinateSystem);
  34827. if (!coordSys) {
  34828. throw new Error('Invalid coordinate system');
  34829. }
  34830. var dimensions = coordSys.dimensions;
  34831. var fromData = new List(dimensions, this);
  34832. var toData = new List(dimensions, this);
  34833. var lineData = new List(['value'], this);
  34834. function geoCoordGetter(item, dim, dataIndex, dimIndex) {
  34835. return item.coord && item.coord[dimIndex];
  34836. }
  34837. fromData.initData(fromDataArr, null, geoCoordGetter);
  34838. toData.initData(toDataArr, null, geoCoordGetter);
  34839. lineData.initData(lineDataArr);
  34840. this.fromData = fromData;
  34841. this.toData = toData;
  34842. return lineData;
  34843. },
  34844. formatTooltip: function (dataIndex) {
  34845. var fromName = this.fromData.getName(dataIndex);
  34846. var toName = this.toData.getName(dataIndex);
  34847. return fromName + ' > ' + toName;
  34848. },
  34849. defaultOption: {
  34850. coordinateSystem: 'geo',
  34851. zlevel: 0,
  34852. z: 2,
  34853. legendHoverLink: true,
  34854. hoverAnimation: true,
  34855. // Cartesian coordinate system
  34856. xAxisIndex: 0,
  34857. yAxisIndex: 0,
  34858. // Geo coordinate system
  34859. geoIndex: 0,
  34860. // symbol: null,
  34861. // symbolSize: 10,
  34862. // symbolRotate: null,
  34863. effect: {
  34864. show: false,
  34865. period: 4,
  34866. symbol: 'circle',
  34867. symbolSize: 3,
  34868. // Length of trail, 0 - 1
  34869. trailLength: 0.2
  34870. // Same with lineStyle.normal.color
  34871. // color
  34872. },
  34873. large: false,
  34874. // Available when large is true
  34875. largeThreshold: 2000,
  34876. label: {
  34877. normal: {
  34878. show: false,
  34879. position: 'end'
  34880. // distance: 5,
  34881. // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  34882. }
  34883. },
  34884. // itemStyle: {
  34885. // normal: {
  34886. // }
  34887. // },
  34888. lineStyle: {
  34889. normal: {
  34890. opacity: 0.5
  34891. }
  34892. }
  34893. }
  34894. });
  34895. /***/ },
  34896. /* 258 */
  34897. /***/ function(module, exports, __webpack_require__) {
  34898. var LineDraw = __webpack_require__(194);
  34899. var EffectLine = __webpack_require__(259);
  34900. var Line = __webpack_require__(195);
  34901. __webpack_require__(1).extendChartView({
  34902. type: 'lines',
  34903. init: function () {},
  34904. render: function (seriesModel, ecModel, api) {
  34905. var data = seriesModel.getData();
  34906. var lineDraw = this._lineDraw;
  34907. var hasEffect = seriesModel.get('effect.show');
  34908. if (hasEffect !== this._hasEffet) {
  34909. if (lineDraw) {
  34910. lineDraw.remove();
  34911. }
  34912. lineDraw = this._lineDraw = new LineDraw(
  34913. hasEffect ? EffectLine : Line
  34914. );
  34915. this._hasEffet = hasEffect;
  34916. }
  34917. var zlevel = seriesModel.get('zlevel');
  34918. var trailLength = seriesModel.get('effect.trailLength');
  34919. var zr = api.getZr();
  34920. // Avoid the drag cause ghost shadow
  34921. // FIXME Better way ?
  34922. zr.painter.getLayer(zlevel).clear(true);
  34923. // Config layer with motion blur
  34924. if (this._lastZlevel != null) {
  34925. zr.configLayer(this._lastZlevel, {
  34926. motionBlur: false
  34927. });
  34928. }
  34929. if (hasEffect && trailLength) {
  34930. zr.configLayer(zlevel, {
  34931. motionBlur: true,
  34932. lastFrameAlpha: Math.max(Math.min(trailLength / 10 + 0.9, 1), 0)
  34933. });
  34934. }
  34935. this.group.add(lineDraw.group);
  34936. lineDraw.updateData(data);
  34937. this._lastZlevel = zlevel;
  34938. },
  34939. updateLayout: function (seriesModel, ecModel, api) {
  34940. this._lineDraw.updateLayout();
  34941. // Not use motion when dragging or zooming
  34942. var zr = api.getZr();
  34943. zr.painter.getLayer(this._lastZlevel).clear(true);
  34944. },
  34945. remove: function (ecModel, api) {
  34946. this._lineDraw && this._lineDraw.remove(api, true);
  34947. }
  34948. });
  34949. /***/ },
  34950. /* 259 */
  34951. /***/ function(module, exports, __webpack_require__) {
  34952. /**
  34953. * @module echarts/chart/helper/EffectLine
  34954. */
  34955. var graphic = __webpack_require__(42);
  34956. var Line = __webpack_require__(195);
  34957. var zrUtil = __webpack_require__(3);
  34958. var symbolUtil = __webpack_require__(101);
  34959. var curveUtil = __webpack_require__(49);
  34960. /**
  34961. * @constructor
  34962. * @extends {module:zrender/graphic/Group}
  34963. * @alias {module:echarts/chart/helper/Line}
  34964. */
  34965. function EffectLine(lineData, idx) {
  34966. graphic.Group.call(this);
  34967. var line = new Line(lineData, idx);
  34968. this.add(line);
  34969. this._updateEffectSymbol(lineData, idx);
  34970. }
  34971. var effectLineProto = EffectLine.prototype;
  34972. function setAnimationPoints(symbol, points) {
  34973. symbol.__p1 = points[0];
  34974. symbol.__p2 = points[1];
  34975. symbol.__cp1 = points[2] || [
  34976. (points[0][0] + points[1][0]) / 2,
  34977. (points[0][1] + points[1][1]) / 2
  34978. ];
  34979. }
  34980. function updateSymbolPosition() {
  34981. var p1 = this.__p1;
  34982. var p2 = this.__p2;
  34983. var cp1 = this.__cp1;
  34984. var t = this.__t;
  34985. var pos = this.position;
  34986. var quadraticAt = curveUtil.quadraticAt;
  34987. var quadraticDerivativeAt = curveUtil.quadraticDerivativeAt;
  34988. pos[0] = quadraticAt(p1[0], cp1[0], p2[0], t);
  34989. pos[1] = quadraticAt(p1[1], cp1[1], p2[1], t);
  34990. // Tangent
  34991. var tx = quadraticDerivativeAt(p1[0], cp1[0], p2[0], t);
  34992. var ty = quadraticDerivativeAt(p1[1], cp1[1], p2[1], t);
  34993. this.rotation = -Math.atan2(ty, tx) - Math.PI / 2;
  34994. this.ignore = false;
  34995. }
  34996. effectLineProto._updateEffectSymbol = function (lineData, idx) {
  34997. var itemModel = lineData.getItemModel(idx);
  34998. var effectModel = itemModel.getModel('effect');
  34999. var size = effectModel.get('symbolSize');
  35000. var symbolType = effectModel.get('symbol');
  35001. if (!zrUtil.isArray(size)) {
  35002. size = [size, size];
  35003. }
  35004. var color = effectModel.get('color') || lineData.getItemVisual(idx, 'color');
  35005. var symbol = this.childAt(1);
  35006. var period = effectModel.get('period') * 1000;
  35007. if (this._symbolType !== symbolType || period !== this._period) {
  35008. symbol = symbolUtil.createSymbol(
  35009. symbolType, -0.5, -0.5, 1, 1, color
  35010. );
  35011. symbol.ignore = true;
  35012. symbol.z2 = 100;
  35013. this._symbolType = symbolType;
  35014. this._period = period;
  35015. this.add(symbol);
  35016. symbol.__t = 0;
  35017. symbol.animate('', true)
  35018. .when(period, {
  35019. __t: 1
  35020. })
  35021. .delay(idx / lineData.count() * period / 2)
  35022. .during(zrUtil.bind(updateSymbolPosition, symbol))
  35023. .start();
  35024. }
  35025. // Shadow color is same with color in default
  35026. symbol.setStyle('shadowColor', color);
  35027. symbol.setStyle(effectModel.getItemStyle(['color']));
  35028. symbol.attr('scale', size);
  35029. var points = lineData.getItemLayout(idx);
  35030. setAnimationPoints(symbol, points);
  35031. symbol.setColor(color);
  35032. symbol.attr('scale', size);
  35033. };
  35034. effectLineProto.updateData = function (lineData, idx) {
  35035. this.childAt(0).updateData(lineData, idx);
  35036. this._updateEffectSymbol(lineData, idx);
  35037. };
  35038. effectLineProto.updateLayout = function (lineData, idx) {
  35039. this.childAt(0).updateLayout(lineData, idx);
  35040. var symbol = this.childAt(1);
  35041. var points = lineData.getItemLayout(idx);
  35042. setAnimationPoints(symbol, points);
  35043. };
  35044. zrUtil.inherits(EffectLine, graphic.Group);
  35045. module.exports = EffectLine;
  35046. /***/ },
  35047. /* 260 */
  35048. /***/ function(module, exports) {
  35049. module.exports = function (ecModel) {
  35050. ecModel.eachSeriesByType('lines', function (seriesModel) {
  35051. var coordSys = seriesModel.coordinateSystem;
  35052. var fromData = seriesModel.fromData;
  35053. var toData = seriesModel.toData;
  35054. var lineData = seriesModel.getData();
  35055. var dims = coordSys.dimensions;
  35056. fromData.each(dims, function (x, y, idx) {
  35057. fromData.setItemLayout(idx, coordSys.dataToPoint([x, y]));
  35058. });
  35059. toData.each(dims, function (x, y, idx) {
  35060. toData.setItemLayout(idx, coordSys.dataToPoint([x, y]));
  35061. });
  35062. lineData.each(function (idx) {
  35063. var p1 = fromData.getItemLayout(idx);
  35064. var p2 = toData.getItemLayout(idx);
  35065. var curveness = lineData.getItemModel(idx).get('lineStyle.normal.curveness');
  35066. var cp1;
  35067. if (curveness > 0) {
  35068. cp1 = [
  35069. (p1[0] + p2[0]) / 2 - (p1[1] - p2[1]) * curveness,
  35070. (p1[1] + p2[1]) / 2 - (p2[0] - p1[0]) * curveness
  35071. ];
  35072. }
  35073. lineData.setItemLayout(idx, [p1, p2, cp1]);
  35074. });
  35075. });
  35076. };
  35077. /***/ },
  35078. /* 261 */
  35079. /***/ function(module, exports, __webpack_require__) {
  35080. __webpack_require__(262);
  35081. __webpack_require__(263);
  35082. /***/ },
  35083. /* 262 */
  35084. /***/ function(module, exports, __webpack_require__) {
  35085. var SeriesModel = __webpack_require__(27);
  35086. var createListFromArray = __webpack_require__(94);
  35087. module.exports = SeriesModel.extend({
  35088. type: 'series.heatmap',
  35089. getInitialData: function (option, ecModel) {
  35090. return createListFromArray(option.data, this, ecModel);
  35091. },
  35092. defaultOption: {
  35093. // Cartesian2D or geo
  35094. coordinateSystem: 'cartesian2d',
  35095. zlevel: 0,
  35096. z: 2,
  35097. // Cartesian coordinate system
  35098. xAxisIndex: 0,
  35099. yAxisIndex: 0,
  35100. // Geo coordinate system
  35101. geoIndex: 0,
  35102. blurSize: 30,
  35103. pointSize: 20,
  35104. maxOpacity: 1,
  35105. minOpacity: 0
  35106. }
  35107. });
  35108. /***/ },
  35109. /* 263 */
  35110. /***/ function(module, exports, __webpack_require__) {
  35111. var graphic = __webpack_require__(42);
  35112. var HeatmapLayer = __webpack_require__(264);
  35113. var zrUtil = __webpack_require__(3);
  35114. function getIsInPiecewiseRange(dataExtent, pieceList, selected) {
  35115. var dataSpan = dataExtent[1] - dataExtent[0];
  35116. pieceList = zrUtil.map(pieceList, function (piece) {
  35117. return {
  35118. interval: [
  35119. (piece.interval[0] - dataExtent[0]) / dataSpan,
  35120. (piece.interval[1] - dataExtent[0]) / dataSpan
  35121. ]
  35122. };
  35123. });
  35124. var len = pieceList.length;
  35125. var lastIndex = 0;
  35126. return function (val) {
  35127. // Try to find in the location of the last found
  35128. for (var i = lastIndex; i < len; i++) {
  35129. var interval = pieceList[i].interval;
  35130. if (interval[0] <= val && val <= interval[1]) {
  35131. lastIndex = i;
  35132. break;
  35133. }
  35134. }
  35135. if (i === len) { // Not found, back interation
  35136. for (var i = lastIndex - 1; i >= 0; i--) {
  35137. var interval = pieceList[i].interval;
  35138. if (interval[0] <= val && val <= interval[1]) {
  35139. lastIndex = i;
  35140. break;
  35141. }
  35142. }
  35143. }
  35144. return i >= 0 && i < len && selected[i];
  35145. };
  35146. }
  35147. function getIsInContinuousRange(dataExtent, range) {
  35148. var dataSpan = dataExtent[1] - dataExtent[0];
  35149. range = [
  35150. (range[0] - dataExtent[0]) / dataSpan,
  35151. (range[1] - dataExtent[0]) / dataSpan
  35152. ];
  35153. return function (val) {
  35154. return val >= range[0] && val <= range[1];
  35155. };
  35156. }
  35157. function isGeoCoordSys(coordSys) {
  35158. var dimensions = coordSys.dimensions;
  35159. // Not use coorSys.type === 'geo' because coordSys maybe extended
  35160. return dimensions[0] === 'lng' && dimensions[1] === 'lat';
  35161. }
  35162. module.exports = __webpack_require__(1).extendChartView({
  35163. type: 'heatmap',
  35164. render: function (seriesModel, ecModel, api) {
  35165. var visualMapOfThisSeries;
  35166. ecModel.eachComponent('visualMap', function (visualMap) {
  35167. visualMap.eachTargetSeries(function (targetSeries) {
  35168. if (targetSeries === seriesModel) {
  35169. visualMapOfThisSeries = visualMap;
  35170. }
  35171. });
  35172. });
  35173. if (!visualMapOfThisSeries) {
  35174. throw new Error('Heatmap must use with visualMap');
  35175. }
  35176. this.group.removeAll();
  35177. var coordSys = seriesModel.coordinateSystem;
  35178. if (coordSys.type === 'cartesian2d') {
  35179. this._renderOnCartesian(coordSys, seriesModel, api);
  35180. }
  35181. else if (isGeoCoordSys(coordSys)) {
  35182. this._renderOnGeo(
  35183. coordSys, seriesModel, visualMapOfThisSeries, api
  35184. );
  35185. }
  35186. },
  35187. _renderOnCartesian: function (cartesian, seriesModel, api) {
  35188. var xAxis = cartesian.getAxis('x');
  35189. var yAxis = cartesian.getAxis('y');
  35190. var group = this.group;
  35191. if (!(xAxis.type === 'category' && yAxis.type === 'category')) {
  35192. throw new Error('Heatmap on cartesian must have two category axes');
  35193. }
  35194. if (!(xAxis.onBand && yAxis.onBand)) {
  35195. throw new Error('Heatmap on cartesian must have two axes with boundaryGap true');
  35196. }
  35197. var width = xAxis.getBandWidth();
  35198. var height = yAxis.getBandWidth();
  35199. var data = seriesModel.getData();
  35200. data.each(['x', 'y', 'z'], function (x, y, z, idx) {
  35201. var itemModel = data.getItemModel(idx);
  35202. var point = cartesian.dataToPoint([x, y]);
  35203. // Ignore empty data
  35204. if (isNaN(z)) {
  35205. return;
  35206. }
  35207. var rect = new graphic.Rect({
  35208. shape: {
  35209. x: point[0] - width / 2,
  35210. y: point[1] - height / 2,
  35211. width: width,
  35212. height: height
  35213. },
  35214. style: {
  35215. fill: data.getItemVisual(idx, 'color'),
  35216. opacity: data.getItemVisual(idx, 'opacity')
  35217. }
  35218. });
  35219. var style = itemModel.getModel('itemStyle.normal').getItemStyle(['color']);
  35220. var hoverStl = itemModel.getModel('itemStyle.emphasis').getItemStyle();
  35221. var labelModel = itemModel.getModel('label.normal');
  35222. var hoverLabelModel = itemModel.getModel('label.emphasis');
  35223. var rawValue = seriesModel.getRawValue(idx);
  35224. var defaultText = '-';
  35225. if (rawValue && rawValue[2] != null) {
  35226. defaultText = rawValue[2];
  35227. }
  35228. if (labelModel.get('show')) {
  35229. graphic.setText(style, labelModel);
  35230. style.text = seriesModel.getFormattedLabel(idx, 'normal') || defaultText;
  35231. }
  35232. if (hoverLabelModel.get('show')) {
  35233. graphic.setText(hoverStl, hoverLabelModel);
  35234. hoverStl.text = seriesModel.getFormattedLabel(idx, 'emphasis') || defaultText;
  35235. }
  35236. rect.setStyle(style);
  35237. graphic.setHoverStyle(rect, hoverStl);
  35238. group.add(rect);
  35239. data.setItemGraphicEl(idx, rect);
  35240. });
  35241. },
  35242. _renderOnGeo: function (geo, seriesModel, visualMapModel, api) {
  35243. var inRangeVisuals = visualMapModel.targetVisuals.inRange;
  35244. var outOfRangeVisuals = visualMapModel.targetVisuals.outOfRange;
  35245. // if (!visualMapping) {
  35246. // throw new Error('Data range must have color visuals');
  35247. // }
  35248. var data = seriesModel.getData();
  35249. var hmLayer = this._hmLayer || (this._hmLayer || new HeatmapLayer());
  35250. hmLayer.blurSize = seriesModel.get('blurSize');
  35251. hmLayer.pointSize = seriesModel.get('pointSize');
  35252. hmLayer.minOpacity = seriesModel.get('minOpacity');
  35253. hmLayer.maxOpacity = seriesModel.get('maxOpacity');
  35254. var rect = geo.getViewRect().clone();
  35255. var roamTransform = geo.getRoamTransform().transform;
  35256. rect.applyTransform(roamTransform);
  35257. // Clamp on viewport
  35258. var x = Math.max(rect.x, 0);
  35259. var y = Math.max(rect.y, 0);
  35260. var x2 = Math.min(rect.width + rect.x, api.getWidth());
  35261. var y2 = Math.min(rect.height + rect.y, api.getHeight());
  35262. var width = x2 - x;
  35263. var height = y2 - y;
  35264. var points = data.mapArray(['lng', 'lat', 'value'], function (lng, lat, value) {
  35265. var pt = geo.dataToPoint([lng, lat]);
  35266. pt[0] -= x;
  35267. pt[1] -= y;
  35268. pt.push(value);
  35269. return pt;
  35270. });
  35271. var dataExtent = visualMapModel.getExtent();
  35272. var isInRange = visualMapModel.type === 'visualMap.continuous'
  35273. ? getIsInContinuousRange(dataExtent, visualMapModel.option.range)
  35274. : getIsInPiecewiseRange(
  35275. dataExtent, visualMapModel.getPieceList(), visualMapModel.option.selected
  35276. );
  35277. hmLayer.update(
  35278. points, width, height,
  35279. inRangeVisuals.color.getNormalizer(),
  35280. {
  35281. inRange: inRangeVisuals.color.getColorMapper(),
  35282. outOfRange: outOfRangeVisuals.color.getColorMapper()
  35283. },
  35284. isInRange
  35285. );
  35286. var img = new graphic.Image({
  35287. style: {
  35288. width: width,
  35289. height: height,
  35290. x: x,
  35291. y: y,
  35292. image: hmLayer.canvas
  35293. },
  35294. silent: true
  35295. });
  35296. this.group.add(img);
  35297. }
  35298. });
  35299. /***/ },
  35300. /* 264 */
  35301. /***/ function(module, exports, __webpack_require__) {
  35302. /**
  35303. * @file defines echarts Heatmap Chart
  35304. * @author Ovilia (me@zhangwenli.com)
  35305. * Inspired by https://github.com/mourner/simpleheat
  35306. *
  35307. * @module
  35308. */
  35309. var GRADIENT_LEVELS = 256;
  35310. var zrUtil = __webpack_require__(3);
  35311. /**
  35312. * Heatmap Chart
  35313. *
  35314. * @class
  35315. */
  35316. function Heatmap() {
  35317. var canvas = zrUtil.createCanvas();
  35318. this.canvas = canvas;
  35319. this.blurSize = 30;
  35320. this.pointSize = 20;
  35321. this.maxOpacity = 1;
  35322. this.minOpacity = 0;
  35323. this._gradientPixels = {};
  35324. }
  35325. Heatmap.prototype = {
  35326. /**
  35327. * Renders Heatmap and returns the rendered canvas
  35328. * @param {Array} data array of data, each has x, y, value
  35329. * @param {number} width canvas width
  35330. * @param {number} height canvas height
  35331. */
  35332. update: function(data, width, height, normalize, colorFunc, isInRange) {
  35333. var brush = this._getBrush();
  35334. var gradientInRange = this._getGradient(data, colorFunc, 'inRange');
  35335. var gradientOutOfRange = this._getGradient(data, colorFunc, 'outOfRange');
  35336. var r = this.pointSize + this.blurSize;
  35337. var canvas = this.canvas;
  35338. var ctx = canvas.getContext('2d');
  35339. var len = data.length;
  35340. canvas.width = width;
  35341. canvas.height = height;
  35342. for (var i = 0; i < len; ++i) {
  35343. var p = data[i];
  35344. var x = p[0];
  35345. var y = p[1];
  35346. var value = p[2];
  35347. // calculate alpha using value
  35348. var alpha = normalize(value);
  35349. // draw with the circle brush with alpha
  35350. ctx.globalAlpha = alpha;
  35351. ctx.drawImage(brush, x - r, y - r);
  35352. }
  35353. // colorize the canvas using alpha value and set with gradient
  35354. var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
  35355. var pixels = imageData.data;
  35356. var offset = 0;
  35357. var pixelLen = pixels.length;
  35358. var minOpacity = this.minOpacity;
  35359. var maxOpacity = this.maxOpacity;
  35360. var diffOpacity = maxOpacity - minOpacity;
  35361. while(offset < pixelLen) {
  35362. var alpha = pixels[offset + 3] / 256;
  35363. var gradientOffset = Math.floor(alpha * (GRADIENT_LEVELS - 1)) * 4;
  35364. // Simple optimize to ignore the empty data
  35365. if (alpha > 0) {
  35366. var gradient = isInRange(alpha) ? gradientInRange : gradientOutOfRange;
  35367. // Any alpha > 0 will be mapped to [minOpacity, maxOpacity]
  35368. alpha > 0 && (alpha = alpha * diffOpacity + minOpacity);
  35369. pixels[offset++] = gradient[gradientOffset];
  35370. pixels[offset++] = gradient[gradientOffset + 1];
  35371. pixels[offset++] = gradient[gradientOffset + 2];
  35372. pixels[offset++] = gradient[gradientOffset + 3] * alpha * 256;
  35373. }
  35374. else {
  35375. offset += 4;
  35376. }
  35377. }
  35378. ctx.putImageData(imageData, 0, 0);
  35379. return canvas;
  35380. },
  35381. /**
  35382. * get canvas of a black circle brush used for canvas to draw later
  35383. * @private
  35384. * @returns {Object} circle brush canvas
  35385. */
  35386. _getBrush: function() {
  35387. var brushCanvas = this._brushCanvas || (this._brushCanvas = zrUtil.createCanvas());
  35388. // set brush size
  35389. var r = this.pointSize + this.blurSize;
  35390. var d = r * 2;
  35391. brushCanvas.width = d;
  35392. brushCanvas.height = d;
  35393. var ctx = brushCanvas.getContext('2d');
  35394. ctx.clearRect(0, 0, d, d);
  35395. // in order to render shadow without the distinct circle,
  35396. // draw the distinct circle in an invisible place,
  35397. // and use shadowOffset to draw shadow in the center of the canvas
  35398. ctx.shadowOffsetX = d;
  35399. ctx.shadowBlur = this.blurSize;
  35400. // draw the shadow in black, and use alpha and shadow blur to generate
  35401. // color in color map
  35402. ctx.shadowColor = '#000';
  35403. // draw circle in the left to the canvas
  35404. ctx.beginPath();
  35405. ctx.arc(-r, r, this.pointSize, 0, Math.PI * 2, true);
  35406. ctx.closePath();
  35407. ctx.fill();
  35408. return brushCanvas;
  35409. },
  35410. /**
  35411. * get gradient color map
  35412. * @private
  35413. */
  35414. _getGradient: function (data, colorFunc, state) {
  35415. var gradientPixels = this._gradientPixels;
  35416. var pixelsSingleState = gradientPixels[state] || (gradientPixels[state] = new Uint8ClampedArray(256 * 4));
  35417. var color = [];
  35418. var off = 0;
  35419. for (var i = 0; i < 256; i++) {
  35420. colorFunc[state](i / 255, true, color);
  35421. pixelsSingleState[off++] = color[0];
  35422. pixelsSingleState[off++] = color[1];
  35423. pixelsSingleState[off++] = color[2];
  35424. pixelsSingleState[off++] = color[3];
  35425. }
  35426. return pixelsSingleState;
  35427. }
  35428. };
  35429. module.exports = Heatmap;
  35430. /***/ },
  35431. /* 265 */
  35432. /***/ function(module, exports, __webpack_require__) {
  35433. /**
  35434. * Legend component entry file8
  35435. */
  35436. __webpack_require__(266);
  35437. __webpack_require__(267);
  35438. __webpack_require__(268);
  35439. var echarts = __webpack_require__(1);
  35440. // Series Filter
  35441. echarts.registerProcessor('filter', __webpack_require__(270));
  35442. /***/ },
  35443. /* 266 */
  35444. /***/ function(module, exports, __webpack_require__) {
  35445. 'use strict';
  35446. var zrUtil = __webpack_require__(3);
  35447. var Model = __webpack_require__(8);
  35448. var LegendModel = __webpack_require__(1).extendComponentModel({
  35449. type: 'legend',
  35450. dependencies: ['series'],
  35451. layoutMode: {
  35452. type: 'box',
  35453. ignoreSize: true
  35454. },
  35455. init: function (option, parentModel, ecModel) {
  35456. this.mergeDefaultAndTheme(option, ecModel);
  35457. option.selected = option.selected || {};
  35458. this._updateData(ecModel);
  35459. var legendData = this._data;
  35460. // If has any selected in option.selected
  35461. var selectedMap = this.option.selected;
  35462. // If selectedMode is single, try to select one
  35463. if (legendData[0] && this.get('selectedMode') === 'single') {
  35464. var hasSelected = false;
  35465. for (var name in selectedMap) {
  35466. if (selectedMap[name]) {
  35467. this.select(name);
  35468. hasSelected = true;
  35469. }
  35470. }
  35471. // Try select the first if selectedMode is single
  35472. !hasSelected && this.select(legendData[0].get('name'));
  35473. }
  35474. },
  35475. mergeOption: function (option) {
  35476. LegendModel.superCall(this, 'mergeOption', option);
  35477. this._updateData(this.ecModel);
  35478. },
  35479. _updateData: function (ecModel) {
  35480. var legendData = zrUtil.map(this.get('data') || [], function (dataItem) {
  35481. if (typeof dataItem === 'string') {
  35482. dataItem = {
  35483. name: dataItem
  35484. };
  35485. }
  35486. return new Model(dataItem, this, this.ecModel);
  35487. }, this);
  35488. this._data = legendData;
  35489. var availableNames = zrUtil.map(ecModel.getSeries(), function (series) {
  35490. return series.name;
  35491. });
  35492. ecModel.eachSeries(function (seriesModel) {
  35493. if (seriesModel.legendDataProvider) {
  35494. var data = seriesModel.legendDataProvider();
  35495. availableNames = availableNames.concat(data.mapArray(data.getName));
  35496. }
  35497. });
  35498. /**
  35499. * @type {Array.<string>}
  35500. * @private
  35501. */
  35502. this._availableNames = availableNames;
  35503. },
  35504. /**
  35505. * @return {Array.<module:echarts/model/Model>}
  35506. */
  35507. getData: function () {
  35508. return this._data;
  35509. },
  35510. /**
  35511. * @param {string} name
  35512. */
  35513. select: function (name) {
  35514. var selected = this.option.selected;
  35515. var selectedMode = this.get('selectedMode');
  35516. if (selectedMode === 'single') {
  35517. var data = this._data;
  35518. zrUtil.each(data, function (dataItem) {
  35519. selected[dataItem.get('name')] = false;
  35520. });
  35521. }
  35522. selected[name] = true;
  35523. },
  35524. /**
  35525. * @param {string} name
  35526. */
  35527. unSelect: function (name) {
  35528. if (this.get('selectedMode') !== 'single') {
  35529. this.option.selected[name] = false;
  35530. }
  35531. },
  35532. /**
  35533. * @param {string} name
  35534. */
  35535. toggleSelected: function (name) {
  35536. var selected = this.option.selected;
  35537. // Default is true
  35538. if (!(name in selected)) {
  35539. selected[name] = true;
  35540. }
  35541. this[selected[name] ? 'unSelect' : 'select'](name);
  35542. },
  35543. /**
  35544. * @param {string} name
  35545. */
  35546. isSelected: function (name) {
  35547. var selected = this.option.selected;
  35548. return !((name in selected) && !selected[name])
  35549. && zrUtil.indexOf(this._availableNames, name) >= 0;
  35550. },
  35551. defaultOption: {
  35552. // 一级层叠
  35553. zlevel: 0,
  35554. // 二级层叠
  35555. z: 4,
  35556. show: true,
  35557. // 布局方式,默认为水平布局,可选为:
  35558. // 'horizontal' | 'vertical'
  35559. orient: 'horizontal',
  35560. left: 'center',
  35561. // right: 'center',
  35562. top: 'top',
  35563. // bottom: 'top',
  35564. // 水平对齐
  35565. // 'auto' | 'left' | 'right'
  35566. // 默认为 'auto', 根据 x 的位置判断是左对齐还是右对齐
  35567. align: 'auto',
  35568. backgroundColor: 'rgba(0,0,0,0)',
  35569. // 图例边框颜色
  35570. borderColor: '#ccc',
  35571. // 图例边框线宽,单位px,默认为0(无边框)
  35572. borderWidth: 0,
  35573. // 图例内边距,单位px,默认各方向内边距为5,
  35574. // 接受数组分别设定上右下左边距,同css
  35575. padding: 5,
  35576. // 各个item之间的间隔,单位px,默认为10,
  35577. // 横向布局时为水平间隔,纵向布局时为纵向间隔
  35578. itemGap: 10,
  35579. // 图例图形宽度
  35580. itemWidth: 25,
  35581. // 图例图形高度
  35582. itemHeight: 14,
  35583. textStyle: {
  35584. // 图例文字颜色
  35585. color: '#333'
  35586. },
  35587. // formatter: '',
  35588. // 选择模式,默认开启图例开关
  35589. selectedMode: true
  35590. // 配置默认选中状态,可配合LEGEND.SELECTED事件做动态数据载入
  35591. // selected: null,
  35592. // 图例内容(详见legend.data,数组中每一项代表一个item
  35593. // data: [],
  35594. }
  35595. });
  35596. module.exports = LegendModel;
  35597. /***/ },
  35598. /* 267 */
  35599. /***/ function(module, exports, __webpack_require__) {
  35600. /**
  35601. * @file Legend action
  35602. */
  35603. var echarts = __webpack_require__(1);
  35604. var zrUtil = __webpack_require__(3);
  35605. function legendSelectActionHandler(methodName, payload, ecModel) {
  35606. var selectedMap = {};
  35607. var isToggleSelect = methodName === 'toggleSelected';
  35608. var isSelected;
  35609. // Update all legend components
  35610. ecModel.eachComponent('legend', function (legendModel) {
  35611. if (isToggleSelect && isSelected != null) {
  35612. // Force other legend has same selected status
  35613. // Or the first is toggled to true and other are toggled to false
  35614. // In the case one legend has some item unSelected in option. And if other legend
  35615. // doesn't has the item, they will assume it is selected.
  35616. legendModel[isSelected ? 'select' : 'unSelect'](payload.name);
  35617. }
  35618. else {
  35619. legendModel[methodName](payload.name);
  35620. isSelected = legendModel.isSelected(payload.name);
  35621. }
  35622. var legendData = legendModel.getData();
  35623. zrUtil.each(legendData, function (model) {
  35624. var name = model.get('name');
  35625. // Wrap element
  35626. if (name === '\n' || name === '') {
  35627. return;
  35628. }
  35629. var isItemSelected = legendModel.isSelected(name);
  35630. if (name in selectedMap) {
  35631. // Unselected if any legend is unselected
  35632. selectedMap[name] = selectedMap[name] && isItemSelected;
  35633. }
  35634. else {
  35635. selectedMap[name] = isItemSelected;
  35636. }
  35637. });
  35638. });
  35639. // Return the event explicitly
  35640. return {
  35641. name: payload.name,
  35642. selected: selectedMap
  35643. };
  35644. }
  35645. /**
  35646. * @event legendToggleSelect
  35647. * @type {Object}
  35648. * @property {string} type 'legendToggleSelect'
  35649. * @property {string} [from]
  35650. * @property {string} name Series name or data item name
  35651. */
  35652. echarts.registerAction(
  35653. 'legendToggleSelect', 'legendselectchanged',
  35654. zrUtil.curry(legendSelectActionHandler, 'toggleSelected')
  35655. );
  35656. /**
  35657. * @event legendSelect
  35658. * @type {Object}
  35659. * @property {string} type 'legendSelect'
  35660. * @property {string} name Series name or data item name
  35661. */
  35662. echarts.registerAction(
  35663. 'legendSelect', 'legendselected',
  35664. zrUtil.curry(legendSelectActionHandler, 'select')
  35665. );
  35666. /**
  35667. * @event legendUnSelect
  35668. * @type {Object}
  35669. * @property {string} type 'legendUnSelect'
  35670. * @property {string} name Series name or data item name
  35671. */
  35672. echarts.registerAction(
  35673. 'legendUnSelect', 'legendunselected',
  35674. zrUtil.curry(legendSelectActionHandler, 'unSelect')
  35675. );
  35676. /***/ },
  35677. /* 268 */
  35678. /***/ function(module, exports, __webpack_require__) {
  35679. var zrUtil = __webpack_require__(3);
  35680. var symbolCreator = __webpack_require__(101);
  35681. var graphic = __webpack_require__(42);
  35682. var listComponentHelper = __webpack_require__(269);
  35683. var curry = zrUtil.curry;
  35684. var LEGEND_DISABLE_COLOR = '#ccc';
  35685. function dispatchSelectAction(name, api) {
  35686. api.dispatchAction({
  35687. type: 'legendToggleSelect',
  35688. name: name
  35689. });
  35690. }
  35691. function dispatchHighlightAction(seriesModel, dataName, api) {
  35692. seriesModel.get('legendHoverLink') && api.dispatchAction({
  35693. type: 'highlight',
  35694. seriesName: seriesModel.name,
  35695. name: dataName
  35696. });
  35697. }
  35698. function dispatchDownplayAction(seriesModel, dataName, api) {
  35699. seriesModel.get('legendHoverLink') && api.dispatchAction({
  35700. type: 'downplay',
  35701. seriesName: seriesModel.name,
  35702. name: dataName
  35703. });
  35704. }
  35705. module.exports = __webpack_require__(1).extendComponentView({
  35706. type: 'legend',
  35707. init: function () {
  35708. this._symbolTypeStore = {};
  35709. },
  35710. render: function (legendModel, ecModel, api) {
  35711. var group = this.group;
  35712. group.removeAll();
  35713. if (!legendModel.get('show')) {
  35714. return;
  35715. }
  35716. var selectMode = legendModel.get('selectedMode');
  35717. var itemAlign = legendModel.get('align');
  35718. if (itemAlign === 'auto') {
  35719. itemAlign = (legendModel.get('left') === 'right'
  35720. && legendModel.get('orient') === 'vertical')
  35721. ? 'right' : 'left';
  35722. }
  35723. var legendDrawedMap = {};
  35724. zrUtil.each(legendModel.getData(), function (itemModel) {
  35725. var name = itemModel.get('name');
  35726. // Use empty string or \n as a newline string
  35727. if (name === '' || name === '\n') {
  35728. group.add(new graphic.Group({
  35729. newline: true
  35730. }));
  35731. return;
  35732. }
  35733. var seriesModel = ecModel.getSeriesByName(name)[0];
  35734. if (legendDrawedMap[name]) {
  35735. // Series not exists
  35736. return;
  35737. }
  35738. // Series legend
  35739. if (seriesModel) {
  35740. var data = seriesModel.getData();
  35741. var color = data.getVisual('color');
  35742. // If color is a callback function
  35743. if (typeof color === 'function') {
  35744. // Use the first data
  35745. color = color(seriesModel.getDataParams(0));
  35746. }
  35747. // Using rect symbol defaultly
  35748. var legendSymbolType = data.getVisual('legendSymbol') || 'roundRect';
  35749. var symbolType = data.getVisual('symbol');
  35750. var itemGroup = this._createItem(
  35751. name, itemModel, legendModel,
  35752. legendSymbolType, symbolType,
  35753. itemAlign, color,
  35754. selectMode
  35755. );
  35756. itemGroup.on('click', curry(dispatchSelectAction, name, api))
  35757. .on('mouseover', curry(dispatchHighlightAction, seriesModel, '', api))
  35758. .on('mouseout', curry(dispatchDownplayAction, seriesModel, '', api));
  35759. legendDrawedMap[name] = true;
  35760. }
  35761. else {
  35762. // Data legend of pie, funnel
  35763. ecModel.eachRawSeries(function (seriesModel) {
  35764. // In case multiple series has same data name
  35765. if (legendDrawedMap[name]) {
  35766. return;
  35767. }
  35768. if (seriesModel.legendDataProvider) {
  35769. var data = seriesModel.legendDataProvider();
  35770. var idx = data.indexOfName(name);
  35771. if (idx < 0) {
  35772. return;
  35773. }
  35774. var color = data.getItemVisual(idx, 'color');
  35775. var legendSymbolType = 'roundRect';
  35776. var itemGroup = this._createItem(
  35777. name, itemModel, legendModel,
  35778. legendSymbolType, null,
  35779. itemAlign, color,
  35780. selectMode
  35781. );
  35782. itemGroup.on('click', curry(dispatchSelectAction, name, api))
  35783. // FIXME Should not specify the series name
  35784. .on('mouseover', curry(dispatchHighlightAction, seriesModel, name, api))
  35785. .on('mouseout', curry(dispatchDownplayAction, seriesModel, name, api));
  35786. legendDrawedMap[name] = true;
  35787. }
  35788. }, this);
  35789. }
  35790. }, this);
  35791. listComponentHelper.layout(group, legendModel, api);
  35792. // Render background after group is layout
  35793. // FIXME
  35794. listComponentHelper.addBackground(group, legendModel);
  35795. },
  35796. _createItem: function (
  35797. name, itemModel, legendModel,
  35798. legendSymbolType, symbolType,
  35799. itemAlign, color, selectMode
  35800. ) {
  35801. var itemWidth = legendModel.get('itemWidth');
  35802. var itemHeight = legendModel.get('itemHeight');
  35803. var isSelected = legendModel.isSelected(name);
  35804. var itemGroup = new graphic.Group();
  35805. var textStyleModel = itemModel.getModel('textStyle');
  35806. var itemIcon = itemModel.get('icon');
  35807. // Use user given icon first
  35808. legendSymbolType = itemIcon || legendSymbolType;
  35809. itemGroup.add(symbolCreator.createSymbol(
  35810. legendSymbolType, 0, 0, itemWidth, itemHeight, isSelected ? color : LEGEND_DISABLE_COLOR
  35811. ));
  35812. // Compose symbols
  35813. // PENDING
  35814. if (!itemIcon && symbolType
  35815. // At least show one symbol, can't be all none
  35816. && ((symbolType !== legendSymbolType) || symbolType == 'none')
  35817. ) {
  35818. var size = itemHeight * 0.8;
  35819. if (symbolType === 'none') {
  35820. symbolType = 'circle';
  35821. }
  35822. // Put symbol in the center
  35823. itemGroup.add(symbolCreator.createSymbol(
  35824. symbolType, (itemWidth - size) / 2, (itemHeight - size) / 2, size, size,
  35825. isSelected ? color : LEGEND_DISABLE_COLOR
  35826. ));
  35827. }
  35828. // Text
  35829. var textX = itemAlign === 'left' ? itemWidth + 5 : -5;
  35830. var textAlign = itemAlign;
  35831. var formatter = legendModel.get('formatter');
  35832. if (typeof formatter === 'string' && formatter) {
  35833. name = formatter.replace('{name}', name);
  35834. }
  35835. else if (typeof formatter === 'function') {
  35836. name = formatter(name);
  35837. }
  35838. var text = new graphic.Text({
  35839. style: {
  35840. text: name,
  35841. x: textX,
  35842. y: itemHeight / 2,
  35843. fill: isSelected ? textStyleModel.getTextColor() : LEGEND_DISABLE_COLOR,
  35844. textFont: textStyleModel.getFont(),
  35845. textAlign: textAlign,
  35846. textVerticalAlign: 'middle'
  35847. }
  35848. });
  35849. itemGroup.add(text);
  35850. // Add a invisible rect to increase the area of mouse hover
  35851. itemGroup.add(new graphic.Rect({
  35852. shape: itemGroup.getBoundingRect(),
  35853. invisible: true
  35854. }));
  35855. itemGroup.eachChild(function (child) {
  35856. child.silent = !selectMode;
  35857. });
  35858. this.group.add(itemGroup);
  35859. graphic.setHoverStyle(itemGroup);
  35860. return itemGroup;
  35861. }
  35862. });
  35863. /***/ },
  35864. /* 269 */
  35865. /***/ function(module, exports, __webpack_require__) {
  35866. // List layout
  35867. var layout = __webpack_require__(21);
  35868. var formatUtil = __webpack_require__(6);
  35869. var graphic = __webpack_require__(42);
  35870. function positionGroup(group, model, api) {
  35871. layout.positionGroup(
  35872. group, model.getBoxLayoutParams(),
  35873. {
  35874. width: api.getWidth(),
  35875. height: api.getHeight()
  35876. },
  35877. model.get('padding')
  35878. );
  35879. }
  35880. module.exports = {
  35881. /**
  35882. * Layout list like component.
  35883. * It will box layout each items in group of component and then position the whole group in the viewport
  35884. * @param {module:zrender/group/Group} group
  35885. * @param {module:echarts/model/Component} componentModel
  35886. * @param {module:echarts/ExtensionAPI}
  35887. */
  35888. layout: function (group, componentModel, api) {
  35889. var rect = layout.getLayoutRect(componentModel.getBoxLayoutParams(), {
  35890. width: api.getWidth(),
  35891. height: api.getHeight()
  35892. }, componentModel.get('padding'));
  35893. layout.box(
  35894. componentModel.get('orient'),
  35895. group,
  35896. componentModel.get('itemGap'),
  35897. rect.width,
  35898. rect.height
  35899. );
  35900. positionGroup(group, componentModel, api);
  35901. },
  35902. addBackground: function (group, componentModel) {
  35903. var padding = formatUtil.normalizeCssArray(
  35904. componentModel.get('padding')
  35905. );
  35906. var boundingRect = group.getBoundingRect();
  35907. var style = componentModel.getItemStyle(['color', 'opacity']);
  35908. style.fill = componentModel.get('backgroundColor');
  35909. var rect = new graphic.Rect({
  35910. shape: {
  35911. x: boundingRect.x - padding[3],
  35912. y: boundingRect.y - padding[0],
  35913. width: boundingRect.width + padding[1] + padding[3],
  35914. height: boundingRect.height + padding[0] + padding[2]
  35915. },
  35916. style: style,
  35917. silent: true,
  35918. z2: -1
  35919. });
  35920. graphic.subPixelOptimizeRect(rect);
  35921. group.add(rect);
  35922. }
  35923. };
  35924. /***/ },
  35925. /* 270 */
  35926. /***/ function(module, exports) {
  35927. module.exports = function (ecModel) {
  35928. var legendModels = ecModel.findComponents({
  35929. mainType: 'legend'
  35930. });
  35931. if (legendModels && legendModels.length) {
  35932. ecModel.filterSeries(function (series) {
  35933. // If in any legend component the status is not selected.
  35934. // Because in legend series is assumed selected when it is not in the legend data.
  35935. for (var i = 0; i < legendModels.length; i++) {
  35936. if (!legendModels[i].isSelected(series.name)) {
  35937. return false;
  35938. }
  35939. }
  35940. return true;
  35941. });
  35942. }
  35943. };
  35944. /***/ },
  35945. /* 271 */
  35946. /***/ function(module, exports, __webpack_require__) {
  35947. // FIXME Better way to pack data in graphic element
  35948. __webpack_require__(272);
  35949. __webpack_require__(273);
  35950. // Show tip action
  35951. /**
  35952. * @action
  35953. * @property {string} type
  35954. * @property {number} seriesIndex
  35955. * @property {number} dataIndex
  35956. * @property {number} [x]
  35957. * @property {number} [y]
  35958. */
  35959. __webpack_require__(1).registerAction(
  35960. {
  35961. type: 'showTip',
  35962. event: 'showTip',
  35963. update: 'none'
  35964. },
  35965. // noop
  35966. function () {}
  35967. );
  35968. // Hide tip action
  35969. __webpack_require__(1).registerAction(
  35970. {
  35971. type: 'hideTip',
  35972. event: 'hideTip',
  35973. update: 'none'
  35974. },
  35975. // noop
  35976. function () {}
  35977. );
  35978. /***/ },
  35979. /* 272 */
  35980. /***/ function(module, exports, __webpack_require__) {
  35981. __webpack_require__(1).extendComponentModel({
  35982. type: 'tooltip',
  35983. defaultOption: {
  35984. zlevel: 0,
  35985. z: 8,
  35986. show: true,
  35987. // tooltip主体内容
  35988. showContent: true,
  35989. // 触发类型,默认数据触发,见下图,可选为:'item' ¦ 'axis'
  35990. trigger: 'item',
  35991. // 触发条件,支持 'click' | 'mousemove'
  35992. triggerOn: 'mousemove',
  35993. // 是否永远显示 content
  35994. alwaysShowContent: false,
  35995. // 位置 {Array} | {Function}
  35996. // position: null
  35997. // 内容格式器:{string}(Template) ¦ {Function}
  35998. // formatter: null
  35999. showDelay: 0,
  36000. // 隐藏延迟,单位ms
  36001. hideDelay: 100,
  36002. // 动画变换时间,单位s
  36003. transitionDuration: 0.4,
  36004. enterable: false,
  36005. // 提示背景颜色,默认为透明度为0.7的黑色
  36006. backgroundColor: 'rgba(50,50,50,0.7)',
  36007. // 提示边框颜色
  36008. borderColor: '#333',
  36009. // 提示边框圆角,单位px,默认为4
  36010. borderRadius: 4,
  36011. // 提示边框线宽,单位px,默认为0(无边框)
  36012. borderWidth: 0,
  36013. // 提示内边距,单位px,默认各方向内边距为5,
  36014. // 接受数组分别设定上右下左边距,同css
  36015. padding: 5,
  36016. // Extra css text
  36017. extraCssText: '',
  36018. // 坐标轴指示器,坐标轴触发有效
  36019. axisPointer: {
  36020. // 默认为直线
  36021. // 可选为:'line' | 'shadow' | 'cross'
  36022. type: 'line',
  36023. // type 为 line 的时候有效,指定 tooltip line 所在的轴,可选
  36024. // 可选 'x' | 'y' | 'angle' | 'radius' | 'auto'
  36025. // 默认 'auto',会选择类型为 cateogry 的轴,对于双数值轴,笛卡尔坐标系会默认选择 x 轴
  36026. // 极坐标系会默认选择 angle 轴
  36027. axis: 'auto',
  36028. animation: true,
  36029. animationDurationUpdate: 200,
  36030. animationEasingUpdate: 'exponentialOut',
  36031. // 直线指示器样式设置
  36032. lineStyle: {
  36033. color: '#555',
  36034. width: 1,
  36035. type: 'solid'
  36036. },
  36037. crossStyle: {
  36038. color: '#555',
  36039. width: 1,
  36040. type: 'dashed',
  36041. // TODO formatter
  36042. textStyle: {}
  36043. },
  36044. // 阴影指示器样式设置
  36045. shadowStyle: {
  36046. color: 'rgba(150,150,150,0.3)'
  36047. }
  36048. },
  36049. textStyle: {
  36050. color: '#fff',
  36051. fontSize: 14
  36052. }
  36053. }
  36054. });
  36055. /***/ },
  36056. /* 273 */
  36057. /***/ function(module, exports, __webpack_require__) {
  36058. var TooltipContent = __webpack_require__(274);
  36059. var graphic = __webpack_require__(42);
  36060. var zrUtil = __webpack_require__(3);
  36061. var formatUtil = __webpack_require__(6);
  36062. var numberUtil = __webpack_require__(7);
  36063. var parsePercent = numberUtil.parsePercent;
  36064. var env = __webpack_require__(79);
  36065. function dataEqual(a, b) {
  36066. if (!a || !b) {
  36067. return false;
  36068. }
  36069. var round = numberUtil.round;
  36070. return round(a[0]) === round(b[0])
  36071. && round(a[1]) === round(b[1]);
  36072. }
  36073. /**
  36074. * @inner
  36075. */
  36076. function makeLineShape(x1, y1, x2, y2) {
  36077. return {
  36078. x1: x1,
  36079. y1: y1,
  36080. x2: x2,
  36081. y2: y2
  36082. };
  36083. }
  36084. /**
  36085. * @inner
  36086. */
  36087. function makeRectShape(x, y, width, height) {
  36088. return {
  36089. x: x,
  36090. y: y,
  36091. width: width,
  36092. height: height
  36093. };
  36094. }
  36095. /**
  36096. * @inner
  36097. */
  36098. function makeSectorShape(cx, cy, r0, r, startAngle, endAngle) {
  36099. return {
  36100. cx: cx,
  36101. cy: cy,
  36102. r0: r0,
  36103. r: r,
  36104. startAngle: startAngle,
  36105. endAngle: endAngle,
  36106. clockwise: true
  36107. };
  36108. }
  36109. function refixTooltipPosition(x, y, el, viewWidth, viewHeight) {
  36110. var width = el.clientWidth;
  36111. var height = el.clientHeight;
  36112. var gap = 20;
  36113. if (x + width + gap > viewWidth) {
  36114. x -= width + gap;
  36115. }
  36116. else {
  36117. x += gap;
  36118. }
  36119. if (y + height + gap > viewHeight) {
  36120. y -= height + gap;
  36121. }
  36122. else {
  36123. y += gap;
  36124. }
  36125. return [x, y];
  36126. }
  36127. function calcTooltipPosition(position, rect, dom) {
  36128. var domWidth = dom.clientWidth;
  36129. var domHeight = dom.clientHeight;
  36130. var gap = 5;
  36131. var x = 0;
  36132. var y = 0;
  36133. var rectWidth = rect.width;
  36134. var rectHeight = rect.height;
  36135. switch (position) {
  36136. case 'inside':
  36137. x = rect.x + rectWidth / 2 - domWidth / 2;
  36138. y = rect.y + rectHeight / 2 - domHeight / 2;
  36139. break;
  36140. case 'top':
  36141. x = rect.x + rectWidth / 2 - domWidth / 2;
  36142. y = rect.y - domHeight - gap;
  36143. break;
  36144. case 'bottom':
  36145. x = rect.x + rectWidth / 2 - domWidth / 2;
  36146. y = rect.y + rectHeight + gap;
  36147. break;
  36148. case 'left':
  36149. x = rect.x - domWidth - gap;
  36150. y = rect.y + rectHeight / 2 - domHeight / 2;
  36151. break;
  36152. case 'right':
  36153. x = rect.x + rectWidth + gap;
  36154. y = rect.y + rectHeight / 2 - domHeight / 2;
  36155. }
  36156. return [x, y];
  36157. }
  36158. /**
  36159. * @param {string|Function|Array.<number>} positionExpr
  36160. * @param {number} x Mouse x
  36161. * @param {number} y Mouse y
  36162. * @param {module:echarts/component/tooltip/TooltipContent} content
  36163. * @param {Object|<Array.<Object>} params
  36164. * @param {module:zrender/Element} el target element
  36165. * @param {module:echarts/ExtensionAPI} api
  36166. * @return {Array.<number>}
  36167. */
  36168. function updatePosition(positionExpr, x, y, content, params, el, api) {
  36169. var viewWidth = api.getWidth();
  36170. var viewHeight = api.getHeight();
  36171. var rect = el && el.getBoundingRect().clone();
  36172. el && rect.applyTransform(el.transform);
  36173. if (typeof positionExpr === 'function') {
  36174. // Callback of position can be an array or a string specify the position
  36175. positionExpr = positionExpr([x, y], params, content.el, rect);
  36176. }
  36177. if (zrUtil.isArray(positionExpr)) {
  36178. x = parsePercent(positionExpr[0], viewWidth);
  36179. y = parsePercent(positionExpr[1], viewHeight);
  36180. }
  36181. // Specify tooltip position by string 'top' 'bottom' 'left' 'right' around graphic element
  36182. else if (typeof positionExpr === 'string' && el) {
  36183. var pos = calcTooltipPosition(
  36184. positionExpr, rect, content.el
  36185. );
  36186. x = pos[0];
  36187. y = pos[1];
  36188. }
  36189. else {
  36190. var pos = refixTooltipPosition(
  36191. x, y, content.el, viewWidth, viewHeight
  36192. );
  36193. x = pos[0];
  36194. y = pos[1];
  36195. }
  36196. content.moveTo(x, y);
  36197. }
  36198. function ifSeriesSupportAxisTrigger(seriesModel) {
  36199. var coordSys = seriesModel.coordinateSystem;
  36200. var trigger = seriesModel.get('tooltip.trigger', true);
  36201. // Ignore series use item tooltip trigger and series coordinate system is not cartesian or
  36202. return !(!coordSys
  36203. || (coordSys.type !== 'cartesian2d' && coordSys.type !== 'polar' && coordSys.type !== 'single')
  36204. || trigger === 'item');
  36205. }
  36206. __webpack_require__(1).extendComponentView({
  36207. type: 'tooltip',
  36208. _axisPointers: {},
  36209. init: function (ecModel, api) {
  36210. if (env.node) {
  36211. return;
  36212. }
  36213. var tooltipContent = new TooltipContent(api.getDom(), api);
  36214. this._tooltipContent = tooltipContent;
  36215. api.on('showTip', this._manuallyShowTip, this);
  36216. api.on('hideTip', this._manuallyHideTip, this);
  36217. },
  36218. render: function (tooltipModel, ecModel, api) {
  36219. if (env.node) {
  36220. return;
  36221. }
  36222. // Reset
  36223. this.group.removeAll();
  36224. /**
  36225. * @type {Object}
  36226. * @private
  36227. */
  36228. this._axisPointers = {};
  36229. /**
  36230. * @private
  36231. * @type {module:echarts/component/tooltip/TooltipModel}
  36232. */
  36233. this._tooltipModel = tooltipModel;
  36234. /**
  36235. * @private
  36236. * @type {module:echarts/model/Global}
  36237. */
  36238. this._ecModel = ecModel;
  36239. /**
  36240. * @private
  36241. * @type {module:echarts/ExtensionAPI}
  36242. */
  36243. this._api = api;
  36244. /**
  36245. * @type {Object}
  36246. * @private
  36247. */
  36248. this._lastHover = {
  36249. // data
  36250. // payloadBatch
  36251. };
  36252. var tooltipContent = this._tooltipContent;
  36253. tooltipContent.update();
  36254. tooltipContent.enterable = tooltipModel.get('enterable');
  36255. this._alwaysShowContent = tooltipModel.get('alwaysShowContent');
  36256. /**
  36257. * @type {Object.<string, Array>}
  36258. */
  36259. this._seriesGroupByAxis = this._prepareAxisTriggerData(
  36260. tooltipModel, ecModel
  36261. );
  36262. var crossText = this._crossText;
  36263. if (crossText) {
  36264. this.group.add(crossText);
  36265. }
  36266. // Try to keep the tooltip show when refreshing
  36267. if (this._lastX != null && this._lastY != null) {
  36268. var self = this;
  36269. clearTimeout(this._refreshUpdateTimeout);
  36270. this._refreshUpdateTimeout = setTimeout(function () {
  36271. // Show tip next tick after other charts are rendered
  36272. // In case highlight action has wrong result
  36273. // FIXME
  36274. self._manuallyShowTip({
  36275. x: self._lastX,
  36276. y: self._lastY
  36277. });
  36278. });
  36279. }
  36280. var zr = this._api.getZr();
  36281. zr.off('click', this._tryShow);
  36282. zr.off('mousemove', this._mousemove);
  36283. zr.off('mouseout', this._hide);
  36284. zr.off('globalout', this._hide);
  36285. if (tooltipModel.get('triggerOn') === 'click') {
  36286. zr.on('click', this._tryShow, this);
  36287. }
  36288. else {
  36289. zr.on('mousemove', this._mousemove, this);
  36290. zr.on('mouseout', this._hide, this);
  36291. zr.on('globalout', this._hide, this);
  36292. }
  36293. },
  36294. _mousemove: function (e) {
  36295. var showDelay = this._tooltipModel.get('showDelay');
  36296. var self = this;
  36297. clearTimeout(this._showTimeout);
  36298. if (showDelay > 0) {
  36299. this._showTimeout = setTimeout(function () {
  36300. self._tryShow(e);
  36301. }, showDelay);
  36302. }
  36303. else {
  36304. this._tryShow(e);
  36305. }
  36306. },
  36307. /**
  36308. * Show tip manually by
  36309. * dispatchAction({
  36310. * type: 'showTip',
  36311. * x: 10,
  36312. * y: 10
  36313. * });
  36314. * Or
  36315. * dispatchAction({
  36316. * type: 'showTip',
  36317. * seriesIndex: 0,
  36318. * dataIndex: 1
  36319. * });
  36320. *
  36321. * TODO Batch
  36322. */
  36323. _manuallyShowTip: function (event) {
  36324. // From self
  36325. if (event.from === this.uid) {
  36326. return;
  36327. }
  36328. var ecModel = this._ecModel;
  36329. var seriesIndex = event.seriesIndex;
  36330. var dataIndex = event.dataIndex;
  36331. var seriesModel = ecModel.getSeriesByIndex(seriesIndex);
  36332. var api = this._api;
  36333. if (event.x == null || event.y == null) {
  36334. if (!seriesModel) {
  36335. // Find the first series can use axis trigger
  36336. ecModel.eachSeries(function (_series) {
  36337. if (ifSeriesSupportAxisTrigger(_series) && !seriesModel) {
  36338. seriesModel = _series;
  36339. }
  36340. });
  36341. }
  36342. if (seriesModel) {
  36343. var data = seriesModel.getData();
  36344. if (dataIndex == null) {
  36345. dataIndex = data.indexOfName(event.name);
  36346. }
  36347. var el = data.getItemGraphicEl(dataIndex);
  36348. var cx, cy;
  36349. // Try to get the point in coordinate system
  36350. var coordSys = seriesModel.coordinateSystem;
  36351. if (coordSys && coordSys.dataToPoint) {
  36352. var point = coordSys.dataToPoint(
  36353. data.getValues(
  36354. zrUtil.map(coordSys.dimensions, function (dim) {
  36355. return seriesModel.coordDimToDataDim(dim)[0];
  36356. }), dataIndex, true
  36357. )
  36358. );
  36359. cx = point && point[0];
  36360. cy = point && point[1];
  36361. }
  36362. else if (el) {
  36363. // Use graphic bounding rect
  36364. var rect = el.getBoundingRect().clone();
  36365. rect.applyTransform(el.transform);
  36366. cx = rect.x + rect.width / 2;
  36367. cy = rect.y + rect.height / 2;
  36368. }
  36369. if (cx != null && cy != null) {
  36370. this._tryShow({
  36371. offsetX: cx,
  36372. offsetY: cy,
  36373. target: el,
  36374. event: {}
  36375. });
  36376. }
  36377. }
  36378. }
  36379. else {
  36380. var el = api.getZr().handler.findHover(event.x, event.y);
  36381. this._tryShow({
  36382. offsetX: event.x,
  36383. offsetY: event.y,
  36384. target: el,
  36385. event: {}
  36386. });
  36387. }
  36388. },
  36389. _manuallyHideTip: function (e) {
  36390. if (e.from === this.uid) {
  36391. return;
  36392. }
  36393. this._hide();
  36394. },
  36395. _prepareAxisTriggerData: function (tooltipModel, ecModel) {
  36396. // Prepare data for axis trigger
  36397. var seriesGroupByAxis = {};
  36398. ecModel.eachSeries(function (seriesModel) {
  36399. if (ifSeriesSupportAxisTrigger(seriesModel)) {
  36400. var coordSys = seriesModel.coordinateSystem;
  36401. var baseAxis;
  36402. var key;
  36403. // Only cartesian2d, polar and single support axis trigger
  36404. if (coordSys.type === 'cartesian2d') {
  36405. // FIXME `axisPointer.axis` is not baseAxis
  36406. baseAxis = coordSys.getBaseAxis();
  36407. key = baseAxis.dim + baseAxis.index;
  36408. }
  36409. else if (coordSys.type === 'single') {
  36410. baseAxis = coordSys.getAxis();
  36411. key = baseAxis.dim + baseAxis.type;
  36412. }
  36413. else {
  36414. baseAxis = coordSys.getBaseAxis();
  36415. key = baseAxis.dim + coordSys.name;
  36416. }
  36417. seriesGroupByAxis[key] = seriesGroupByAxis[key] || {
  36418. coordSys: [],
  36419. series: []
  36420. };
  36421. seriesGroupByAxis[key].coordSys.push(coordSys);
  36422. seriesGroupByAxis[key].series.push(seriesModel);
  36423. }
  36424. }, this);
  36425. return seriesGroupByAxis;
  36426. },
  36427. /**
  36428. * mousemove handler
  36429. * @param {Object} e
  36430. * @private
  36431. */
  36432. _tryShow: function (e) {
  36433. var el = e.target;
  36434. var tooltipModel = this._tooltipModel;
  36435. var globalTrigger = tooltipModel.get('trigger');
  36436. var ecModel = this._ecModel;
  36437. var api = this._api;
  36438. if (!tooltipModel) {
  36439. return;
  36440. }
  36441. // Save mouse x, mouse y. So we can try to keep showing the tip if chart is refreshed
  36442. this._lastX = e.offsetX;
  36443. this._lastY = e.offsetY;
  36444. // Always show item tooltip if mouse is on the element with dataIndex
  36445. if (el && el.dataIndex != null) {
  36446. // Use dataModel in element if possible
  36447. // Used when mouseover on a element like markPoint or edge
  36448. // In which case, the data is not main data in series.
  36449. var dataModel = el.dataModel || ecModel.getSeriesByIndex(el.seriesIndex);
  36450. var dataIndex = el.dataIndex;
  36451. var itemModel = dataModel.getData().getItemModel(dataIndex);
  36452. // Series or single data may use item trigger when global is axis trigger
  36453. if ((itemModel.get('tooltip.trigger') || globalTrigger) === 'axis') {
  36454. this._showAxisTooltip(tooltipModel, ecModel, e);
  36455. }
  36456. else {
  36457. // Reset ticket
  36458. this._ticket = '';
  36459. // If either single data or series use item trigger
  36460. this._hideAxisPointer();
  36461. // Reset last hover and dispatch downplay action
  36462. this._resetLastHover();
  36463. this._showItemTooltipContent(dataModel, dataIndex, el.dataType, e);
  36464. }
  36465. api.dispatchAction({
  36466. type: 'showTip',
  36467. from: this.uid,
  36468. dataIndex: el.dataIndex,
  36469. seriesIndex: el.seriesIndex
  36470. });
  36471. }
  36472. else {
  36473. if (globalTrigger === 'item') {
  36474. this._hide();
  36475. }
  36476. else {
  36477. // Try show axis tooltip
  36478. this._showAxisTooltip(tooltipModel, ecModel, e);
  36479. }
  36480. // Action of cross pointer
  36481. // other pointer types will trigger action in _dispatchAndShowSeriesTooltipContent method
  36482. if (tooltipModel.get('axisPointer.type') === 'cross') {
  36483. api.dispatchAction({
  36484. type: 'showTip',
  36485. from: this.uid,
  36486. x: e.offsetX,
  36487. y: e.offsetY
  36488. });
  36489. }
  36490. }
  36491. },
  36492. /**
  36493. * Show tooltip on axis
  36494. * @param {module:echarts/component/tooltip/TooltipModel} tooltipModel
  36495. * @param {module:echarts/model/Global} ecModel
  36496. * @param {Object} e
  36497. * @private
  36498. */
  36499. _showAxisTooltip: function (tooltipModel, ecModel, e) {
  36500. var axisPointerModel = tooltipModel.getModel('axisPointer');
  36501. var axisPointerType = axisPointerModel.get('type');
  36502. if (axisPointerType === 'cross') {
  36503. var el = e.target;
  36504. if (el && el.dataIndex != null) {
  36505. var seriesModel = ecModel.getSeriesByIndex(el.seriesIndex);
  36506. var dataIndex = el.dataIndex;
  36507. this._showItemTooltipContent(seriesModel, dataIndex, el.dataType, e);
  36508. }
  36509. }
  36510. this._showAxisPointer();
  36511. var allNotShow = true;
  36512. zrUtil.each(this._seriesGroupByAxis, function (seriesCoordSysSameAxis) {
  36513. // Try show the axis pointer
  36514. var allCoordSys = seriesCoordSysSameAxis.coordSys;
  36515. var coordSys = allCoordSys[0];
  36516. // If mouse position is not in the grid or polar
  36517. var point = [e.offsetX, e.offsetY];
  36518. if (!coordSys.containPoint(point)) {
  36519. // Hide axis pointer
  36520. this._hideAxisPointer(coordSys.name);
  36521. return;
  36522. }
  36523. allNotShow = false;
  36524. // Make sure point is discrete on cateogry axis
  36525. var dimensions = coordSys.dimensions;
  36526. var value = coordSys.pointToData(point, true);
  36527. point = coordSys.dataToPoint(value);
  36528. var baseAxis = coordSys.getBaseAxis();
  36529. var axisType = axisPointerModel.get('axis');
  36530. if (axisType === 'auto') {
  36531. axisType = baseAxis.dim;
  36532. }
  36533. var contentNotChange = false;
  36534. var lastHover = this._lastHover;
  36535. if (axisPointerType === 'cross') {
  36536. // If hover data not changed
  36537. // Possible when two axes are all category
  36538. if (dataEqual(lastHover.data, value)) {
  36539. contentNotChange = true;
  36540. }
  36541. lastHover.data = value;
  36542. }
  36543. else {
  36544. var valIndex = zrUtil.indexOf(dimensions, axisType);
  36545. // If hover data not changed on the axis dimension
  36546. if (lastHover.data === value[valIndex]) {
  36547. contentNotChange = true;
  36548. }
  36549. lastHover.data = value[valIndex];
  36550. }
  36551. if (coordSys.type === 'cartesian2d' && !contentNotChange) {
  36552. this._showCartesianPointer(
  36553. axisPointerModel, coordSys, axisType, point
  36554. );
  36555. }
  36556. else if (coordSys.type === 'polar' && !contentNotChange) {
  36557. this._showPolarPointer(
  36558. axisPointerModel, coordSys, axisType, point
  36559. );
  36560. }
  36561. else if (coordSys.type === 'single' && !contentNotChange) {
  36562. this._showSinglePointer(
  36563. axisPointerModel, coordSys, axisType, point
  36564. );
  36565. }
  36566. if (axisPointerType !== 'cross') {
  36567. this._dispatchAndShowSeriesTooltipContent(
  36568. coordSys, seriesCoordSysSameAxis.series, point, value, contentNotChange
  36569. );
  36570. }
  36571. }, this);
  36572. if (!this._tooltipModel.get('show')) {
  36573. this._hideAxisPointer();
  36574. }
  36575. if (allNotShow) {
  36576. this._hide();
  36577. }
  36578. },
  36579. /**
  36580. * Show tooltip on axis of cartesian coordinate
  36581. * @param {module:echarts/model/Model} axisPointerModel
  36582. * @param {module:echarts/coord/cartesian/Cartesian2D} cartesians
  36583. * @param {string} axisType
  36584. * @param {Array.<number>} point
  36585. * @private
  36586. */
  36587. _showCartesianPointer: function (axisPointerModel, cartesian, axisType, point) {
  36588. var self = this;
  36589. var axisPointerType = axisPointerModel.get('type');
  36590. var moveAnimation = axisPointerType !== 'cross';
  36591. if (axisPointerType === 'cross') {
  36592. moveGridLine('x', point, cartesian.getAxis('y').getGlobalExtent());
  36593. moveGridLine('y', point, cartesian.getAxis('x').getGlobalExtent());
  36594. this._updateCrossText(cartesian, point, axisPointerModel);
  36595. }
  36596. else {
  36597. var otherAxis = cartesian.getAxis(axisType === 'x' ? 'y' : 'x');
  36598. var otherExtent = otherAxis.getGlobalExtent();
  36599. if (cartesian.type === 'cartesian2d') {
  36600. (axisPointerType === 'line' ? moveGridLine : moveGridShadow)(
  36601. axisType, point, otherExtent
  36602. );
  36603. }
  36604. }
  36605. /**
  36606. * @inner
  36607. */
  36608. function moveGridLine(axisType, point, otherExtent) {
  36609. var targetShape = axisType === 'x'
  36610. ? makeLineShape(point[0], otherExtent[0], point[0], otherExtent[1])
  36611. : makeLineShape(otherExtent[0], point[1], otherExtent[1], point[1]);
  36612. var pointerEl = self._getPointerElement(
  36613. cartesian, axisPointerModel, axisType, targetShape
  36614. );
  36615. moveAnimation
  36616. ? graphic.updateProps(pointerEl, {
  36617. shape: targetShape
  36618. }, axisPointerModel)
  36619. : pointerEl.attr({
  36620. shape: targetShape
  36621. });
  36622. }
  36623. /**
  36624. * @inner
  36625. */
  36626. function moveGridShadow(axisType, point, otherExtent) {
  36627. var axis = cartesian.getAxis(axisType);
  36628. var bandWidth = axis.getBandWidth();
  36629. var span = otherExtent[1] - otherExtent[0];
  36630. var targetShape = axisType === 'x'
  36631. ? makeRectShape(point[0] - bandWidth / 2, otherExtent[0], bandWidth, span)
  36632. : makeRectShape(otherExtent[0], point[1] - bandWidth / 2, span, bandWidth);
  36633. var pointerEl = self._getPointerElement(
  36634. cartesian, axisPointerModel, axisType, targetShape
  36635. );
  36636. moveAnimation
  36637. ? graphic.updateProps(pointerEl, {
  36638. shape: targetShape
  36639. }, axisPointerModel)
  36640. : pointerEl.attr({
  36641. shape: targetShape
  36642. });
  36643. }
  36644. },
  36645. _showSinglePointer: function (axisPointerModel, single, axisType, point) {
  36646. var self = this;
  36647. var axisPointerType = axisPointerModel.get('type');
  36648. var moveAnimation = axisPointerType !== 'cross';
  36649. var rect = single.getRect();
  36650. var otherExtent = [rect.y, rect.y + rect.height];
  36651. moveSingleLine(axisType, point, otherExtent);
  36652. /**
  36653. * @inner
  36654. */
  36655. function moveSingleLine(axisType, point, otherExtent) {
  36656. var axis = single.getAxis();
  36657. var orient = axis.orient;
  36658. var targetShape = orient === 'horizontal'
  36659. ? makeLineShape(point[0], otherExtent[0], point[0], otherExtent[1])
  36660. : makeLineShape(otherExtent[0], point[1], otherExtent[1], point[1]);
  36661. var pointerEl = self._getPointerElement(
  36662. single, axisPointerModel, axisType, targetShape
  36663. );
  36664. moveAnimation
  36665. ? graphic.updateProps(pointerEl, {
  36666. shape: targetShape
  36667. }, axisPointerModel)
  36668. : pointerEl.attr({
  36669. shape: targetShape
  36670. });
  36671. }
  36672. },
  36673. /**
  36674. * Show tooltip on axis of polar coordinate
  36675. * @param {module:echarts/model/Model} axisPointerModel
  36676. * @param {Array.<module:echarts/coord/polar/Polar>} polar
  36677. * @param {string} axisType
  36678. * @param {Array.<number>} point
  36679. */
  36680. _showPolarPointer: function (axisPointerModel, polar, axisType, point) {
  36681. var self = this;
  36682. var axisPointerType = axisPointerModel.get('type');
  36683. var angleAxis = polar.getAngleAxis();
  36684. var radiusAxis = polar.getRadiusAxis();
  36685. var moveAnimation = axisPointerType !== 'cross';
  36686. if (axisPointerType === 'cross') {
  36687. movePolarLine('angle', point, radiusAxis.getExtent());
  36688. movePolarLine('radius', point, angleAxis.getExtent());
  36689. this._updateCrossText(polar, point, axisPointerModel);
  36690. }
  36691. else {
  36692. var otherAxis = polar.getAxis(axisType === 'radius' ? 'angle' : 'radius');
  36693. var otherExtent = otherAxis.getExtent();
  36694. (axisPointerType === 'line' ? movePolarLine : movePolarShadow)(
  36695. axisType, point, otherExtent
  36696. );
  36697. }
  36698. /**
  36699. * @inner
  36700. */
  36701. function movePolarLine(axisType, point, otherExtent) {
  36702. var mouseCoord = polar.pointToCoord(point);
  36703. var targetShape;
  36704. if (axisType === 'angle') {
  36705. var p1 = polar.coordToPoint([otherExtent[0], mouseCoord[1]]);
  36706. var p2 = polar.coordToPoint([otherExtent[1], mouseCoord[1]]);
  36707. targetShape = makeLineShape(p1[0], p1[1], p2[0], p2[1]);
  36708. }
  36709. else {
  36710. targetShape = {
  36711. cx: polar.cx,
  36712. cy: polar.cy,
  36713. r: mouseCoord[0]
  36714. };
  36715. }
  36716. var pointerEl = self._getPointerElement(
  36717. polar, axisPointerModel, axisType, targetShape
  36718. );
  36719. moveAnimation
  36720. ? graphic.updateProps(pointerEl, {
  36721. shape: targetShape
  36722. }, axisPointerModel)
  36723. : pointerEl.attr({
  36724. shape: targetShape
  36725. });
  36726. }
  36727. /**
  36728. * @inner
  36729. */
  36730. function movePolarShadow(axisType, point, otherExtent) {
  36731. var axis = polar.getAxis(axisType);
  36732. var bandWidth = axis.getBandWidth();
  36733. var mouseCoord = polar.pointToCoord(point);
  36734. var targetShape;
  36735. var radian = Math.PI / 180;
  36736. if (axisType === 'angle') {
  36737. targetShape = makeSectorShape(
  36738. polar.cx, polar.cy,
  36739. otherExtent[0], otherExtent[1],
  36740. // In ECharts y is negative if angle is positive
  36741. (-mouseCoord[1] - bandWidth / 2) * radian,
  36742. (-mouseCoord[1] + bandWidth / 2) * radian
  36743. );
  36744. }
  36745. else {
  36746. targetShape = makeSectorShape(
  36747. polar.cx, polar.cy,
  36748. mouseCoord[0] - bandWidth / 2,
  36749. mouseCoord[0] + bandWidth / 2,
  36750. 0, Math.PI * 2
  36751. );
  36752. }
  36753. var pointerEl = self._getPointerElement(
  36754. polar, axisPointerModel, axisType, targetShape
  36755. );
  36756. moveAnimation
  36757. ? graphic.updateProps(pointerEl, {
  36758. shape: targetShape
  36759. }, axisPointerModel)
  36760. : pointerEl.attr({
  36761. shape: targetShape
  36762. });
  36763. }
  36764. },
  36765. _updateCrossText: function (coordSys, point, axisPointerModel) {
  36766. var crossStyleModel = axisPointerModel.getModel('crossStyle');
  36767. var textStyleModel = crossStyleModel.getModel('textStyle');
  36768. var tooltipModel = this._tooltipModel;
  36769. var text = this._crossText;
  36770. if (!text) {
  36771. text = this._crossText = new graphic.Text({
  36772. style: {
  36773. textAlign: 'left',
  36774. textVerticalAlign: 'bottom'
  36775. }
  36776. });
  36777. this.group.add(text);
  36778. }
  36779. var value = coordSys.pointToData(point);
  36780. var dims = coordSys.dimensions;
  36781. value = zrUtil.map(value, function (val, idx) {
  36782. var axis = coordSys.getAxis(dims[idx]);
  36783. if (axis.type === 'category' || axis.type === 'time') {
  36784. val = axis.scale.getLabel(val);
  36785. }
  36786. else {
  36787. val = formatUtil.addCommas(
  36788. val.toFixed(axis.getPixelPrecision())
  36789. );
  36790. }
  36791. return val;
  36792. });
  36793. text.setStyle({
  36794. fill: textStyleModel.getTextColor() || crossStyleModel.get('color'),
  36795. textFont: textStyleModel.getFont(),
  36796. text: value.join(', '),
  36797. x: point[0] + 5,
  36798. y: point[1] - 5
  36799. });
  36800. text.z = tooltipModel.get('z');
  36801. text.zlevel = tooltipModel.get('zlevel');
  36802. },
  36803. _getPointerElement: function (coordSys, pointerModel, axisType, initShape) {
  36804. var tooltipModel = this._tooltipModel;
  36805. var z = tooltipModel.get('z');
  36806. var zlevel = tooltipModel.get('zlevel');
  36807. var axisPointers = this._axisPointers;
  36808. var coordSysName = coordSys.name;
  36809. axisPointers[coordSysName] = axisPointers[coordSysName] || {};
  36810. if (axisPointers[coordSysName][axisType]) {
  36811. return axisPointers[coordSysName][axisType];
  36812. }
  36813. // Create if not exists
  36814. var pointerType = pointerModel.get('type');
  36815. var styleModel = pointerModel.getModel(pointerType + 'Style');
  36816. var isShadow = pointerType === 'shadow';
  36817. var style = styleModel[isShadow ? 'getAreaStyle' : 'getLineStyle']();
  36818. var elementType = coordSys.type === 'polar'
  36819. ? (isShadow ? 'Sector' : (axisType === 'radius' ? 'Circle' : 'Line'))
  36820. : (isShadow ? 'Rect' : 'Line');
  36821. isShadow ? (style.stroke = null) : (style.fill = null);
  36822. var el = axisPointers[coordSysName][axisType] = new graphic[elementType]({
  36823. style: style,
  36824. z: z,
  36825. zlevel: zlevel,
  36826. silent: true,
  36827. shape: initShape
  36828. });
  36829. this.group.add(el);
  36830. return el;
  36831. },
  36832. /**
  36833. * Dispatch actions and show tooltip on series
  36834. * @param {Array.<module:echarts/model/Series>} seriesList
  36835. * @param {Array.<number>} point
  36836. * @param {Array.<number>} value
  36837. * @param {boolean} contentNotChange
  36838. * @param {Object} e
  36839. */
  36840. _dispatchAndShowSeriesTooltipContent: function (
  36841. coordSys, seriesList, point, value, contentNotChange
  36842. ) {
  36843. var rootTooltipModel = this._tooltipModel;
  36844. var tooltipContent = this._tooltipContent;
  36845. var baseAxis = coordSys.getBaseAxis();
  36846. var payloadBatch = zrUtil.map(seriesList, function (series) {
  36847. return {
  36848. seriesIndex: series.seriesIndex,
  36849. dataIndex: series.getAxisTooltipDataIndex
  36850. ? series.getAxisTooltipDataIndex(series.coordDimToDataDim(baseAxis.dim), value, baseAxis)
  36851. : series.getData().indexOfNearest(
  36852. series.coordDimToDataDim(baseAxis.dim)[0],
  36853. value[baseAxis.dim === 'x' || baseAxis.dim === 'radius' ? 0 : 1]
  36854. )
  36855. };
  36856. });
  36857. var lastHover = this._lastHover;
  36858. var api = this._api;
  36859. // Dispatch downplay action
  36860. if (lastHover.payloadBatch && !contentNotChange) {
  36861. api.dispatchAction({
  36862. type: 'downplay',
  36863. batch: lastHover.payloadBatch
  36864. });
  36865. }
  36866. // Dispatch highlight action
  36867. if (!contentNotChange) {
  36868. api.dispatchAction({
  36869. type: 'highlight',
  36870. batch: payloadBatch
  36871. });
  36872. lastHover.payloadBatch = payloadBatch;
  36873. }
  36874. // Dispatch showTip action
  36875. api.dispatchAction({
  36876. type: 'showTip',
  36877. dataIndex: payloadBatch[0].dataIndex,
  36878. seriesIndex: payloadBatch[0].seriesIndex,
  36879. from: this.uid
  36880. });
  36881. if (baseAxis && rootTooltipModel.get('showContent') && rootTooltipModel.get('show')) {
  36882. var formatter = rootTooltipModel.get('formatter');
  36883. var positionExpr = rootTooltipModel.get('position');
  36884. var html;
  36885. var paramsList = zrUtil.map(seriesList, function (series, index) {
  36886. return series.getDataParams(payloadBatch[index].dataIndex);
  36887. });
  36888. // If only one series
  36889. // FIXME
  36890. // if (paramsList.length === 1) {
  36891. // paramsList = paramsList[0];
  36892. // }
  36893. tooltipContent.show(rootTooltipModel);
  36894. // Update html content
  36895. var firstDataIndex = payloadBatch[0].dataIndex;
  36896. if (!contentNotChange) {
  36897. // Reset ticket
  36898. this._ticket = '';
  36899. if (!formatter) {
  36900. // Default tooltip content
  36901. // FIXME
  36902. // (1) shold be the first data which has name?
  36903. // (2) themeRiver, firstDataIndex is array, and first line is unnecessary.
  36904. var firstLine = seriesList[0].getData().getName(firstDataIndex);
  36905. html = (firstLine ? firstLine + '<br />' : '')
  36906. + zrUtil.map(seriesList, function (series, index) {
  36907. return series.formatTooltip(payloadBatch[index].dataIndex, true);
  36908. }).join('<br />');
  36909. }
  36910. else {
  36911. if (typeof formatter === 'string') {
  36912. html = formatUtil.formatTpl(formatter, paramsList);
  36913. }
  36914. else if (typeof formatter === 'function') {
  36915. var self = this;
  36916. var ticket = 'axis_' + coordSys.name + '_' + firstDataIndex;
  36917. var callback = function (cbTicket, html) {
  36918. if (cbTicket === self._ticket) {
  36919. tooltipContent.setContent(html);
  36920. updatePosition(
  36921. positionExpr, point[0], point[1],
  36922. tooltipContent, paramsList, null, api
  36923. );
  36924. }
  36925. };
  36926. self._ticket = ticket;
  36927. html = formatter(paramsList, ticket, callback);
  36928. }
  36929. }
  36930. tooltipContent.setContent(html);
  36931. }
  36932. updatePosition(
  36933. positionExpr, point[0], point[1],
  36934. tooltipContent, paramsList, null, api
  36935. );
  36936. }
  36937. },
  36938. /**
  36939. * Show tooltip on item
  36940. * @param {module:echarts/model/Series} seriesModel
  36941. * @param {number} dataIndex
  36942. * @param {string} dataType
  36943. * @param {Object} e
  36944. */
  36945. _showItemTooltipContent: function (seriesModel, dataIndex, dataType, e) {
  36946. // FIXME Graph data
  36947. var api = this._api;
  36948. var data = seriesModel.getData(dataType);
  36949. var itemModel = data.getItemModel(dataIndex);
  36950. var rootTooltipModel = this._tooltipModel;
  36951. var tooltipContent = this._tooltipContent;
  36952. var tooltipModel = itemModel.getModel('tooltip');
  36953. // If series model
  36954. if (tooltipModel.parentModel) {
  36955. tooltipModel.parentModel.parentModel = rootTooltipModel;
  36956. }
  36957. else {
  36958. tooltipModel.parentModel = this._tooltipModel;
  36959. }
  36960. if (tooltipModel.get('showContent') && tooltipModel.get('show')) {
  36961. var formatter = tooltipModel.get('formatter');
  36962. var positionExpr = tooltipModel.get('position');
  36963. var params = seriesModel.getDataParams(dataIndex, dataType);
  36964. var html;
  36965. if (!formatter) {
  36966. html = seriesModel.formatTooltip(dataIndex, false, dataType);
  36967. }
  36968. else {
  36969. if (typeof formatter === 'string') {
  36970. html = formatUtil.formatTpl(formatter, params);
  36971. }
  36972. else if (typeof formatter === 'function') {
  36973. var self = this;
  36974. var ticket = 'item_' + seriesModel.name + '_' + dataIndex;
  36975. var callback = function (cbTicket, html) {
  36976. if (cbTicket === self._ticket) {
  36977. tooltipContent.setContent(html);
  36978. updatePosition(
  36979. positionExpr, e.offsetX, e.offsetY,
  36980. tooltipContent, params, e.target, api
  36981. );
  36982. }
  36983. };
  36984. self._ticket = ticket;
  36985. html = formatter(params, ticket, callback);
  36986. }
  36987. }
  36988. tooltipContent.show(tooltipModel);
  36989. tooltipContent.setContent(html);
  36990. updatePosition(
  36991. positionExpr, e.offsetX, e.offsetY,
  36992. tooltipContent, params, e.target, api
  36993. );
  36994. }
  36995. },
  36996. /**
  36997. * Show axis pointer
  36998. * @param {string} [coordSysName]
  36999. */
  37000. _showAxisPointer: function (coordSysName) {
  37001. if (coordSysName) {
  37002. var axisPointers = this._axisPointers[coordSysName];
  37003. axisPointers && zrUtil.each(axisPointers, function (el) {
  37004. el.show();
  37005. });
  37006. }
  37007. else {
  37008. this.group.eachChild(function (child) {
  37009. child.show();
  37010. });
  37011. this.group.show();
  37012. }
  37013. },
  37014. _resetLastHover: function () {
  37015. var lastHover = this._lastHover;
  37016. if (lastHover.payloadBatch) {
  37017. this._api.dispatchAction({
  37018. type: 'downplay',
  37019. batch: lastHover.payloadBatch
  37020. });
  37021. }
  37022. // Reset lastHover
  37023. this._lastHover = {};
  37024. },
  37025. /**
  37026. * Hide axis pointer
  37027. * @param {string} [coordSysName]
  37028. */
  37029. _hideAxisPointer: function (coordSysName) {
  37030. if (coordSysName) {
  37031. var axisPointers = this._axisPointers[coordSysName];
  37032. axisPointers && zrUtil.each(axisPointers, function (el) {
  37033. el.hide();
  37034. });
  37035. }
  37036. else {
  37037. this.group.hide();
  37038. }
  37039. },
  37040. _hide: function () {
  37041. clearTimeout(this._showTimeout);
  37042. this._hideAxisPointer();
  37043. this._resetLastHover();
  37044. if (!this._alwaysShowContent) {
  37045. this._tooltipContent.hideLater(this._tooltipModel.get('hideDelay'));
  37046. }
  37047. this._api.dispatchAction({
  37048. type: 'hideTip',
  37049. from: this.uid
  37050. });
  37051. this._lastX = this._lastY = null;
  37052. },
  37053. dispose: function (ecModel, api) {
  37054. if (env.node) {
  37055. return;
  37056. }
  37057. var zr = api.getZr();
  37058. this._tooltipContent.hide();
  37059. zr.off('click', this._tryShow);
  37060. zr.off('mousemove', this._mousemove);
  37061. zr.off('mouseout', this._hide);
  37062. zr.off('globalout', this._hide);
  37063. api.off('showTip', this._manuallyShowTip);
  37064. api.off('hideTip', this._manuallyHideTip);
  37065. }
  37066. });
  37067. /***/ },
  37068. /* 274 */
  37069. /***/ function(module, exports, __webpack_require__) {
  37070. /**
  37071. * @module echarts/component/tooltip/TooltipContent
  37072. */
  37073. var zrUtil = __webpack_require__(3);
  37074. var zrColor = __webpack_require__(38);
  37075. var eventUtil = __webpack_require__(81);
  37076. var formatUtil = __webpack_require__(6);
  37077. var each = zrUtil.each;
  37078. var toCamelCase = formatUtil.toCamelCase;
  37079. var env = __webpack_require__(79);
  37080. var vendors = ['', '-webkit-', '-moz-', '-o-'];
  37081. var gCssText = 'position:absolute;display:block;border-style:solid;white-space:nowrap;z-index:9999999;';
  37082. /**
  37083. * @param {number} duration
  37084. * @return {string}
  37085. * @inner
  37086. */
  37087. function assembleTransition(duration) {
  37088. var transitionCurve = 'cubic-bezier(0.23, 1, 0.32, 1)';
  37089. var transitionText = 'left ' + duration + 's ' + transitionCurve + ','
  37090. + 'top ' + duration + 's ' + transitionCurve;
  37091. return zrUtil.map(vendors, function (vendorPrefix) {
  37092. return vendorPrefix + 'transition:' + transitionText;
  37093. }).join(';');
  37094. }
  37095. /**
  37096. * @param {Object} textStyle
  37097. * @return {string}
  37098. * @inner
  37099. */
  37100. function assembleFont(textStyleModel) {
  37101. var cssText = [];
  37102. var fontSize = textStyleModel.get('fontSize');
  37103. var color = textStyleModel.getTextColor();
  37104. color && cssText.push('color:' + color);
  37105. cssText.push('font:' + textStyleModel.getFont());
  37106. fontSize &&
  37107. cssText.push('line-height:' + Math.round(fontSize * 3 / 2) + 'px');
  37108. each(['decoration', 'align'], function (name) {
  37109. var val = textStyleModel.get(name);
  37110. val && cssText.push('text-' + name + ':' + val);
  37111. });
  37112. return cssText.join(';');
  37113. }
  37114. /**
  37115. * @param {Object} tooltipModel
  37116. * @return {string}
  37117. * @inner
  37118. */
  37119. function assembleCssText(tooltipModel) {
  37120. tooltipModel = tooltipModel;
  37121. var cssText = [];
  37122. var transitionDuration = tooltipModel.get('transitionDuration');
  37123. var backgroundColor = tooltipModel.get('backgroundColor');
  37124. var textStyleModel = tooltipModel.getModel('textStyle');
  37125. var padding = tooltipModel.get('padding');
  37126. // Animation transition
  37127. transitionDuration &&
  37128. cssText.push(assembleTransition(transitionDuration));
  37129. if (backgroundColor) {
  37130. if (env.canvasSupported) {
  37131. cssText.push('background-Color:' + backgroundColor);
  37132. }
  37133. else {
  37134. // for ie
  37135. cssText.push(
  37136. 'background-Color:#' + zrColor.toHex(backgroundColor)
  37137. );
  37138. cssText.push('filter:alpha(opacity=70)');
  37139. }
  37140. }
  37141. // Border style
  37142. each(['width', 'color', 'radius'], function (name) {
  37143. var borderName = 'border-' + name;
  37144. var camelCase = toCamelCase(borderName);
  37145. var val = tooltipModel.get(camelCase);
  37146. val != null &&
  37147. cssText.push(borderName + ':' + val + (name === 'color' ? '' : 'px'));
  37148. });
  37149. // Text style
  37150. cssText.push(assembleFont(textStyleModel));
  37151. // Padding
  37152. if (padding != null) {
  37153. cssText.push('padding:' + formatUtil.normalizeCssArray(padding).join('px ') + 'px');
  37154. }
  37155. return cssText.join(';') + ';';
  37156. }
  37157. /**
  37158. * @alias module:echarts/component/tooltip/TooltipContent
  37159. * @constructor
  37160. */
  37161. function TooltipContent(container, api) {
  37162. var el = document.createElement('div');
  37163. var zr = api.getZr();
  37164. this.el = el;
  37165. this._x = api.getWidth() / 2;
  37166. this._y = api.getHeight() / 2;
  37167. container.appendChild(el);
  37168. this._container = container;
  37169. this._show = false;
  37170. /**
  37171. * @private
  37172. */
  37173. this._hideTimeout;
  37174. var self = this;
  37175. el.onmouseenter = function () {
  37176. // clear the timeout in hideLater and keep showing tooltip
  37177. if (self.enterable) {
  37178. clearTimeout(self._hideTimeout);
  37179. self._show = true;
  37180. }
  37181. self._inContent = true;
  37182. };
  37183. el.onmousemove = function (e) {
  37184. if (!self.enterable) {
  37185. // Try trigger zrender event to avoid mouse
  37186. // in and out shape too frequently
  37187. var handler = zr.handler;
  37188. eventUtil.normalizeEvent(container, e);
  37189. handler.dispatch('mousemove', e);
  37190. }
  37191. };
  37192. el.onmouseleave = function () {
  37193. if (self.enterable) {
  37194. if (self._show) {
  37195. self.hideLater(self._hideDelay);
  37196. }
  37197. }
  37198. self._inContent = false;
  37199. };
  37200. compromiseMobile(el, container);
  37201. }
  37202. function compromiseMobile(tooltipContentEl, container) {
  37203. // Prevent default behavior on mobile. For example,
  37204. // default pinch gesture will cause browser zoom.
  37205. // We do not preventing event on tooltip contnet el,
  37206. // because user may need customization in tooltip el.
  37207. eventUtil.addEventListener(container, 'touchstart', preventDefault);
  37208. eventUtil.addEventListener(container, 'touchmove', preventDefault);
  37209. eventUtil.addEventListener(container, 'touchend', preventDefault);
  37210. function preventDefault(e) {
  37211. if (contains(e.target)) {
  37212. e.preventDefault();
  37213. }
  37214. }
  37215. function contains(targetEl) {
  37216. while (targetEl && targetEl !== container) {
  37217. if (targetEl === tooltipContentEl) {
  37218. return true;
  37219. }
  37220. targetEl = targetEl.parentNode;
  37221. }
  37222. }
  37223. }
  37224. TooltipContent.prototype = {
  37225. constructor: TooltipContent,
  37226. enterable: true,
  37227. /**
  37228. * Update when tooltip is rendered
  37229. */
  37230. update: function () {
  37231. var container = this._container;
  37232. var stl = container.currentStyle
  37233. || document.defaultView.getComputedStyle(container);
  37234. var domStyle = container.style;
  37235. if (domStyle.position !== 'absolute' && stl.position !== 'absolute') {
  37236. domStyle.position = 'relative';
  37237. }
  37238. // Hide the tooltip
  37239. // PENDING
  37240. // this.hide();
  37241. },
  37242. show: function (tooltipModel) {
  37243. clearTimeout(this._hideTimeout);
  37244. this.el.style.cssText = gCssText + assembleCssText(tooltipModel)
  37245. // http://stackoverflow.com/questions/21125587/css3-transition-not-working-in-chrome-anymore
  37246. + ';left:' + this._x + 'px;top:' + this._y + 'px;'
  37247. + (tooltipModel.get('extraCssText') || '');
  37248. this._show = true;
  37249. },
  37250. setContent: function (content) {
  37251. var el = this.el;
  37252. el.innerHTML = content;
  37253. el.style.display = content ? 'block' : 'none';
  37254. },
  37255. moveTo: function (x, y) {
  37256. var style = this.el.style;
  37257. style.left = x + 'px';
  37258. style.top = y + 'px';
  37259. this._x = x;
  37260. this._y = y;
  37261. },
  37262. hide: function () {
  37263. this.el.style.display = 'none';
  37264. this._show = false;
  37265. },
  37266. // showLater: function ()
  37267. hideLater: function (time) {
  37268. if (this._show && !(this._inContent && this.enterable)) {
  37269. if (time) {
  37270. this._hideDelay = time;
  37271. // Set show false to avoid invoke hideLater mutiple times
  37272. this._show = false;
  37273. this._hideTimeout = setTimeout(zrUtil.bind(this.hide, this), time);
  37274. }
  37275. else {
  37276. this.hide();
  37277. }
  37278. }
  37279. },
  37280. isShow: function () {
  37281. return this._show;
  37282. }
  37283. };
  37284. module.exports = TooltipContent;
  37285. /***/ },
  37286. /* 275 */
  37287. /***/ function(module, exports, __webpack_require__) {
  37288. 'use strict';
  37289. __webpack_require__(276);
  37290. __webpack_require__(282);
  37291. __webpack_require__(284);
  37292. // Polar view
  37293. __webpack_require__(1).extendComponentView({
  37294. type: 'polar'
  37295. });
  37296. /***/ },
  37297. /* 276 */
  37298. /***/ function(module, exports, __webpack_require__) {
  37299. // TODO Axis scale
  37300. var Polar = __webpack_require__(277);
  37301. var numberUtil = __webpack_require__(7);
  37302. var axisHelper = __webpack_require__(109);
  37303. var niceScaleExtent = axisHelper.niceScaleExtent;
  37304. // 依赖 PolarModel 做预处理
  37305. __webpack_require__(280);
  37306. /**
  37307. * Resize method bound to the polar
  37308. * @param {module:echarts/coord/polar/PolarModel} polarModel
  37309. * @param {module:echarts/ExtensionAPI} api
  37310. */
  37311. function resizePolar(polarModel, api) {
  37312. var center = polarModel.get('center');
  37313. var radius = polarModel.get('radius');
  37314. var width = api.getWidth();
  37315. var height = api.getHeight();
  37316. var parsePercent = numberUtil.parsePercent;
  37317. this.cx = parsePercent(center[0], width);
  37318. this.cy = parsePercent(center[1], height);
  37319. var radiusAxis = this.getRadiusAxis();
  37320. var size = Math.min(width, height) / 2;
  37321. // var idx = radiusAxis.inverse ? 1 : 0;
  37322. radiusAxis.setExtent(0, parsePercent(radius, size));
  37323. }
  37324. /**
  37325. * Update polar
  37326. */
  37327. function updatePolarScale(ecModel, api) {
  37328. var polar = this;
  37329. var angleAxis = polar.getAngleAxis();
  37330. var radiusAxis = polar.getRadiusAxis();
  37331. // Reset scale
  37332. angleAxis.scale.setExtent(Infinity, -Infinity);
  37333. radiusAxis.scale.setExtent(Infinity, -Infinity);
  37334. ecModel.eachSeries(function (seriesModel) {
  37335. if (seriesModel.coordinateSystem === polar) {
  37336. var data = seriesModel.getData();
  37337. radiusAxis.scale.unionExtent(
  37338. data.getDataExtent('radius', radiusAxis.type !== 'category')
  37339. );
  37340. angleAxis.scale.unionExtent(
  37341. data.getDataExtent('angle', angleAxis.type !== 'category')
  37342. );
  37343. }
  37344. });
  37345. niceScaleExtent(angleAxis, angleAxis.model);
  37346. niceScaleExtent(radiusAxis, radiusAxis.model);
  37347. // Fix extent of category angle axis
  37348. if (angleAxis.type === 'category' && !angleAxis.onBand) {
  37349. var extent = angleAxis.getExtent();
  37350. var diff = 360 / angleAxis.scale.count();
  37351. angleAxis.inverse ? (extent[1] += diff) : (extent[1] -= diff);
  37352. angleAxis.setExtent(extent[0], extent[1]);
  37353. }
  37354. }
  37355. /**
  37356. * Set common axis properties
  37357. * @param {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
  37358. * @param {module:echarts/coord/polar/AxisModel}
  37359. * @inner
  37360. */
  37361. function setAxis(axis, axisModel) {
  37362. axis.type = axisModel.get('type');
  37363. axis.scale = axisHelper.createScaleByModel(axisModel);
  37364. axis.onBand = axisModel.get('boundaryGap') && axis.type === 'category';
  37365. // FIXME Radius axis not support inverse axis
  37366. if (axisModel.mainType === 'angleAxis') {
  37367. var startAngle = axisModel.get('startAngle');
  37368. axis.inverse = axisModel.get('inverse') ^ axisModel.get('clockwise');
  37369. axis.setExtent(startAngle, startAngle + (axis.inverse ? -360 : 360));
  37370. }
  37371. // Inject axis instance
  37372. axisModel.axis = axis;
  37373. axis.model = axisModel;
  37374. }
  37375. var polarCreator = {
  37376. dimensions: Polar.prototype.dimensions,
  37377. create: function (ecModel, api) {
  37378. var polarList = [];
  37379. ecModel.eachComponent('polar', function (polarModel, idx) {
  37380. var polar = new Polar(idx);
  37381. // Inject resize and update method
  37382. polar.resize = resizePolar;
  37383. polar.update = updatePolarScale;
  37384. var radiusAxis = polar.getRadiusAxis();
  37385. var angleAxis = polar.getAngleAxis();
  37386. var radiusAxisModel = polarModel.findAxisModel('radiusAxis');
  37387. var angleAxisModel = polarModel.findAxisModel('angleAxis');
  37388. setAxis(radiusAxis, radiusAxisModel);
  37389. setAxis(angleAxis, angleAxisModel);
  37390. polar.resize(polarModel, api);
  37391. polarList.push(polar);
  37392. polarModel.coordinateSystem = polar;
  37393. });
  37394. // Inject coordinateSystem to series
  37395. ecModel.eachSeries(function (seriesModel) {
  37396. if (seriesModel.get('coordinateSystem') === 'polar') {
  37397. seriesModel.coordinateSystem = polarList[seriesModel.get('polarIndex')];
  37398. }
  37399. });
  37400. return polarList;
  37401. }
  37402. };
  37403. __webpack_require__(25).register('polar', polarCreator);
  37404. /***/ },
  37405. /* 277 */
  37406. /***/ function(module, exports, __webpack_require__) {
  37407. 'use strict';
  37408. /**
  37409. * @module echarts/coord/polar/Polar
  37410. */
  37411. var RadiusAxis = __webpack_require__(278);
  37412. var AngleAxis = __webpack_require__(279);
  37413. /**
  37414. * @alias {module:echarts/coord/polar/Polar}
  37415. * @constructor
  37416. * @param {string} name
  37417. */
  37418. var Polar = function (name) {
  37419. /**
  37420. * @type {string}
  37421. */
  37422. this.name = name || '';
  37423. /**
  37424. * x of polar center
  37425. * @type {number}
  37426. */
  37427. this.cx = 0;
  37428. /**
  37429. * y of polar center
  37430. * @type {number}
  37431. */
  37432. this.cy = 0;
  37433. /**
  37434. * @type {module:echarts/coord/polar/RadiusAxis}
  37435. * @private
  37436. */
  37437. this._radiusAxis = new RadiusAxis();
  37438. /**
  37439. * @type {module:echarts/coord/polar/AngleAxis}
  37440. * @private
  37441. */
  37442. this._angleAxis = new AngleAxis();
  37443. };
  37444. Polar.prototype = {
  37445. constructor: Polar,
  37446. type: 'polar',
  37447. /**
  37448. * @param {Array.<string>}
  37449. * @readOnly
  37450. */
  37451. dimensions: ['radius', 'angle'],
  37452. /**
  37453. * If contain coord
  37454. * @param {Array.<number>} point
  37455. * @return {boolean}
  37456. */
  37457. containPoint: function (point) {
  37458. var coord = this.pointToCoord(point);
  37459. return this._radiusAxis.contain(coord[0])
  37460. && this._angleAxis.contain(coord[1]);
  37461. },
  37462. /**
  37463. * If contain data
  37464. * @param {Array.<number>} data
  37465. * @return {boolean}
  37466. */
  37467. containData: function (data) {
  37468. return this._radiusAxis.containData(data[0])
  37469. && this._angleAxis.containData(data[1]);
  37470. },
  37471. /**
  37472. * @param {string} axisType
  37473. * @return {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
  37474. */
  37475. getAxis: function (axisType) {
  37476. return this['_' + axisType + 'Axis'];
  37477. },
  37478. /**
  37479. * Get axes by type of scale
  37480. * @param {string} scaleType
  37481. * @return {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
  37482. */
  37483. getAxesByScale: function (scaleType) {
  37484. var axes = [];
  37485. var angleAxis = this._angleAxis;
  37486. var radiusAxis = this._radiusAxis;
  37487. angleAxis.scale.type === scaleType && axes.push(angleAxis);
  37488. radiusAxis.scale.type === scaleType && axes.push(radiusAxis);
  37489. return axes;
  37490. },
  37491. /**
  37492. * @return {module:echarts/coord/polar/AngleAxis}
  37493. */
  37494. getAngleAxis: function () {
  37495. return this._angleAxis;
  37496. },
  37497. /**
  37498. * @return {module:echarts/coord/polar/RadiusAxis}
  37499. */
  37500. getRadiusAxis: function () {
  37501. return this._radiusAxis;
  37502. },
  37503. /**
  37504. * @param {module:echarts/coord/polar/Axis}
  37505. * @return {module:echarts/coord/polar/Axis}
  37506. */
  37507. getOtherAxis: function (axis) {
  37508. var angleAxis = this._angleAxis;
  37509. return axis === angleAxis ? this._radiusAxis : angleAxis;
  37510. },
  37511. /**
  37512. * Base axis will be used on stacking.
  37513. *
  37514. * @return {module:echarts/coord/polar/Axis}
  37515. */
  37516. getBaseAxis: function () {
  37517. return this.getAxesByScale('ordinal')[0]
  37518. || this.getAxesByScale('time')[0]
  37519. || this.getAngleAxis();
  37520. },
  37521. /**
  37522. * Convert series data to a list of (x, y) points
  37523. * @param {module:echarts/data/List} data
  37524. * @return {Array}
  37525. * Return list of coordinates. For example:
  37526. * `[[10, 10], [20, 20], [30, 30]]`
  37527. */
  37528. dataToPoints: function (data) {
  37529. return data.mapArray(this.dimensions, function (radius, angle) {
  37530. return this.dataToPoint([radius, angle]);
  37531. }, this);
  37532. },
  37533. /**
  37534. * Convert a single data item to (x, y) point.
  37535. * Parameter data is an array which the first element is radius and the second is angle
  37536. * @param {Array.<number>} data
  37537. * @param {boolean} [clamp=false]
  37538. * @return {Array.<number>}
  37539. */
  37540. dataToPoint: function (data, clamp) {
  37541. return this.coordToPoint([
  37542. this._radiusAxis.dataToRadius(data[0], clamp),
  37543. this._angleAxis.dataToAngle(data[1], clamp)
  37544. ]);
  37545. },
  37546. /**
  37547. * Convert a (x, y) point to data
  37548. * @param {Array.<number>} point
  37549. * @param {boolean} [clamp=false]
  37550. * @return {Array.<number>}
  37551. */
  37552. pointToData: function (point, clamp) {
  37553. var coord = this.pointToCoord(point);
  37554. return [
  37555. this._radiusAxis.radiusToData(coord[0], clamp),
  37556. this._angleAxis.angleToData(coord[1], clamp)
  37557. ];
  37558. },
  37559. /**
  37560. * Convert a (x, y) point to (radius, angle) coord
  37561. * @param {Array.<number>} point
  37562. * @return {Array.<number>}
  37563. */
  37564. pointToCoord: function (point) {
  37565. var dx = point[0] - this.cx;
  37566. var dy = point[1] - this.cy;
  37567. var angleAxis = this.getAngleAxis();
  37568. var extent = angleAxis.getExtent();
  37569. var minAngle = Math.min(extent[0], extent[1]);
  37570. var maxAngle = Math.max(extent[0], extent[1]);
  37571. // Fix fixed extent in polarCreator
  37572. // FIXME
  37573. angleAxis.inverse
  37574. ? (minAngle = maxAngle - 360)
  37575. : (maxAngle = minAngle + 360);
  37576. var radius = Math.sqrt(dx * dx + dy * dy);
  37577. dx /= radius;
  37578. dy /= radius;
  37579. var radian = Math.atan2(-dy, dx) / Math.PI * 180;
  37580. // move to angleExtent
  37581. var dir = radian < minAngle ? 1 : -1;
  37582. while (radian < minAngle || radian > maxAngle) {
  37583. radian += dir * 360;
  37584. }
  37585. return [radius, radian];
  37586. },
  37587. /**
  37588. * Convert a (radius, angle) coord to (x, y) point
  37589. * @param {Array.<number>} coord
  37590. * @return {Array.<number>}
  37591. */
  37592. coordToPoint: function (coord) {
  37593. var radius = coord[0];
  37594. var radian = coord[1] / 180 * Math.PI;
  37595. var x = Math.cos(radian) * radius + this.cx;
  37596. // Inverse the y
  37597. var y = -Math.sin(radian) * radius + this.cy;
  37598. return [x, y];
  37599. }
  37600. };
  37601. module.exports = Polar;
  37602. /***/ },
  37603. /* 278 */
  37604. /***/ function(module, exports, __webpack_require__) {
  37605. 'use strict';
  37606. var zrUtil = __webpack_require__(3);
  37607. var Axis = __webpack_require__(118);
  37608. function RadiusAxis(scale, radiusExtent) {
  37609. Axis.call(this, 'radius', scale, radiusExtent);
  37610. /**
  37611. * Axis type
  37612. * - 'category'
  37613. * - 'value'
  37614. * - 'time'
  37615. * - 'log'
  37616. * @type {string}
  37617. */
  37618. this.type = 'category';
  37619. }
  37620. RadiusAxis.prototype = {
  37621. constructor: RadiusAxis,
  37622. dataToRadius: Axis.prototype.dataToCoord,
  37623. radiusToData: Axis.prototype.coordToData
  37624. };
  37625. zrUtil.inherits(RadiusAxis, Axis);
  37626. module.exports = RadiusAxis;
  37627. /***/ },
  37628. /* 279 */
  37629. /***/ function(module, exports, __webpack_require__) {
  37630. 'use strict';
  37631. var zrUtil = __webpack_require__(3);
  37632. var Axis = __webpack_require__(118);
  37633. function AngleAxis(scale, angleExtent) {
  37634. angleExtent = angleExtent || [0, 360];
  37635. Axis.call(this, 'angle', scale, angleExtent);
  37636. /**
  37637. * Axis type
  37638. * - 'category'
  37639. * - 'value'
  37640. * - 'time'
  37641. * - 'log'
  37642. * @type {string}
  37643. */
  37644. this.type = 'category';
  37645. }
  37646. AngleAxis.prototype = {
  37647. constructor: AngleAxis,
  37648. dataToAngle: Axis.prototype.dataToCoord,
  37649. angleToData: Axis.prototype.coordToData
  37650. };
  37651. zrUtil.inherits(AngleAxis, Axis);
  37652. module.exports = AngleAxis;
  37653. /***/ },
  37654. /* 280 */
  37655. /***/ function(module, exports, __webpack_require__) {
  37656. 'use strict';
  37657. __webpack_require__(281);
  37658. __webpack_require__(1).extendComponentModel({
  37659. type: 'polar',
  37660. dependencies: ['polarAxis', 'angleAxis'],
  37661. /**
  37662. * @type {module:echarts/coord/polar/Polar}
  37663. */
  37664. coordinateSystem: null,
  37665. /**
  37666. * @param {string} axisType
  37667. * @return {module:echarts/coord/polar/AxisModel}
  37668. */
  37669. findAxisModel: function (axisType) {
  37670. var angleAxisModel;
  37671. var ecModel = this.ecModel;
  37672. ecModel.eachComponent(axisType, function (axisModel) {
  37673. if (ecModel.getComponent(
  37674. 'polar', axisModel.getShallow('polarIndex')
  37675. ) === this) {
  37676. angleAxisModel = axisModel;
  37677. }
  37678. }, this);
  37679. return angleAxisModel;
  37680. },
  37681. defaultOption: {
  37682. zlevel: 0,
  37683. z: 0,
  37684. center: ['50%', '50%'],
  37685. radius: '80%'
  37686. }
  37687. });
  37688. /***/ },
  37689. /* 281 */
  37690. /***/ function(module, exports, __webpack_require__) {
  37691. 'use strict';
  37692. var zrUtil = __webpack_require__(3);
  37693. var ComponentModel = __webpack_require__(19);
  37694. var axisModelCreator = __webpack_require__(122);
  37695. var PolarAxisModel = ComponentModel.extend({
  37696. type: 'polarAxis',
  37697. /**
  37698. * @type {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
  37699. */
  37700. axis: null
  37701. });
  37702. zrUtil.merge(PolarAxisModel.prototype, __webpack_require__(124));
  37703. var polarAxisDefaultExtendedOption = {
  37704. angle: {
  37705. polarIndex: 0,
  37706. startAngle: 90,
  37707. clockwise: true,
  37708. splitNumber: 12,
  37709. axisLabel: {
  37710. rotate: false
  37711. }
  37712. },
  37713. radius: {
  37714. polarIndex: 0,
  37715. splitNumber: 5
  37716. }
  37717. };
  37718. function getAxisType(axisDim, option) {
  37719. // Default axis with data is category axis
  37720. return option.type || (option.data ? 'category' : 'value');
  37721. }
  37722. axisModelCreator('angle', PolarAxisModel, getAxisType, polarAxisDefaultExtendedOption.angle);
  37723. axisModelCreator('radius', PolarAxisModel, getAxisType, polarAxisDefaultExtendedOption.radius);
  37724. /***/ },
  37725. /* 282 */
  37726. /***/ function(module, exports, __webpack_require__) {
  37727. 'use strict';
  37728. __webpack_require__(276);
  37729. __webpack_require__(283);
  37730. /***/ },
  37731. /* 283 */
  37732. /***/ function(module, exports, __webpack_require__) {
  37733. 'use strict';
  37734. var zrUtil = __webpack_require__(3);
  37735. var graphic = __webpack_require__(42);
  37736. var Model = __webpack_require__(8);
  37737. var elementList = ['axisLine', 'axisLabel', 'axisTick', 'splitLine', 'splitArea'];
  37738. function getAxisLineShape(polar, r0, r, angle) {
  37739. var start = polar.coordToPoint([r0, angle]);
  37740. var end = polar.coordToPoint([r, angle]);
  37741. return {
  37742. x1: start[0],
  37743. y1: start[1],
  37744. x2: end[0],
  37745. y2: end[1]
  37746. };
  37747. }
  37748. __webpack_require__(1).extendComponentView({
  37749. type: 'angleAxis',
  37750. render: function (angleAxisModel, ecModel) {
  37751. this.group.removeAll();
  37752. if (!angleAxisModel.get('show')) {
  37753. return;
  37754. }
  37755. var polarModel = ecModel.getComponent('polar', angleAxisModel.get('polarIndex'));
  37756. var angleAxis = angleAxisModel.axis;
  37757. var polar = polarModel.coordinateSystem;
  37758. var radiusExtent = polar.getRadiusAxis().getExtent();
  37759. var ticksAngles = angleAxis.getTicksCoords();
  37760. if (angleAxis.type !== 'category') {
  37761. // Remove the last tick which will overlap the first tick
  37762. ticksAngles.pop();
  37763. }
  37764. zrUtil.each(elementList, function (name) {
  37765. if (angleAxisModel.get(name +'.show')) {
  37766. this['_' + name](angleAxisModel, polar, ticksAngles, radiusExtent);
  37767. }
  37768. }, this);
  37769. },
  37770. /**
  37771. * @private
  37772. */
  37773. _axisLine: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
  37774. var lineStyleModel = angleAxisModel.getModel('axisLine.lineStyle');
  37775. var circle = new graphic.Circle({
  37776. shape: {
  37777. cx: polar.cx,
  37778. cy: polar.cy,
  37779. r: radiusExtent[1]
  37780. },
  37781. style: lineStyleModel.getLineStyle(),
  37782. z2: 1,
  37783. silent: true
  37784. });
  37785. circle.style.fill = null;
  37786. this.group.add(circle);
  37787. },
  37788. /**
  37789. * @private
  37790. */
  37791. _axisTick: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
  37792. var tickModel = angleAxisModel.getModel('axisTick');
  37793. var tickLen = (tickModel.get('inside') ? -1 : 1) * tickModel.get('length');
  37794. var lines = zrUtil.map(ticksAngles, function (tickAngle) {
  37795. return new graphic.Line({
  37796. shape: getAxisLineShape(polar, radiusExtent[1], radiusExtent[1] + tickLen, tickAngle)
  37797. });
  37798. });
  37799. this.group.add(graphic.mergePath(
  37800. lines, {
  37801. style: tickModel.getModel('lineStyle').getLineStyle()
  37802. }
  37803. ));
  37804. },
  37805. /**
  37806. * @private
  37807. */
  37808. _axisLabel: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
  37809. var axis = angleAxisModel.axis;
  37810. var categoryData = angleAxisModel.get('data');
  37811. var labelModel = angleAxisModel.getModel('axisLabel');
  37812. var axisTextStyleModel = labelModel.getModel('textStyle');
  37813. var labels = angleAxisModel.getFormattedLabels();
  37814. var labelMargin = labelModel.get('margin');
  37815. var labelsAngles = axis.getLabelsCoords();
  37816. // Use length of ticksAngles because it may remove the last tick to avoid overlapping
  37817. for (var i = 0; i < ticksAngles.length; i++) {
  37818. var r = radiusExtent[1];
  37819. var p = polar.coordToPoint([r + labelMargin, labelsAngles[i]]);
  37820. var cx = polar.cx;
  37821. var cy = polar.cy;
  37822. var labelTextAlign = Math.abs(p[0] - cx) / r < 0.3
  37823. ? 'center' : (p[0] > cx ? 'left' : 'right');
  37824. var labelTextBaseline = Math.abs(p[1] - cy) / r < 0.3
  37825. ? 'middle' : (p[1] > cy ? 'top' : 'bottom');
  37826. var textStyleModel = axisTextStyleModel;
  37827. if (categoryData && categoryData[i] && categoryData[i].textStyle) {
  37828. textStyleModel = new Model(
  37829. categoryData[i].textStyle, axisTextStyleModel
  37830. );
  37831. }
  37832. this.group.add(new graphic.Text({
  37833. style: {
  37834. x: p[0],
  37835. y: p[1],
  37836. fill: textStyleModel.getTextColor(),
  37837. text: labels[i],
  37838. textAlign: labelTextAlign,
  37839. textVerticalAlign: labelTextBaseline,
  37840. textFont: textStyleModel.getFont()
  37841. },
  37842. silent: true
  37843. }));
  37844. }
  37845. },
  37846. /**
  37847. * @private
  37848. */
  37849. _splitLine: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
  37850. var splitLineModel = angleAxisModel.getModel('splitLine');
  37851. var lineStyleModel = splitLineModel.getModel('lineStyle');
  37852. var lineColors = lineStyleModel.get('color');
  37853. var lineCount = 0;
  37854. lineColors = lineColors instanceof Array ? lineColors : [lineColors];
  37855. var splitLines = [];
  37856. for (var i = 0; i < ticksAngles.length; i++) {
  37857. var colorIndex = (lineCount++) % lineColors.length;
  37858. splitLines[colorIndex] = splitLines[colorIndex] || [];
  37859. splitLines[colorIndex].push(new graphic.Line({
  37860. shape: getAxisLineShape(polar, radiusExtent[0], radiusExtent[1], ticksAngles[i])
  37861. }));
  37862. }
  37863. // Simple optimization
  37864. // Batching the lines if color are the same
  37865. for (var i = 0; i < splitLines.length; i++) {
  37866. this.group.add(graphic.mergePath(splitLines[i], {
  37867. style: zrUtil.defaults({
  37868. stroke: lineColors[i % lineColors.length]
  37869. }, lineStyleModel.getLineStyle()),
  37870. silent: true,
  37871. z: angleAxisModel.get('z')
  37872. }));
  37873. }
  37874. },
  37875. /**
  37876. * @private
  37877. */
  37878. _splitArea: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
  37879. var splitAreaModel = angleAxisModel.getModel('splitArea');
  37880. var areaStyleModel = splitAreaModel.getModel('areaStyle');
  37881. var areaColors = areaStyleModel.get('color');
  37882. var lineCount = 0;
  37883. areaColors = areaColors instanceof Array ? areaColors : [areaColors];
  37884. var splitAreas = [];
  37885. var RADIAN = Math.PI / 180;
  37886. var prevAngle = -ticksAngles[0] * RADIAN;
  37887. var r0 = Math.min(radiusExtent[0], radiusExtent[1]);
  37888. var r1 = Math.max(radiusExtent[0], radiusExtent[1]);
  37889. var clockwise = angleAxisModel.get('clockwise');
  37890. for (var i = 1; i < ticksAngles.length; i++) {
  37891. var colorIndex = (lineCount++) % areaColors.length;
  37892. splitAreas[colorIndex] = splitAreas[colorIndex] || [];
  37893. splitAreas[colorIndex].push(new graphic.Sector({
  37894. shape: {
  37895. cx: polar.cx,
  37896. cy: polar.cy,
  37897. r0: r0,
  37898. r: r1,
  37899. startAngle: prevAngle,
  37900. endAngle: -ticksAngles[i] * RADIAN,
  37901. clockwise: clockwise
  37902. },
  37903. silent: true
  37904. }));
  37905. prevAngle = -ticksAngles[i] * RADIAN;
  37906. }
  37907. // Simple optimization
  37908. // Batching the lines if color are the same
  37909. for (var i = 0; i < splitAreas.length; i++) {
  37910. this.group.add(graphic.mergePath(splitAreas[i], {
  37911. style: zrUtil.defaults({
  37912. fill: areaColors[i % areaColors.length]
  37913. }, areaStyleModel.getAreaStyle()),
  37914. silent: true
  37915. }));
  37916. }
  37917. }
  37918. });
  37919. /***/ },
  37920. /* 284 */
  37921. /***/ function(module, exports, __webpack_require__) {
  37922. __webpack_require__(276);
  37923. __webpack_require__(285);
  37924. /***/ },
  37925. /* 285 */
  37926. /***/ function(module, exports, __webpack_require__) {
  37927. 'use strict';
  37928. var zrUtil = __webpack_require__(3);
  37929. var graphic = __webpack_require__(42);
  37930. var AxisBuilder = __webpack_require__(127);
  37931. var axisBuilderAttrs = [
  37932. 'axisLine', 'axisLabel', 'axisTick', 'axisName'
  37933. ];
  37934. var selfBuilderAttrs = [
  37935. 'splitLine', 'splitArea'
  37936. ];
  37937. __webpack_require__(1).extendComponentView({
  37938. type: 'radiusAxis',
  37939. render: function (radiusAxisModel, ecModel) {
  37940. this.group.removeAll();
  37941. if (!radiusAxisModel.get('show')) {
  37942. return;
  37943. }
  37944. var polarModel = ecModel.getComponent('polar', radiusAxisModel.get('polarIndex'));
  37945. var angleAxis = polarModel.coordinateSystem.getAngleAxis();
  37946. var radiusAxis = radiusAxisModel.axis;
  37947. var polar = polarModel.coordinateSystem;
  37948. var ticksCoords = radiusAxis.getTicksCoords();
  37949. var axisAngle = angleAxis.getExtent()[0];
  37950. var radiusExtent = radiusAxis.getExtent();
  37951. var layout = layoutAxis(polar, radiusAxisModel, axisAngle);
  37952. var axisBuilder = new AxisBuilder(radiusAxisModel, layout);
  37953. zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder);
  37954. this.group.add(axisBuilder.getGroup());
  37955. zrUtil.each(selfBuilderAttrs, function (name) {
  37956. if (radiusAxisModel.get(name +'.show')) {
  37957. this['_' + name](radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords);
  37958. }
  37959. }, this);
  37960. },
  37961. /**
  37962. * @private
  37963. */
  37964. _splitLine: function (radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords) {
  37965. var splitLineModel = radiusAxisModel.getModel('splitLine');
  37966. var lineStyleModel = splitLineModel.getModel('lineStyle');
  37967. var lineColors = lineStyleModel.get('color');
  37968. var lineCount = 0;
  37969. lineColors = lineColors instanceof Array ? lineColors : [lineColors];
  37970. var splitLines = [];
  37971. for (var i = 0; i < ticksCoords.length; i++) {
  37972. var colorIndex = (lineCount++) % lineColors.length;
  37973. splitLines[colorIndex] = splitLines[colorIndex] || [];
  37974. splitLines[colorIndex].push(new graphic.Circle({
  37975. shape: {
  37976. cx: polar.cx,
  37977. cy: polar.cy,
  37978. r: ticksCoords[i]
  37979. },
  37980. silent: true
  37981. }));
  37982. }
  37983. // Simple optimization
  37984. // Batching the lines if color are the same
  37985. for (var i = 0; i < splitLines.length; i++) {
  37986. this.group.add(graphic.mergePath(splitLines[i], {
  37987. style: zrUtil.defaults({
  37988. stroke: lineColors[i % lineColors.length],
  37989. fill: null
  37990. }, lineStyleModel.getLineStyle()),
  37991. silent: true
  37992. }));
  37993. }
  37994. },
  37995. /**
  37996. * @private
  37997. */
  37998. _splitArea: function (radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords) {
  37999. var splitAreaModel = radiusAxisModel.getModel('splitArea');
  38000. var areaStyleModel = splitAreaModel.getModel('areaStyle');
  38001. var areaColors = areaStyleModel.get('color');
  38002. var lineCount = 0;
  38003. areaColors = areaColors instanceof Array ? areaColors : [areaColors];
  38004. var splitAreas = [];
  38005. var prevRadius = ticksCoords[0];
  38006. for (var i = 1; i < ticksCoords.length; i++) {
  38007. var colorIndex = (lineCount++) % areaColors.length;
  38008. splitAreas[colorIndex] = splitAreas[colorIndex] || [];
  38009. splitAreas[colorIndex].push(new graphic.Sector({
  38010. shape: {
  38011. cx: polar.cx,
  38012. cy: polar.cy,
  38013. r0: prevRadius,
  38014. r: ticksCoords[i],
  38015. startAngle: 0,
  38016. endAngle: Math.PI * 2
  38017. },
  38018. silent: true
  38019. }));
  38020. prevRadius = ticksCoords[i];
  38021. }
  38022. // Simple optimization
  38023. // Batching the lines if color are the same
  38024. for (var i = 0; i < splitAreas.length; i++) {
  38025. this.group.add(graphic.mergePath(splitAreas[i], {
  38026. style: zrUtil.defaults({
  38027. fill: areaColors[i % areaColors.length]
  38028. }, areaStyleModel.getAreaStyle()),
  38029. silent: true
  38030. }));
  38031. }
  38032. }
  38033. });
  38034. /**
  38035. * @inner
  38036. */
  38037. function layoutAxis(polar, radiusAxisModel, axisAngle) {
  38038. return {
  38039. position: [polar.cx, polar.cy],
  38040. rotation: axisAngle / 180 * Math.PI,
  38041. labelDirection: -1,
  38042. tickDirection: -1,
  38043. nameDirection: 1,
  38044. labelRotation: radiusAxisModel.getModel('axisLabel').get('rotate'),
  38045. // Over splitLine and splitArea
  38046. z2: 1
  38047. };
  38048. }
  38049. /***/ },
  38050. /* 286 */
  38051. /***/ function(module, exports, __webpack_require__) {
  38052. __webpack_require__(287);
  38053. __webpack_require__(158);
  38054. __webpack_require__(288);
  38055. __webpack_require__(171);
  38056. var echarts = __webpack_require__(1);
  38057. var zrUtil = __webpack_require__(3);
  38058. function makeAction(method, actionInfo) {
  38059. actionInfo.update = 'updateView';
  38060. echarts.registerAction(actionInfo, function (payload, ecModel) {
  38061. var selected = {};
  38062. ecModel.eachComponent(
  38063. { mainType: 'geo', query: payload},
  38064. function (geoModel) {
  38065. geoModel[method](payload.name);
  38066. var geo = geoModel.coordinateSystem;
  38067. zrUtil.each(geo.regions, function (region) {
  38068. selected[region.name] = geoModel.isSelected(region.name) || false;
  38069. });
  38070. }
  38071. );
  38072. return {
  38073. selected: selected,
  38074. name: payload.name
  38075. }
  38076. });
  38077. }
  38078. makeAction('toggleSelected', {
  38079. type: 'geoToggleSelect',
  38080. event: 'geoselectchanged'
  38081. });
  38082. makeAction('select', {
  38083. type: 'geoSelect',
  38084. event: 'geoselected'
  38085. });
  38086. makeAction('unSelect', {
  38087. type: 'geoUnSelect',
  38088. event: 'geounselected'
  38089. });
  38090. /***/ },
  38091. /* 287 */
  38092. /***/ function(module, exports, __webpack_require__) {
  38093. 'use strict';
  38094. var modelUtil = __webpack_require__(5);
  38095. var ComponentModel = __webpack_require__(19);
  38096. var Model = __webpack_require__(8);
  38097. var zrUtil = __webpack_require__(3);
  38098. var selectableMixin = __webpack_require__(135);
  38099. var geoCreator = __webpack_require__(158);
  38100. var GeoModel = ComponentModel.extend({
  38101. type: 'geo',
  38102. /**
  38103. * @type {module:echarts/coord/geo/Geo}
  38104. */
  38105. coordinateSystem: null,
  38106. init: function (option) {
  38107. ComponentModel.prototype.init.apply(this, arguments);
  38108. // Default label emphasis `position` and `show`
  38109. modelUtil.defaultEmphasis(
  38110. option.label, ['position', 'show', 'textStyle', 'distance', 'formatter']
  38111. );
  38112. },
  38113. optionUpdated: function () {
  38114. var option = this.option;
  38115. var self = this;
  38116. option.regions = geoCreator.getFilledRegions(option.regions, option.map);
  38117. this._optionModelMap = zrUtil.reduce(option.regions || [], function (obj, regionOpt) {
  38118. if (regionOpt.name) {
  38119. obj[regionOpt.name] = new Model(regionOpt, self);
  38120. }
  38121. return obj;
  38122. }, {});
  38123. this.updateSelectedMap(option.regions);
  38124. },
  38125. defaultOption: {
  38126. zlevel: 0,
  38127. z: 0,
  38128. show: true,
  38129. left: 'center',
  38130. top: 'center',
  38131. // 自适应
  38132. // width:,
  38133. // height:,
  38134. // right
  38135. // bottom
  38136. // Map type
  38137. map: '',
  38138. // Default on center of map
  38139. center: null,
  38140. zoom: 1,
  38141. scaleLimit: null,
  38142. // selectedMode: false
  38143. label: {
  38144. normal: {
  38145. show: false,
  38146. textStyle: {
  38147. color: '#000'
  38148. }
  38149. },
  38150. emphasis: {
  38151. show: true,
  38152. textStyle: {
  38153. color: 'rgb(100,0,0)'
  38154. }
  38155. }
  38156. },
  38157. itemStyle: {
  38158. normal: {
  38159. // color: 各异,
  38160. borderWidth: 0.5,
  38161. borderColor: '#444',
  38162. color: '#eee'
  38163. },
  38164. emphasis: { // 也是选中样式
  38165. color: 'rgba(255,215,0,0.8)'
  38166. }
  38167. },
  38168. regions: []
  38169. },
  38170. /**
  38171. * Get model of region
  38172. * @param {string} name
  38173. * @return {module:echarts/model/Model}
  38174. */
  38175. getRegionModel: function (name) {
  38176. return this._optionModelMap[name];
  38177. },
  38178. /**
  38179. * Format label
  38180. * @param {string} name Region name
  38181. * @param {string} [status='normal'] 'normal' or 'emphasis'
  38182. * @return {string}
  38183. */
  38184. getFormattedLabel: function (name, status) {
  38185. var formatter = this.get('label.' + status + '.formatter');
  38186. var params = {
  38187. name: name
  38188. };
  38189. if (typeof formatter === 'function') {
  38190. params.status = status;
  38191. return formatter(params);
  38192. }
  38193. else if (typeof formatter === 'string') {
  38194. return formatter.replace('{a}', params.seriesName);
  38195. }
  38196. },
  38197. setZoom: function (zoom) {
  38198. this.option.zoom = zoom;
  38199. },
  38200. setCenter: function (center) {
  38201. this.option.center = center;
  38202. }
  38203. });
  38204. zrUtil.mixin(GeoModel, selectableMixin);
  38205. module.exports = GeoModel;
  38206. /***/ },
  38207. /* 288 */
  38208. /***/ function(module, exports, __webpack_require__) {
  38209. 'use strict';
  38210. var MapDraw = __webpack_require__(168);
  38211. module.exports = __webpack_require__(1).extendComponentView({
  38212. type: 'geo',
  38213. init: function (ecModel, api) {
  38214. var mapDraw = new MapDraw(api, true);
  38215. this._mapDraw = mapDraw;
  38216. this.group.add(mapDraw.group);
  38217. },
  38218. render: function (geoModel, ecModel, api, payload) {
  38219. // Not render if it is an toggleSelect action from self
  38220. if (payload && payload.type === 'geoToggleSelect'
  38221. && payload.from === this.uid
  38222. ) {
  38223. return;
  38224. }
  38225. var mapDraw = this._mapDraw;
  38226. if (geoModel.get('show')) {
  38227. mapDraw.draw(geoModel, ecModel, api, this, payload);
  38228. }
  38229. else {
  38230. this._mapDraw.group.removeAll();
  38231. }
  38232. }
  38233. });
  38234. /***/ },
  38235. /* 289 */
  38236. /***/ function(module, exports, __webpack_require__) {
  38237. 'use strict';
  38238. var echarts = __webpack_require__(1);
  38239. var graphic = __webpack_require__(42);
  38240. var layout = __webpack_require__(21);
  38241. // Model
  38242. echarts.extendComponentModel({
  38243. type: 'title',
  38244. layoutMode: {type: 'box', ignoreSize: true},
  38245. defaultOption: {
  38246. // 一级层叠
  38247. zlevel: 0,
  38248. // 二级层叠
  38249. z: 6,
  38250. show: true,
  38251. text: '',
  38252. // 超链接跳转
  38253. // link: null,
  38254. // 仅支持self | blank
  38255. target: 'blank',
  38256. subtext: '',
  38257. // 超链接跳转
  38258. // sublink: null,
  38259. // 仅支持self | blank
  38260. subtarget: 'blank',
  38261. // 'center' ¦ 'left' ¦ 'right'
  38262. // ¦ {number}(x坐标,单位px)
  38263. left: 0,
  38264. // 'top' ¦ 'bottom' ¦ 'center'
  38265. // ¦ {number}(y坐标,单位px)
  38266. top: 0,
  38267. // 水平对齐
  38268. // 'auto' | 'left' | 'right'
  38269. // 默认根据 x 的位置判断是左对齐还是右对齐
  38270. //textAlign: null
  38271. backgroundColor: 'rgba(0,0,0,0)',
  38272. // 标题边框颜色
  38273. borderColor: '#ccc',
  38274. // 标题边框线宽,单位px,默认为0(无边框)
  38275. borderWidth: 0,
  38276. // 标题内边距,单位px,默认各方向内边距为5,
  38277. // 接受数组分别设定上右下左边距,同css
  38278. padding: 5,
  38279. // 主副标题纵向间隔,单位px,默认为10,
  38280. itemGap: 10,
  38281. textStyle: {
  38282. fontSize: 18,
  38283. fontWeight: 'bolder',
  38284. // 主标题文字颜色
  38285. color: '#333'
  38286. },
  38287. subtextStyle: {
  38288. // 副标题文字颜色
  38289. color: '#aaa'
  38290. }
  38291. }
  38292. });
  38293. // View
  38294. echarts.extendComponentView({
  38295. type: 'title',
  38296. render: function (titleModel, ecModel, api) {
  38297. this.group.removeAll();
  38298. if (!titleModel.get('show')) {
  38299. return;
  38300. }
  38301. var group = this.group;
  38302. var textStyleModel = titleModel.getModel('textStyle');
  38303. var subtextStyleModel = titleModel.getModel('subtextStyle');
  38304. var textAlign = titleModel.get('textAlign');
  38305. var textEl = new graphic.Text({
  38306. style: {
  38307. text: titleModel.get('text'),
  38308. textFont: textStyleModel.getFont(),
  38309. fill: textStyleModel.getTextColor(),
  38310. textBaseline: 'top'
  38311. },
  38312. z2: 10
  38313. });
  38314. var textRect = textEl.getBoundingRect();
  38315. var subText = titleModel.get('subtext');
  38316. var subTextEl = new graphic.Text({
  38317. style: {
  38318. text: subText,
  38319. textFont: subtextStyleModel.getFont(),
  38320. fill: subtextStyleModel.getTextColor(),
  38321. y: textRect.height + titleModel.get('itemGap'),
  38322. textBaseline: 'top'
  38323. },
  38324. z2: 10
  38325. });
  38326. var link = titleModel.get('link');
  38327. var sublink = titleModel.get('sublink');
  38328. textEl.silent = !link;
  38329. subTextEl.silent = !sublink;
  38330. if (link) {
  38331. textEl.on('click', function () {
  38332. window.open(link, '_' + titleModel.get('target'));
  38333. });
  38334. }
  38335. if (sublink) {
  38336. subTextEl.on('click', function () {
  38337. window.open(sublink, '_' + titleModel.get('subtarget'));
  38338. });
  38339. }
  38340. group.add(textEl);
  38341. subText && group.add(subTextEl);
  38342. // If no subText, but add subTextEl, there will be an empty line.
  38343. var groupRect = group.getBoundingRect();
  38344. var layoutOption = titleModel.getBoxLayoutParams();
  38345. layoutOption.width = groupRect.width;
  38346. layoutOption.height = groupRect.height;
  38347. var layoutRect = layout.getLayoutRect(
  38348. layoutOption, {
  38349. width: api.getWidth(),
  38350. height: api.getHeight()
  38351. }, titleModel.get('padding')
  38352. );
  38353. // Adjust text align based on position
  38354. if (!textAlign) {
  38355. // Align left if title is on the left. center and right is same
  38356. textAlign = titleModel.get('left') || titleModel.get('right');
  38357. if (textAlign === 'middle') {
  38358. textAlign = 'center';
  38359. }
  38360. // Adjust layout by text align
  38361. if (textAlign === 'right') {
  38362. layoutRect.x += layoutRect.width;
  38363. }
  38364. else if (textAlign === 'center') {
  38365. layoutRect.x += layoutRect.width / 2;
  38366. }
  38367. }
  38368. group.position = [layoutRect.x, layoutRect.y];
  38369. textEl.setStyle('textAlign', textAlign);
  38370. subTextEl.setStyle('textAlign', textAlign);
  38371. // Render background
  38372. // Get groupRect again because textAlign has been changed
  38373. groupRect = group.getBoundingRect();
  38374. var padding = layoutRect.margin;
  38375. var style = titleModel.getItemStyle(['color', 'opacity']);
  38376. style.fill = titleModel.get('backgroundColor');
  38377. var rect = new graphic.Rect({
  38378. shape: {
  38379. x: groupRect.x - padding[3],
  38380. y: groupRect.y - padding[0],
  38381. width: groupRect.width + padding[1] + padding[3],
  38382. height: groupRect.height + padding[0] + padding[2]
  38383. },
  38384. style: style,
  38385. silent: true
  38386. });
  38387. graphic.subPixelOptimizeRect(rect);
  38388. group.add(rect);
  38389. }
  38390. });
  38391. /***/ },
  38392. /* 290 */
  38393. /***/ function(module, exports, __webpack_require__) {
  38394. /**
  38395. * DataZoom component entry
  38396. */
  38397. __webpack_require__(291);
  38398. __webpack_require__(292);
  38399. __webpack_require__(294);
  38400. __webpack_require__(295);
  38401. __webpack_require__(296);
  38402. __webpack_require__(299);
  38403. __webpack_require__(300);
  38404. __webpack_require__(302);
  38405. __webpack_require__(303);
  38406. /***/ },
  38407. /* 291 */
  38408. /***/ function(module, exports, __webpack_require__) {
  38409. __webpack_require__(19).registerSubTypeDefaulter('dataZoom', function (option) {
  38410. // Default 'slider' when no type specified.
  38411. return 'slider';
  38412. });
  38413. /***/ },
  38414. /* 292 */
  38415. /***/ function(module, exports, __webpack_require__) {
  38416. /**
  38417. * @file Data zoom model
  38418. */
  38419. var zrUtil = __webpack_require__(3);
  38420. var env = __webpack_require__(79);
  38421. var echarts = __webpack_require__(1);
  38422. var modelUtil = __webpack_require__(5);
  38423. var AxisProxy = __webpack_require__(293);
  38424. var each = zrUtil.each;
  38425. var eachAxisDim = modelUtil.eachAxisDim;
  38426. var DataZoomModel = echarts.extendComponentModel({
  38427. type: 'dataZoom',
  38428. dependencies: [
  38429. 'xAxis', 'yAxis', 'zAxis', 'radiusAxis', 'angleAxis', 'series'
  38430. ],
  38431. /**
  38432. * @protected
  38433. */
  38434. defaultOption: {
  38435. zlevel: 0,
  38436. z: 4, // Higher than normal component (z: 2).
  38437. orient: null, // Default auto by axisIndex. Possible value: 'horizontal', 'vertical'.
  38438. xAxisIndex: null, // Default all horizontal category axis.
  38439. yAxisIndex: null, // Default all vertical category axis.
  38440. angleAxisIndex: null,
  38441. radiusAxisIndex: null,
  38442. filterMode: 'filter', // Possible values: 'filter' or 'empty'.
  38443. // 'filter': data items which are out of window will be removed.
  38444. // This option is applicable when filtering outliers.
  38445. // 'empty': data items which are out of window will be set to empty.
  38446. // This option is applicable when user should not neglect
  38447. // that there are some data items out of window.
  38448. // Taking line chart as an example, line will be broken in
  38449. // the filtered points when filterModel is set to 'empty', but
  38450. // be connected when set to 'filter'.
  38451. throttle: 100, // Dispatch action by the fixed rate, avoid frequency.
  38452. // default 100. Do not throttle when use null/undefined.
  38453. start: 0, // Start percent. 0 ~ 100
  38454. end: 100, // End percent. 0 ~ 100
  38455. startValue: null, // Start value. If startValue specified, start is ignored.
  38456. endValue: null // End value. If endValue specified, end is ignored.
  38457. },
  38458. /**
  38459. * @override
  38460. */
  38461. init: function (option, parentModel, ecModel) {
  38462. /**
  38463. * key like x_0, y_1
  38464. * @private
  38465. * @type {Object}
  38466. */
  38467. this._dataIntervalByAxis = {};
  38468. /**
  38469. * @private
  38470. */
  38471. this._dataInfo = {};
  38472. /**
  38473. * key like x_0, y_1
  38474. * @private
  38475. */
  38476. this._axisProxies = {};
  38477. /**
  38478. * @readOnly
  38479. */
  38480. this.textStyleModel;
  38481. var rawOption = retrieveRaw(option);
  38482. this.mergeDefaultAndTheme(option, ecModel);
  38483. this.doInit(rawOption);
  38484. },
  38485. /**
  38486. * @override
  38487. */
  38488. mergeOption: function (newOption) {
  38489. var rawOption = retrieveRaw(newOption);
  38490. //FIX #2591
  38491. zrUtil.merge(this.option, newOption, true);
  38492. this.doInit(rawOption);
  38493. },
  38494. /**
  38495. * @protected
  38496. */
  38497. doInit: function (rawOption) {
  38498. var thisOption = this.option;
  38499. // Disable realtime view update if canvas is not supported.
  38500. if (!env.canvasSupported) {
  38501. thisOption.realtime = false;
  38502. }
  38503. processRangeProp('start', 'startValue', rawOption, thisOption);
  38504. processRangeProp('end', 'endValue', rawOption, thisOption);
  38505. this.textStyleModel = this.getModel('textStyle');
  38506. this._resetTarget();
  38507. this._giveAxisProxies();
  38508. },
  38509. /**
  38510. * @private
  38511. */
  38512. _giveAxisProxies: function () {
  38513. var axisProxies = this._axisProxies;
  38514. this.eachTargetAxis(function (dimNames, axisIndex, dataZoomModel, ecModel) {
  38515. var axisModel = this.dependentModels[dimNames.axis][axisIndex];
  38516. // If exists, share axisProxy with other dataZoomModels.
  38517. var axisProxy = axisModel.__dzAxisProxy || (
  38518. // Use the first dataZoomModel as the main model of axisProxy.
  38519. axisModel.__dzAxisProxy = new AxisProxy(
  38520. dimNames.name, axisIndex, this, ecModel
  38521. )
  38522. );
  38523. // FIXME
  38524. // dispose __dzAxisProxy
  38525. axisProxies[dimNames.name + '_' + axisIndex] = axisProxy;
  38526. }, this);
  38527. },
  38528. /**
  38529. * @private
  38530. */
  38531. _resetTarget: function () {
  38532. var thisOption = this.option;
  38533. var autoMode = this._judgeAutoMode();
  38534. eachAxisDim(function (dimNames) {
  38535. var axisIndexName = dimNames.axisIndex;
  38536. thisOption[axisIndexName] = modelUtil.normalizeToArray(
  38537. thisOption[axisIndexName]
  38538. );
  38539. }, this);
  38540. if (autoMode === 'axisIndex') {
  38541. this._autoSetAxisIndex();
  38542. }
  38543. else if (autoMode === 'orient') {
  38544. this._autoSetOrient();
  38545. }
  38546. },
  38547. /**
  38548. * @private
  38549. */
  38550. _judgeAutoMode: function () {
  38551. // Auto set only works for setOption at the first time.
  38552. // The following is user's reponsibility. So using merged
  38553. // option is OK.
  38554. var thisOption = this.option;
  38555. var hasIndexSpecified = false;
  38556. eachAxisDim(function (dimNames) {
  38557. // When user set axisIndex as a empty array, we think that user specify axisIndex
  38558. // but do not want use auto mode. Because empty array may be encountered when
  38559. // some error occured.
  38560. if (thisOption[dimNames.axisIndex] != null) {
  38561. hasIndexSpecified = true;
  38562. }
  38563. }, this);
  38564. var orient = thisOption.orient;
  38565. if (orient == null && hasIndexSpecified) {
  38566. return 'orient';
  38567. }
  38568. else if (!hasIndexSpecified) {
  38569. if (orient == null) {
  38570. thisOption.orient = 'horizontal';
  38571. }
  38572. return 'axisIndex';
  38573. }
  38574. },
  38575. /**
  38576. * @private
  38577. */
  38578. _autoSetAxisIndex: function () {
  38579. var autoAxisIndex = true;
  38580. var orient = this.get('orient', true);
  38581. var thisOption = this.option;
  38582. if (autoAxisIndex) {
  38583. // Find axis that parallel to dataZoom as default.
  38584. var dimNames = orient === 'vertical'
  38585. ? {dim: 'y', axisIndex: 'yAxisIndex', axis: 'yAxis'}
  38586. : {dim: 'x', axisIndex: 'xAxisIndex', axis: 'xAxis'};
  38587. if (this.dependentModels[dimNames.axis].length) {
  38588. thisOption[dimNames.axisIndex] = [0];
  38589. autoAxisIndex = false;
  38590. }
  38591. }
  38592. if (autoAxisIndex) {
  38593. // Find the first category axis as default. (consider polar)
  38594. eachAxisDim(function (dimNames) {
  38595. if (!autoAxisIndex) {
  38596. return;
  38597. }
  38598. var axisIndices = [];
  38599. var axisModels = this.dependentModels[dimNames.axis];
  38600. if (axisModels.length && !axisIndices.length) {
  38601. for (var i = 0, len = axisModels.length; i < len; i++) {
  38602. if (axisModels[i].get('type') === 'category') {
  38603. axisIndices.push(i);
  38604. }
  38605. }
  38606. }
  38607. thisOption[dimNames.axisIndex] = axisIndices;
  38608. if (axisIndices.length) {
  38609. autoAxisIndex = false;
  38610. }
  38611. }, this);
  38612. }
  38613. if (autoAxisIndex) {
  38614. // FIXME
  38615. // 这里是兼容ec2的写法(没指定xAxisIndex和yAxisIndex时把scatter和双数值轴折柱纳入dataZoom控制),
  38616. // 但是实际是否需要Grid.js#getScaleByOption来判断(考虑time,log等axis type)?
  38617. // If both dataZoom.xAxisIndex and dataZoom.yAxisIndex is not specified,
  38618. // dataZoom component auto adopts series that reference to
  38619. // both xAxis and yAxis which type is 'value'.
  38620. this.ecModel.eachSeries(function (seriesModel) {
  38621. if (this._isSeriesHasAllAxesTypeOf(seriesModel, 'value')) {
  38622. eachAxisDim(function (dimNames) {
  38623. var axisIndices = thisOption[dimNames.axisIndex];
  38624. var axisIndex = seriesModel.get(dimNames.axisIndex);
  38625. if (zrUtil.indexOf(axisIndices, axisIndex) < 0) {
  38626. axisIndices.push(axisIndex);
  38627. }
  38628. });
  38629. }
  38630. }, this);
  38631. }
  38632. },
  38633. /**
  38634. * @private
  38635. */
  38636. _autoSetOrient: function () {
  38637. var dim;
  38638. // Find the first axis
  38639. this.eachTargetAxis(function (dimNames) {
  38640. !dim && (dim = dimNames.name);
  38641. }, this);
  38642. this.option.orient = dim === 'y' ? 'vertical' : 'horizontal';
  38643. },
  38644. /**
  38645. * @private
  38646. */
  38647. _isSeriesHasAllAxesTypeOf: function (seriesModel, axisType) {
  38648. // FIXME
  38649. // 需要series的xAxisIndex和yAxisIndex都首先自动设置上。
  38650. // 例如series.type === scatter时。
  38651. var is = true;
  38652. eachAxisDim(function (dimNames) {
  38653. var seriesAxisIndex = seriesModel.get(dimNames.axisIndex);
  38654. var axisModel = this.dependentModels[dimNames.axis][seriesAxisIndex];
  38655. if (!axisModel || axisModel.get('type') !== axisType) {
  38656. is = false;
  38657. }
  38658. }, this);
  38659. return is;
  38660. },
  38661. /**
  38662. * @public
  38663. */
  38664. getFirstTargetAxisModel: function () {
  38665. var firstAxisModel;
  38666. eachAxisDim(function (dimNames) {
  38667. if (firstAxisModel == null) {
  38668. var indices = this.get(dimNames.axisIndex);
  38669. if (indices.length) {
  38670. firstAxisModel = this.dependentModels[dimNames.axis][indices[0]];
  38671. }
  38672. }
  38673. }, this);
  38674. return firstAxisModel;
  38675. },
  38676. /**
  38677. * @public
  38678. * @param {Function} callback param: axisModel, dimNames, axisIndex, dataZoomModel, ecModel
  38679. */
  38680. eachTargetAxis: function (callback, context) {
  38681. var ecModel = this.ecModel;
  38682. eachAxisDim(function (dimNames) {
  38683. each(
  38684. this.get(dimNames.axisIndex),
  38685. function (axisIndex) {
  38686. callback.call(context, dimNames, axisIndex, this, ecModel);
  38687. },
  38688. this
  38689. );
  38690. }, this);
  38691. },
  38692. getAxisProxy: function (dimName, axisIndex) {
  38693. return this._axisProxies[dimName + '_' + axisIndex];
  38694. },
  38695. /**
  38696. * If not specified, set to undefined.
  38697. *
  38698. * @public
  38699. * @param {Object} opt
  38700. * @param {number} [opt.start]
  38701. * @param {number} [opt.end]
  38702. * @param {number} [opt.startValue]
  38703. * @param {number} [opt.endValue]
  38704. */
  38705. setRawRange: function (opt) {
  38706. each(['start', 'end', 'startValue', 'endValue'], function (name) {
  38707. // If any of those prop is null/undefined, we should alos set
  38708. // them, because only one pair between start/end and
  38709. // startValue/endValue can work.
  38710. this.option[name] = opt[name];
  38711. }, this);
  38712. },
  38713. /**
  38714. * @public
  38715. * @return {Array.<number>} [startPercent, endPercent]
  38716. */
  38717. getPercentRange: function () {
  38718. var axisProxy = this.findRepresentativeAxisProxy();
  38719. if (axisProxy) {
  38720. return axisProxy.getDataPercentWindow();
  38721. }
  38722. },
  38723. /**
  38724. * @public
  38725. * For example, chart.getModel().getComponent('dataZoom').getValueRange('y', 0);
  38726. *
  38727. * @param {string} [axisDimName]
  38728. * @param {number} [axisIndex]
  38729. * @return {Array.<number>} [startValue, endValue]
  38730. */
  38731. getValueRange: function (axisDimName, axisIndex) {
  38732. if (axisDimName == null && axisIndex == null) {
  38733. var axisProxy = this.findRepresentativeAxisProxy();
  38734. if (axisProxy) {
  38735. return axisProxy.getDataValueWindow();
  38736. }
  38737. }
  38738. else {
  38739. return this.getAxisProxy(axisDimName, axisIndex).getDataValueWindow();
  38740. }
  38741. },
  38742. /**
  38743. * @public
  38744. * @return {module:echarts/component/dataZoom/AxisProxy}
  38745. */
  38746. findRepresentativeAxisProxy: function () {
  38747. // Find the first hosted axisProxy
  38748. var axisProxies = this._axisProxies;
  38749. for (var key in axisProxies) {
  38750. if (axisProxies.hasOwnProperty(key) && axisProxies[key].hostedBy(this)) {
  38751. return axisProxies[key];
  38752. }
  38753. }
  38754. // If no hosted axis find not hosted axisProxy.
  38755. // Consider this case: dataZoomModel1 and dataZoomModel2 control the same axis,
  38756. // and the option.start or option.end settings are different. The percentRange
  38757. // should follow axisProxy.
  38758. // (We encounter this problem in toolbox data zoom.)
  38759. for (var key in axisProxies) {
  38760. if (axisProxies.hasOwnProperty(key) && !axisProxies[key].hostedBy(this)) {
  38761. return axisProxies[key];
  38762. }
  38763. }
  38764. }
  38765. });
  38766. function retrieveRaw(option) {
  38767. var ret = {};
  38768. each(
  38769. ['start', 'end', 'startValue', 'endValue'],
  38770. function (name) {
  38771. ret[name] = option[name];
  38772. }
  38773. );
  38774. return ret;
  38775. }
  38776. function processRangeProp(percentProp, valueProp, rawOption, thisOption) {
  38777. // start/end has higher priority over startValue/endValue,
  38778. // but we should make chart.setOption({endValue: 1000}) effective,
  38779. // rather than chart.setOption({endValue: 1000, end: null}).
  38780. if (rawOption[valueProp] != null && rawOption[percentProp] == null) {
  38781. thisOption[percentProp] = null;
  38782. }
  38783. // Otherwise do nothing and use the merge result.
  38784. }
  38785. module.exports = DataZoomModel;
  38786. /***/ },
  38787. /* 293 */
  38788. /***/ function(module, exports, __webpack_require__) {
  38789. /**
  38790. * @file Axis operator
  38791. */
  38792. var zrUtil = __webpack_require__(3);
  38793. var numberUtil = __webpack_require__(7);
  38794. var each = zrUtil.each;
  38795. var asc = numberUtil.asc;
  38796. /**
  38797. * Operate single axis.
  38798. * One axis can only operated by one axis operator.
  38799. * Different dataZoomModels may be defined to operate the same axis.
  38800. * (i.e. 'inside' data zoom and 'slider' data zoom components)
  38801. * So dataZoomModels share one axisProxy in that case.
  38802. *
  38803. * @class
  38804. */
  38805. var AxisProxy = function (dimName, axisIndex, dataZoomModel, ecModel) {
  38806. /**
  38807. * @private
  38808. * @type {string}
  38809. */
  38810. this._dimName = dimName;
  38811. /**
  38812. * @private
  38813. */
  38814. this._axisIndex = axisIndex;
  38815. /**
  38816. * @private
  38817. * @type {Array.<number>}
  38818. */
  38819. this._valueWindow;
  38820. /**
  38821. * @private
  38822. * @type {Array.<number>}
  38823. */
  38824. this._percentWindow;
  38825. /**
  38826. * @private
  38827. * @type {Array.<number>}
  38828. */
  38829. this._dataExtent;
  38830. /**
  38831. * @readOnly
  38832. * @type {module: echarts/model/Global}
  38833. */
  38834. this.ecModel = ecModel;
  38835. /**
  38836. * @private
  38837. * @type {module: echarts/component/dataZoom/DataZoomModel}
  38838. */
  38839. this._dataZoomModel = dataZoomModel;
  38840. };
  38841. AxisProxy.prototype = {
  38842. constructor: AxisProxy,
  38843. /**
  38844. * Whether the axisProxy is hosted by dataZoomModel.
  38845. *
  38846. * @public
  38847. * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel
  38848. * @return {boolean}
  38849. */
  38850. hostedBy: function (dataZoomModel) {
  38851. return this._dataZoomModel === dataZoomModel;
  38852. },
  38853. /**
  38854. * @return {Array.<number>}
  38855. */
  38856. getDataExtent: function () {
  38857. return this._dataExtent.slice();
  38858. },
  38859. /**
  38860. * @return {Array.<number>}
  38861. */
  38862. getDataValueWindow: function () {
  38863. return this._valueWindow.slice();
  38864. },
  38865. /**
  38866. * @return {Array.<number>}
  38867. */
  38868. getDataPercentWindow: function () {
  38869. return this._percentWindow.slice();
  38870. },
  38871. /**
  38872. * @public
  38873. * @param {number} axisIndex
  38874. * @return {Array} seriesModels
  38875. */
  38876. getTargetSeriesModels: function () {
  38877. var seriesModels = [];
  38878. this.ecModel.eachSeries(function (seriesModel) {
  38879. if (this._axisIndex === seriesModel.get(this._dimName + 'AxisIndex')) {
  38880. seriesModels.push(seriesModel);
  38881. }
  38882. }, this);
  38883. return seriesModels;
  38884. },
  38885. getAxisModel: function () {
  38886. return this.ecModel.getComponent(this._dimName + 'Axis', this._axisIndex);
  38887. },
  38888. getOtherAxisModel: function () {
  38889. var axisDim = this._dimName;
  38890. var ecModel = this.ecModel;
  38891. var axisModel = this.getAxisModel();
  38892. var isCartesian = axisDim === 'x' || axisDim === 'y';
  38893. var otherAxisDim;
  38894. var coordSysIndexName;
  38895. if (isCartesian) {
  38896. coordSysIndexName = 'gridIndex';
  38897. otherAxisDim = axisDim === 'x' ? 'y' : 'x';
  38898. }
  38899. else {
  38900. coordSysIndexName = 'polarIndex';
  38901. otherAxisDim = axisDim === 'angle' ? 'radius' : 'angle';
  38902. }
  38903. var foundOtherAxisModel;
  38904. ecModel.eachComponent(otherAxisDim + 'Axis', function (otherAxisModel) {
  38905. if ((otherAxisModel.get(coordSysIndexName) || 0)
  38906. === (axisModel.get(coordSysIndexName) || 0)
  38907. ) {
  38908. foundOtherAxisModel = otherAxisModel;
  38909. }
  38910. });
  38911. return foundOtherAxisModel;
  38912. },
  38913. /**
  38914. * Notice: reset should not be called before series.restoreData() called,
  38915. * so it is recommanded to be called in "process stage" but not "model init
  38916. * stage".
  38917. *
  38918. * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel
  38919. */
  38920. reset: function (dataZoomModel) {
  38921. if (dataZoomModel !== this._dataZoomModel) {
  38922. return;
  38923. }
  38924. // Culculate data window and data extent, and record them.
  38925. var dataExtent = this._dataExtent = calculateDataExtent(
  38926. this._dimName, this.getTargetSeriesModels()
  38927. );
  38928. var dataWindow = calculateDataWindow(
  38929. dataZoomModel.option, dataExtent, this
  38930. );
  38931. this._valueWindow = dataWindow.valueWindow;
  38932. this._percentWindow = dataWindow.percentWindow;
  38933. // Update axis setting then.
  38934. setAxisModel(this);
  38935. },
  38936. /**
  38937. * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel
  38938. */
  38939. restore: function (dataZoomModel) {
  38940. if (dataZoomModel !== this._dataZoomModel) {
  38941. return;
  38942. }
  38943. this._valueWindow = this._percentWindow = null;
  38944. setAxisModel(this, true);
  38945. },
  38946. /**
  38947. * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel
  38948. */
  38949. filterData: function (dataZoomModel) {
  38950. if (dataZoomModel !== this._dataZoomModel) {
  38951. return;
  38952. }
  38953. var axisDim = this._dimName;
  38954. var seriesModels = this.getTargetSeriesModels();
  38955. var filterMode = dataZoomModel.get('filterMode');
  38956. var valueWindow = this._valueWindow;
  38957. // FIXME
  38958. // Toolbox may has dataZoom injected. And if there are stacked bar chart
  38959. // with NaN data, NaN will be filtered and stack will be wrong.
  38960. // So we need to force the mode to be set empty.
  38961. // In fect, it is not a big deal that do not support filterMode-'filter'
  38962. // when using toolbox#dataZoom, utill tooltip#dataZoom support "single axis
  38963. // selection" some day, which might need "adapt to data extent on the
  38964. // otherAxis", which is disabled by filterMode-'empty'.
  38965. var otherAxisModel = this.getOtherAxisModel();
  38966. if (dataZoomModel.get('$fromToolbox')
  38967. && otherAxisModel
  38968. && otherAxisModel.get('type') === 'category'
  38969. ) {
  38970. filterMode = 'empty';
  38971. }
  38972. // Process series data
  38973. each(seriesModels, function (seriesModel) {
  38974. var seriesData = seriesModel.getData();
  38975. seriesData && each(seriesModel.coordDimToDataDim(axisDim), function (dim) {
  38976. if (filterMode === 'empty') {
  38977. seriesModel.setData(
  38978. seriesData.map(dim, function (value) {
  38979. return !isInWindow(value) ? NaN : value;
  38980. })
  38981. );
  38982. }
  38983. else {
  38984. seriesData.filterSelf(dim, isInWindow);
  38985. }
  38986. });
  38987. });
  38988. function isInWindow(value) {
  38989. return value >= valueWindow[0] && value <= valueWindow[1];
  38990. }
  38991. }
  38992. };
  38993. function calculateDataExtent(axisDim, seriesModels) {
  38994. var dataExtent = [Infinity, -Infinity];
  38995. each(seriesModels, function (seriesModel) {
  38996. var seriesData = seriesModel.getData();
  38997. if (seriesData) {
  38998. each(seriesModel.coordDimToDataDim(axisDim), function (dim) {
  38999. var seriesExtent = seriesData.getDataExtent(dim);
  39000. seriesExtent[0] < dataExtent[0] && (dataExtent[0] = seriesExtent[0]);
  39001. seriesExtent[1] > dataExtent[1] && (dataExtent[1] = seriesExtent[1]);
  39002. });
  39003. }
  39004. }, this);
  39005. return dataExtent;
  39006. }
  39007. function calculateDataWindow(opt, dataExtent, axisProxy) {
  39008. var axisModel = axisProxy.getAxisModel();
  39009. var scale = axisModel.axis.scale;
  39010. var percentExtent = [0, 100];
  39011. var percentWindow = [
  39012. opt.start,
  39013. opt.end
  39014. ];
  39015. var valueWindow = [];
  39016. // In percent range is used and axis min/max/scale is set,
  39017. // window should be based on min/max/0, but should not be
  39018. // based on the extent of filtered data.
  39019. dataExtent = dataExtent.slice();
  39020. fixExtendByAxis(dataExtent, axisModel, scale);
  39021. each(['startValue', 'endValue'], function (prop) {
  39022. valueWindow.push(
  39023. opt[prop] != null
  39024. ? scale.parse(opt[prop])
  39025. : null
  39026. );
  39027. });
  39028. // Normalize bound.
  39029. each([0, 1], function (idx) {
  39030. var boundValue = valueWindow[idx];
  39031. var boundPercent = percentWindow[idx];
  39032. // start/end has higher priority over startValue/endValue,
  39033. // because start/end can be consistent among different type
  39034. // of axis but startValue/endValue not.
  39035. if (boundPercent != null || boundValue == null) {
  39036. if (boundPercent == null) {
  39037. boundPercent = percentExtent[idx];
  39038. }
  39039. // Use scale.parse to math round for category or time axis.
  39040. boundValue = scale.parse(numberUtil.linearMap(
  39041. boundPercent, percentExtent, dataExtent, true
  39042. ));
  39043. }
  39044. else { // boundPercent == null && boundValue != null
  39045. boundPercent = numberUtil.linearMap(
  39046. boundValue, dataExtent, percentExtent, true
  39047. );
  39048. }
  39049. // valueWindow[idx] = round(boundValue);
  39050. // percentWindow[idx] = round(boundPercent);
  39051. valueWindow[idx] = boundValue;
  39052. percentWindow[idx] = boundPercent;
  39053. });
  39054. return {
  39055. valueWindow: asc(valueWindow),
  39056. percentWindow: asc(percentWindow)
  39057. };
  39058. }
  39059. function fixExtendByAxis(dataExtent, axisModel, scale) {
  39060. each(['min', 'max'], function (minMax, index) {
  39061. var axisMax = axisModel.get(minMax, true);
  39062. // Consider 'dataMin', 'dataMax'
  39063. if (axisMax != null && (axisMax + '').toLowerCase() !== 'data' + minMax) {
  39064. dataExtent[index] = scale.parse(axisMax);
  39065. }
  39066. });
  39067. if (!axisModel.get('scale', true)) {
  39068. dataExtent[0] > 0 && (dataExtent[0] = 0);
  39069. dataExtent[1] < 0 && (dataExtent[1] = 0);
  39070. }
  39071. return dataExtent;
  39072. }
  39073. function setAxisModel(axisProxy, isRestore) {
  39074. var axisModel = axisProxy.getAxisModel();
  39075. var percentWindow = axisProxy._percentWindow;
  39076. var valueWindow = axisProxy._valueWindow;
  39077. if (!percentWindow) {
  39078. return;
  39079. }
  39080. var isFull = isRestore || (percentWindow[0] === 0 && percentWindow[1] === 100);
  39081. // [0, 500]: arbitrary value, guess axis extent.
  39082. var precision = !isRestore && numberUtil.getPixelPrecision(valueWindow, [0, 500]);
  39083. // toFixed() digits argument must be between 0 and 20
  39084. var invalidPrecision = !isRestore && !(precision < 20 && precision >= 0);
  39085. var useOrigin = isRestore || isFull || invalidPrecision;
  39086. axisModel.setRange && axisModel.setRange(
  39087. useOrigin ? null : +valueWindow[0].toFixed(precision),
  39088. useOrigin ? null : +valueWindow[1].toFixed(precision)
  39089. );
  39090. }
  39091. module.exports = AxisProxy;
  39092. /***/ },
  39093. /* 294 */
  39094. /***/ function(module, exports, __webpack_require__) {
  39095. var ComponentView = __webpack_require__(28);
  39096. module.exports = ComponentView.extend({
  39097. type: 'dataZoom',
  39098. render: function (dataZoomModel, ecModel, api, payload) {
  39099. this.dataZoomModel = dataZoomModel;
  39100. this.ecModel = ecModel;
  39101. this.api = api;
  39102. },
  39103. /**
  39104. * Find the first target coordinate system.
  39105. *
  39106. * @protected
  39107. * @return {Object} {
  39108. * cartesians: [
  39109. * {model: coord0, axisModels: [axis1, axis3], coordIndex: 1},
  39110. * {model: coord1, axisModels: [axis0, axis2], coordIndex: 0},
  39111. * ...
  39112. * ], // cartesians must not be null/undefined.
  39113. * polars: [
  39114. * {model: coord0, axisModels: [axis4], coordIndex: 0},
  39115. * ...
  39116. * ], // polars must not be null/undefined.
  39117. * axisModels: [axis0, axis1, axis2, axis3, axis4]
  39118. * // axisModels must not be null/undefined.
  39119. * }
  39120. */
  39121. getTargetInfo: function () {
  39122. var dataZoomModel = this.dataZoomModel;
  39123. var ecModel = this.ecModel;
  39124. var cartesians = [];
  39125. var polars = [];
  39126. var axisModels = [];
  39127. dataZoomModel.eachTargetAxis(function (dimNames, axisIndex) {
  39128. var axisModel = ecModel.getComponent(dimNames.axis, axisIndex);
  39129. if (axisModel) {
  39130. axisModels.push(axisModel);
  39131. var gridIndex = axisModel.get('gridIndex');
  39132. var polarIndex = axisModel.get('polarIndex');
  39133. if (gridIndex != null) {
  39134. var coordModel = ecModel.getComponent('grid', gridIndex);
  39135. save(coordModel, axisModel, cartesians, gridIndex);
  39136. }
  39137. else if (polarIndex != null) {
  39138. var coordModel = ecModel.getComponent('polar', polarIndex);
  39139. save(coordModel, axisModel, polars, polarIndex);
  39140. }
  39141. }
  39142. }, this);
  39143. function save(coordModel, axisModel, store, coordIndex) {
  39144. var item;
  39145. for (var i = 0; i < store.length; i++) {
  39146. if (store[i].model === coordModel) {
  39147. item = store[i];
  39148. break;
  39149. }
  39150. }
  39151. if (!item) {
  39152. store.push(item = {
  39153. model: coordModel, axisModels: [], coordIndex: coordIndex
  39154. });
  39155. }
  39156. item.axisModels.push(axisModel);
  39157. }
  39158. return {
  39159. cartesians: cartesians,
  39160. polars: polars,
  39161. axisModels: axisModels
  39162. };
  39163. }
  39164. });
  39165. /***/ },
  39166. /* 295 */
  39167. /***/ function(module, exports, __webpack_require__) {
  39168. /**
  39169. * @file Data zoom model
  39170. */
  39171. var DataZoomModel = __webpack_require__(292);
  39172. var SliderZoomModel = DataZoomModel.extend({
  39173. type: 'dataZoom.slider',
  39174. layoutMode: 'box',
  39175. /**
  39176. * @protected
  39177. */
  39178. defaultOption: {
  39179. show: true,
  39180. // ph => placeholder. Using placehoder here because
  39181. // deault value can only be drived in view stage.
  39182. right: 'ph', // Default align to grid rect.
  39183. top: 'ph', // Default align to grid rect.
  39184. width: 'ph', // Default align to grid rect.
  39185. height: 'ph', // Default align to grid rect.
  39186. left: null, // Default align to grid rect.
  39187. bottom: null, // Default align to grid rect.
  39188. backgroundColor: 'rgba(47,69,84,0)', // Background of slider zoom component.
  39189. dataBackgroundColor: '#ddd', // Background of data shadow.
  39190. fillerColor: 'rgba(47,69,84,0.15)', // Color of selected area.
  39191. handleColor: 'rgba(148,164,165,0.95)', // Color of handle.
  39192. handleSize: 10,
  39193. labelPrecision: null,
  39194. labelFormatter: null,
  39195. showDetail: true,
  39196. showDataShadow: 'auto', // Default auto decision.
  39197. realtime: true,
  39198. zoomLock: false, // Whether disable zoom.
  39199. textStyle: {
  39200. color: '#333'
  39201. }
  39202. },
  39203. /**
  39204. * @override
  39205. */
  39206. mergeOption: function (option) {
  39207. SliderZoomModel.superApply(this, 'mergeOption', arguments);
  39208. }
  39209. });
  39210. module.exports = SliderZoomModel;
  39211. /***/ },
  39212. /* 296 */
  39213. /***/ function(module, exports, __webpack_require__) {
  39214. var zrUtil = __webpack_require__(3);
  39215. var graphic = __webpack_require__(42);
  39216. var throttle = __webpack_require__(297);
  39217. var DataZoomView = __webpack_require__(294);
  39218. var Rect = graphic.Rect;
  39219. var numberUtil = __webpack_require__(7);
  39220. var linearMap = numberUtil.linearMap;
  39221. var layout = __webpack_require__(21);
  39222. var sliderMove = __webpack_require__(298);
  39223. var asc = numberUtil.asc;
  39224. var bind = zrUtil.bind;
  39225. var mathRound = Math.round;
  39226. var mathMax = Math.max;
  39227. var each = zrUtil.each;
  39228. // Constants
  39229. var DEFAULT_LOCATION_EDGE_GAP = 7;
  39230. var DEFAULT_FRAME_BORDER_WIDTH = 1;
  39231. var DEFAULT_FILLER_SIZE = 30;
  39232. var HORIZONTAL = 'horizontal';
  39233. var VERTICAL = 'vertical';
  39234. var LABEL_GAP = 5;
  39235. var SHOW_DATA_SHADOW_SERIES_TYPE = ['line', 'bar', 'candlestick', 'scatter'];
  39236. var SliderZoomView = DataZoomView.extend({
  39237. type: 'dataZoom.slider',
  39238. init: function (ecModel, api) {
  39239. /**
  39240. * @private
  39241. * @type {Object}
  39242. */
  39243. this._displayables = {};
  39244. /**
  39245. * @private
  39246. * @type {string}
  39247. */
  39248. this._orient;
  39249. /**
  39250. * [0, 100]
  39251. * @private
  39252. */
  39253. this._range;
  39254. /**
  39255. * [coord of the first handle, coord of the second handle]
  39256. * @private
  39257. */
  39258. this._handleEnds;
  39259. /**
  39260. * [length, thick]
  39261. * @private
  39262. * @type {Array.<number>}
  39263. */
  39264. this._size;
  39265. /**
  39266. * @private
  39267. * @type {number}
  39268. */
  39269. this._halfHandleSize;
  39270. /**
  39271. * @private
  39272. */
  39273. this._location;
  39274. /**
  39275. * @private
  39276. */
  39277. this._dragging;
  39278. /**
  39279. * @private
  39280. */
  39281. this._dataShadowInfo;
  39282. this.api = api;
  39283. },
  39284. /**
  39285. * @override
  39286. */
  39287. render: function (dataZoomModel, ecModel, api, payload) {
  39288. SliderZoomView.superApply(this, 'render', arguments);
  39289. throttle.createOrUpdate(
  39290. this,
  39291. '_dispatchZoomAction',
  39292. this.dataZoomModel.get('throttle'),
  39293. 'fixRate'
  39294. );
  39295. this._orient = dataZoomModel.get('orient');
  39296. this._halfHandleSize = mathRound(dataZoomModel.get('handleSize') / 2);
  39297. if (this.dataZoomModel.get('show') === false) {
  39298. this.group.removeAll();
  39299. return;
  39300. }
  39301. // Notice: this._resetInterval() should not be executed when payload.type
  39302. // is 'dataZoom', origin this._range should be maintained, otherwise 'pan'
  39303. // or 'zoom' info will be missed because of 'throttle' of this.dispatchAction,
  39304. if (!payload || payload.type !== 'dataZoom' || payload.from !== this.uid) {
  39305. this._buildView();
  39306. }
  39307. this._updateView();
  39308. },
  39309. /**
  39310. * @override
  39311. */
  39312. remove: function () {
  39313. SliderZoomView.superApply(this, 'remove', arguments);
  39314. throttle.clear(this, '_dispatchZoomAction');
  39315. },
  39316. /**
  39317. * @override
  39318. */
  39319. dispose: function () {
  39320. SliderZoomView.superApply(this, 'dispose', arguments);
  39321. throttle.clear(this, '_dispatchZoomAction');
  39322. },
  39323. _buildView: function () {
  39324. var thisGroup = this.group;
  39325. thisGroup.removeAll();
  39326. this._resetLocation();
  39327. this._resetInterval();
  39328. var barGroup = this._displayables.barGroup = new graphic.Group();
  39329. this._renderBackground();
  39330. this._renderDataShadow();
  39331. this._renderHandle();
  39332. thisGroup.add(barGroup);
  39333. this._positionGroup();
  39334. },
  39335. /**
  39336. * @private
  39337. */
  39338. _resetLocation: function () {
  39339. var dataZoomModel = this.dataZoomModel;
  39340. var api = this.api;
  39341. // If some of x/y/width/height are not specified,
  39342. // auto-adapt according to target grid.
  39343. var coordRect = this._findCoordRect();
  39344. var ecSize = {width: api.getWidth(), height: api.getHeight()};
  39345. // Default align by coordinate system rect.
  39346. var positionInfo = this._orient === HORIZONTAL
  39347. ? {
  39348. // Why using 'right', because right should be used in vertical,
  39349. // and it is better to be consistent for dealing with position param merge.
  39350. right: ecSize.width - coordRect.x - coordRect.width,
  39351. top: (ecSize.height - DEFAULT_FILLER_SIZE - DEFAULT_LOCATION_EDGE_GAP),
  39352. width: coordRect.width,
  39353. height: DEFAULT_FILLER_SIZE
  39354. }
  39355. : { // vertical
  39356. right: DEFAULT_LOCATION_EDGE_GAP,
  39357. top: coordRect.y,
  39358. width: DEFAULT_FILLER_SIZE,
  39359. height: coordRect.height
  39360. };
  39361. // Do not write back to option and replace value 'ph', because
  39362. // the 'ph' value should be recalculated when resize.
  39363. var layoutParams = layout.getLayoutParams(dataZoomModel.option);
  39364. // Replace the placeholder value.
  39365. zrUtil.each(['right', 'top', 'width', 'height'], function (name) {
  39366. if (layoutParams[name] === 'ph') {
  39367. layoutParams[name] = positionInfo[name];
  39368. }
  39369. });
  39370. var layoutRect = layout.getLayoutRect(
  39371. layoutParams,
  39372. ecSize,
  39373. dataZoomModel.padding
  39374. );
  39375. this._location = {x: layoutRect.x, y: layoutRect.y};
  39376. this._size = [layoutRect.width, layoutRect.height];
  39377. this._orient === VERTICAL && this._size.reverse();
  39378. },
  39379. /**
  39380. * @private
  39381. */
  39382. _positionGroup: function () {
  39383. var thisGroup = this.group;
  39384. var location = this._location;
  39385. var orient = this._orient;
  39386. // Just use the first axis to determine mapping.
  39387. var targetAxisModel = this.dataZoomModel.getFirstTargetAxisModel();
  39388. var inverse = targetAxisModel && targetAxisModel.get('inverse');
  39389. var barGroup = this._displayables.barGroup;
  39390. var otherAxisInverse = (this._dataShadowInfo || {}).otherAxisInverse;
  39391. // Transform barGroup.
  39392. barGroup.attr(
  39393. (orient === HORIZONTAL && !inverse)
  39394. ? {scale: otherAxisInverse ? [1, 1] : [1, -1]}
  39395. : (orient === HORIZONTAL && inverse)
  39396. ? {scale: otherAxisInverse ? [-1, 1] : [-1, -1]}
  39397. : (orient === VERTICAL && !inverse)
  39398. ? {scale: otherAxisInverse ? [1, -1] : [1, 1], rotation: Math.PI / 2}
  39399. // Dont use Math.PI, considering shadow direction.
  39400. : {scale: otherAxisInverse ? [-1, -1] : [-1, 1], rotation: Math.PI / 2}
  39401. );
  39402. // Position barGroup
  39403. var rect = thisGroup.getBoundingRect([barGroup]);
  39404. thisGroup.position[0] = location.x - rect.x;
  39405. thisGroup.position[1] = location.y - rect.y;
  39406. },
  39407. /**
  39408. * @private
  39409. */
  39410. _getViewExtent: function () {
  39411. // View total length.
  39412. var halfHandleSize = this._halfHandleSize;
  39413. var totalLength = mathMax(this._size[0], halfHandleSize * 4);
  39414. var extent = [halfHandleSize, totalLength - halfHandleSize];
  39415. return extent;
  39416. },
  39417. _renderBackground : function () {
  39418. var dataZoomModel = this.dataZoomModel;
  39419. var size = this._size;
  39420. this._displayables.barGroup.add(new Rect({
  39421. silent: true,
  39422. shape: {
  39423. x: 0, y: 0, width: size[0], height: size[1]
  39424. },
  39425. style: {
  39426. fill: dataZoomModel.get('backgroundColor')
  39427. }
  39428. }));
  39429. },
  39430. _renderDataShadow: function () {
  39431. var info = this._dataShadowInfo = this._prepareDataShadowInfo();
  39432. if (!info) {
  39433. return;
  39434. }
  39435. var size = this._size;
  39436. var seriesModel = info.series;
  39437. var data = seriesModel.getRawData();
  39438. var otherDim = seriesModel.getShadowDim
  39439. ? seriesModel.getShadowDim() // @see candlestick
  39440. : info.otherDim;
  39441. var otherDataExtent = data.getDataExtent(otherDim);
  39442. // Nice extent.
  39443. var otherOffset = (otherDataExtent[1] - otherDataExtent[0]) * 0.3;
  39444. otherDataExtent = [
  39445. otherDataExtent[0] - otherOffset,
  39446. otherDataExtent[1] + otherOffset
  39447. ];
  39448. var otherShadowExtent = [0, size[1]];
  39449. var thisShadowExtent = [0, size[0]];
  39450. var points = [[size[0], 0], [0, 0]];
  39451. var step = thisShadowExtent[1] / (data.count() - 1);
  39452. var thisCoord = 0;
  39453. // Optimize for large data shadow
  39454. var stride = Math.round(data.count() / size[0]);
  39455. data.each([otherDim], function (value, index) {
  39456. if (stride > 0 && (index % stride)) {
  39457. thisCoord += step;
  39458. return;
  39459. }
  39460. // FIXME
  39461. // 应该使用统计的空判断?还是在list里进行空判断?
  39462. var otherCoord = (value == null || isNaN(value) || value === '')
  39463. ? null
  39464. : linearMap(value, otherDataExtent, otherShadowExtent, true);
  39465. otherCoord != null && points.push([thisCoord, otherCoord]);
  39466. thisCoord += step;
  39467. });
  39468. this._displayables.barGroup.add(new graphic.Polyline({
  39469. shape: {points: points},
  39470. style: {fill: this.dataZoomModel.get('dataBackgroundColor'), lineWidth: 0},
  39471. silent: true,
  39472. z2: -20
  39473. }));
  39474. },
  39475. _prepareDataShadowInfo: function () {
  39476. var dataZoomModel = this.dataZoomModel;
  39477. var showDataShadow = dataZoomModel.get('showDataShadow');
  39478. if (showDataShadow === false) {
  39479. return;
  39480. }
  39481. // Find a representative series.
  39482. var result;
  39483. var ecModel = this.ecModel;
  39484. dataZoomModel.eachTargetAxis(function (dimNames, axisIndex) {
  39485. var seriesModels = dataZoomModel
  39486. .getAxisProxy(dimNames.name, axisIndex)
  39487. .getTargetSeriesModels();
  39488. zrUtil.each(seriesModels, function (seriesModel) {
  39489. if (result) {
  39490. return;
  39491. }
  39492. if (showDataShadow !== true && zrUtil.indexOf(
  39493. SHOW_DATA_SHADOW_SERIES_TYPE, seriesModel.get('type')
  39494. ) < 0
  39495. ) {
  39496. return;
  39497. }
  39498. var otherDim = getOtherDim(dimNames.name);
  39499. var thisAxis = ecModel.getComponent(dimNames.axis, axisIndex).axis;
  39500. result = {
  39501. thisAxis: thisAxis,
  39502. series: seriesModel,
  39503. thisDim: dimNames.name,
  39504. otherDim: otherDim,
  39505. otherAxisInverse: seriesModel
  39506. .coordinateSystem.getOtherAxis(thisAxis).inverse
  39507. };
  39508. }, this);
  39509. }, this);
  39510. return result;
  39511. },
  39512. _renderHandle: function () {
  39513. var displaybles = this._displayables;
  39514. var handles = displaybles.handles = [];
  39515. var handleLabels = displaybles.handleLabels = [];
  39516. var barGroup = this._displayables.barGroup;
  39517. var size = this._size;
  39518. barGroup.add(displaybles.filler = new Rect({
  39519. draggable: true,
  39520. cursor: 'move',
  39521. drift: bind(this._onDragMove, this, 'all'),
  39522. ondragend: bind(this._onDragEnd, this),
  39523. onmouseover: bind(this._showDataInfo, this, true),
  39524. onmouseout: bind(this._showDataInfo, this, false),
  39525. style: {
  39526. fill: this.dataZoomModel.get('fillerColor'),
  39527. // text: ':::',
  39528. textPosition : 'inside'
  39529. }
  39530. }));
  39531. // Frame border.
  39532. barGroup.add(new Rect(graphic.subPixelOptimizeRect({
  39533. silent: true,
  39534. shape: {
  39535. x: 0,
  39536. y: 0,
  39537. width: size[0],
  39538. height: size[1]
  39539. },
  39540. style: {
  39541. stroke: this.dataZoomModel.get('dataBackgroundColor'),
  39542. lineWidth: DEFAULT_FRAME_BORDER_WIDTH,
  39543. fill: 'rgba(0,0,0,0)'
  39544. }
  39545. })));
  39546. each([0, 1], function (handleIndex) {
  39547. barGroup.add(handles[handleIndex] = new Rect({
  39548. style: {
  39549. fill: this.dataZoomModel.get('handleColor')
  39550. },
  39551. cursor: 'move',
  39552. draggable: true,
  39553. drift: bind(this._onDragMove, this, handleIndex),
  39554. ondragend: bind(this._onDragEnd, this),
  39555. onmouseover: bind(this._showDataInfo, this, true),
  39556. onmouseout: bind(this._showDataInfo, this, false)
  39557. }));
  39558. var textStyleModel = this.dataZoomModel.textStyleModel;
  39559. this.group.add(
  39560. handleLabels[handleIndex] = new graphic.Text({
  39561. silent: true,
  39562. invisible: true,
  39563. style: {
  39564. x: 0, y: 0, text: '',
  39565. textVerticalAlign: 'middle',
  39566. textAlign: 'center',
  39567. fill: textStyleModel.getTextColor(),
  39568. textFont: textStyleModel.getFont()
  39569. }
  39570. }));
  39571. }, this);
  39572. },
  39573. /**
  39574. * @private
  39575. */
  39576. _resetInterval: function () {
  39577. var range = this._range = this.dataZoomModel.getPercentRange();
  39578. var viewExtent = this._getViewExtent();
  39579. this._handleEnds = [
  39580. linearMap(range[0], [0, 100], viewExtent, true),
  39581. linearMap(range[1], [0, 100], viewExtent, true)
  39582. ];
  39583. },
  39584. /**
  39585. * @private
  39586. * @param {(number|string)} handleIndex 0 or 1 or 'all'
  39587. * @param {number} dx
  39588. * @param {number} dy
  39589. */
  39590. _updateInterval: function (handleIndex, delta) {
  39591. var handleEnds = this._handleEnds;
  39592. var viewExtend = this._getViewExtent();
  39593. sliderMove(
  39594. delta,
  39595. handleEnds,
  39596. viewExtend,
  39597. (handleIndex === 'all' || this.dataZoomModel.get('zoomLock'))
  39598. ? 'rigid' : 'cross',
  39599. handleIndex
  39600. );
  39601. this._range = asc([
  39602. linearMap(handleEnds[0], viewExtend, [0, 100], true),
  39603. linearMap(handleEnds[1], viewExtend, [0, 100], true)
  39604. ]);
  39605. },
  39606. /**
  39607. * @private
  39608. */
  39609. _updateView: function () {
  39610. var displaybles = this._displayables;
  39611. var handleEnds = this._handleEnds;
  39612. var handleInterval = asc(handleEnds.slice());
  39613. var size = this._size;
  39614. var halfHandleSize = this._halfHandleSize;
  39615. each([0, 1], function (handleIndex) {
  39616. // Handles
  39617. var handle = displaybles.handles[handleIndex];
  39618. handle.setShape({
  39619. x: handleEnds[handleIndex] - halfHandleSize,
  39620. y: -1,
  39621. width: halfHandleSize * 2,
  39622. height: size[1] + 2,
  39623. r: 1
  39624. });
  39625. }, this);
  39626. // Filler
  39627. displaybles.filler.setShape({
  39628. x: handleInterval[0],
  39629. y: 0,
  39630. width: handleInterval[1] - handleInterval[0],
  39631. height: this._size[1]
  39632. });
  39633. this._updateDataInfo();
  39634. },
  39635. /**
  39636. * @private
  39637. */
  39638. _updateDataInfo: function () {
  39639. var dataZoomModel = this.dataZoomModel;
  39640. var displaybles = this._displayables;
  39641. var handleLabels = displaybles.handleLabels;
  39642. var orient = this._orient;
  39643. var labelTexts = ['', ''];
  39644. // FIXME
  39645. // date型,支持formatter,autoformatter(ec2 date.getAutoFormatter)
  39646. if (dataZoomModel.get('showDetail')) {
  39647. var dataInterval;
  39648. var axis;
  39649. dataZoomModel.eachTargetAxis(function (dimNames, axisIndex) {
  39650. // Using dataInterval of the first axis.
  39651. if (!dataInterval) {
  39652. dataInterval = dataZoomModel
  39653. .getAxisProxy(dimNames.name, axisIndex)
  39654. .getDataValueWindow();
  39655. axis = this.ecModel.getComponent(dimNames.axis, axisIndex).axis;
  39656. }
  39657. }, this);
  39658. if (dataInterval) {
  39659. labelTexts = [
  39660. this._formatLabel(dataInterval[0], axis),
  39661. this._formatLabel(dataInterval[1], axis)
  39662. ];
  39663. }
  39664. }
  39665. var orderedHandleEnds = asc(this._handleEnds.slice());
  39666. setLabel.call(this, 0);
  39667. setLabel.call(this, 1);
  39668. function setLabel(handleIndex) {
  39669. // Label
  39670. // Text should not transform by barGroup.
  39671. var barTransform = graphic.getTransform(
  39672. displaybles.handles[handleIndex], this.group
  39673. );
  39674. var direction = graphic.transformDirection(
  39675. handleIndex === 0 ? 'right' : 'left', barTransform
  39676. );
  39677. var offset = this._halfHandleSize + LABEL_GAP;
  39678. var textPoint = graphic.applyTransform(
  39679. [
  39680. orderedHandleEnds[handleIndex] + (handleIndex === 0 ? -offset : offset),
  39681. this._size[1] / 2
  39682. ],
  39683. barTransform
  39684. );
  39685. handleLabels[handleIndex].setStyle({
  39686. x: textPoint[0],
  39687. y: textPoint[1],
  39688. textVerticalAlign: orient === HORIZONTAL ? 'middle' : direction,
  39689. textAlign: orient === HORIZONTAL ? direction : 'center',
  39690. text: labelTexts[handleIndex]
  39691. });
  39692. }
  39693. },
  39694. /**
  39695. * @private
  39696. */
  39697. _formatLabel: function (value, axis) {
  39698. var dataZoomModel = this.dataZoomModel;
  39699. var labelFormatter = dataZoomModel.get('labelFormatter');
  39700. if (zrUtil.isFunction(labelFormatter)) {
  39701. return labelFormatter(value);
  39702. }
  39703. var labelPrecision = dataZoomModel.get('labelPrecision');
  39704. if (labelPrecision == null || labelPrecision === 'auto') {
  39705. labelPrecision = axis.getPixelPrecision();
  39706. }
  39707. value = (value == null && isNaN(value))
  39708. ? ''
  39709. // FIXME Glue code
  39710. : (axis.type === 'category' || axis.type === 'time')
  39711. ? axis.scale.getLabel(Math.round(value))
  39712. // param of toFixed should less then 20.
  39713. : value.toFixed(Math.min(labelPrecision, 20));
  39714. if (zrUtil.isString(labelFormatter)) {
  39715. value = labelFormatter.replace('{value}', value);
  39716. }
  39717. return value;
  39718. },
  39719. /**
  39720. * @private
  39721. * @param {boolean} showOrHide true: show, false: hide
  39722. */
  39723. _showDataInfo: function (showOrHide) {
  39724. // Always show when drgging.
  39725. showOrHide = this._dragging || showOrHide;
  39726. var handleLabels = this._displayables.handleLabels;
  39727. handleLabels[0].attr('invisible', !showOrHide);
  39728. handleLabels[1].attr('invisible', !showOrHide);
  39729. },
  39730. _onDragMove: function (handleIndex, dx, dy) {
  39731. this._dragging = true;
  39732. // Transform dx, dy to bar coordination.
  39733. var vertex = this._applyBarTransform([dx, dy], true);
  39734. this._updateInterval(handleIndex, vertex[0]);
  39735. this._updateView();
  39736. if (this.dataZoomModel.get('realtime')) {
  39737. this._dispatchZoomAction();
  39738. }
  39739. },
  39740. _onDragEnd: function () {
  39741. this._dragging = false;
  39742. this._showDataInfo(false);
  39743. this._dispatchZoomAction();
  39744. },
  39745. /**
  39746. * This action will be throttled.
  39747. * @private
  39748. */
  39749. _dispatchZoomAction: function () {
  39750. var range = this._range;
  39751. this.api.dispatchAction({
  39752. type: 'dataZoom',
  39753. from: this.uid,
  39754. dataZoomId: this.dataZoomModel.id,
  39755. start: range[0],
  39756. end: range[1]
  39757. });
  39758. },
  39759. /**
  39760. * @private
  39761. */
  39762. _applyBarTransform: function (vertex, inverse) {
  39763. var barTransform = this._displayables.barGroup.getLocalTransform();
  39764. return graphic.applyTransform(vertex, barTransform, inverse);
  39765. },
  39766. /**
  39767. * @private
  39768. */
  39769. _findCoordRect: function () {
  39770. // Find the grid coresponding to the first axis referred by dataZoom.
  39771. var targetInfo = this.getTargetInfo();
  39772. // FIXME
  39773. // 判断是catesian还是polar
  39774. var rect;
  39775. if (targetInfo.cartesians.length) {
  39776. rect = targetInfo.cartesians[0].model.coordinateSystem.getRect();
  39777. }
  39778. else { // Polar
  39779. // FIXME
  39780. // 暂时随便写的
  39781. var width = this.api.getWidth();
  39782. var height = this.api.getHeight();
  39783. rect = {
  39784. x: width * 0.2,
  39785. y: height * 0.2,
  39786. width: width * 0.6,
  39787. height: height * 0.6
  39788. };
  39789. }
  39790. return rect;
  39791. }
  39792. });
  39793. function getOtherDim(thisDim) {
  39794. // FIXME
  39795. // 这个逻辑和getOtherAxis里一致,但是写在这里是否不好
  39796. return thisDim === 'x' ? 'y' : 'x';
  39797. }
  39798. module.exports = SliderZoomView;
  39799. /***/ },
  39800. /* 297 */
  39801. /***/ function(module, exports) {
  39802. var lib = {};
  39803. var ORIGIN_METHOD = '\0__throttleOriginMethod';
  39804. var RATE = '\0__throttleRate';
  39805. /**
  39806. * 频率控制 返回函数连续调用时,fn 执行频率限定为每多少时间执行一次
  39807. * 例如常见效果:
  39808. * notifyWhenChangesStop
  39809. * 频繁调用时,只保证最后一次执行
  39810. * 配成:trailing:true;debounce:true 即可
  39811. * notifyAtFixRate
  39812. * 频繁调用时,按规律心跳执行
  39813. * 配成:trailing:true;debounce:false 即可
  39814. * 注意:
  39815. * 根据model更新view的时候,可以使用throttle,
  39816. * 但是根据view更新model的时候,避免使用这种延迟更新的方式。
  39817. * 因为这可能导致model和server同步出现问题。
  39818. *
  39819. * @public
  39820. * @param {(Function|Array.<Function>)} fn 需要调用的函数
  39821. * 如果fn为array,则表示可以对多个函数进行throttle。
  39822. * 他们共享同一个timer。
  39823. * @param {number} delay 延迟时间,单位毫秒
  39824. * @param {bool} trailing 是否保证最后一次触发的执行
  39825. * true:表示保证最后一次调用会触发执行。
  39826. * 但任何调用后不可能立即执行,总会delay。
  39827. * false:表示不保证最后一次调用会触发执行。
  39828. * 但只要间隔大于delay,调用就会立即执行。
  39829. * @param {bool} debounce 节流
  39830. * true:表示:频繁调用(间隔小于delay)时,根本不执行
  39831. * false:表示:频繁调用(间隔小于delay)时,按规律心跳执行
  39832. * @return {(Function|Array.<Function>)} 实际调用函数。
  39833. * 当输入的fn为array时,返回值也为array。
  39834. * 每项是Function。
  39835. */
  39836. lib.throttle = function (fn, delay, trailing, debounce) {
  39837. var currCall = (new Date()).getTime();
  39838. var lastCall = 0;
  39839. var lastExec = 0;
  39840. var timer = null;
  39841. var diff;
  39842. var scope;
  39843. var args;
  39844. var isSingle = typeof fn === 'function';
  39845. delay = delay || 0;
  39846. if (isSingle) {
  39847. return createCallback();
  39848. }
  39849. else {
  39850. var ret = [];
  39851. for (var i = 0; i < fn.length; i++) {
  39852. ret[i] = createCallback(i);
  39853. }
  39854. return ret;
  39855. }
  39856. function createCallback(index) {
  39857. function exec() {
  39858. lastExec = (new Date()).getTime();
  39859. timer = null;
  39860. (isSingle ? fn : fn[index]).apply(scope, args || []);
  39861. }
  39862. var cb = function () {
  39863. currCall = (new Date()).getTime();
  39864. scope = this;
  39865. args = arguments;
  39866. diff = currCall - (debounce ? lastCall : lastExec) - delay;
  39867. clearTimeout(timer);
  39868. if (debounce) {
  39869. if (trailing) {
  39870. timer = setTimeout(exec, delay);
  39871. }
  39872. else if (diff >= 0) {
  39873. exec();
  39874. }
  39875. }
  39876. else {
  39877. if (diff >= 0) {
  39878. exec();
  39879. }
  39880. else if (trailing) {
  39881. timer = setTimeout(exec, -diff);
  39882. }
  39883. }
  39884. lastCall = currCall;
  39885. };
  39886. /**
  39887. * Clear throttle.
  39888. * @public
  39889. */
  39890. cb.clear = function () {
  39891. if (timer) {
  39892. clearTimeout(timer);
  39893. timer = null;
  39894. }
  39895. };
  39896. return cb;
  39897. }
  39898. };
  39899. /**
  39900. * 按一定频率执行,最后一次调用总归会执行
  39901. *
  39902. * @public
  39903. */
  39904. lib.fixRate = function (fn, delay) {
  39905. return delay != null
  39906. ? lib.throttle(fn, delay, true, false)
  39907. : fn;
  39908. };
  39909. /**
  39910. * 直到不频繁调用了才会执行,最后一次调用总归会执行
  39911. *
  39912. * @public
  39913. */
  39914. lib.debounce = function (fn, delay) {
  39915. return delay != null
  39916. ? lib.throttle(fn, delay, true, true)
  39917. : fn;
  39918. };
  39919. /**
  39920. * Create throttle method or update throttle rate.
  39921. *
  39922. * @example
  39923. * ComponentView.prototype.render = function () {
  39924. * ...
  39925. * throttle.createOrUpdate(
  39926. * this,
  39927. * '_dispatchAction',
  39928. * this.model.get('throttle'),
  39929. * 'fixRate'
  39930. * );
  39931. * };
  39932. * ComponentView.prototype.remove = function () {
  39933. * throttle.clear(this, '_dispatchAction');
  39934. * };
  39935. * ComponentView.prototype.dispose = function () {
  39936. * throttle.clear(this, '_dispatchAction');
  39937. * };
  39938. *
  39939. * @public
  39940. * @param {Object} obj
  39941. * @param {string} fnAttr
  39942. * @param {number} rate
  39943. * @param {string} throttleType 'fixRate' or 'debounce'
  39944. */
  39945. lib.createOrUpdate = function (obj, fnAttr, rate, throttleType) {
  39946. var fn = obj[fnAttr];
  39947. if (!fn || rate == null || !throttleType) {
  39948. return;
  39949. }
  39950. var originFn = fn[ORIGIN_METHOD] || fn;
  39951. var lastRate = fn[RATE];
  39952. if (lastRate !== rate) {
  39953. fn = obj[fnAttr] = lib[throttleType](originFn, rate);
  39954. fn[ORIGIN_METHOD] = originFn;
  39955. fn[RATE] = rate;
  39956. }
  39957. };
  39958. /**
  39959. * Clear throttle. Example see throttle.createOrUpdate.
  39960. *
  39961. * @public
  39962. * @param {Object} obj
  39963. * @param {string} fnAttr
  39964. */
  39965. lib.clear = function (obj, fnAttr) {
  39966. var fn = obj[fnAttr];
  39967. if (fn && fn[ORIGIN_METHOD]) {
  39968. obj[fnAttr] = fn[ORIGIN_METHOD];
  39969. }
  39970. };
  39971. module.exports = lib;
  39972. /***/ },
  39973. /* 298 */
  39974. /***/ function(module, exports) {
  39975. /**
  39976. * Calculate slider move result.
  39977. *
  39978. * @param {number} delta Move length.
  39979. * @param {Array.<number>} handleEnds handleEnds[0] and be bigger then handleEnds[1].
  39980. * handleEnds will be modified in this method.
  39981. * @param {Array.<number>} extent handleEnds is restricted by extent.
  39982. * extent[0] should less or equals than extent[1].
  39983. * @param {string} mode 'rigid': Math.abs(handleEnds[0] - handleEnds[1]) remain unchanged,
  39984. * 'cross' handleEnds[0] can be bigger then handleEnds[1],
  39985. * 'push' handleEnds[0] can not be bigger then handleEnds[1],
  39986. * when they touch, one push other.
  39987. * @param {number} handleIndex If mode is 'rigid', handleIndex is not required.
  39988. * @param {Array.<number>} The input handleEnds.
  39989. */
  39990. module.exports = function (delta, handleEnds, extent, mode, handleIndex) {
  39991. if (!delta) {
  39992. return handleEnds;
  39993. }
  39994. if (mode === 'rigid') {
  39995. delta = getRealDelta(delta, handleEnds, extent);
  39996. handleEnds[0] += delta;
  39997. handleEnds[1] += delta;
  39998. }
  39999. else {
  40000. delta = getRealDelta(delta, handleEnds[handleIndex], extent);
  40001. handleEnds[handleIndex] += delta;
  40002. if (mode === 'push' && handleEnds[0] > handleEnds[1]) {
  40003. handleEnds[1 - handleIndex] = handleEnds[handleIndex];
  40004. }
  40005. }
  40006. return handleEnds;
  40007. function getRealDelta(delta, handleEnds, extent) {
  40008. var handleMinMax = !handleEnds.length
  40009. ? [handleEnds, handleEnds]
  40010. : handleEnds.slice();
  40011. handleEnds[0] > handleEnds[1] && handleMinMax.reverse();
  40012. if (delta < 0 && handleMinMax[0] + delta < extent[0]) {
  40013. delta = extent[0] - handleMinMax[0];
  40014. }
  40015. if (delta > 0 && handleMinMax[1] + delta > extent[1]) {
  40016. delta = extent[1] - handleMinMax[1];
  40017. }
  40018. return delta;
  40019. }
  40020. };
  40021. /***/ },
  40022. /* 299 */
  40023. /***/ function(module, exports, __webpack_require__) {
  40024. /**
  40025. * @file Data zoom model
  40026. */
  40027. module.exports = __webpack_require__(292).extend({
  40028. type: 'dataZoom.inside',
  40029. /**
  40030. * @protected
  40031. */
  40032. defaultOption: {
  40033. zoomLock: false // Whether disable zoom but only pan.
  40034. }
  40035. });
  40036. /***/ },
  40037. /* 300 */
  40038. /***/ function(module, exports, __webpack_require__) {
  40039. var DataZoomView = __webpack_require__(294);
  40040. var zrUtil = __webpack_require__(3);
  40041. var sliderMove = __webpack_require__(298);
  40042. var roams = __webpack_require__(301);
  40043. var bind = zrUtil.bind;
  40044. var InsideZoomView = DataZoomView.extend({
  40045. type: 'dataZoom.inside',
  40046. /**
  40047. * @override
  40048. */
  40049. init: function (ecModel, api) {
  40050. /**
  40051. * 'throttle' is used in this.dispatchAction, so we save range
  40052. * to avoid missing some 'pan' info.
  40053. * @private
  40054. * @type {Array.<number>}
  40055. */
  40056. this._range;
  40057. },
  40058. /**
  40059. * @override
  40060. */
  40061. render: function (dataZoomModel, ecModel, api, payload) {
  40062. InsideZoomView.superApply(this, 'render', arguments);
  40063. // Notice: origin this._range should be maintained, and should not be re-fetched
  40064. // from dataZoomModel when payload.type is 'dataZoom', otherwise 'pan' or 'zoom'
  40065. // info will be missed because of 'throttle' of this.dispatchAction.
  40066. if (roams.shouldRecordRange(payload, dataZoomModel.id)) {
  40067. this._range = dataZoomModel.getPercentRange();
  40068. }
  40069. // Reset controllers.
  40070. var coordInfoList = this.getTargetInfo().cartesians;
  40071. var allCoordIds = zrUtil.map(coordInfoList, function (coordInfo) {
  40072. return roams.generateCoordId(coordInfo.model);
  40073. });
  40074. zrUtil.each(coordInfoList, function (coordInfo) {
  40075. var coordModel = coordInfo.model;
  40076. roams.register(
  40077. api,
  40078. {
  40079. coordId: roams.generateCoordId(coordModel),
  40080. allCoordIds: allCoordIds,
  40081. coordinateSystem: coordModel.coordinateSystem,
  40082. dataZoomId: dataZoomModel.id,
  40083. throttleRage: dataZoomModel.get('throttle', true),
  40084. panGetRange: bind(this._onPan, this, coordInfo),
  40085. zoomGetRange: bind(this._onZoom, this, coordInfo)
  40086. }
  40087. );
  40088. }, this);
  40089. // TODO
  40090. // polar支持
  40091. },
  40092. /**
  40093. * @override
  40094. */
  40095. remove: function () {
  40096. roams.unregister(this.api, this.dataZoomModel.id);
  40097. InsideZoomView.superApply(this, 'remove', arguments);
  40098. this._range = null;
  40099. },
  40100. /**
  40101. * @override
  40102. */
  40103. dispose: function () {
  40104. roams.unregister(this.api, this.dataZoomModel.id);
  40105. InsideZoomView.superApply(this, 'dispose', arguments);
  40106. this._range = null;
  40107. },
  40108. /**
  40109. * @private
  40110. */
  40111. _onPan: function (coordInfo, controller, dx, dy) {
  40112. return (
  40113. this._range = panCartesian(
  40114. [dx, dy], this._range, controller, coordInfo
  40115. )
  40116. );
  40117. },
  40118. /**
  40119. * @private
  40120. */
  40121. _onZoom: function (coordInfo, controller, scale, mouseX, mouseY) {
  40122. var dataZoomModel = this.dataZoomModel;
  40123. if (dataZoomModel.option.zoomLock) {
  40124. return this._range;
  40125. }
  40126. return (
  40127. this._range = scaleCartesian(
  40128. 1 / scale, [mouseX, mouseY], this._range,
  40129. controller, coordInfo, dataZoomModel
  40130. )
  40131. );
  40132. }
  40133. });
  40134. function panCartesian(pixelDeltas, range, controller, coordInfo) {
  40135. range = range.slice();
  40136. // Calculate transform by the first axis.
  40137. var axisModel = coordInfo.axisModels[0];
  40138. if (!axisModel) {
  40139. return;
  40140. }
  40141. var directionInfo = getDirectionInfo(pixelDeltas, axisModel, controller);
  40142. var percentDelta = directionInfo.signal
  40143. * (range[1] - range[0])
  40144. * directionInfo.pixel / directionInfo.pixelLength;
  40145. sliderMove(
  40146. percentDelta,
  40147. range,
  40148. [0, 100],
  40149. 'rigid'
  40150. );
  40151. return range;
  40152. }
  40153. function scaleCartesian(scale, mousePoint, range, controller, coordInfo, dataZoomModel) {
  40154. range = range.slice();
  40155. // Calculate transform by the first axis.
  40156. var axisModel = coordInfo.axisModels[0];
  40157. if (!axisModel) {
  40158. return;
  40159. }
  40160. var directionInfo = getDirectionInfo(mousePoint, axisModel, controller);
  40161. var mouse = directionInfo.pixel - directionInfo.pixelStart;
  40162. var percentPoint = mouse / directionInfo.pixelLength * (range[1] - range[0]) + range[0];
  40163. scale = Math.max(scale, 0);
  40164. range[0] = (range[0] - percentPoint) * scale + percentPoint;
  40165. range[1] = (range[1] - percentPoint) * scale + percentPoint;
  40166. return fixRange(range);
  40167. }
  40168. function getDirectionInfo(xy, axisModel, controller) {
  40169. var axis = axisModel.axis;
  40170. var rect = controller.rectProvider();
  40171. var ret = {};
  40172. if (axis.dim === 'x') {
  40173. ret.pixel = xy[0];
  40174. ret.pixelLength = rect.width;
  40175. ret.pixelStart = rect.x;
  40176. ret.signal = axis.inverse ? 1 : -1;
  40177. }
  40178. else { // axis.dim === 'y'
  40179. ret.pixel = xy[1];
  40180. ret.pixelLength = rect.height;
  40181. ret.pixelStart = rect.y;
  40182. ret.signal = axis.inverse ? -1 : 1;
  40183. }
  40184. return ret;
  40185. }
  40186. function fixRange(range) {
  40187. // Clamp, using !(<= or >=) to handle NaN.
  40188. // jshint ignore:start
  40189. var bound = [0, 100];
  40190. !(range[0] <= bound[1]) && (range[0] = bound[1]);
  40191. !(range[1] <= bound[1]) && (range[1] = bound[1]);
  40192. !(range[0] >= bound[0]) && (range[0] = bound[0]);
  40193. !(range[1] >= bound[0]) && (range[1] = bound[0]);
  40194. // jshint ignore:end
  40195. return range;
  40196. }
  40197. module.exports = InsideZoomView;
  40198. /***/ },
  40199. /* 301 */
  40200. /***/ function(module, exports, __webpack_require__) {
  40201. /**
  40202. * @file Roam controller manager.
  40203. */
  40204. // Only create one roam controller for each coordinate system.
  40205. // one roam controller might be refered by two inside data zoom
  40206. // components (for example, one for x and one for y). When user
  40207. // pan or zoom, only dispatch one action for those data zoom
  40208. // components.
  40209. var zrUtil = __webpack_require__(3);
  40210. var RoamController = __webpack_require__(169);
  40211. var throttle = __webpack_require__(297);
  40212. var curry = zrUtil.curry;
  40213. var ATTR = '\0_ec_dataZoom_roams';
  40214. var roams = {
  40215. /**
  40216. * @public
  40217. * @param {module:echarts/ExtensionAPI} api
  40218. * @param {Object} dataZoomInfo
  40219. * @param {string} dataZoomInfo.coordId
  40220. * @param {Object} dataZoomInfo.coordinateSystem
  40221. * @param {Array.<string>} dataZoomInfo.allCoordIds
  40222. * @param {string} dataZoomInfo.dataZoomId
  40223. * @param {number} dataZoomInfo.throttleRate
  40224. * @param {Function} dataZoomInfo.panGetRange
  40225. * @param {Function} dataZoomInfo.zoomGetRange
  40226. */
  40227. register: function (api, dataZoomInfo) {
  40228. var store = giveStore(api);
  40229. var theDataZoomId = dataZoomInfo.dataZoomId;
  40230. var theCoordId = dataZoomInfo.coordId;
  40231. // Do clean when a dataZoom changes its target coordnate system.
  40232. zrUtil.each(store, function (record, coordId) {
  40233. var dataZoomInfos = record.dataZoomInfos;
  40234. if (dataZoomInfos[theDataZoomId]
  40235. && zrUtil.indexOf(dataZoomInfo.allCoordIds, theCoordId) < 0
  40236. ) {
  40237. delete dataZoomInfos[theDataZoomId];
  40238. record.count--;
  40239. }
  40240. });
  40241. cleanStore(store);
  40242. var record = store[theCoordId];
  40243. // Create if needed.
  40244. if (!record) {
  40245. record = store[theCoordId] = {
  40246. coordId: theCoordId,
  40247. dataZoomInfos: {},
  40248. count: 0
  40249. };
  40250. record.controller = createController(api, dataZoomInfo, record);
  40251. record.dispatchAction = zrUtil.curry(dispatchAction, api);
  40252. }
  40253. // Consider resize, area should be always updated.
  40254. var rect = dataZoomInfo.coordinateSystem.getRect().clone();
  40255. record.controller.rectProvider = function () {
  40256. return rect;
  40257. };
  40258. // Update throttle.
  40259. throttle.createOrUpdate(
  40260. record,
  40261. 'dispatchAction',
  40262. dataZoomInfo.throttleRate,
  40263. 'fixRate'
  40264. );
  40265. // Update reference of dataZoom.
  40266. !(record.dataZoomInfos[theDataZoomId]) && record.count++;
  40267. record.dataZoomInfos[theDataZoomId] = dataZoomInfo;
  40268. },
  40269. /**
  40270. * @public
  40271. * @param {module:echarts/ExtensionAPI} api
  40272. * @param {string} dataZoomId
  40273. */
  40274. unregister: function (api, dataZoomId) {
  40275. var store = giveStore(api);
  40276. zrUtil.each(store, function (record) {
  40277. var dataZoomInfos = record.dataZoomInfos;
  40278. if (dataZoomInfos[dataZoomId]) {
  40279. delete dataZoomInfos[dataZoomId];
  40280. record.count--;
  40281. }
  40282. });
  40283. cleanStore(store);
  40284. },
  40285. /**
  40286. * @public
  40287. */
  40288. shouldRecordRange: function (payload, dataZoomId) {
  40289. if (payload && payload.type === 'dataZoom' && payload.batch) {
  40290. for (var i = 0, len = payload.batch.length; i < len; i++) {
  40291. if (payload.batch[i].dataZoomId === dataZoomId) {
  40292. return false;
  40293. }
  40294. }
  40295. }
  40296. return true;
  40297. },
  40298. /**
  40299. * @public
  40300. */
  40301. generateCoordId: function (coordModel) {
  40302. return coordModel.type + '\0_' + coordModel.id;
  40303. }
  40304. };
  40305. /**
  40306. * Key: coordId, value: {dataZoomInfos: [], count, controller}
  40307. * @type {Array.<Object>}
  40308. */
  40309. function giveStore(api) {
  40310. // Mount store on zrender instance, so that we do not
  40311. // need to worry about dispose.
  40312. var zr = api.getZr();
  40313. return zr[ATTR] || (zr[ATTR] = {});
  40314. }
  40315. function createController(api, dataZoomInfo, newRecord) {
  40316. var controller = new RoamController(api.getZr());
  40317. controller.enable();
  40318. controller.on('pan', curry(onPan, newRecord));
  40319. controller.on('zoom', curry(onZoom, newRecord));
  40320. return controller;
  40321. }
  40322. function cleanStore(store) {
  40323. zrUtil.each(store, function (record, coordId) {
  40324. if (!record.count) {
  40325. record.controller.off('pan').off('zoom');
  40326. delete store[coordId];
  40327. }
  40328. });
  40329. }
  40330. function onPan(record, dx, dy) {
  40331. wrapAndDispatch(record, function (info) {
  40332. return info.panGetRange(record.controller, dx, dy);
  40333. });
  40334. }
  40335. function onZoom(record, scale, mouseX, mouseY) {
  40336. wrapAndDispatch(record, function (info) {
  40337. return info.zoomGetRange(record.controller, scale, mouseX, mouseY);
  40338. });
  40339. }
  40340. function wrapAndDispatch(record, getRange) {
  40341. var batch = [];
  40342. zrUtil.each(record.dataZoomInfos, function (info) {
  40343. var range = getRange(info);
  40344. range && batch.push({
  40345. dataZoomId: info.dataZoomId,
  40346. start: range[0],
  40347. end: range[1]
  40348. });
  40349. });
  40350. record.dispatchAction(batch);
  40351. }
  40352. /**
  40353. * This action will be throttled.
  40354. */
  40355. function dispatchAction(api, batch) {
  40356. api.dispatchAction({
  40357. type: 'dataZoom',
  40358. batch: batch
  40359. });
  40360. }
  40361. module.exports = roams;
  40362. /***/ },
  40363. /* 302 */
  40364. /***/ function(module, exports, __webpack_require__) {
  40365. /**
  40366. * @file Data zoom processor
  40367. */
  40368. var echarts = __webpack_require__(1);
  40369. echarts.registerProcessor('filter', function (ecModel, api) {
  40370. ecModel.eachComponent('dataZoom', function (dataZoomModel) {
  40371. // We calculate window and reset axis here but not in model
  40372. // init stage and not after action dispatch handler, because
  40373. // reset should be called after seriesData.restoreData.
  40374. dataZoomModel.eachTargetAxis(resetSingleAxis);
  40375. // Caution: data zoom filtering is order sensitive when using
  40376. // percent range and no min/max/scale set on axis.
  40377. // For example, we have dataZoom definition:
  40378. // [
  40379. // {xAxisIndex: 0, start: 30, end: 70},
  40380. // {yAxisIndex: 0, start: 20, end: 80}
  40381. // ]
  40382. // In this case, [20, 80] of y-dataZoom should be based on data
  40383. // that have filtered by x-dataZoom using range of [30, 70],
  40384. // but should not be based on full raw data. Thus sliding
  40385. // x-dataZoom will change both ranges of xAxis and yAxis,
  40386. // while sliding y-dataZoom will only change the range of yAxis.
  40387. // So we should filter x-axis after reset x-axis immediately,
  40388. // and then reset y-axis and filter y-axis.
  40389. dataZoomModel.eachTargetAxis(filterSingleAxis);
  40390. });
  40391. ecModel.eachComponent('dataZoom', function (dataZoomModel) {
  40392. // Fullfill all of the range props so that user
  40393. // is able to get them from chart.getOption().
  40394. var axisProxy = dataZoomModel.findRepresentativeAxisProxy();
  40395. var percentRange = axisProxy.getDataPercentWindow();
  40396. var valueRange = axisProxy.getDataValueWindow();
  40397. dataZoomModel.setRawRange({
  40398. start: percentRange[0],
  40399. end: percentRange[1],
  40400. startValue: valueRange[0],
  40401. endValue: valueRange[1]
  40402. });
  40403. });
  40404. });
  40405. function resetSingleAxis(dimNames, axisIndex, dataZoomModel) {
  40406. dataZoomModel.getAxisProxy(dimNames.name, axisIndex).reset(dataZoomModel);
  40407. }
  40408. function filterSingleAxis(dimNames, axisIndex, dataZoomModel) {
  40409. dataZoomModel.getAxisProxy(dimNames.name, axisIndex).filterData(dataZoomModel);
  40410. }
  40411. /***/ },
  40412. /* 303 */
  40413. /***/ function(module, exports, __webpack_require__) {
  40414. /**
  40415. * @file Data zoom action
  40416. */
  40417. var zrUtil = __webpack_require__(3);
  40418. var modelUtil = __webpack_require__(5);
  40419. var echarts = __webpack_require__(1);
  40420. echarts.registerAction('dataZoom', function (payload, ecModel) {
  40421. var linkedNodesFinder = modelUtil.createLinkedNodesFinder(
  40422. zrUtil.bind(ecModel.eachComponent, ecModel, 'dataZoom'),
  40423. modelUtil.eachAxisDim,
  40424. function (model, dimNames) {
  40425. return model.get(dimNames.axisIndex);
  40426. }
  40427. );
  40428. var effectedModels = [];
  40429. ecModel.eachComponent(
  40430. {mainType: 'dataZoom', query: payload},
  40431. function (model, index) {
  40432. effectedModels.push.apply(
  40433. effectedModels, linkedNodesFinder(model).nodes
  40434. );
  40435. }
  40436. );
  40437. zrUtil.each(effectedModels, function (dataZoomModel, index) {
  40438. dataZoomModel.setRawRange({
  40439. start: payload.start,
  40440. end: payload.end,
  40441. startValue: payload.startValue,
  40442. endValue: payload.endValue
  40443. });
  40444. });
  40445. });
  40446. /***/ },
  40447. /* 304 */
  40448. /***/ function(module, exports, __webpack_require__) {
  40449. /**
  40450. * visualMap component entry
  40451. */
  40452. __webpack_require__(305);
  40453. __webpack_require__(316);
  40454. /***/ },
  40455. /* 305 */
  40456. /***/ function(module, exports, __webpack_require__) {
  40457. /**
  40458. * DataZoom component entry
  40459. */
  40460. __webpack_require__(1).registerPreprocessor(
  40461. __webpack_require__(306)
  40462. );
  40463. __webpack_require__(307);
  40464. __webpack_require__(308);
  40465. __webpack_require__(309);
  40466. __webpack_require__(312);
  40467. __webpack_require__(315);
  40468. /***/ },
  40469. /* 306 */
  40470. /***/ function(module, exports, __webpack_require__) {
  40471. /**
  40472. * @file VisualMap preprocessor
  40473. */
  40474. var zrUtil = __webpack_require__(3);
  40475. var each = zrUtil.each;
  40476. module.exports = function (option) {
  40477. var visualMap = option && option.visualMap;
  40478. if (!zrUtil.isArray(visualMap)) {
  40479. visualMap = visualMap ? [visualMap] : [];
  40480. }
  40481. each(visualMap, function (opt) {
  40482. if (!opt) {
  40483. return;
  40484. }
  40485. // rename splitList to pieces
  40486. if (has(opt, 'splitList') && !has(opt, 'pieces')) {
  40487. opt.pieces = opt.splitList;
  40488. delete opt.splitList;
  40489. }
  40490. var pieces = opt.pieces;
  40491. if (pieces && zrUtil.isArray(pieces)) {
  40492. each(pieces, function (piece) {
  40493. if (zrUtil.isObject(piece)) {
  40494. if (has(piece, 'start') && !has(piece, 'min')) {
  40495. piece.min = piece.start;
  40496. }
  40497. if (has(piece, 'end') && !has(piece, 'max')) {
  40498. piece.max = piece.end;
  40499. }
  40500. }
  40501. });
  40502. }
  40503. });
  40504. };
  40505. function has(obj, name) {
  40506. return obj && obj.hasOwnProperty && obj.hasOwnProperty(name);
  40507. }
  40508. /***/ },
  40509. /* 307 */
  40510. /***/ function(module, exports, __webpack_require__) {
  40511. __webpack_require__(19).registerSubTypeDefaulter('visualMap', function (option) {
  40512. // Compatible with ec2, when splitNumber === 0, continuous visualMap will be used.
  40513. return (
  40514. !option.categories
  40515. && (
  40516. !(
  40517. option.pieces
  40518. ? option.pieces.length > 0
  40519. : option.splitNumber > 0
  40520. )
  40521. || option.calculable
  40522. )
  40523. )
  40524. ? 'continuous' : 'piecewise';
  40525. });
  40526. /***/ },
  40527. /* 308 */
  40528. /***/ function(module, exports, __webpack_require__) {
  40529. /**
  40530. * @file Data range visual coding.
  40531. */
  40532. var echarts = __webpack_require__(1);
  40533. var VisualMapping = __webpack_require__(187);
  40534. var zrUtil = __webpack_require__(3);
  40535. echarts.registerVisualCoding('component', function (ecModel) {
  40536. ecModel.eachComponent('visualMap', function (visualMapModel) {
  40537. processSingleVisualMap(visualMapModel, ecModel);
  40538. });
  40539. });
  40540. function processSingleVisualMap(visualMapModel, ecModel) {
  40541. var visualMappings = visualMapModel.targetVisuals;
  40542. var visualTypesMap = {};
  40543. zrUtil.each(['inRange', 'outOfRange'], function (state) {
  40544. var visualTypes = VisualMapping.prepareVisualTypes(visualMappings[state]);
  40545. visualTypesMap[state] = visualTypes;
  40546. });
  40547. visualMapModel.eachTargetSeries(function (seriesModel) {
  40548. var data = seriesModel.getData();
  40549. var dimension = visualMapModel.getDataDimension(data);
  40550. var dataIndex;
  40551. function getVisual(key) {
  40552. return data.getItemVisual(dataIndex, key);
  40553. }
  40554. function setVisual(key, value) {
  40555. data.setItemVisual(dataIndex, key, value);
  40556. }
  40557. data.each([dimension], function (value, index) {
  40558. // For performance consideration, do not use curry.
  40559. dataIndex = index;
  40560. var valueState = visualMapModel.getValueState(value);
  40561. var mappings = visualMappings[valueState];
  40562. var visualTypes = visualTypesMap[valueState];
  40563. for (var i = 0, len = visualTypes.length; i < len; i++) {
  40564. var type = visualTypes[i];
  40565. mappings[type] && mappings[type].applyVisual(value, getVisual, setVisual);
  40566. }
  40567. }, true);
  40568. });
  40569. }
  40570. /***/ },
  40571. /* 309 */
  40572. /***/ function(module, exports, __webpack_require__) {
  40573. /**
  40574. * @file Data zoom model
  40575. */
  40576. var VisualMapModel = __webpack_require__(310);
  40577. var zrUtil = __webpack_require__(3);
  40578. var numberUtil = __webpack_require__(7);
  40579. // Constant
  40580. var DEFAULT_BAR_BOUND = [20, 140];
  40581. var ContinuousModel = VisualMapModel.extend({
  40582. type: 'visualMap.continuous',
  40583. /**
  40584. * @protected
  40585. */
  40586. defaultOption: {
  40587. align: 'auto', // 'auto', 'left', 'right', 'top', 'bottom'
  40588. calculable: false, // This prop effect default component type determine,
  40589. // See echarts/component/visualMap/typeDefaulter.
  40590. range: null, // selected range. In default case `range` is [min, max]
  40591. // and can auto change along with modification of min max,
  40592. // util use specifid a range.
  40593. realtime: true, // Whether realtime update.
  40594. itemHeight: null, // The length of the range control edge.
  40595. itemWidth: null, // The length of the other side.
  40596. hoverLink: true // Enable hover highlight.
  40597. },
  40598. /**
  40599. * @override
  40600. */
  40601. doMergeOption: function (newOption, isInit) {
  40602. ContinuousModel.superApply(this, 'doMergeOption', arguments);
  40603. this.resetTargetSeries(newOption, isInit);
  40604. this.resetExtent();
  40605. this.resetVisual(function (mappingOption) {
  40606. mappingOption.mappingMethod = 'linear';
  40607. });
  40608. this._resetRange();
  40609. },
  40610. /**
  40611. * @protected
  40612. * @override
  40613. */
  40614. resetItemSize: function () {
  40615. VisualMapModel.prototype.resetItemSize.apply(this, arguments);
  40616. var itemSize = this.itemSize;
  40617. this._orient === 'horizontal' && itemSize.reverse();
  40618. (itemSize[0] == null || isNaN(itemSize[0])) && (itemSize[0] = DEFAULT_BAR_BOUND[0]);
  40619. (itemSize[1] == null || isNaN(itemSize[1])) && (itemSize[1] = DEFAULT_BAR_BOUND[1]);
  40620. },
  40621. /**
  40622. * @private
  40623. */
  40624. _resetRange: function () {
  40625. var dataExtent = this.getExtent();
  40626. var range = this.option.range;
  40627. if (!range || range.auto) {
  40628. // `range` should always be array (so we dont use other
  40629. // value like 'auto') for user-friend. (consider getOption).
  40630. dataExtent.auto = 1;
  40631. this.option.range = dataExtent;
  40632. }
  40633. else if (zrUtil.isArray(range)) {
  40634. if (range[0] > range[1]) {
  40635. range.reverse();
  40636. }
  40637. range[0] = Math.max(range[0], dataExtent[0]);
  40638. range[1] = Math.min(range[1], dataExtent[1]);
  40639. }
  40640. },
  40641. /**
  40642. * @protected
  40643. * @override
  40644. */
  40645. completeVisualOption: function () {
  40646. VisualMapModel.prototype.completeVisualOption.apply(this, arguments);
  40647. zrUtil.each(this.stateList, function (state) {
  40648. var symbolSize = this.option.controller[state].symbolSize;
  40649. if (symbolSize && symbolSize[0] !== symbolSize[1]) {
  40650. symbolSize[0] = 0; // For good looking.
  40651. }
  40652. }, this);
  40653. },
  40654. /**
  40655. * @public
  40656. * @override
  40657. */
  40658. setSelected: function (selected) {
  40659. this.option.range = selected.slice();
  40660. this._resetRange();
  40661. },
  40662. /**
  40663. * @public
  40664. */
  40665. getSelected: function () {
  40666. var dataExtent = this.getExtent();
  40667. var dataInterval = numberUtil.asc(
  40668. (this.get('range') || []).slice()
  40669. );
  40670. // Clamp
  40671. dataInterval[0] > dataExtent[1] && (dataInterval[0] = dataExtent[1]);
  40672. dataInterval[1] > dataExtent[1] && (dataInterval[1] = dataExtent[1]);
  40673. dataInterval[0] < dataExtent[0] && (dataInterval[0] = dataExtent[0]);
  40674. dataInterval[1] < dataExtent[0] && (dataInterval[1] = dataExtent[0]);
  40675. return dataInterval;
  40676. },
  40677. /**
  40678. * @public
  40679. * @override
  40680. */
  40681. getValueState: function (value) {
  40682. var range = this.option.range;
  40683. var dataExtent = this.getExtent();
  40684. // When range[0] === dataExtent[0], any value larger than dataExtent[0] maps to 'inRange'.
  40685. // range[1] is processed likewise.
  40686. return (
  40687. (range[0] <= dataExtent[0] || range[0] <= value)
  40688. && (range[1] >= dataExtent[1] || value <= range[1])
  40689. ) ? 'inRange' : 'outOfRange';
  40690. },
  40691. /**
  40692. * @public
  40693. * @params {Array.<number>} range target value: range[0] <= value && value <= range[1]
  40694. * @return {Array.<Object>} [{seriesId, dataIndices: <Array.<number>>}, ...]
  40695. */
  40696. findTargetDataIndices: function (range) {
  40697. var result = [];
  40698. this.eachTargetSeries(function (seriesModel) {
  40699. var dataIndices = [];
  40700. var data = seriesModel.getData();
  40701. data.each(this.getDataDimension(data), function (value, dataIndex) {
  40702. range[0] <= value && value <= range[1] && dataIndices.push(dataIndex);
  40703. }, true, this);
  40704. result.push({seriesId: seriesModel.id, dataIndices: dataIndices});
  40705. }, this);
  40706. return result;
  40707. }
  40708. });
  40709. module.exports = ContinuousModel;
  40710. /***/ },
  40711. /* 310 */
  40712. /***/ function(module, exports, __webpack_require__) {
  40713. /**
  40714. * @file Data zoom model
  40715. */
  40716. var zrUtil = __webpack_require__(3);
  40717. var env = __webpack_require__(79);
  40718. var echarts = __webpack_require__(1);
  40719. var modelUtil = __webpack_require__(5);
  40720. var visualDefault = __webpack_require__(311);
  40721. var VisualMapping = __webpack_require__(187);
  40722. var mapVisual = VisualMapping.mapVisual;
  40723. var eachVisual = VisualMapping.eachVisual;
  40724. var numberUtil = __webpack_require__(7);
  40725. var isArray = zrUtil.isArray;
  40726. var each = zrUtil.each;
  40727. var asc = numberUtil.asc;
  40728. var linearMap = numberUtil.linearMap;
  40729. var VisualMapModel = echarts.extendComponentModel({
  40730. type: 'visualMap',
  40731. dependencies: ['series'],
  40732. /**
  40733. * [lowerBound, upperBound]
  40734. *
  40735. * @readOnly
  40736. * @type {Array.<number>}
  40737. */
  40738. dataBound: [-Infinity, Infinity],
  40739. /**
  40740. * @readOnly
  40741. * @type {Array.<string>}
  40742. */
  40743. stateList: ['inRange', 'outOfRange'],
  40744. /**
  40745. * @readOnly
  40746. * @type {string|Object}
  40747. */
  40748. layoutMode: {type: 'box', ignoreSize: true},
  40749. /**
  40750. * @protected
  40751. */
  40752. defaultOption: {
  40753. show: true,
  40754. zlevel: 0,
  40755. z: 4,
  40756. // set min: 0, max: 200, only for campatible with ec2.
  40757. // In fact min max should not have default value.
  40758. min: 0, // min value, must specified if pieces is not specified.
  40759. max: 200, // max value, must specified if pieces is not specified.
  40760. dimension: null,
  40761. inRange: null, // 'color', 'colorHue', 'colorSaturation', 'colorLightness', 'colorAlpha',
  40762. // 'symbol', 'symbolSize'
  40763. outOfRange: null, // 'color', 'colorHue', 'colorSaturation',
  40764. // 'colorLightness', 'colorAlpha',
  40765. // 'symbol', 'symbolSize'
  40766. left: 0, // 'center' ¦ 'left' ¦ 'right' ¦ {number} (px)
  40767. right: null, // The same as left.
  40768. top: null, // 'top' ¦ 'bottom' ¦ 'center' ¦ {number} (px)
  40769. bottom: 0, // The same as top.
  40770. itemWidth: null,
  40771. itemHeight: null,
  40772. inverse: false,
  40773. orient: 'vertical', // 'horizontal' ¦ 'vertical'
  40774. seriesIndex: null, // 所控制的series indices,默认所有有value的series.
  40775. backgroundColor: 'rgba(0,0,0,0)',
  40776. borderColor: '#ccc', // 值域边框颜色
  40777. contentColor: '#5793f3',
  40778. inactiveColor: '#aaa',
  40779. borderWidth: 0, // 值域边框线宽,单位px,默认为0(无边框)
  40780. padding: 5, // 值域内边距,单位px,默认各方向内边距为5,
  40781. // 接受数组分别设定上右下左边距,同css
  40782. textGap: 10, //
  40783. precision: 0, // 小数精度,默认为0,无小数点
  40784. color: ['#bf444c', '#d88273', '#f6efa6'], //颜色(deprecated,兼容ec2,顺序同pieces,不同于inRange/outOfRange)
  40785. formatter: null,
  40786. text: null, // 文本,如['高', '低'],兼容ec2,text[0]对应高值,text[1]对应低值
  40787. textStyle: {
  40788. color: '#333' // 值域文字颜色
  40789. }
  40790. },
  40791. /**
  40792. * @protected
  40793. */
  40794. init: function (option, parentModel, ecModel) {
  40795. /**
  40796. * @private
  40797. * @type {Array.<number>}
  40798. */
  40799. this._dataExtent;
  40800. /**
  40801. * @readOnly
  40802. */
  40803. this.controllerVisuals = {};
  40804. /**
  40805. * @readOnly
  40806. */
  40807. this.targetVisuals = {};
  40808. /**
  40809. * @readOnly
  40810. */
  40811. this.textStyleModel;
  40812. /**
  40813. * [width, height]
  40814. * @readOnly
  40815. * @type {Array.<number>}
  40816. */
  40817. this.itemSize;
  40818. this.mergeDefaultAndTheme(option, ecModel);
  40819. this.doMergeOption({}, true);
  40820. },
  40821. /**
  40822. * @public
  40823. */
  40824. mergeOption: function (option) {
  40825. VisualMapModel.superApply(this, 'mergeOption', arguments);
  40826. this.doMergeOption(option, false);
  40827. },
  40828. /**
  40829. * @protected
  40830. */
  40831. doMergeOption: function (newOption, isInit) {
  40832. var thisOption = this.option;
  40833. !isInit && replaceVisualOption(thisOption, newOption);
  40834. // FIXME
  40835. // necessary?
  40836. // Disable realtime view update if canvas is not supported.
  40837. if (!env.canvasSupported) {
  40838. thisOption.realtime = false;
  40839. }
  40840. this.textStyleModel = this.getModel('textStyle');
  40841. this.resetItemSize();
  40842. this.completeVisualOption();
  40843. },
  40844. /**
  40845. * @example
  40846. * this.formatValueText(someVal); // format single numeric value to text.
  40847. * this.formatValueText(someVal, true); // format single category value to text.
  40848. * this.formatValueText([min, max]); // format numeric min-max to text.
  40849. * this.formatValueText([this.dataBound[0], max]); // using data lower bound.
  40850. * this.formatValueText([min, this.dataBound[1]]); // using data upper bound.
  40851. *
  40852. * @param {number|Array.<number>} value Real value, or this.dataBound[0 or 1].
  40853. * @param {boolean} [isCategory=false] Only available when value is number.
  40854. * @return {string}
  40855. * @protected
  40856. */
  40857. formatValueText: function(value, isCategory) {
  40858. var option = this.option;
  40859. var precision = option.precision;
  40860. var dataBound = this.dataBound;
  40861. var formatter = option.formatter;
  40862. var isMinMax;
  40863. var textValue;
  40864. if (zrUtil.isArray(value)) {
  40865. value = value.slice();
  40866. isMinMax = true;
  40867. }
  40868. textValue = isCategory
  40869. ? value
  40870. : (isMinMax
  40871. ? [toFixed(value[0]), toFixed(value[1])]
  40872. : toFixed(value)
  40873. );
  40874. if (zrUtil.isString(formatter)) {
  40875. return formatter
  40876. .replace('{value}', isMinMax ? textValue[0] : textValue)
  40877. .replace('{value2}', isMinMax ? textValue[1] : textValue);
  40878. }
  40879. else if (zrUtil.isFunction(formatter)) {
  40880. return isMinMax
  40881. ? formatter(value[0], value[1])
  40882. : formatter(value);
  40883. }
  40884. if (isMinMax) {
  40885. if (value[0] === dataBound[0]) {
  40886. return '< ' + textValue[1];
  40887. }
  40888. else if (value[1] === dataBound[1]) {
  40889. return '> ' + textValue[0];
  40890. }
  40891. else {
  40892. return textValue[0] + ' - ' + textValue[1];
  40893. }
  40894. }
  40895. else { // Format single value (includes category case).
  40896. return textValue;
  40897. }
  40898. function toFixed(val) {
  40899. return val === dataBound[0]
  40900. ? 'min'
  40901. : val === dataBound[1]
  40902. ? 'max'
  40903. : (+val).toFixed(precision);
  40904. }
  40905. },
  40906. /**
  40907. * @protected
  40908. */
  40909. resetTargetSeries: function (newOption, isInit) {
  40910. var thisOption = this.option;
  40911. var allSeriesIndex = thisOption.seriesIndex == null;
  40912. thisOption.seriesIndex = allSeriesIndex
  40913. ? [] : modelUtil.normalizeToArray(thisOption.seriesIndex);
  40914. allSeriesIndex && this.ecModel.eachSeries(function (seriesModel, index) {
  40915. var data = seriesModel.getData();
  40916. // FIXME
  40917. // 只考虑了list,还没有考虑map等。
  40918. // FIXME
  40919. // 这里可能应该这么判断:data.dimensions中有超出其所属coordSystem的量。
  40920. if (data.type === 'list') {
  40921. thisOption.seriesIndex.push(index);
  40922. }
  40923. });
  40924. },
  40925. /**
  40926. * @protected
  40927. */
  40928. resetExtent: function () {
  40929. var thisOption = this.option;
  40930. // Can not calculate data extent by data here.
  40931. // Because series and data may be modified in processing stage.
  40932. // So we do not support the feature "auto min/max".
  40933. var extent = asc([thisOption.min, thisOption.max]);
  40934. this._dataExtent = extent;
  40935. },
  40936. /**
  40937. * @protected
  40938. */
  40939. getDataDimension: function (list) {
  40940. var optDim = this.option.dimension;
  40941. return optDim != null
  40942. ? optDim : list.dimensions.length - 1;
  40943. },
  40944. /**
  40945. * @public
  40946. * @override
  40947. */
  40948. getExtent: function () {
  40949. return this._dataExtent.slice();
  40950. },
  40951. /**
  40952. * @protected
  40953. */
  40954. resetVisual: function (fillVisualOption) {
  40955. var dataExtent = this.getExtent();
  40956. doReset.call(this, 'controller', this.controllerVisuals);
  40957. doReset.call(this, 'target', this.targetVisuals);
  40958. function doReset(baseAttr, visualMappings) {
  40959. each(this.stateList, function (state) {
  40960. var mappings = visualMappings[state] || (
  40961. visualMappings[state] = createMappings()
  40962. );
  40963. var visaulOption = this.option[baseAttr][state] || {};
  40964. each(visaulOption, function (visualData, visualType) {
  40965. if (!VisualMapping.isValidType(visualType)) {
  40966. return;
  40967. }
  40968. var mappingOption = {
  40969. type: visualType,
  40970. dataExtent: dataExtent,
  40971. visual: visualData
  40972. };
  40973. fillVisualOption && fillVisualOption.call(this, mappingOption, state);
  40974. mappings[visualType] = new VisualMapping(mappingOption);
  40975. // Prepare a alpha for opacity, for some case that opacity
  40976. // is not supported, such as rendering using gradient color.
  40977. if (baseAttr === 'controller' && visualType === 'opacity') {
  40978. mappingOption = zrUtil.clone(mappingOption);
  40979. mappingOption.type = 'colorAlpha';
  40980. mappings.__hidden.__alphaForOpacity = new VisualMapping(mappingOption);
  40981. }
  40982. }, this);
  40983. }, this);
  40984. }
  40985. function createMappings() {
  40986. var Creater = function () {};
  40987. // Make sure hidden fields will not be visited by
  40988. // object iteration (with hasOwnProperty checking).
  40989. Creater.prototype.__hidden = Creater.prototype;
  40990. var obj = new Creater();
  40991. return obj;
  40992. }
  40993. },
  40994. /**
  40995. * @protected
  40996. */
  40997. completeVisualOption: function () {
  40998. var thisOption = this.option;
  40999. var base = {inRange: thisOption.inRange, outOfRange: thisOption.outOfRange};
  41000. var target = thisOption.target || (thisOption.target = {});
  41001. var controller = thisOption.controller || (thisOption.controller = {});
  41002. zrUtil.merge(target, base); // Do not override
  41003. zrUtil.merge(controller, base); // Do not override
  41004. var isCategory = this.isCategory();
  41005. completeSingle.call(this, target);
  41006. completeSingle.call(this, controller);
  41007. completeInactive.call(this, target, 'inRange', 'outOfRange');
  41008. completeInactive.call(this, target, 'outOfRange', 'inRange');
  41009. completeController.call(this, controller);
  41010. function completeSingle(base) {
  41011. // Compatible with ec2 dataRange.color.
  41012. // The mapping order of dataRange.color is: [high value, ..., low value]
  41013. // whereas inRange.color and outOfRange.color is [low value, ..., high value]
  41014. // Notice: ec2 has no inverse.
  41015. if (isArray(thisOption.color)
  41016. // If there has been inRange: {symbol: ...}, adding color is a mistake.
  41017. // So adding color only when no inRange defined.
  41018. && !base.inRange
  41019. ) {
  41020. base.inRange = {color: thisOption.color.slice().reverse()};
  41021. }
  41022. // If using shortcut like: {inRange: 'symbol'}, complete default value.
  41023. each(this.stateList, function (state) {
  41024. var visualType = base[state];
  41025. if (zrUtil.isString(visualType)) {
  41026. var defa = visualDefault.get(visualType, 'active', isCategory);
  41027. if (defa) {
  41028. base[state] = {};
  41029. base[state][visualType] = defa;
  41030. }
  41031. else {
  41032. // Mark as not specified.
  41033. delete base[state];
  41034. }
  41035. }
  41036. }, this);
  41037. }
  41038. function completeInactive(base, stateExist, stateAbsent) {
  41039. var optExist = base[stateExist];
  41040. var optAbsent = base[stateAbsent];
  41041. if (optExist && !optAbsent) {
  41042. optAbsent = base[stateAbsent] = {};
  41043. each(optExist, function (visualData, visualType) {
  41044. if (!VisualMapping.isValidType(visualType)) {
  41045. return;
  41046. }
  41047. var defa = visualDefault.get(visualType, 'inactive', isCategory);
  41048. if (defa != null) {
  41049. optAbsent[visualType] = defa;
  41050. // Compatibable with ec2:
  41051. // Only inactive color to rgba(0,0,0,0) can not
  41052. // make label transparent, so use opacity also.
  41053. if (visualType === 'color'
  41054. && !optAbsent.hasOwnProperty('opacity')
  41055. && !optAbsent.hasOwnProperty('colorAlpha')
  41056. ) {
  41057. optAbsent.opacity = [0, 0];
  41058. }
  41059. }
  41060. });
  41061. }
  41062. }
  41063. function completeController(controller) {
  41064. var symbolExists = (controller.inRange || {}).symbol
  41065. || (controller.outOfRange || {}).symbol;
  41066. var symbolSizeExists = (controller.inRange || {}).symbolSize
  41067. || (controller.outOfRange || {}).symbolSize;
  41068. var inactiveColor = this.get('inactiveColor');
  41069. each(this.stateList, function (state) {
  41070. var itemSize = this.itemSize;
  41071. var visuals = controller[state];
  41072. // Set inactive color for controller if no other color
  41073. // attr (like colorAlpha) specified.
  41074. if (!visuals) {
  41075. visuals = controller[state] = {
  41076. color: isCategory ? inactiveColor : [inactiveColor]
  41077. };
  41078. }
  41079. // Consistent symbol and symbolSize if not specified.
  41080. if (visuals.symbol == null) {
  41081. visuals.symbol = symbolExists
  41082. && zrUtil.clone(symbolExists)
  41083. || (isCategory ? 'roundRect' : ['roundRect']);
  41084. }
  41085. if (visuals.symbolSize == null) {
  41086. visuals.symbolSize = symbolSizeExists
  41087. && zrUtil.clone(symbolSizeExists)
  41088. || (isCategory ? itemSize[0] : [itemSize[0], itemSize[0]]);
  41089. }
  41090. // Filter square and none.
  41091. visuals.symbol = mapVisual(visuals.symbol, function (symbol) {
  41092. return (symbol === 'none' || symbol === 'square') ? 'roundRect' : symbol;
  41093. });
  41094. // Normalize symbolSize
  41095. var symbolSize = visuals.symbolSize;
  41096. if (symbolSize != null) {
  41097. var max = -Infinity;
  41098. // symbolSize can be object when categories defined.
  41099. eachVisual(symbolSize, function (value) {
  41100. value > max && (max = value);
  41101. });
  41102. visuals.symbolSize = mapVisual(symbolSize, function (value) {
  41103. return linearMap(value, [0, max], [0, itemSize[0]], true);
  41104. });
  41105. }
  41106. }, this);
  41107. }
  41108. },
  41109. /**
  41110. * @public
  41111. */
  41112. eachTargetSeries: function (callback, context) {
  41113. zrUtil.each(this.option.seriesIndex, function (seriesIndex) {
  41114. callback.call(context, this.ecModel.getSeriesByIndex(seriesIndex));
  41115. }, this);
  41116. },
  41117. /**
  41118. * @public
  41119. */
  41120. isCategory: function () {
  41121. return !!this.option.categories;
  41122. },
  41123. /**
  41124. * @protected
  41125. */
  41126. resetItemSize: function () {
  41127. this.itemSize = [
  41128. parseFloat(this.get('itemWidth')),
  41129. parseFloat(this.get('itemHeight'))
  41130. ];
  41131. },
  41132. /**
  41133. * @public
  41134. * @abstract
  41135. */
  41136. setSelected: zrUtil.noop,
  41137. /**
  41138. * @public
  41139. * @abstract
  41140. */
  41141. getValueState: zrUtil.noop
  41142. });
  41143. function replaceVisualOption(thisOption, newOption) {
  41144. // Visual attributes merge is not supported, otherwise it
  41145. // brings overcomplicated merge logic. See #2853. So if
  41146. // newOption has anyone of these keys, all of these keys
  41147. // will be reset. Otherwise, all keys remain.
  41148. var visualKeys = [
  41149. 'inRange', 'outOfRange', 'target', 'controller', 'color'
  41150. ];
  41151. var has;
  41152. zrUtil.each(visualKeys, function (key) {
  41153. if (newOption.hasOwnProperty(key)) {
  41154. has = true;
  41155. }
  41156. });
  41157. has && zrUtil.each(visualKeys, function (key) {
  41158. if (newOption.hasOwnProperty(key)) {
  41159. thisOption[key] = zrUtil.clone(newOption[key]);
  41160. }
  41161. else {
  41162. delete thisOption[key];
  41163. }
  41164. });
  41165. }
  41166. module.exports = VisualMapModel;
  41167. /***/ },
  41168. /* 311 */
  41169. /***/ function(module, exports, __webpack_require__) {
  41170. /**
  41171. * @file Visual mapping.
  41172. */
  41173. var zrUtil = __webpack_require__(3);
  41174. var visualDefault = {
  41175. /**
  41176. * @public
  41177. */
  41178. get: function (visualType, key, isCategory) {
  41179. var value = zrUtil.clone(
  41180. (defaultOption[visualType] || {})[key]
  41181. );
  41182. return isCategory
  41183. ? (zrUtil.isArray(value) ? value[value.length - 1] : value)
  41184. : value;
  41185. }
  41186. };
  41187. var defaultOption = {
  41188. color: {
  41189. active: ['#006edd', '#e0ffff'],
  41190. inactive: ['rgba(0,0,0,0)']
  41191. },
  41192. colorHue: {
  41193. active: [0, 360],
  41194. inactive: [0, 0]
  41195. },
  41196. colorSaturation: {
  41197. active: [0.3, 1],
  41198. inactive: [0, 0]
  41199. },
  41200. colorLightness: {
  41201. active: [0.9, 0.5],
  41202. inactive: [0, 0]
  41203. },
  41204. colorAlpha: {
  41205. active: [0.3, 1],
  41206. inactive: [0, 0]
  41207. },
  41208. opacity: {
  41209. active: [0.3, 1],
  41210. inactive: [0, 0]
  41211. },
  41212. symbol: {
  41213. active: ['circle', 'roundRect', 'diamond'],
  41214. inactive: ['none']
  41215. },
  41216. symbolSize: {
  41217. active: [10, 50],
  41218. inactive: [0, 0]
  41219. }
  41220. };
  41221. module.exports = visualDefault;
  41222. /***/ },
  41223. /* 312 */
  41224. /***/ function(module, exports, __webpack_require__) {
  41225. var VisualMapView = __webpack_require__(313);
  41226. var graphic = __webpack_require__(42);
  41227. var zrUtil = __webpack_require__(3);
  41228. var numberUtil = __webpack_require__(7);
  41229. var sliderMove = __webpack_require__(298);
  41230. var LinearGradient = __webpack_require__(76);
  41231. var helper = __webpack_require__(314);
  41232. var linearMap = numberUtil.linearMap;
  41233. var convertDataIndicesToBatch = helper.convertDataIndicesToBatch;
  41234. var each = zrUtil.each;
  41235. var mathMin = Math.min;
  41236. var mathMax = Math.max;
  41237. // Arbitrary value
  41238. var HOVER_LINK_RANGE = 6;
  41239. var HOVER_LINK_OUT = 6;
  41240. // Notice:
  41241. // Any "interval" should be by the order of [low, high].
  41242. // "handle0" (handleIndex === 0) maps to
  41243. // low data value: this._dataInterval[0] and has low coord.
  41244. // "handle1" (handleIndex === 1) maps to
  41245. // high data value: this._dataInterval[1] and has high coord.
  41246. // The logic of transform is implemented in this._createBarGroup.
  41247. var ContinuousVisualMapView = VisualMapView.extend({
  41248. type: 'visualMap.continuous',
  41249. /**
  41250. * @override
  41251. */
  41252. init: function () {
  41253. VisualMapView.prototype.init.apply(this, arguments);
  41254. /**
  41255. * @private
  41256. */
  41257. this._shapes = {};
  41258. /**
  41259. * @private
  41260. */
  41261. this._dataInterval = [];
  41262. /**
  41263. * @private
  41264. */
  41265. this._handleEnds = [];
  41266. /**
  41267. * @private
  41268. */
  41269. this._orient;
  41270. /**
  41271. * @private
  41272. */
  41273. this._useHandle;
  41274. /**
  41275. * @private
  41276. */
  41277. this._hoverLinkDataIndices = [];
  41278. },
  41279. /**
  41280. * @protected
  41281. * @override
  41282. */
  41283. doRender: function (visualMapModel, ecModel, api, payload) {
  41284. if (!payload || payload.type !== 'selectDataRange' || payload.from !== this.uid) {
  41285. this._buildView();
  41286. }
  41287. else {
  41288. this._updateView();
  41289. }
  41290. },
  41291. /**
  41292. * @private
  41293. */
  41294. _buildView: function () {
  41295. this.group.removeAll();
  41296. var visualMapModel = this.visualMapModel;
  41297. var thisGroup = this.group;
  41298. this._orient = visualMapModel.get('orient');
  41299. this._useHandle = visualMapModel.get('calculable');
  41300. this._resetInterval();
  41301. this._renderBar(thisGroup);
  41302. var dataRangeText = visualMapModel.get('text');
  41303. this._renderEndsText(thisGroup, dataRangeText, 0);
  41304. this._renderEndsText(thisGroup, dataRangeText, 1);
  41305. // Do this for background size calculation.
  41306. this._updateView(true);
  41307. // After updating view, inner shapes is built completely,
  41308. // and then background can be rendered.
  41309. this.renderBackground(thisGroup);
  41310. // Real update view
  41311. this._updateView();
  41312. this._enableHoverLinkToSeries();
  41313. this._enableHoverLinkFromSeries();
  41314. this.positionGroup(thisGroup);
  41315. },
  41316. /**
  41317. * @private
  41318. */
  41319. _renderEndsText: function (group, dataRangeText, endsIndex) {
  41320. if (!dataRangeText) {
  41321. return;
  41322. }
  41323. // Compatible with ec2, text[0] map to high value, text[1] map low value.
  41324. var text = dataRangeText[1 - endsIndex];
  41325. text = text != null ? text + '' : '';
  41326. var visualMapModel = this.visualMapModel;
  41327. var textGap = visualMapModel.get('textGap');
  41328. var itemSize = visualMapModel.itemSize;
  41329. var barGroup = this._shapes.barGroup;
  41330. var position = this._applyTransform(
  41331. [
  41332. itemSize[0] / 2,
  41333. endsIndex === 0 ? -textGap : itemSize[1] + textGap
  41334. ],
  41335. barGroup
  41336. );
  41337. var align = this._applyTransform(
  41338. endsIndex === 0 ? 'bottom' : 'top',
  41339. barGroup
  41340. );
  41341. var orient = this._orient;
  41342. var textStyleModel = this.visualMapModel.textStyleModel;
  41343. this.group.add(new graphic.Text({
  41344. style: {
  41345. x: position[0],
  41346. y: position[1],
  41347. textVerticalAlign: orient === 'horizontal' ? 'middle' : align,
  41348. textAlign: orient === 'horizontal' ? align : 'center',
  41349. text: text,
  41350. textFont: textStyleModel.getFont(),
  41351. fill: textStyleModel.getTextColor()
  41352. }
  41353. }));
  41354. },
  41355. /**
  41356. * @private
  41357. */
  41358. _renderBar: function (targetGroup) {
  41359. var visualMapModel = this.visualMapModel;
  41360. var shapes = this._shapes;
  41361. var itemSize = visualMapModel.itemSize;
  41362. var orient = this._orient;
  41363. var useHandle = this._useHandle;
  41364. var itemAlign = helper.getItemAlign(visualMapModel, this.api, itemSize);
  41365. var barGroup = shapes.barGroup = this._createBarGroup(itemAlign);
  41366. // Bar
  41367. barGroup.add(shapes.outOfRange = createPolygon());
  41368. barGroup.add(shapes.inRange = createPolygon(
  41369. null,
  41370. zrUtil.bind(this._modifyHandle, this, 'all'),
  41371. useHandle ? 'move' : null
  41372. ));
  41373. var textRect = visualMapModel.textStyleModel.getTextRect('国');
  41374. var textSize = Math.max(textRect.width, textRect.height);
  41375. // Handle
  41376. if (useHandle) {
  41377. shapes.handleThumbs = [];
  41378. shapes.handleLabels = [];
  41379. shapes.handleLabelPoints = [];
  41380. this._createHandle(barGroup, 0, itemSize, textSize, orient, itemAlign);
  41381. this._createHandle(barGroup, 1, itemSize, textSize, orient, itemAlign);
  41382. }
  41383. this._createIndicator(barGroup, itemSize, textSize, orient);
  41384. targetGroup.add(barGroup);
  41385. },
  41386. /**
  41387. * @private
  41388. */
  41389. _createHandle: function (barGroup, handleIndex, itemSize, textSize, orient) {
  41390. var modifyHandle = zrUtil.bind(this._modifyHandle, this, handleIndex);
  41391. var handleThumb = createPolygon(
  41392. createHandlePoints(handleIndex, textSize),
  41393. modifyHandle,
  41394. 'move'
  41395. );
  41396. handleThumb.position[0] = itemSize[0];
  41397. barGroup.add(handleThumb);
  41398. // Text is always horizontal layout but should not be effected by
  41399. // transform (orient/inverse). So label is built separately but not
  41400. // use zrender/graphic/helper/RectText, and is located based on view
  41401. // group (according to handleLabelPoint) but not barGroup.
  41402. var textStyleModel = this.visualMapModel.textStyleModel;
  41403. var handleLabel = new graphic.Text({
  41404. draggable: true,
  41405. drift: modifyHandle,
  41406. style: {
  41407. x: 0, y: 0, text: '',
  41408. textFont: textStyleModel.getFont(),
  41409. fill: textStyleModel.getTextColor()
  41410. }
  41411. });
  41412. this.group.add(handleLabel);
  41413. var handleLabelPoint = [
  41414. orient === 'horizontal'
  41415. ? textSize / 2
  41416. : textSize * 1.5,
  41417. orient === 'horizontal'
  41418. ? (handleIndex === 0 ? -(textSize * 1.5) : (textSize * 1.5))
  41419. : (handleIndex === 0 ? -textSize / 2 : textSize / 2)
  41420. ];
  41421. var shapes = this._shapes;
  41422. shapes.handleThumbs[handleIndex] = handleThumb;
  41423. shapes.handleLabelPoints[handleIndex] = handleLabelPoint;
  41424. shapes.handleLabels[handleIndex] = handleLabel;
  41425. },
  41426. /**
  41427. * @private
  41428. */
  41429. _createIndicator: function (barGroup, itemSize, textSize, orient) {
  41430. var indicator = createPolygon([[0, 0]], null, 'move');
  41431. indicator.position[0] = itemSize[0];
  41432. indicator.attr({invisible: true, silent: true});
  41433. barGroup.add(indicator);
  41434. var textStyleModel = this.visualMapModel.textStyleModel;
  41435. var indicatorLabel = new graphic.Text({
  41436. silent: true,
  41437. invisible: true,
  41438. style: {
  41439. x: 0, y: 0, text: '',
  41440. textFont: textStyleModel.getFont(),
  41441. fill: textStyleModel.getTextColor()
  41442. }
  41443. });
  41444. this.group.add(indicatorLabel);
  41445. var indicatorLabelPoint = [
  41446. orient === 'horizontal' ? textSize / 2 : HOVER_LINK_OUT + 3,
  41447. 0
  41448. ];
  41449. var shapes = this._shapes;
  41450. shapes.indicator = indicator;
  41451. shapes.indicatorLabel = indicatorLabel;
  41452. shapes.indicatorLabelPoint = indicatorLabelPoint;
  41453. },
  41454. /**
  41455. * @private
  41456. */
  41457. _modifyHandle: function (handleIndex, dx, dy) {
  41458. if (!this._useHandle) {
  41459. return;
  41460. }
  41461. // Transform dx, dy to bar coordination.
  41462. var vertex = this._applyTransform([dx, dy], this._shapes.barGroup, true);
  41463. this._updateInterval(handleIndex, vertex[1]);
  41464. this.api.dispatchAction({
  41465. type: 'selectDataRange',
  41466. from: this.uid,
  41467. visualMapId: this.visualMapModel.id,
  41468. selected: this._dataInterval.slice()
  41469. });
  41470. },
  41471. /**
  41472. * @private
  41473. */
  41474. _resetInterval: function () {
  41475. var visualMapModel = this.visualMapModel;
  41476. var dataInterval = this._dataInterval = visualMapModel.getSelected();
  41477. var dataExtent = visualMapModel.getExtent();
  41478. var sizeExtent = [0, visualMapModel.itemSize[1]];
  41479. this._handleEnds = [
  41480. linearMap(dataInterval[0], dataExtent, sizeExtent, true),
  41481. linearMap(dataInterval[1], dataExtent, sizeExtent, true)
  41482. ];
  41483. },
  41484. /**
  41485. * @private
  41486. * @param {(number|string)} handleIndex 0 or 1 or 'all'
  41487. * @param {number} dx
  41488. * @param {number} dy
  41489. */
  41490. _updateInterval: function (handleIndex, delta) {
  41491. delta = delta || 0;
  41492. var visualMapModel = this.visualMapModel;
  41493. var handleEnds = this._handleEnds;
  41494. sliderMove(
  41495. delta,
  41496. handleEnds,
  41497. [0, visualMapModel.itemSize[1]],
  41498. handleIndex === 'all' ? 'rigid' : 'push',
  41499. handleIndex
  41500. );
  41501. var dataExtent = visualMapModel.getExtent();
  41502. var sizeExtent = [0, visualMapModel.itemSize[1]];
  41503. // Update data interval.
  41504. this._dataInterval = [
  41505. linearMap(handleEnds[0], sizeExtent, dataExtent, true),
  41506. linearMap(handleEnds[1], sizeExtent, dataExtent, true)
  41507. ];
  41508. },
  41509. /**
  41510. * @private
  41511. */
  41512. _updateView: function (forSketch) {
  41513. var visualMapModel = this.visualMapModel;
  41514. var dataExtent = visualMapModel.getExtent();
  41515. var shapes = this._shapes;
  41516. var outOfRangeHandleEnds = [0, visualMapModel.itemSize[1]];
  41517. var inRangeHandleEnds = forSketch ? outOfRangeHandleEnds : this._handleEnds;
  41518. var visualInRange = this._createBarVisual(
  41519. this._dataInterval, dataExtent, inRangeHandleEnds, 'inRange'
  41520. );
  41521. var visualOutOfRange = this._createBarVisual(
  41522. dataExtent, dataExtent, outOfRangeHandleEnds, 'outOfRange'
  41523. );
  41524. shapes.inRange
  41525. .setStyle({
  41526. fill: visualInRange.barColor,
  41527. opacity: visualInRange.opacity
  41528. })
  41529. .setShape('points', visualInRange.barPoints);
  41530. shapes.outOfRange
  41531. .setStyle({
  41532. fill: visualOutOfRange.barColor,
  41533. opacity: visualOutOfRange.opacity
  41534. })
  41535. .setShape('points', visualOutOfRange.barPoints);
  41536. this._updateHandle(inRangeHandleEnds, visualInRange);
  41537. },
  41538. /**
  41539. * @private
  41540. */
  41541. _createBarVisual: function (dataInterval, dataExtent, handleEnds, forceState) {
  41542. var opts = {
  41543. forceState: forceState,
  41544. convertOpacityToAlpha: true
  41545. };
  41546. var colorStops = this._makeColorGradient(dataInterval, opts);
  41547. var symbolSizes = [
  41548. this.getControllerVisual(dataInterval[0], 'symbolSize', opts),
  41549. this.getControllerVisual(dataInterval[1], 'symbolSize', opts)
  41550. ];
  41551. var barPoints = this._createBarPoints(handleEnds, symbolSizes);
  41552. return {
  41553. barColor: new LinearGradient(0, 0, 1, 1, colorStops),
  41554. barPoints: barPoints,
  41555. handlesColor: [
  41556. colorStops[0].color,
  41557. colorStops[colorStops.length - 1].color
  41558. ]
  41559. };
  41560. },
  41561. /**
  41562. * @private
  41563. */
  41564. _makeColorGradient: function (dataInterval, opts) {
  41565. // Considering colorHue, which is not linear, so we have to sample
  41566. // to calculate gradient color stops, but not only caculate head
  41567. // and tail.
  41568. var sampleNumber = 100; // Arbitrary value.
  41569. var colorStops = [];
  41570. var step = (dataInterval[1] - dataInterval[0]) / sampleNumber;
  41571. colorStops.push({
  41572. color: this.getControllerVisual(dataInterval[0], 'color', opts),
  41573. offset: 0
  41574. });
  41575. for (var i = 1; i < sampleNumber; i++) {
  41576. var currValue = dataInterval[0] + step * i;
  41577. if (currValue > dataInterval[1]) {
  41578. break;
  41579. }
  41580. colorStops.push({
  41581. color: this.getControllerVisual(currValue, 'color', opts),
  41582. offset: i / sampleNumber
  41583. });
  41584. }
  41585. colorStops.push({
  41586. color: this.getControllerVisual(dataInterval[1], 'color', opts),
  41587. offset: 1
  41588. });
  41589. return colorStops;
  41590. },
  41591. /**
  41592. * @private
  41593. */
  41594. _createBarPoints: function (handleEnds, symbolSizes) {
  41595. var itemSize = this.visualMapModel.itemSize;
  41596. return [
  41597. [itemSize[0] - symbolSizes[0], handleEnds[0]],
  41598. [itemSize[0], handleEnds[0]],
  41599. [itemSize[0], handleEnds[1]],
  41600. [itemSize[0] - symbolSizes[1], handleEnds[1]]
  41601. ];
  41602. },
  41603. /**
  41604. * @private
  41605. */
  41606. _createBarGroup: function (itemAlign) {
  41607. var orient = this._orient;
  41608. var inverse = this.visualMapModel.get('inverse');
  41609. return new graphic.Group(
  41610. (orient === 'horizontal' && !inverse)
  41611. ? {scale: itemAlign === 'bottom' ? [1, 1] : [-1, 1], rotation: Math.PI / 2}
  41612. : (orient === 'horizontal' && inverse)
  41613. ? {scale: itemAlign === 'bottom' ? [-1, 1] : [1, 1], rotation: -Math.PI / 2}
  41614. : (orient === 'vertical' && !inverse)
  41615. ? {scale: itemAlign === 'left' ? [1, -1] : [-1, -1]}
  41616. : {scale: itemAlign === 'left' ? [1, 1] : [-1, 1]}
  41617. );
  41618. },
  41619. /**
  41620. * @private
  41621. */
  41622. _updateHandle: function (handleEnds, visualInRange) {
  41623. if (!this._useHandle) {
  41624. return;
  41625. }
  41626. var shapes = this._shapes;
  41627. var visualMapModel = this.visualMapModel;
  41628. var handleThumbs = shapes.handleThumbs;
  41629. var handleLabels = shapes.handleLabels;
  41630. each([0, 1], function (handleIndex) {
  41631. var handleThumb = handleThumbs[handleIndex];
  41632. handleThumb.setStyle('fill', visualInRange.handlesColor[handleIndex]);
  41633. handleThumb.position[1] = handleEnds[handleIndex];
  41634. // Update handle label position.
  41635. var textPoint = graphic.applyTransform(
  41636. shapes.handleLabelPoints[handleIndex],
  41637. graphic.getTransform(handleThumb, this.group)
  41638. );
  41639. handleLabels[handleIndex].setStyle({
  41640. x: textPoint[0],
  41641. y: textPoint[1],
  41642. text: visualMapModel.formatValueText(this._dataInterval[handleIndex]),
  41643. textVerticalAlign: 'middle',
  41644. textAlign: this._applyTransform(
  41645. this._orient === 'horizontal'
  41646. ? (handleIndex === 0 ? 'bottom' : 'top')
  41647. : 'left',
  41648. shapes.barGroup
  41649. )
  41650. });
  41651. }, this);
  41652. },
  41653. /**
  41654. * @private
  41655. */
  41656. _showIndicator: function (value, isRange) {
  41657. var visualMapModel = this.visualMapModel;
  41658. var dataExtent = visualMapModel.getExtent();
  41659. var itemSize = visualMapModel.itemSize;
  41660. var sizeExtent = [0, itemSize[1]];
  41661. var pos = linearMap(value, dataExtent, sizeExtent, true);
  41662. var shapes = this._shapes;
  41663. var indicator = shapes.indicator;
  41664. if (!indicator) {
  41665. return;
  41666. }
  41667. indicator.position[1] = pos;
  41668. indicator.attr('invisible', false);
  41669. indicator.setShape('points', createIndicatorPoints(isRange, pos, itemSize[1]));
  41670. var opts = {convertOpacityToAlpha: true};
  41671. var color = this.getControllerVisual(value, 'color', opts);
  41672. indicator.setStyle('fill', color);
  41673. // Update handle label position.
  41674. var textPoint = graphic.applyTransform(
  41675. shapes.indicatorLabelPoint,
  41676. graphic.getTransform(indicator, this.group)
  41677. );
  41678. var indicatorLabel = shapes.indicatorLabel;
  41679. indicatorLabel.attr('invisible', false);
  41680. var align = this._applyTransform('left', shapes.barGroup);
  41681. var orient = this._orient;
  41682. indicatorLabel.setStyle({
  41683. text: (isRange ? '≈' : '') + visualMapModel.formatValueText(value),
  41684. textVerticalAlign: orient === 'horizontal' ? align : 'middle',
  41685. textAlign: orient === 'horizontal' ? 'center' : align,
  41686. x: textPoint[0],
  41687. y: textPoint[1]
  41688. });
  41689. },
  41690. /**
  41691. * @private
  41692. */
  41693. _enableHoverLinkToSeries: function () {
  41694. this._shapes.barGroup
  41695. .on('mousemove', zrUtil.bind(onMouseOver, this))
  41696. .on('mouseout', zrUtil.bind(this._clearHoverLinkToSeries, this));
  41697. function onMouseOver(e) {
  41698. var visualMapModel = this.visualMapModel;
  41699. var itemSize = visualMapModel.itemSize;
  41700. if (!visualMapModel.option.hoverLink) {
  41701. return;
  41702. }
  41703. var pos = this._applyTransform(
  41704. [e.offsetX, e.offsetY], this._shapes.barGroup, true, true
  41705. );
  41706. var hoverRange = [pos[1] - HOVER_LINK_RANGE / 2, pos[1] + HOVER_LINK_RANGE / 2];
  41707. var sizeExtent = [0, itemSize[1]];
  41708. var dataExtent = visualMapModel.getExtent();
  41709. var valueRange = [
  41710. linearMap(hoverRange[0], sizeExtent, dataExtent, true),
  41711. linearMap(hoverRange[1], sizeExtent, dataExtent, true)
  41712. ];
  41713. // Do not show indicator when mouse is over handle,
  41714. // otherwise labels overlap, especially when dragging.
  41715. if (0 <= pos[0] && pos[0] <= itemSize[0]) {
  41716. this._showIndicator((valueRange[0] + valueRange[1]) / 2, true);
  41717. }
  41718. var oldBatch = convertDataIndicesToBatch(this._hoverLinkDataIndices);
  41719. this._hoverLinkDataIndices = visualMapModel.findTargetDataIndices(valueRange);
  41720. var newBatch = convertDataIndicesToBatch(this._hoverLinkDataIndices);
  41721. var resultBatches = helper.removeDuplicateBatch(oldBatch, newBatch);
  41722. this.api.dispatchAction({type: 'downplay', batch: resultBatches[0]});
  41723. this.api.dispatchAction({type: 'highlight', batch: resultBatches[1]});
  41724. }
  41725. },
  41726. /**
  41727. * @private
  41728. */
  41729. _enableHoverLinkFromSeries: function () {
  41730. var zr = this.api.getZr();
  41731. if (this.visualMapModel.option.hoverLink) {
  41732. zr.on('mouseover', this._hoverLinkFromSeriesMouseOver, this);
  41733. zr.on('mouseout', this._hideIndicator, this);
  41734. }
  41735. else {
  41736. this._clearHoverLinkFromSeries();
  41737. }
  41738. },
  41739. /**
  41740. * @private
  41741. */
  41742. _hoverLinkFromSeriesMouseOver: function (e) {
  41743. var el = e.target;
  41744. if (!el || el.dataIndex == null) {
  41745. return;
  41746. }
  41747. var dataModel = el.dataModel || this.ecModel.getSeriesByIndex(el.seriesIndex);
  41748. var data = dataModel.getData(el.dataType);
  41749. var dim = data.getDimension(this.visualMapModel.getDataDimension(data));
  41750. var value = data.get(dim, el.dataIndex, true);
  41751. this._showIndicator(value);
  41752. },
  41753. /**
  41754. * @private
  41755. */
  41756. _hideIndicator: function () {
  41757. var shapes = this._shapes;
  41758. shapes.indicator && shapes.indicator.attr('invisible', true);
  41759. shapes.indicatorLabel && shapes.indicatorLabel.attr('invisible', true);
  41760. },
  41761. /**
  41762. * @private
  41763. */
  41764. _clearHoverLinkToSeries: function () {
  41765. this._hideIndicator();
  41766. var indices = this._hoverLinkDataIndices;
  41767. this.api.dispatchAction({
  41768. type: 'downplay',
  41769. batch: convertDataIndicesToBatch(indices)
  41770. });
  41771. indices.length = 0;
  41772. },
  41773. /**
  41774. * @private
  41775. */
  41776. _clearHoverLinkFromSeries: function () {
  41777. this._hideIndicator();
  41778. var zr = this.api.getZr();
  41779. zr.off('mouseover', this._hoverLinkFromSeriesMouseOver);
  41780. zr.off('mouseout', this._hideIndicator);
  41781. },
  41782. /**
  41783. * @private
  41784. */
  41785. _applyTransform: function (vertex, element, inverse, global) {
  41786. var transform = graphic.getTransform(element, global ? null : this.group);
  41787. return graphic[
  41788. zrUtil.isArray(vertex) ? 'applyTransform' : 'transformDirection'
  41789. ](vertex, transform, inverse);
  41790. },
  41791. /**
  41792. * @override
  41793. */
  41794. dispose: function () {
  41795. this._clearHoverLinkFromSeries();
  41796. this._clearHoverLinkToSeries();
  41797. },
  41798. /**
  41799. * @override
  41800. */
  41801. remove: function () {
  41802. this._clearHoverLinkFromSeries();
  41803. this._clearHoverLinkToSeries();
  41804. }
  41805. });
  41806. function createPolygon(points, onDrift, cursor) {
  41807. return new graphic.Polygon({
  41808. shape: {points: points},
  41809. draggable: !!onDrift,
  41810. cursor: cursor,
  41811. drift: onDrift
  41812. });
  41813. }
  41814. function createHandlePoints(handleIndex, textSize) {
  41815. return handleIndex === 0
  41816. ? [[0, 0], [textSize, 0], [textSize, -textSize]]
  41817. : [[0, 0], [textSize, 0], [textSize, textSize]];
  41818. }
  41819. function createIndicatorPoints(isRange, pos, extentMax) {
  41820. return isRange
  41821. ? [ // indicate range
  41822. [0, -mathMin(HOVER_LINK_RANGE, mathMax(pos, 0))],
  41823. [HOVER_LINK_OUT, 0],
  41824. [0, mathMin(HOVER_LINK_RANGE, mathMax(extentMax - pos, 0))]
  41825. ]
  41826. : [ // indicate single value
  41827. [0, 0], [5, -5], [5, 5]
  41828. ];
  41829. }
  41830. module.exports = ContinuousVisualMapView;
  41831. /***/ },
  41832. /* 313 */
  41833. /***/ function(module, exports, __webpack_require__) {
  41834. var echarts = __webpack_require__(1);
  41835. var zrUtil = __webpack_require__(3);
  41836. var graphic = __webpack_require__(42);
  41837. var formatUtil = __webpack_require__(6);
  41838. var layout = __webpack_require__(21);
  41839. var VisualMapping = __webpack_require__(187);
  41840. module.exports = echarts.extendComponentView({
  41841. type: 'visualMap',
  41842. /**
  41843. * @readOnly
  41844. * @type {Object}
  41845. */
  41846. autoPositionValues: {left: 1, right: 1, top: 1, bottom: 1},
  41847. init: function (ecModel, api) {
  41848. /**
  41849. * @readOnly
  41850. * @type {module:echarts/model/Global}
  41851. */
  41852. this.ecModel = ecModel;
  41853. /**
  41854. * @readOnly
  41855. * @type {module:echarts/ExtensionAPI}
  41856. */
  41857. this.api = api;
  41858. /**
  41859. * @readOnly
  41860. * @type {module:echarts/component/visualMap/visualMapModel}
  41861. */
  41862. this.visualMapModel;
  41863. /**
  41864. * @private
  41865. * @type {Object}
  41866. */
  41867. this._updatableShapes = {};
  41868. },
  41869. /**
  41870. * @protected
  41871. */
  41872. render: function (visualMapModel, ecModel, api, payload) {
  41873. this.visualMapModel = visualMapModel;
  41874. if (visualMapModel.get('show') === false) {
  41875. this.group.removeAll();
  41876. return;
  41877. }
  41878. this.doRender.apply(this, arguments);
  41879. },
  41880. /**
  41881. * @protected
  41882. */
  41883. renderBackground: function (group) {
  41884. var visualMapModel = this.visualMapModel;
  41885. var padding = formatUtil.normalizeCssArray(visualMapModel.get('padding') || 0);
  41886. var rect = group.getBoundingRect();
  41887. group.add(new graphic.Rect({
  41888. z2: -1, // Lay background rect on the lowest layer.
  41889. silent: true,
  41890. shape: {
  41891. x: rect.x - padding[3],
  41892. y: rect.y - padding[0],
  41893. width: rect.width + padding[3] + padding[1],
  41894. height: rect.height + padding[0] + padding[2]
  41895. },
  41896. style: {
  41897. fill: visualMapModel.get('backgroundColor'),
  41898. stroke: visualMapModel.get('borderColor'),
  41899. lineWidth: visualMapModel.get('borderWidth')
  41900. }
  41901. }));
  41902. },
  41903. /**
  41904. * @protected
  41905. * @param {number} targetValue
  41906. * @param {string=} visualCluster Only can be 'color' 'opacity' 'symbol' 'symbolSize'
  41907. * @param {Object} [opts]
  41908. * @param {string=} [opts.forceState] Specify state, instead of using getValueState method.
  41909. * @param {string=} [opts.convertOpacityToAlpha=false] For color gradient in controller widget.
  41910. * @return {*} Visual value.
  41911. */
  41912. getControllerVisual: function (targetValue, visualCluster, opts) {
  41913. opts = opts || {};
  41914. var forceState = opts.forceState;
  41915. var visualMapModel = this.visualMapModel;
  41916. var visualObj = {};
  41917. // Default values.
  41918. if (visualCluster === 'symbol') {
  41919. visualObj.symbol = visualMapModel.get('itemSymbol');
  41920. }
  41921. if (visualCluster === 'color') {
  41922. var defaultColor = visualMapModel.get('contentColor');
  41923. visualObj.color = defaultColor;
  41924. }
  41925. function getter(key) {
  41926. return visualObj[key];
  41927. }
  41928. function setter(key, value) {
  41929. visualObj[key] = value;
  41930. }
  41931. var mappings = visualMapModel.controllerVisuals[
  41932. forceState || visualMapModel.getValueState(targetValue)
  41933. ];
  41934. var visualTypes = VisualMapping.prepareVisualTypes(mappings);
  41935. zrUtil.each(visualTypes, function (type) {
  41936. var visualMapping = mappings[type];
  41937. if (opts.convertOpacityToAlpha && type === 'opacity') {
  41938. type = 'colorAlpha';
  41939. visualMapping = mappings.__alphaForOpacity;
  41940. }
  41941. if (VisualMapping.dependsOn(type, visualCluster)) {
  41942. visualMapping && visualMapping.applyVisual(
  41943. targetValue, getter, setter
  41944. );
  41945. }
  41946. });
  41947. return visualObj[visualCluster];
  41948. },
  41949. /**
  41950. * @protected
  41951. */
  41952. positionGroup: function (group) {
  41953. var model = this.visualMapModel;
  41954. var api = this.api;
  41955. layout.positionGroup(
  41956. group,
  41957. model.getBoxLayoutParams(),
  41958. {width: api.getWidth(), height: api.getHeight()}
  41959. );
  41960. },
  41961. /**
  41962. * @protected
  41963. * @abstract
  41964. */
  41965. doRender: zrUtil.noop
  41966. });
  41967. /***/ },
  41968. /* 314 */
  41969. /***/ function(module, exports, __webpack_require__) {
  41970. var layout = __webpack_require__(21);
  41971. var zrUtil = __webpack_require__(3);
  41972. var DataDiffer = __webpack_require__(96);
  41973. var helper = {
  41974. /**
  41975. * @param {module:echarts/component/visualMap/VisualMapModel} visualMapModel\
  41976. * @param {module:echarts/ExtensionAPI} api
  41977. * @param {Array.<number>} itemSize always [short, long]
  41978. * @return {string} 'left' or 'right' or 'top' or 'bottom'
  41979. */
  41980. getItemAlign: function (visualMapModel, api, itemSize) {
  41981. var modelOption = visualMapModel.option;
  41982. var itemAlign = modelOption.align;
  41983. if (itemAlign != null && itemAlign !== 'auto') {
  41984. return itemAlign;
  41985. }
  41986. // Auto decision align.
  41987. var ecSize = {width: api.getWidth(), height: api.getHeight()};
  41988. var realIndex = modelOption.orient === 'horizontal' ? 1 : 0;
  41989. var paramsSet = [
  41990. ['left', 'right', 'width'],
  41991. ['top', 'bottom', 'height']
  41992. ];
  41993. var reals = paramsSet[realIndex];
  41994. var fakeValue = [0, null, 10];
  41995. var layoutInput = {};
  41996. for (var i = 0; i < 3; i++) {
  41997. layoutInput[paramsSet[1 - realIndex][i]] = fakeValue[i];
  41998. layoutInput[reals[i]] = i === 2 ? itemSize[0] : modelOption[reals[i]];
  41999. }
  42000. var rParam = [['x', 'width', 3], ['y', 'height', 0]][realIndex];
  42001. var rect = layout.getLayoutRect(layoutInput, ecSize, modelOption.padding);
  42002. return reals[
  42003. (rect.margin[rParam[2]] || 0) + rect[rParam[0]] + rect[rParam[1]] * 0.5
  42004. < ecSize[rParam[1]] * 0.5 ? 0 : 1
  42005. ];
  42006. },
  42007. convertDataIndicesToBatch: function (dataIndicesBySeries) {
  42008. var batch = [];
  42009. zrUtil.each(dataIndicesBySeries, function (item) {
  42010. zrUtil.each(item.dataIndices, function (dataIndex) {
  42011. batch.push({seriesId: item.seriesId, dataIndex: dataIndex});
  42012. });
  42013. });
  42014. return batch;
  42015. },
  42016. removeDuplicateBatch: function (batchA, batchB) {
  42017. var result = [[], []];
  42018. (new DataDiffer(batchA, batchB, getKey, getKey))
  42019. .add(add)
  42020. .update(zrUtil.noop)
  42021. .remove(remove)
  42022. .execute();
  42023. function getKey(item) {
  42024. return item.seriesId + '-' + item.dataIndex;
  42025. }
  42026. function add(index) {
  42027. result[1].push(batchB[index]);
  42028. }
  42029. function remove(index) {
  42030. result[0].push(batchA[index]);
  42031. }
  42032. return result;
  42033. }
  42034. };
  42035. module.exports = helper;
  42036. /***/ },
  42037. /* 315 */
  42038. /***/ function(module, exports, __webpack_require__) {
  42039. /**
  42040. * @file Data range action
  42041. */
  42042. var echarts = __webpack_require__(1);
  42043. var actionInfo = {
  42044. type: 'selectDataRange',
  42045. event: 'dataRangeSelected',
  42046. // FIXME use updateView appears wrong
  42047. update: 'update'
  42048. };
  42049. echarts.registerAction(actionInfo, function (payload, ecModel) {
  42050. ecModel.eachComponent({mainType: 'visualMap', query: payload}, function (model) {
  42051. model.setSelected(payload.selected);
  42052. });
  42053. });
  42054. /***/ },
  42055. /* 316 */
  42056. /***/ function(module, exports, __webpack_require__) {
  42057. /**
  42058. * DataZoom component entry
  42059. */
  42060. __webpack_require__(1).registerPreprocessor(
  42061. __webpack_require__(306)
  42062. );
  42063. __webpack_require__(307);
  42064. __webpack_require__(308);
  42065. __webpack_require__(317);
  42066. __webpack_require__(318);
  42067. __webpack_require__(315);
  42068. /***/ },
  42069. /* 317 */
  42070. /***/ function(module, exports, __webpack_require__) {
  42071. var VisualMapModel = __webpack_require__(310);
  42072. var zrUtil = __webpack_require__(3);
  42073. var VisualMapping = __webpack_require__(187);
  42074. var PiecewiseModel = VisualMapModel.extend({
  42075. type: 'visualMap.piecewise',
  42076. /**
  42077. * Order Rule:
  42078. *
  42079. * option.categories / option.pieces / option.text / option.selected:
  42080. * If !option.inverse,
  42081. * Order when vertical: ['top', ..., 'bottom'].
  42082. * Order when horizontal: ['left', ..., 'right'].
  42083. * If option.inverse, the meaning of
  42084. * the order should be reversed.
  42085. *
  42086. * this._pieceList:
  42087. * The order is always [low, ..., high].
  42088. *
  42089. * Mapping from location to low-high:
  42090. * If !option.inverse
  42091. * When vertical, top is high.
  42092. * When horizontal, right is high.
  42093. * If option.inverse, reverse.
  42094. */
  42095. /**
  42096. * @protected
  42097. */
  42098. defaultOption: {
  42099. selected: null, // Object. If not specified, means selected.
  42100. // When pieces and splitNumber: {'0': true, '5': true}
  42101. // When categories: {'cate1': false, 'cate3': true}
  42102. // When selected === false, means all unselected.
  42103. align: 'auto', // 'auto', 'left', 'right'
  42104. itemWidth: 20, // When put the controller vertically, it is the length of
  42105. // horizontal side of each item. Otherwise, vertical side.
  42106. itemHeight: 14, // When put the controller vertically, it is the length of
  42107. // vertical side of each item. Otherwise, horizontal side.
  42108. itemSymbol: 'roundRect',
  42109. pieceList: null, // Each item is Object, with some of those attrs:
  42110. // {min, max, value, color, colorSaturation, colorAlpha, opacity,
  42111. // symbol, symbolSize}, which customize the range or visual
  42112. // coding of the certain piece. Besides, see "Order Rule".
  42113. categories: null, // category names, like: ['some1', 'some2', 'some3'].
  42114. // Attr min/max are ignored when categories set. See "Order Rule"
  42115. splitNumber: 5, // If set to 5, auto split five pieces equally.
  42116. // If set to 0 and component type not set, component type will be
  42117. // determined as "continuous". (It is less reasonable but for ec2
  42118. // compatibility, see echarts/component/visualMap/typeDefaulter)
  42119. selectedMode: 'multiple', // Can be 'multiple' or 'single'.
  42120. itemGap: 10, // The gap between two items, in px.
  42121. hoverLink: true // Enable hover highlight.
  42122. },
  42123. /**
  42124. * @override
  42125. */
  42126. doMergeOption: function (newOption, isInit) {
  42127. PiecewiseModel.superApply(this, 'doMergeOption', arguments);
  42128. /**
  42129. * The order is always [low, ..., high].
  42130. * [{text: string, interval: Array.<number>}, ...]
  42131. * @private
  42132. * @type {Array.<Object>}
  42133. */
  42134. this._pieceList = [];
  42135. this.resetTargetSeries(newOption, isInit);
  42136. this.resetExtent();
  42137. /**
  42138. * 'pieces', 'categories', 'splitNumber'
  42139. * @type {string}
  42140. */
  42141. var mode = this._mode = this._decideMode();
  42142. resetMethods[this._mode].call(this);
  42143. this._resetSelected(newOption, isInit);
  42144. var categories = this.option.categories;
  42145. this.resetVisual(function (mappingOption, state) {
  42146. if (mode === 'categories') {
  42147. mappingOption.mappingMethod = 'category';
  42148. mappingOption.categories = zrUtil.clone(categories);
  42149. }
  42150. else {
  42151. mappingOption.mappingMethod = 'piecewise';
  42152. mappingOption.pieceList = zrUtil.map(this._pieceList, function (piece) {
  42153. var piece = zrUtil.clone(piece);
  42154. if (state !== 'inRange') {
  42155. piece.visual = null;
  42156. }
  42157. return piece;
  42158. });
  42159. }
  42160. });
  42161. },
  42162. _resetSelected: function (newOption, isInit) {
  42163. var thisOption = this.option;
  42164. var pieceList = this._pieceList;
  42165. // Selected do not merge but all override.
  42166. var selected = (isInit ? thisOption : newOption).selected || {};
  42167. thisOption.selected = selected;
  42168. // Consider 'not specified' means true.
  42169. zrUtil.each(pieceList, function (piece, index) {
  42170. var key = this.getSelectedMapKey(piece);
  42171. if (!(key in selected)) {
  42172. selected[key] = true;
  42173. }
  42174. }, this);
  42175. if (thisOption.selectedMode === 'single') {
  42176. // Ensure there is only one selected.
  42177. var hasSel = false;
  42178. zrUtil.each(pieceList, function (piece, index) {
  42179. var key = this.getSelectedMapKey(piece);
  42180. if (selected[key]) {
  42181. hasSel
  42182. ? (selected[key] = false)
  42183. : (hasSel = true);
  42184. }
  42185. }, this);
  42186. }
  42187. // thisOption.selectedMode === 'multiple', default: all selected.
  42188. },
  42189. /**
  42190. * @public
  42191. */
  42192. getSelectedMapKey: function (piece) {
  42193. return this._mode === 'categories'
  42194. ? piece.value + '' : piece.index + '';
  42195. },
  42196. /**
  42197. * @public
  42198. */
  42199. getPieceList: function () {
  42200. return this._pieceList;
  42201. },
  42202. /**
  42203. * @private
  42204. * @return {string}
  42205. */
  42206. _decideMode: function () {
  42207. var option = this.option;
  42208. return option.pieces && option.pieces.length > 0
  42209. ? 'pieces'
  42210. : this.option.categories
  42211. ? 'categories'
  42212. : 'splitNumber';
  42213. },
  42214. /**
  42215. * @public
  42216. * @override
  42217. */
  42218. setSelected: function (selected) {
  42219. this.option.selected = zrUtil.clone(selected);
  42220. },
  42221. /**
  42222. * @public
  42223. * @override
  42224. */
  42225. getValueState: function (value) {
  42226. var index = VisualMapping.findPieceIndex(value, this._pieceList);
  42227. return index != null
  42228. ? (this.option.selected[this.getSelectedMapKey(this._pieceList[index])]
  42229. ? 'inRange' : 'outOfRange'
  42230. )
  42231. : 'outOfRange';
  42232. },
  42233. /**
  42234. * @public
  42235. * @params {number} pieceIndex piece index in visualMapModel.getPieceList()
  42236. * @return {Array.<Object>} [{seriesId, dataIndices: <Array.<number>>}, ...]
  42237. */
  42238. findTargetDataIndices: function (pieceIndex) {
  42239. var result = [];
  42240. this.eachTargetSeries(function (seriesModel) {
  42241. var dataIndices = [];
  42242. var data = seriesModel.getData();
  42243. data.each(this.getDataDimension(data), function (value, dataIndex) {
  42244. // Should always base on model pieceList, because it is order sensitive.
  42245. var pIdx = VisualMapping.findPieceIndex(value, this._pieceList);
  42246. pIdx === pieceIndex && dataIndices.push(dataIndex);
  42247. }, true, this);
  42248. result.push({seriesId: seriesModel.id, dataIndices: dataIndices});
  42249. }, this);
  42250. return result;
  42251. }
  42252. });
  42253. /**
  42254. * Key is this._mode
  42255. * @type {Object}
  42256. * @this {module:echarts/component/viusalMap/PiecewiseMode}
  42257. */
  42258. var resetMethods = {
  42259. splitNumber: function () {
  42260. var thisOption = this.option;
  42261. var precision = thisOption.precision;
  42262. var dataExtent = this.getExtent();
  42263. var splitNumber = thisOption.splitNumber;
  42264. splitNumber = Math.max(parseInt(splitNumber, 10), 1);
  42265. thisOption.splitNumber = splitNumber;
  42266. var splitStep = (dataExtent[1] - dataExtent[0]) / splitNumber;
  42267. // Precision auto-adaption
  42268. while (+splitStep.toFixed(precision) !== splitStep && precision < 5) {
  42269. precision++;
  42270. }
  42271. thisOption.precision = precision;
  42272. splitStep = +splitStep.toFixed(precision);
  42273. for (var i = 0, curr = dataExtent[0]; i < splitNumber; i++, curr += splitStep) {
  42274. var max = i === splitNumber - 1 ? dataExtent[1] : (curr + splitStep);
  42275. this._pieceList.push({
  42276. text: this.formatValueText([curr, max]),
  42277. index: i,
  42278. interval: [curr, max]
  42279. });
  42280. }
  42281. },
  42282. categories: function () {
  42283. var thisOption = this.option;
  42284. zrUtil.each(thisOption.categories, function (cate) {
  42285. // FIXME category模式也使用pieceList,但在visualMapping中不是使用pieceList。
  42286. // 是否改一致。
  42287. this._pieceList.push({
  42288. text: this.formatValueText(cate, true),
  42289. value: cate
  42290. });
  42291. }, this);
  42292. // See "Order Rule".
  42293. normalizeReverse(thisOption, this._pieceList);
  42294. },
  42295. pieces: function () {
  42296. var thisOption = this.option;
  42297. zrUtil.each(thisOption.pieces, function (pieceListItem, index) {
  42298. if (!zrUtil.isObject(pieceListItem)) {
  42299. pieceListItem = {value: pieceListItem};
  42300. }
  42301. var item = {text: '', index: index};
  42302. var hasLabel;
  42303. if (pieceListItem.label != null) {
  42304. item.text = pieceListItem.label;
  42305. hasLabel = true;
  42306. }
  42307. if (pieceListItem.hasOwnProperty('value')) {
  42308. item.value = pieceListItem.value;
  42309. if (!hasLabel) {
  42310. item.text = this.formatValueText(item.value);
  42311. }
  42312. }
  42313. else {
  42314. var min = pieceListItem.min;
  42315. var max = pieceListItem.max;
  42316. min == null && (min = -Infinity);
  42317. max == null && (max = Infinity);
  42318. if (min === max) {
  42319. // Consider: [{min: 5, max: 5, visual: {...}}, {min: 0, max: 5}],
  42320. // we use value to lift the priority when min === max
  42321. item.value = min;
  42322. }
  42323. item.interval = [min, max];
  42324. if (!hasLabel) {
  42325. item.text = this.formatValueText([min, max]);
  42326. }
  42327. }
  42328. item.visual = VisualMapping.retrieveVisuals(pieceListItem);
  42329. this._pieceList.push(item);
  42330. }, this);
  42331. // See "Order Rule".
  42332. normalizeReverse(thisOption, this._pieceList);
  42333. }
  42334. };
  42335. function normalizeReverse(thisOption, arr) {
  42336. var inverse = thisOption.inverse;
  42337. if (thisOption.orient === 'vertical' ? !inverse : inverse) {
  42338. arr.reverse();
  42339. }
  42340. }
  42341. module.exports = PiecewiseModel;
  42342. /***/ },
  42343. /* 318 */
  42344. /***/ function(module, exports, __webpack_require__) {
  42345. var VisualMapView = __webpack_require__(313);
  42346. var zrUtil = __webpack_require__(3);
  42347. var graphic = __webpack_require__(42);
  42348. var symbolCreators = __webpack_require__(101);
  42349. var layout = __webpack_require__(21);
  42350. var helper = __webpack_require__(314);
  42351. var PiecewiseVisualMapView = VisualMapView.extend({
  42352. type: 'visualMap.piecewise',
  42353. /**
  42354. * @protected
  42355. * @override
  42356. */
  42357. doRender: function () {
  42358. var thisGroup = this.group;
  42359. thisGroup.removeAll();
  42360. var visualMapModel = this.visualMapModel;
  42361. var textGap = visualMapModel.get('textGap');
  42362. var textStyleModel = visualMapModel.textStyleModel;
  42363. var textFont = textStyleModel.getFont();
  42364. var textFill = textStyleModel.getTextColor();
  42365. var itemAlign = this._getItemAlign();
  42366. var itemSize = visualMapModel.itemSize;
  42367. var viewData = this._getViewData();
  42368. var showLabel = !viewData.endsText;
  42369. var showEndsText = !showLabel;
  42370. showEndsText && this._renderEndsText(thisGroup, viewData.endsText[0], itemSize);
  42371. zrUtil.each(viewData.viewPieceList, renderItem, this);
  42372. showEndsText && this._renderEndsText(thisGroup, viewData.endsText[1], itemSize);
  42373. layout.box(
  42374. visualMapModel.get('orient'), thisGroup, visualMapModel.get('itemGap')
  42375. );
  42376. this.renderBackground(thisGroup);
  42377. this.positionGroup(thisGroup);
  42378. function renderItem(item) {
  42379. var piece = item.piece;
  42380. var itemGroup = new graphic.Group();
  42381. itemGroup.onclick = zrUtil.bind(this._onItemClick, this, piece);
  42382. this._enableHoverLink(itemGroup, item.indexInModelPieceList);
  42383. var representValue = this._getRepresentValue(piece);
  42384. this._createItemSymbol(
  42385. itemGroup, representValue, [0, 0, itemSize[0], itemSize[1]]
  42386. );
  42387. if (showLabel) {
  42388. var visualState = this.visualMapModel.getValueState(representValue);
  42389. itemGroup.add(new graphic.Text({
  42390. style: {
  42391. x: itemAlign === 'right' ? -textGap : itemSize[0] + textGap,
  42392. y: itemSize[1] / 2,
  42393. text: piece.text,
  42394. textVerticalAlign: 'middle',
  42395. textAlign: itemAlign,
  42396. textFont: textFont,
  42397. fill: textFill,
  42398. opacity: visualState === 'outOfRange' ? 0.5 : 1
  42399. }
  42400. }));
  42401. }
  42402. thisGroup.add(itemGroup);
  42403. }
  42404. },
  42405. /**
  42406. * @private
  42407. */
  42408. _enableHoverLink: function (itemGroup, pieceIndex) {
  42409. itemGroup
  42410. .on('mouseover', zrUtil.bind(onHoverLink, this, 'highlight'))
  42411. .on('mouseout', zrUtil.bind(onHoverLink, this, 'downplay'));
  42412. function onHoverLink(method) {
  42413. var visualMapModel = this.visualMapModel;
  42414. visualMapModel.option.hoverLink && this.api.dispatchAction({
  42415. type: method,
  42416. batch: helper.convertDataIndicesToBatch(
  42417. visualMapModel.findTargetDataIndices(pieceIndex)
  42418. )
  42419. });
  42420. }
  42421. },
  42422. /**
  42423. * @private
  42424. */
  42425. _getItemAlign: function () {
  42426. var visualMapModel = this.visualMapModel;
  42427. var modelOption = visualMapModel.option;
  42428. if (modelOption.orient === 'vertical') {
  42429. return helper.getItemAlign(
  42430. visualMapModel, this.api, visualMapModel.itemSize
  42431. );
  42432. }
  42433. else { // horizontal, most case left unless specifying right.
  42434. var align = modelOption.align;
  42435. if (!align || align === 'auto') {
  42436. align = 'left';
  42437. }
  42438. return align;
  42439. }
  42440. },
  42441. /**
  42442. * @private
  42443. */
  42444. _renderEndsText: function (group, text, itemSize) {
  42445. if (!text) {
  42446. return;
  42447. }
  42448. var itemGroup = new graphic.Group();
  42449. var textStyleModel = this.visualMapModel.textStyleModel;
  42450. itemGroup.add(new graphic.Text({
  42451. style: {
  42452. x: itemSize[0] / 2,
  42453. y: itemSize[1] / 2,
  42454. textVerticalAlign: 'middle',
  42455. textAlign: 'center',
  42456. text: text,
  42457. textFont: textStyleModel.getFont(),
  42458. fill: textStyleModel.getTextColor()
  42459. }
  42460. }));
  42461. group.add(itemGroup);
  42462. },
  42463. /**
  42464. * @private
  42465. * @return {Object} {peiceList, endsText} The order is the same as screen pixel order.
  42466. */
  42467. _getViewData: function () {
  42468. var visualMapModel = this.visualMapModel;
  42469. var viewPieceList = zrUtil.map(visualMapModel.getPieceList(), function (piece, index) {
  42470. return {piece: piece, indexInModelPieceList: index};
  42471. });
  42472. var endsText = visualMapModel.get('text');
  42473. // Consider orient and inverse.
  42474. var orient = visualMapModel.get('orient');
  42475. var inverse = visualMapModel.get('inverse');
  42476. // Order of model pieceList is always [low, ..., high]
  42477. if (orient === 'horizontal' ? inverse : !inverse) {
  42478. viewPieceList.reverse();
  42479. }
  42480. // Origin order of endsText is [high, low]
  42481. else if (endsText) {
  42482. endsText = endsText.slice().reverse();
  42483. }
  42484. return {viewPieceList: viewPieceList, endsText: endsText};
  42485. },
  42486. /**
  42487. * @private
  42488. */
  42489. _getRepresentValue: function (piece) {
  42490. var representValue;
  42491. if (this.visualMapModel.isCategory()) {
  42492. representValue = piece.value;
  42493. }
  42494. else {
  42495. if (piece.value != null) {
  42496. representValue = piece.value;
  42497. }
  42498. else {
  42499. var pieceInterval = piece.interval || [];
  42500. representValue = (pieceInterval[0] + pieceInterval[1]) / 2;
  42501. }
  42502. }
  42503. return representValue;
  42504. },
  42505. /**
  42506. * @private
  42507. */
  42508. _createItemSymbol: function (group, representValue, shapeParam) {
  42509. group.add(symbolCreators.createSymbol(
  42510. this.getControllerVisual(representValue, 'symbol'),
  42511. shapeParam[0], shapeParam[1], shapeParam[2], shapeParam[3],
  42512. this.getControllerVisual(representValue, 'color')
  42513. ));
  42514. },
  42515. /**
  42516. * @private
  42517. */
  42518. _onItemClick: function (piece) {
  42519. var visualMapModel = this.visualMapModel;
  42520. var option = visualMapModel.option;
  42521. var selected = zrUtil.clone(option.selected);
  42522. var newKey = visualMapModel.getSelectedMapKey(piece);
  42523. if (option.selectedMode === 'single') {
  42524. selected[newKey] = true;
  42525. zrUtil.each(selected, function (o, key) {
  42526. selected[key] = key === newKey;
  42527. });
  42528. }
  42529. else {
  42530. selected[newKey] = !selected[newKey];
  42531. }
  42532. this.api.dispatchAction({
  42533. type: 'selectDataRange',
  42534. from: this.uid,
  42535. visualMapId: this.visualMapModel.id,
  42536. selected: selected
  42537. });
  42538. }
  42539. });
  42540. module.exports = PiecewiseVisualMapView;
  42541. /***/ },
  42542. /* 319 */
  42543. /***/ function(module, exports, __webpack_require__) {
  42544. // HINT Markpoint can't be used too much
  42545. __webpack_require__(320);
  42546. __webpack_require__(321);
  42547. __webpack_require__(1).registerPreprocessor(function (opt) {
  42548. // Make sure markPoint component is enabled
  42549. opt.markPoint = opt.markPoint || {};
  42550. });
  42551. /***/ },
  42552. /* 320 */
  42553. /***/ function(module, exports, __webpack_require__) {
  42554. var modelUtil = __webpack_require__(5);
  42555. var zrUtil = __webpack_require__(3);
  42556. function fillLabel(opt) {
  42557. modelUtil.defaultEmphasis(
  42558. opt.label,
  42559. modelUtil.LABEL_OPTIONS
  42560. );
  42561. }
  42562. var MarkPointModel = __webpack_require__(1).extendComponentModel({
  42563. type: 'markPoint',
  42564. dependencies: ['series', 'grid', 'polar'],
  42565. /**
  42566. * @overrite
  42567. */
  42568. init: function (option, parentModel, ecModel, extraOpt) {
  42569. this.mergeDefaultAndTheme(option, ecModel);
  42570. this.mergeOption(option, ecModel, extraOpt.createdBySelf, true);
  42571. },
  42572. mergeOption: function (newOpt, ecModel, createdBySelf, isInit) {
  42573. if (!createdBySelf) {
  42574. ecModel.eachSeries(function (seriesModel) {
  42575. var markPointOpt = seriesModel.get('markPoint');
  42576. var mpModel = seriesModel.markPointModel;
  42577. if (!markPointOpt || !markPointOpt.data) {
  42578. seriesModel.markPointModel = null;
  42579. return;
  42580. }
  42581. if (!mpModel) {
  42582. if (isInit) {
  42583. // Default label emphasis `position` and `show`
  42584. fillLabel(markPointOpt);
  42585. }
  42586. zrUtil.each(markPointOpt.data, fillLabel);
  42587. var opt = {
  42588. mainType: 'markPoint',
  42589. // Use the same series index and name
  42590. seriesIndex: seriesModel.seriesIndex,
  42591. name: seriesModel.name,
  42592. createdBySelf: true
  42593. };
  42594. mpModel = new MarkPointModel(
  42595. markPointOpt, this, ecModel, opt
  42596. );
  42597. }
  42598. else {
  42599. mpModel.mergeOption(markPointOpt, ecModel, true);
  42600. }
  42601. seriesModel.markPointModel = mpModel;
  42602. }, this);
  42603. }
  42604. },
  42605. defaultOption: {
  42606. zlevel: 0,
  42607. z: 5,
  42608. symbol: 'pin',
  42609. symbolSize: 50,
  42610. //symbolRotate: 0,
  42611. //symbolOffset: [0, 0]
  42612. tooltip: {
  42613. trigger: 'item'
  42614. },
  42615. label: {
  42616. normal: {
  42617. show: true,
  42618. position: 'inside'
  42619. },
  42620. emphasis: {
  42621. show: true
  42622. }
  42623. },
  42624. itemStyle: {
  42625. normal: {
  42626. borderWidth: 2
  42627. }
  42628. }
  42629. }
  42630. });
  42631. module.exports = MarkPointModel;
  42632. /***/ },
  42633. /* 321 */
  42634. /***/ function(module, exports, __webpack_require__) {
  42635. var SymbolDraw = __webpack_require__(99);
  42636. var zrUtil = __webpack_require__(3);
  42637. var formatUtil = __webpack_require__(6);
  42638. var modelUtil = __webpack_require__(5);
  42639. var numberUtil = __webpack_require__(7);
  42640. var addCommas = formatUtil.addCommas;
  42641. var encodeHTML = formatUtil.encodeHTML;
  42642. var List = __webpack_require__(95);
  42643. var markerHelper = __webpack_require__(322);
  42644. function updateMarkerLayout(mpData, seriesModel, api) {
  42645. var coordSys = seriesModel.coordinateSystem;
  42646. mpData.each(function (idx) {
  42647. var itemModel = mpData.getItemModel(idx);
  42648. var point;
  42649. var xPx = itemModel.getShallow('x');
  42650. var yPx = itemModel.getShallow('y');
  42651. if (xPx != null && yPx != null) {
  42652. point = [
  42653. numberUtil.parsePercent(xPx, api.getWidth()),
  42654. numberUtil.parsePercent(yPx, api.getHeight())
  42655. ];
  42656. }
  42657. // Chart like bar may have there own marker positioning logic
  42658. else if (seriesModel.getMarkerPosition) {
  42659. // Use the getMarkerPoisition
  42660. point = seriesModel.getMarkerPosition(
  42661. mpData.getValues(mpData.dimensions, idx)
  42662. );
  42663. }
  42664. else if (coordSys) {
  42665. var x = mpData.get(coordSys.dimensions[0], idx);
  42666. var y = mpData.get(coordSys.dimensions[1], idx);
  42667. point = coordSys.dataToPoint([x, y]);
  42668. }
  42669. mpData.setItemLayout(idx, point);
  42670. });
  42671. }
  42672. // FIXME
  42673. var markPointFormatMixin = {
  42674. formatTooltip: function (dataIndex) {
  42675. var data = this.getData();
  42676. var value = this.getRawValue(dataIndex);
  42677. var formattedValue = zrUtil.isArray(value)
  42678. ? zrUtil.map(value, addCommas).join(', ') : addCommas(value);
  42679. var name = data.getName(dataIndex);
  42680. return this.name + '<br />'
  42681. + ((name ? encodeHTML(name) + ' : ' : '') + formattedValue);
  42682. },
  42683. getData: function () {
  42684. return this._data;
  42685. },
  42686. setData: function (data) {
  42687. this._data = data;
  42688. }
  42689. };
  42690. zrUtil.defaults(markPointFormatMixin, modelUtil.dataFormatMixin);
  42691. __webpack_require__(1).extendComponentView({
  42692. type: 'markPoint',
  42693. init: function () {
  42694. this._symbolDrawMap = {};
  42695. },
  42696. render: function (markPointModel, ecModel, api) {
  42697. var symbolDrawMap = this._symbolDrawMap;
  42698. for (var name in symbolDrawMap) {
  42699. symbolDrawMap[name].__keep = false;
  42700. }
  42701. ecModel.eachSeries(function (seriesModel) {
  42702. var mpModel = seriesModel.markPointModel;
  42703. mpModel && this._renderSeriesMP(seriesModel, mpModel, api);
  42704. }, this);
  42705. for (var name in symbolDrawMap) {
  42706. if (!symbolDrawMap[name].__keep) {
  42707. symbolDrawMap[name].remove();
  42708. this.group.remove(symbolDrawMap[name].group);
  42709. }
  42710. }
  42711. },
  42712. updateLayout: function (markPointModel, ecModel, api) {
  42713. ecModel.eachSeries(function (seriesModel) {
  42714. var mpModel = seriesModel.markPointModel;
  42715. if (mpModel) {
  42716. updateMarkerLayout(mpModel.getData(), seriesModel, api);
  42717. this._symbolDrawMap[seriesModel.name].updateLayout(mpModel);
  42718. }
  42719. }, this);
  42720. },
  42721. _renderSeriesMP: function (seriesModel, mpModel, api) {
  42722. var coordSys = seriesModel.coordinateSystem;
  42723. var seriesName = seriesModel.name;
  42724. var seriesData = seriesModel.getData();
  42725. var symbolDrawMap = this._symbolDrawMap;
  42726. var symbolDraw = symbolDrawMap[seriesName];
  42727. if (!symbolDraw) {
  42728. symbolDraw = symbolDrawMap[seriesName] = new SymbolDraw();
  42729. }
  42730. var mpData = createList(coordSys, seriesModel, mpModel);
  42731. // FIXME
  42732. zrUtil.mixin(mpModel, markPointFormatMixin);
  42733. mpModel.setData(mpData);
  42734. updateMarkerLayout(mpModel.getData(), seriesModel, api);
  42735. mpData.each(function (idx) {
  42736. var itemModel = mpData.getItemModel(idx);
  42737. var symbolSize = itemModel.getShallow('symbolSize');
  42738. if (typeof symbolSize === 'function') {
  42739. // FIXME 这里不兼容 ECharts 2.x,2.x 貌似参数是整个数据?
  42740. symbolSize = symbolSize(
  42741. mpModel.getRawValue(idx), mpModel.getDataParams(idx)
  42742. );
  42743. }
  42744. mpData.setItemVisual(idx, {
  42745. symbolSize: symbolSize,
  42746. color: itemModel.get('itemStyle.normal.color')
  42747. || seriesData.getVisual('color'),
  42748. symbol: itemModel.getShallow('symbol')
  42749. });
  42750. });
  42751. // TODO Text are wrong
  42752. symbolDraw.updateData(mpData);
  42753. this.group.add(symbolDraw.group);
  42754. // Set host model for tooltip
  42755. // FIXME
  42756. mpData.eachItemGraphicEl(function (el) {
  42757. el.traverse(function (child) {
  42758. child.dataModel = mpModel;
  42759. });
  42760. });
  42761. symbolDraw.__keep = true;
  42762. }
  42763. });
  42764. /**
  42765. * @inner
  42766. * @param {module:echarts/coord/*} [coordSys]
  42767. * @param {module:echarts/model/Series} seriesModel
  42768. * @param {module:echarts/model/Model} mpModel
  42769. */
  42770. function createList(coordSys, seriesModel, mpModel) {
  42771. var coordDimsInfos;
  42772. if (coordSys) {
  42773. coordDimsInfos = zrUtil.map(coordSys && coordSys.dimensions, function (coordDim) {
  42774. var info = seriesModel.getData().getDimensionInfo(
  42775. seriesModel.coordDimToDataDim(coordDim)[0]
  42776. ) || {}; // In map series data don't have lng and lat dimension. Fallback to same with coordSys
  42777. info.name = coordDim;
  42778. return info;
  42779. });
  42780. }
  42781. else {
  42782. coordDimsInfos =[{
  42783. name: 'value',
  42784. type: 'float'
  42785. }];
  42786. }
  42787. var mpData = new List(coordDimsInfos, mpModel);
  42788. var dataOpt = zrUtil.map(mpModel.get('data'), zrUtil.curry(
  42789. markerHelper.dataTransform, seriesModel
  42790. ));
  42791. if (coordSys) {
  42792. dataOpt = zrUtil.filter(
  42793. dataOpt, zrUtil.curry(markerHelper.dataFilter, coordSys)
  42794. );
  42795. }
  42796. mpData.initData(dataOpt, null,
  42797. coordSys ? markerHelper.dimValueGetter : function (item) {
  42798. return item.value;
  42799. }
  42800. );
  42801. return mpData;
  42802. }
  42803. /***/ },
  42804. /* 322 */
  42805. /***/ function(module, exports, __webpack_require__) {
  42806. var zrUtil = __webpack_require__(3);
  42807. var numberUtil = __webpack_require__(7);
  42808. var indexOf = zrUtil.indexOf;
  42809. function getPrecision(data, valueAxisDim, dataIndex) {
  42810. var precision = -1;
  42811. do {
  42812. precision = Math.max(
  42813. numberUtil.getPrecision(data.get(
  42814. valueAxisDim, dataIndex
  42815. )),
  42816. precision
  42817. );
  42818. data = data.stackedOn;
  42819. } while (data);
  42820. return precision;
  42821. }
  42822. function markerTypeCalculatorWithExtent(
  42823. mlType, data, baseDataDim, valueDataDim, baseCoordIndex, valueCoordIndex
  42824. ) {
  42825. var coordArr = [];
  42826. var value = numCalculate(data, valueDataDim, mlType);
  42827. var dataIndex = data.indexOfNearest(valueDataDim, value, true);
  42828. coordArr[baseCoordIndex] = data.get(baseDataDim, dataIndex, true);
  42829. coordArr[valueCoordIndex] = data.get(valueDataDim, dataIndex, true);
  42830. var precision = getPrecision(data, valueDataDim, dataIndex);
  42831. if (precision >= 0) {
  42832. coordArr[valueCoordIndex] = +coordArr[valueCoordIndex].toFixed(precision);
  42833. }
  42834. return coordArr;
  42835. }
  42836. var curry = zrUtil.curry;
  42837. // TODO Specified percent
  42838. var markerTypeCalculator = {
  42839. /**
  42840. * @method
  42841. * @param {module:echarts/data/List} data
  42842. * @param {string} baseAxisDim
  42843. * @param {string} valueAxisDim
  42844. */
  42845. min: curry(markerTypeCalculatorWithExtent, 'min'),
  42846. /**
  42847. * @method
  42848. * @param {module:echarts/data/List} data
  42849. * @param {string} baseAxisDim
  42850. * @param {string} valueAxisDim
  42851. */
  42852. max: curry(markerTypeCalculatorWithExtent, 'max'),
  42853. /**
  42854. * @method
  42855. * @param {module:echarts/data/List} data
  42856. * @param {string} baseAxisDim
  42857. * @param {string} valueAxisDim
  42858. */
  42859. average: curry(markerTypeCalculatorWithExtent, 'average')
  42860. };
  42861. /**
  42862. * Transform markPoint data item to format used in List by do the following
  42863. * 1. Calculate statistic like `max`, `min`, `average`
  42864. * 2. Convert `item.xAxis`, `item.yAxis` to `item.coord` array
  42865. * @param {module:echarts/model/Series} seriesModel
  42866. * @param {module:echarts/coord/*} [coordSys]
  42867. * @param {Object} item
  42868. * @return {Object}
  42869. */
  42870. var dataTransform = function (seriesModel, item) {
  42871. var data = seriesModel.getData();
  42872. var coordSys = seriesModel.coordinateSystem;
  42873. // 1. If not specify the position with pixel directly
  42874. // 2. If `coord` is not a data array. Which uses `xAxis`,
  42875. // `yAxis` to specify the coord on each dimension
  42876. // parseFloat first because item.x and item.y can be percent string like '20%'
  42877. if (item && (isNaN(parseFloat(item.x)) || isNaN(parseFloat(item.y)))
  42878. && !zrUtil.isArray(item.coord)
  42879. && coordSys
  42880. ) {
  42881. var axisInfo = getAxisInfo(item, data, coordSys, seriesModel);
  42882. // Clone the option
  42883. // Transform the properties xAxis, yAxis, radiusAxis, angleAxis, geoCoord to value
  42884. item = zrUtil.clone(item);
  42885. if (item.type
  42886. && markerTypeCalculator[item.type]
  42887. && axisInfo.baseAxis && axisInfo.valueAxis
  42888. ) {
  42889. var dims = coordSys.dimensions;
  42890. var baseCoordIndex = indexOf(dims, axisInfo.baseAxis.dim);
  42891. var valueCoordIndex = indexOf(dims, axisInfo.valueAxis.dim);
  42892. item.coord = markerTypeCalculator[item.type](
  42893. data, axisInfo.baseDataDim, axisInfo.valueDataDim,
  42894. baseCoordIndex, valueCoordIndex
  42895. );
  42896. // Force to use the value of calculated value.
  42897. item.value = item.coord[valueCoordIndex];
  42898. }
  42899. else {
  42900. // FIXME Only has one of xAxis and yAxis.
  42901. item.coord = [
  42902. item.xAxis != null ? item.xAxis : item.radiusAxis,
  42903. item.yAxis != null ? item.yAxis : item.angleAxis
  42904. ];
  42905. }
  42906. }
  42907. return item;
  42908. };
  42909. var getAxisInfo = function (item, data, coordSys, seriesModel) {
  42910. var ret = {};
  42911. if (item.valueIndex != null || item.valueDim != null) {
  42912. ret.valueDataDim = item.valueIndex != null
  42913. ? data.getDimension(item.valueIndex) : item.valueDim;
  42914. ret.valueAxis = coordSys.getAxis(seriesModel.dataDimToCoordDim(ret.valueDataDim));
  42915. ret.baseAxis = coordSys.getOtherAxis(ret.valueAxis);
  42916. ret.baseDataDim = seriesModel.coordDimToDataDim(ret.baseAxis.dim)[0];
  42917. }
  42918. else {
  42919. ret.baseAxis = seriesModel.getBaseAxis();
  42920. ret.valueAxis = coordSys.getOtherAxis(ret.baseAxis);
  42921. ret.baseDataDim = seriesModel.coordDimToDataDim(ret.baseAxis.dim)[0];
  42922. ret.valueDataDim = seriesModel.coordDimToDataDim(ret.valueAxis.dim)[0];
  42923. }
  42924. return ret;
  42925. };
  42926. /**
  42927. * Filter data which is out of coordinateSystem range
  42928. * [dataFilter description]
  42929. * @param {module:echarts/coord/*} [coordSys]
  42930. * @param {Object} item
  42931. * @return {boolean}
  42932. */
  42933. var dataFilter = function (coordSys, item) {
  42934. // Alwalys return true if there is no coordSys
  42935. return (coordSys && coordSys.containData && item.coord && (item.x == null || item.y == null))
  42936. ? coordSys.containData(item.coord) : true;
  42937. };
  42938. var dimValueGetter = function (item, dimName, dataIndex, dimIndex) {
  42939. // x, y, radius, angle
  42940. if (dimIndex < 2) {
  42941. return item.coord && item.coord[dimIndex];
  42942. }
  42943. return item.value;
  42944. };
  42945. var numCalculate = function (data, valueDataDim, mlType) {
  42946. return mlType === 'average'
  42947. ? data.getSum(valueDataDim, true) / data.count()
  42948. : data.getDataExtent(valueDataDim, true)[mlType === 'max' ? 1 : 0];
  42949. };
  42950. module.exports = {
  42951. dataTransform: dataTransform,
  42952. dataFilter: dataFilter,
  42953. dimValueGetter: dimValueGetter,
  42954. getAxisInfo: getAxisInfo,
  42955. numCalculate: numCalculate
  42956. };
  42957. /***/ },
  42958. /* 323 */
  42959. /***/ function(module, exports, __webpack_require__) {
  42960. __webpack_require__(324);
  42961. __webpack_require__(325);
  42962. __webpack_require__(1).registerPreprocessor(function (opt) {
  42963. // Make sure markLine component is enabled
  42964. opt.markLine = opt.markLine || {};
  42965. });
  42966. /***/ },
  42967. /* 324 */
  42968. /***/ function(module, exports, __webpack_require__) {
  42969. var modelUtil = __webpack_require__(5);
  42970. var zrUtil = __webpack_require__(3);
  42971. function fillLabel(opt) {
  42972. modelUtil.defaultEmphasis(
  42973. opt.label,
  42974. modelUtil.LABEL_OPTIONS
  42975. );
  42976. }
  42977. var MarkLineModel = __webpack_require__(1).extendComponentModel({
  42978. type: 'markLine',
  42979. dependencies: ['series', 'grid', 'polar', 'geo'],
  42980. /**
  42981. * @overrite
  42982. */
  42983. init: function (option, parentModel, ecModel, extraOpt) {
  42984. this.mergeDefaultAndTheme(option, ecModel);
  42985. this.mergeOption(option, ecModel, extraOpt.createdBySelf, true);
  42986. },
  42987. mergeOption: function (newOpt, ecModel, createdBySelf, isInit) {
  42988. if (!createdBySelf) {
  42989. ecModel.eachSeries(function (seriesModel) {
  42990. var markLineOpt = seriesModel.get('markLine');
  42991. var mlModel = seriesModel.markLineModel;
  42992. if (!markLineOpt || !markLineOpt.data) {
  42993. seriesModel.markLineModel = null;
  42994. return;
  42995. }
  42996. if (!mlModel) {
  42997. if (isInit) {
  42998. // Default label emphasis `position` and `show`
  42999. fillLabel(markLineOpt);
  43000. }
  43001. zrUtil.each(markLineOpt.data, function (item) {
  43002. if (item instanceof Array) {
  43003. fillLabel(item[0]);
  43004. fillLabel(item[1]);
  43005. }
  43006. else {
  43007. fillLabel(item);
  43008. }
  43009. });
  43010. var opt = {
  43011. mainType: 'markLine',
  43012. // Use the same series index and name
  43013. seriesIndex: seriesModel.seriesIndex,
  43014. name: seriesModel.name,
  43015. createdBySelf: true
  43016. };
  43017. mlModel = new MarkLineModel(
  43018. markLineOpt, this, ecModel, opt
  43019. );
  43020. }
  43021. else {
  43022. mlModel.mergeOption(markLineOpt, ecModel, true);
  43023. }
  43024. seriesModel.markLineModel = mlModel;
  43025. }, this);
  43026. }
  43027. },
  43028. defaultOption: {
  43029. zlevel: 0,
  43030. z: 5,
  43031. symbol: ['circle', 'arrow'],
  43032. symbolSize: [8, 16],
  43033. //symbolRotate: 0,
  43034. precision: 2,
  43035. tooltip: {
  43036. trigger: 'item'
  43037. },
  43038. label: {
  43039. normal: {
  43040. show: true,
  43041. position: 'end'
  43042. },
  43043. emphasis: {
  43044. show: true
  43045. }
  43046. },
  43047. lineStyle: {
  43048. normal: {
  43049. type: 'dashed'
  43050. },
  43051. emphasis: {
  43052. width: 3
  43053. }
  43054. },
  43055. animationEasing: 'linear'
  43056. }
  43057. });
  43058. module.exports = MarkLineModel;
  43059. /***/ },
  43060. /* 325 */
  43061. /***/ function(module, exports, __webpack_require__) {
  43062. var zrUtil = __webpack_require__(3);
  43063. var List = __webpack_require__(95);
  43064. var formatUtil = __webpack_require__(6);
  43065. var modelUtil = __webpack_require__(5);
  43066. var numberUtil = __webpack_require__(7);
  43067. var addCommas = formatUtil.addCommas;
  43068. var encodeHTML = formatUtil.encodeHTML;
  43069. var markerHelper = __webpack_require__(322);
  43070. var LineDraw = __webpack_require__(194);
  43071. var markLineTransform = function (seriesModel, coordSys, mlModel, item) {
  43072. var data = seriesModel.getData();
  43073. // Special type markLine like 'min', 'max', 'average'
  43074. var mlType = item.type;
  43075. if (!zrUtil.isArray(item)
  43076. && (
  43077. mlType === 'min' || mlType === 'max' || mlType === 'average'
  43078. // In case
  43079. // data: [{
  43080. // yAxis: 10
  43081. // }]
  43082. || (item.xAxis != null || item.yAxis != null)
  43083. )
  43084. ) {
  43085. var valueAxis;
  43086. var valueDataDim;
  43087. var value;
  43088. if (item.yAxis != null || item.xAxis != null) {
  43089. valueDataDim = item.yAxis != null ? 'y' : 'x';
  43090. valueAxis = coordSys.getAxis(valueDataDim);
  43091. value = zrUtil.retrieve(item.yAxis, item.xAxis);
  43092. }
  43093. else {
  43094. var axisInfo = markerHelper.getAxisInfo(item, data, coordSys, seriesModel);
  43095. valueDataDim = axisInfo.valueDataDim;
  43096. valueAxis = axisInfo.valueAxis;
  43097. value = markerHelper.numCalculate(data, valueDataDim, mlType);
  43098. }
  43099. var valueIndex = valueDataDim === 'x' ? 0 : 1;
  43100. var baseIndex = 1 - valueIndex;
  43101. var mlFrom = zrUtil.clone(item);
  43102. var mlTo = {};
  43103. mlFrom.type = null;
  43104. mlFrom.coord = [];
  43105. mlTo.coord = [];
  43106. mlFrom.coord[baseIndex] = -Infinity;
  43107. mlTo.coord[baseIndex] = Infinity;
  43108. var precision = mlModel.get('precision');
  43109. if (precision >= 0) {
  43110. value = +value.toFixed(precision);
  43111. }
  43112. mlFrom.coord[valueIndex] = mlTo.coord[valueIndex] = value;
  43113. item = [mlFrom, mlTo, { // Extra option for tooltip and label
  43114. type: mlType,
  43115. valueIndex: item.valueIndex,
  43116. // Force to use the value of calculated value.
  43117. value: value
  43118. }];
  43119. }
  43120. item = [
  43121. markerHelper.dataTransform(seriesModel, item[0]),
  43122. markerHelper.dataTransform(seriesModel, item[1]),
  43123. zrUtil.extend({}, item[2])
  43124. ];
  43125. // Avoid line data type is extended by from(to) data type
  43126. item[2].type = item[2].type || '';
  43127. // Merge from option and to option into line option
  43128. zrUtil.merge(item[2], item[0]);
  43129. zrUtil.merge(item[2], item[1]);
  43130. return item;
  43131. };
  43132. function isInifinity(val) {
  43133. return !isNaN(val) && !isFinite(val);
  43134. }
  43135. // If a markLine has one dim
  43136. function ifMarkLineHasOnlyDim(dimIndex, fromCoord, toCoord, coordSys) {
  43137. var otherDimIndex = 1 - dimIndex;
  43138. var dimName = coordSys.dimensions[dimIndex];
  43139. return isInifinity(fromCoord[otherDimIndex]) && isInifinity(toCoord[otherDimIndex])
  43140. && fromCoord[dimIndex] === toCoord[dimIndex] && coordSys.getAxis(dimName).containData(fromCoord[dimIndex]);
  43141. }
  43142. function markLineFilter(coordSys, item) {
  43143. if (coordSys.type === 'cartesian2d') {
  43144. var fromCoord = item[0].coord;
  43145. var toCoord = item[1].coord;
  43146. // In case
  43147. // {
  43148. // markLine: {
  43149. // data: [{ yAxis: 2 }]
  43150. // }
  43151. // }
  43152. if (
  43153. fromCoord && toCoord &&
  43154. (ifMarkLineHasOnlyDim(1, fromCoord, toCoord, coordSys)
  43155. || ifMarkLineHasOnlyDim(0, fromCoord, toCoord, coordSys))
  43156. ) {
  43157. return true;
  43158. }
  43159. }
  43160. return markerHelper.dataFilter(coordSys, item[0])
  43161. && markerHelper.dataFilter(coordSys, item[1]);
  43162. }
  43163. function updateSingleMarkerEndLayout(
  43164. data, idx, isFrom, mlType, valueIndex, seriesModel, api
  43165. ) {
  43166. var coordSys = seriesModel.coordinateSystem;
  43167. var itemModel = data.getItemModel(idx);
  43168. var point;
  43169. var xPx = itemModel.get('x');
  43170. var yPx = itemModel.get('y');
  43171. if (xPx != null && yPx != null) {
  43172. point = [
  43173. numberUtil.parsePercent(xPx, api.getWidth()),
  43174. numberUtil.parsePercent(yPx, api.getHeight())
  43175. ];
  43176. }
  43177. else {
  43178. // Chart like bar may have there own marker positioning logic
  43179. if (seriesModel.getMarkerPosition) {
  43180. // Use the getMarkerPoisition
  43181. point = seriesModel.getMarkerPosition(
  43182. data.getValues(data.dimensions, idx)
  43183. );
  43184. }
  43185. else {
  43186. var dims = coordSys.dimensions;
  43187. var x = data.get(dims[0], idx);
  43188. var y = data.get(dims[1], idx);
  43189. point = coordSys.dataToPoint([x, y]);
  43190. }
  43191. // Expand line to the edge of grid if value on one axis is Inifnity
  43192. // In case
  43193. // markLine: {
  43194. // data: [{
  43195. // yAxis: 2
  43196. // // or
  43197. // type: 'average'
  43198. // }]
  43199. // }
  43200. if (coordSys.type === 'cartesian2d') {
  43201. var xAxis = coordSys.getAxis('x');
  43202. var yAxis = coordSys.getAxis('y');
  43203. var dims = coordSys.dimensions;
  43204. if (isInifinity(data.get(dims[0], idx))) {
  43205. point[0] = xAxis.toGlobalCoord(xAxis.getExtent()[isFrom ? 0 : 1]);
  43206. }
  43207. else if (isInifinity(data.get(dims[1], idx))) {
  43208. point[1] = yAxis.toGlobalCoord(yAxis.getExtent()[isFrom ? 0 : 1]);
  43209. }
  43210. }
  43211. }
  43212. data.setItemLayout(idx, point);
  43213. }
  43214. var markLineFormatMixin = {
  43215. formatTooltip: function (dataIndex) {
  43216. var data = this._data;
  43217. var value = this.getRawValue(dataIndex);
  43218. var formattedValue = zrUtil.isArray(value)
  43219. ? zrUtil.map(value, addCommas).join(', ') : addCommas(value);
  43220. var name = data.getName(dataIndex);
  43221. return this.name + '<br />'
  43222. + ((name ? encodeHTML(name) + ' : ' : '') + formattedValue);
  43223. },
  43224. getData: function () {
  43225. return this._data;
  43226. },
  43227. setData: function (data) {
  43228. this._data = data;
  43229. }
  43230. };
  43231. zrUtil.defaults(markLineFormatMixin, modelUtil.dataFormatMixin);
  43232. __webpack_require__(1).extendComponentView({
  43233. type: 'markLine',
  43234. init: function () {
  43235. /**
  43236. * Markline grouped by series
  43237. * @private
  43238. * @type {Object}
  43239. */
  43240. this._markLineMap = {};
  43241. },
  43242. render: function (markLineModel, ecModel, api) {
  43243. var lineDrawMap = this._markLineMap;
  43244. for (var name in lineDrawMap) {
  43245. lineDrawMap[name].__keep = false;
  43246. }
  43247. ecModel.eachSeries(function (seriesModel) {
  43248. var mlModel = seriesModel.markLineModel;
  43249. mlModel && this._renderSeriesML(seriesModel, mlModel, ecModel, api);
  43250. }, this);
  43251. for (var name in lineDrawMap) {
  43252. if (!lineDrawMap[name].__keep) {
  43253. this.group.remove(lineDrawMap[name].group);
  43254. }
  43255. }
  43256. },
  43257. updateLayout: function (markLineModel, ecModel, api) {
  43258. ecModel.eachSeries(function (seriesModel) {
  43259. var mlModel = seriesModel.markLineModel;
  43260. if (mlModel) {
  43261. var mlData = mlModel.getData();
  43262. var fromData = mlModel.__from;
  43263. var toData = mlModel.__to;
  43264. // Update visual and layout of from symbol and to symbol
  43265. fromData.each(function (idx) {
  43266. var lineModel = mlData.getItemModel(idx);
  43267. var mlType = lineModel.get('type');
  43268. var valueIndex = lineModel.get('valueIndex');
  43269. updateSingleMarkerEndLayout(fromData, idx, true, mlType, valueIndex, seriesModel, api);
  43270. updateSingleMarkerEndLayout(toData, idx, false, mlType, valueIndex, seriesModel, api);
  43271. });
  43272. // Update layout of line
  43273. mlData.each(function (idx) {
  43274. mlData.setItemLayout(idx, [
  43275. fromData.getItemLayout(idx),
  43276. toData.getItemLayout(idx)
  43277. ]);
  43278. });
  43279. this._markLineMap[seriesModel.name].updateLayout();
  43280. }
  43281. }, this);
  43282. },
  43283. _renderSeriesML: function (seriesModel, mlModel, ecModel, api) {
  43284. var coordSys = seriesModel.coordinateSystem;
  43285. var seriesName = seriesModel.name;
  43286. var seriesData = seriesModel.getData();
  43287. var lineDrawMap = this._markLineMap;
  43288. var lineDraw = lineDrawMap[seriesName];
  43289. if (!lineDraw) {
  43290. lineDraw = lineDrawMap[seriesName] = new LineDraw();
  43291. }
  43292. this.group.add(lineDraw.group);
  43293. var mlData = createList(coordSys, seriesModel, mlModel);
  43294. var fromData = mlData.from;
  43295. var toData = mlData.to;
  43296. var lineData = mlData.line;
  43297. mlModel.__from = fromData;
  43298. mlModel.__to = toData;
  43299. // Line data for tooltip and formatter
  43300. zrUtil.extend(mlModel, markLineFormatMixin);
  43301. mlModel.setData(lineData);
  43302. var symbolType = mlModel.get('symbol');
  43303. var symbolSize = mlModel.get('symbolSize');
  43304. if (!zrUtil.isArray(symbolType)) {
  43305. symbolType = [symbolType, symbolType];
  43306. }
  43307. if (typeof symbolSize === 'number') {
  43308. symbolSize = [symbolSize, symbolSize];
  43309. }
  43310. // Update visual and layout of from symbol and to symbol
  43311. mlData.from.each(function (idx) {
  43312. var lineModel = lineData.getItemModel(idx);
  43313. var mlType = lineModel.get('type');
  43314. var valueIndex = lineModel.get('valueIndex');
  43315. updateDataVisualAndLayout(fromData, idx, true, mlType, valueIndex);
  43316. updateDataVisualAndLayout(toData, idx, false, mlType, valueIndex);
  43317. });
  43318. // Update visual and layout of line
  43319. lineData.each(function (idx) {
  43320. var lineColor = lineData.getItemModel(idx).get('lineStyle.normal.color');
  43321. lineData.setItemVisual(idx, {
  43322. color: lineColor || fromData.getItemVisual(idx, 'color')
  43323. });
  43324. lineData.setItemLayout(idx, [
  43325. fromData.getItemLayout(idx),
  43326. toData.getItemLayout(idx)
  43327. ]);
  43328. lineData.setItemVisual(idx, {
  43329. 'fromSymbolSize': fromData.getItemVisual(idx, 'symbolSize'),
  43330. 'fromSymbol': fromData.getItemVisual(idx, 'symbol'),
  43331. 'toSymbolSize': toData.getItemVisual(idx, 'symbolSize'),
  43332. 'toSymbol': toData.getItemVisual(idx, 'symbol')
  43333. });
  43334. });
  43335. lineDraw.updateData(lineData);
  43336. // Set host model for tooltip
  43337. // FIXME
  43338. mlData.line.eachItemGraphicEl(function (el, idx) {
  43339. el.traverse(function (child) {
  43340. child.dataModel = mlModel;
  43341. });
  43342. });
  43343. function updateDataVisualAndLayout(data, idx, isFrom, mlType, valueIndex) {
  43344. var itemModel = data.getItemModel(idx);
  43345. updateSingleMarkerEndLayout(
  43346. data, idx, isFrom, mlType, valueIndex, seriesModel, api
  43347. );
  43348. data.setItemVisual(idx, {
  43349. symbolSize: itemModel.get('symbolSize') || symbolSize[isFrom ? 0 : 1],
  43350. symbol: itemModel.get('symbol', true) || symbolType[isFrom ? 0 : 1],
  43351. color: itemModel.get('itemStyle.normal.color') || seriesData.getVisual('color')
  43352. });
  43353. }
  43354. lineDraw.__keep = true;
  43355. }
  43356. });
  43357. /**
  43358. * @inner
  43359. * @param {module:echarts/coord/*} coordSys
  43360. * @param {module:echarts/model/Series} seriesModel
  43361. * @param {module:echarts/model/Model} mpModel
  43362. */
  43363. function createList(coordSys, seriesModel, mlModel) {
  43364. var coordDimsInfos;
  43365. if (coordSys) {
  43366. coordDimsInfos = zrUtil.map(coordSys && coordSys.dimensions, function (coordDim) {
  43367. var info = seriesModel.getData().getDimensionInfo(
  43368. seriesModel.coordDimToDataDim(coordDim)[0]
  43369. ) || {}; // In map series data don't have lng and lat dimension. Fallback to same with coordSys
  43370. info.name = coordDim;
  43371. return info;
  43372. });
  43373. }
  43374. else {
  43375. coordDimsInfos =[{
  43376. name: 'value',
  43377. type: 'float'
  43378. }];
  43379. }
  43380. var fromData = new List(coordDimsInfos, mlModel);
  43381. var toData = new List(coordDimsInfos, mlModel);
  43382. // No dimensions
  43383. var lineData = new List([], mlModel);
  43384. var optData = zrUtil.map(mlModel.get('data'), zrUtil.curry(
  43385. markLineTransform, seriesModel, coordSys, mlModel
  43386. ));
  43387. if (coordSys) {
  43388. optData = zrUtil.filter(
  43389. optData, zrUtil.curry(markLineFilter, coordSys)
  43390. );
  43391. }
  43392. var dimValueGetter = coordSys ? markerHelper.dimValueGetter : function (item) {
  43393. return item.value;
  43394. };
  43395. fromData.initData(
  43396. zrUtil.map(optData, function (item) { return item[0]; }),
  43397. null, dimValueGetter
  43398. );
  43399. toData.initData(
  43400. zrUtil.map(optData, function (item) { return item[1]; }),
  43401. null, dimValueGetter
  43402. );
  43403. lineData.initData(
  43404. zrUtil.map(optData, function (item) { return item[2]; })
  43405. );
  43406. return {
  43407. from: fromData,
  43408. to: toData,
  43409. line: lineData
  43410. };
  43411. }
  43412. /***/ },
  43413. /* 326 */
  43414. /***/ function(module, exports, __webpack_require__) {
  43415. /**
  43416. * DataZoom component entry
  43417. */
  43418. var echarts = __webpack_require__(1);
  43419. echarts.registerPreprocessor(__webpack_require__(327));
  43420. __webpack_require__(328);
  43421. __webpack_require__(329);
  43422. __webpack_require__(330);
  43423. __webpack_require__(332);
  43424. /***/ },
  43425. /* 327 */
  43426. /***/ function(module, exports, __webpack_require__) {
  43427. /**
  43428. * @file Timeline preprocessor
  43429. */
  43430. var zrUtil = __webpack_require__(3);
  43431. module.exports = function (option) {
  43432. var timelineOpt = option && option.timeline;
  43433. if (!zrUtil.isArray(timelineOpt)) {
  43434. timelineOpt = timelineOpt ? [timelineOpt] : [];
  43435. }
  43436. zrUtil.each(timelineOpt, function (opt) {
  43437. if (!opt) {
  43438. return;
  43439. }
  43440. compatibleEC2(opt);
  43441. });
  43442. };
  43443. function compatibleEC2(opt) {
  43444. var type = opt.type;
  43445. var ec2Types = {'number': 'value', 'time': 'time'};
  43446. // Compatible with ec2
  43447. if (ec2Types[type]) {
  43448. opt.axisType = ec2Types[type];
  43449. delete opt.type;
  43450. }
  43451. transferItem(opt);
  43452. if (has(opt, 'controlPosition')) {
  43453. var controlStyle = opt.controlStyle || (opt.controlStyle = {});
  43454. if (!has(controlStyle, 'position')) {
  43455. controlStyle.position = opt.controlPosition;
  43456. }
  43457. if (controlStyle.position === 'none' && !has(controlStyle, 'show')) {
  43458. controlStyle.show = false;
  43459. delete controlStyle.position;
  43460. }
  43461. delete opt.controlPosition;
  43462. }
  43463. zrUtil.each(opt.data || [], function (dataItem) {
  43464. if (zrUtil.isObject(dataItem) && !zrUtil.isArray(dataItem)) {
  43465. if (!has(dataItem, 'value') && has(dataItem, 'name')) {
  43466. // In ec2, using name as value.
  43467. dataItem.value = dataItem.name;
  43468. }
  43469. transferItem(dataItem);
  43470. }
  43471. });
  43472. }
  43473. function transferItem(opt) {
  43474. var itemStyle = opt.itemStyle || (opt.itemStyle = {});
  43475. var itemStyleEmphasis = itemStyle.emphasis || (itemStyle.emphasis = {});
  43476. // Transfer label out
  43477. var label = opt.label || (opt.label || {});
  43478. var labelNormal = label.normal || (label.normal = {});
  43479. var excludeLabelAttr = {normal: 1, emphasis: 1};
  43480. zrUtil.each(label, function (value, name) {
  43481. if (!excludeLabelAttr[name] && !has(labelNormal, name)) {
  43482. labelNormal[name] = value;
  43483. }
  43484. });
  43485. if (itemStyleEmphasis.label && !has(label, 'emphasis')) {
  43486. label.emphasis = itemStyleEmphasis.label;
  43487. delete itemStyleEmphasis.label;
  43488. }
  43489. }
  43490. function has(obj, attr) {
  43491. return obj.hasOwnProperty(attr);
  43492. }
  43493. /***/ },
  43494. /* 328 */
  43495. /***/ function(module, exports, __webpack_require__) {
  43496. __webpack_require__(19).registerSubTypeDefaulter('timeline', function () {
  43497. // Only slider now.
  43498. return 'slider';
  43499. });
  43500. /***/ },
  43501. /* 329 */
  43502. /***/ function(module, exports, __webpack_require__) {
  43503. /**
  43504. * @file Timeilne action
  43505. */
  43506. var echarts = __webpack_require__(1);
  43507. echarts.registerAction(
  43508. {type: 'timelineChange', event: 'timelineChanged', update: 'prepareAndUpdate'},
  43509. function (payload, ecModel) {
  43510. var timelineModel = ecModel.getComponent('timeline');
  43511. if (timelineModel && payload.currentIndex != null) {
  43512. timelineModel.setCurrentIndex(payload.currentIndex);
  43513. if (!timelineModel.get('loop', true) && timelineModel.isIndexMax()) {
  43514. timelineModel.setPlayState(false);
  43515. }
  43516. }
  43517. ecModel.resetOption('timeline');
  43518. }
  43519. );
  43520. echarts.registerAction(
  43521. {type: 'timelinePlayChange', event: 'timelinePlayChanged', update: 'update'},
  43522. function (payload, ecModel) {
  43523. var timelineModel = ecModel.getComponent('timeline');
  43524. if (timelineModel && payload.playState != null) {
  43525. timelineModel.setPlayState(payload.playState);
  43526. }
  43527. }
  43528. );
  43529. /***/ },
  43530. /* 330 */
  43531. /***/ function(module, exports, __webpack_require__) {
  43532. /**
  43533. * @file Silder timeline model
  43534. */
  43535. var TimelineModel = __webpack_require__(331);
  43536. var zrUtil = __webpack_require__(3);
  43537. var modelUtil = __webpack_require__(5);
  43538. var SliderTimelineModel = TimelineModel.extend({
  43539. type: 'timeline.slider',
  43540. /**
  43541. * @protected
  43542. */
  43543. defaultOption: {
  43544. backgroundColor: 'rgba(0,0,0,0)', // 时间轴背景颜色
  43545. borderColor: '#ccc', // 时间轴边框颜色
  43546. borderWidth: 0, // 时间轴边框线宽,单位px,默认为0(无边框)
  43547. orient: 'horizontal', // 'vertical'
  43548. inverse: false,
  43549. tooltip: { // boolean or Object
  43550. trigger: 'item' // data item may also have tootip attr.
  43551. },
  43552. symbol: 'emptyCircle',
  43553. symbolSize: 10,
  43554. lineStyle: {
  43555. show: true,
  43556. width: 2,
  43557. color: '#304654'
  43558. },
  43559. label: { // 文本标签
  43560. position: 'auto', // auto left right top bottom
  43561. // When using number, label position is not
  43562. // restricted by viewRect.
  43563. // positive: right/bottom, negative: left/top
  43564. normal: {
  43565. show: true,
  43566. interval: 'auto',
  43567. rotate: 0,
  43568. // formatter: null,
  43569. textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  43570. color: '#304654'
  43571. }
  43572. },
  43573. emphasis: {
  43574. show: true,
  43575. textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  43576. color: '#c23531'
  43577. }
  43578. }
  43579. },
  43580. itemStyle: {
  43581. normal: {
  43582. color: '#304654',
  43583. borderWidth: 1
  43584. },
  43585. emphasis: {
  43586. color: '#c23531'
  43587. }
  43588. },
  43589. checkpointStyle: {
  43590. symbol: 'circle',
  43591. symbolSize: 13,
  43592. color: '#c23531',
  43593. borderWidth: 5,
  43594. borderColor: 'rgba(194,53,49, 0.5)',
  43595. animation: true,
  43596. animationDuration: 300,
  43597. animationEasing: 'quinticInOut'
  43598. },
  43599. controlStyle: {
  43600. show: true,
  43601. showPlayBtn: true,
  43602. showPrevBtn: true,
  43603. showNextBtn: true,
  43604. itemSize: 22,
  43605. itemGap: 12,
  43606. position: 'left', // 'left' 'right' 'top' 'bottom'
  43607. 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
  43608. 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
  43609. 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
  43610. 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
  43611. normal: {
  43612. color: '#304654',
  43613. borderColor: '#304654',
  43614. borderWidth: 1
  43615. },
  43616. emphasis: {
  43617. color: '#c23531',
  43618. borderColor: '#c23531',
  43619. borderWidth: 2
  43620. }
  43621. },
  43622. data: []
  43623. }
  43624. });
  43625. zrUtil.mixin(SliderTimelineModel, modelUtil.dataFormatMixin);
  43626. module.exports = SliderTimelineModel;
  43627. /***/ },
  43628. /* 331 */
  43629. /***/ function(module, exports, __webpack_require__) {
  43630. /**
  43631. * @file Timeline model
  43632. */
  43633. var ComponentModel = __webpack_require__(19);
  43634. var List = __webpack_require__(95);
  43635. var zrUtil = __webpack_require__(3);
  43636. var modelUtil = __webpack_require__(5);
  43637. var TimelineModel = ComponentModel.extend({
  43638. type: 'timeline',
  43639. layoutMode: 'box',
  43640. /**
  43641. * @protected
  43642. */
  43643. defaultOption: {
  43644. zlevel: 0, // 一级层叠
  43645. z: 4, // 二级层叠
  43646. show: true,
  43647. axisType: 'time', // 模式是时间类型,支持 value, category
  43648. realtime: true,
  43649. left: '20%',
  43650. top: null,
  43651. right: '20%',
  43652. bottom: 0,
  43653. width: null,
  43654. height: 40,
  43655. padding: 5,
  43656. controlPosition: 'left', // 'left' 'right' 'top' 'bottom' 'none'
  43657. autoPlay: false,
  43658. rewind: false, // 反向播放
  43659. loop: true,
  43660. playInterval: 2000, // 播放时间间隔,单位ms
  43661. currentIndex: 0,
  43662. itemStyle: {
  43663. normal: {},
  43664. emphasis: {}
  43665. },
  43666. label: {
  43667. normal: {
  43668. textStyle: {
  43669. color: '#000'
  43670. }
  43671. },
  43672. emphasis: {}
  43673. },
  43674. data: []
  43675. },
  43676. /**
  43677. * @override
  43678. */
  43679. init: function (option, parentModel, ecModel) {
  43680. /**
  43681. * @private
  43682. * @type {module:echarts/data/List}
  43683. */
  43684. this._data;
  43685. /**
  43686. * @private
  43687. * @type {Array.<string>}
  43688. */
  43689. this._names;
  43690. this.mergeDefaultAndTheme(option, ecModel);
  43691. this._initData();
  43692. },
  43693. /**
  43694. * @override
  43695. */
  43696. mergeOption: function (option) {
  43697. TimelineModel.superApply(this, 'mergeOption', arguments);
  43698. this._initData();
  43699. },
  43700. /**
  43701. * @param {number} [currentIndex]
  43702. */
  43703. setCurrentIndex: function (currentIndex) {
  43704. if (currentIndex == null) {
  43705. currentIndex = this.option.currentIndex;
  43706. }
  43707. var count = this._data.count();
  43708. if (this.option.loop) {
  43709. currentIndex = (currentIndex % count + count) % count;
  43710. }
  43711. else {
  43712. currentIndex >= count && (currentIndex = count - 1);
  43713. currentIndex < 0 && (currentIndex = 0);
  43714. }
  43715. this.option.currentIndex = currentIndex;
  43716. },
  43717. /**
  43718. * @return {number} currentIndex
  43719. */
  43720. getCurrentIndex: function () {
  43721. return this.option.currentIndex;
  43722. },
  43723. /**
  43724. * @return {boolean}
  43725. */
  43726. isIndexMax: function () {
  43727. return this.getCurrentIndex() >= this._data.count() - 1;
  43728. },
  43729. /**
  43730. * @param {boolean} state true: play, false: stop
  43731. */
  43732. setPlayState: function (state) {
  43733. this.option.autoPlay = !!state;
  43734. },
  43735. /**
  43736. * @return {boolean} true: play, false: stop
  43737. */
  43738. getPlayState: function () {
  43739. return !!this.option.autoPlay;
  43740. },
  43741. /**
  43742. * @private
  43743. */
  43744. _initData: function () {
  43745. var thisOption = this.option;
  43746. var dataArr = thisOption.data || [];
  43747. var axisType = thisOption.axisType;
  43748. var names = this._names = [];
  43749. if (axisType === 'category') {
  43750. var idxArr = [];
  43751. zrUtil.each(dataArr, function (item, index) {
  43752. var value = modelUtil.getDataItemValue(item);
  43753. var newItem;
  43754. if (zrUtil.isObject(item)) {
  43755. newItem = zrUtil.clone(item);
  43756. newItem.value = index;
  43757. }
  43758. else {
  43759. newItem = index;
  43760. }
  43761. idxArr.push(newItem);
  43762. if (!zrUtil.isString(value) && (value == null || isNaN(value))) {
  43763. value = '';
  43764. }
  43765. names.push(value + '');
  43766. });
  43767. dataArr = idxArr;
  43768. }
  43769. var dimType = ({category: 'ordinal', time: 'time'})[axisType] || 'number';
  43770. var data = this._data = new List([{name: 'value', type: dimType}], this);
  43771. data.initData(dataArr, names);
  43772. },
  43773. getData: function () {
  43774. return this._data;
  43775. },
  43776. /**
  43777. * @public
  43778. * @return {Array.<string>} categoreis
  43779. */
  43780. getCategories: function () {
  43781. if (this.get('axisType') === 'category') {
  43782. return this._names.slice();
  43783. }
  43784. }
  43785. });
  43786. module.exports = TimelineModel;
  43787. /***/ },
  43788. /* 332 */
  43789. /***/ function(module, exports, __webpack_require__) {
  43790. /**
  43791. * @file Silder timeline view
  43792. */
  43793. var zrUtil = __webpack_require__(3);
  43794. var graphic = __webpack_require__(42);
  43795. var layout = __webpack_require__(21);
  43796. var TimelineView = __webpack_require__(333);
  43797. var TimelineAxis = __webpack_require__(334);
  43798. var symbolUtil = __webpack_require__(101);
  43799. var axisHelper = __webpack_require__(109);
  43800. var BoundingRect = __webpack_require__(15);
  43801. var matrix = __webpack_require__(17);
  43802. var numberUtil = __webpack_require__(7);
  43803. var formatUtil = __webpack_require__(6);
  43804. var encodeHTML = formatUtil.encodeHTML;
  43805. var bind = zrUtil.bind;
  43806. var each = zrUtil.each;
  43807. var PI = Math.PI;
  43808. module.exports = TimelineView.extend({
  43809. type: 'timeline.slider',
  43810. init: function (ecModel, api) {
  43811. this.api = api;
  43812. /**
  43813. * @private
  43814. * @type {module:echarts/component/timeline/TimelineAxis}
  43815. */
  43816. this._axis;
  43817. /**
  43818. * @private
  43819. * @type {module:zrender/core/BoundingRect}
  43820. */
  43821. this._viewRect;
  43822. /**
  43823. * @type {number}
  43824. */
  43825. this._timer;
  43826. /**
  43827. * @type {module:zrende/Element}
  43828. */
  43829. this._currentPointer;
  43830. /**
  43831. * @type {module:zrender/container/Group}
  43832. */
  43833. this._mainGroup;
  43834. /**
  43835. * @type {module:zrender/container/Group}
  43836. */
  43837. this._labelGroup;
  43838. },
  43839. /**
  43840. * @override
  43841. */
  43842. render: function (timelineModel, ecModel, api, payload) {
  43843. this.model = timelineModel;
  43844. this.api = api;
  43845. this.ecModel = ecModel;
  43846. this.group.removeAll();
  43847. if (timelineModel.get('show', true)) {
  43848. var layoutInfo = this._layout(timelineModel, api);
  43849. var mainGroup = this._createGroup('mainGroup');
  43850. var labelGroup = this._createGroup('labelGroup');
  43851. /**
  43852. * @private
  43853. * @type {module:echarts/component/timeline/TimelineAxis}
  43854. */
  43855. var axis = this._axis = this._createAxis(layoutInfo, timelineModel);
  43856. timelineModel.formatTooltip = function (dataIndex) {
  43857. return encodeHTML(axis.scale.getLabel(dataIndex));
  43858. };
  43859. each(
  43860. ['AxisLine', 'AxisTick', 'Control', 'CurrentPointer'],
  43861. function (name) {
  43862. this['_render' + name](layoutInfo, mainGroup, axis, timelineModel);
  43863. },
  43864. this
  43865. );
  43866. this._renderAxisLabel(layoutInfo, labelGroup, axis, timelineModel);
  43867. this._position(layoutInfo, timelineModel);
  43868. }
  43869. this._doPlayStop();
  43870. },
  43871. /**
  43872. * @override
  43873. */
  43874. remove: function () {
  43875. this._clearTimer();
  43876. this.group.removeAll();
  43877. },
  43878. /**
  43879. * @override
  43880. */
  43881. dispose: function () {
  43882. this._clearTimer();
  43883. },
  43884. _layout: function (timelineModel, api) {
  43885. var labelPosOpt = timelineModel.get('label.normal.position');
  43886. var orient = timelineModel.get('orient');
  43887. var viewRect = getViewRect(timelineModel, api);
  43888. // Auto label offset.
  43889. if (labelPosOpt == null || labelPosOpt === 'auto') {
  43890. labelPosOpt = orient === 'horizontal'
  43891. ? ((viewRect.y + viewRect.height / 2) < api.getHeight() / 2 ? '-' : '+')
  43892. : ((viewRect.x + viewRect.width / 2) < api.getWidth() / 2 ? '+' : '-');
  43893. }
  43894. else if (isNaN(labelPosOpt)) {
  43895. labelPosOpt = ({
  43896. horizontal: {top: '-', bottom: '+'},
  43897. vertical: {left: '-', right: '+'}
  43898. })[orient][labelPosOpt];
  43899. }
  43900. // FIXME
  43901. // 暂没有实现用户传入
  43902. // var labelAlign = timelineModel.get('label.normal.textStyle.align');
  43903. // var labelBaseline = timelineModel.get('label.normal.textStyle.baseline');
  43904. var labelAlignMap = {
  43905. horizontal: 'center',
  43906. vertical: (labelPosOpt >= 0 || labelPosOpt === '+') ? 'left' : 'right'
  43907. };
  43908. var labelBaselineMap = {
  43909. horizontal: (labelPosOpt >= 0 || labelPosOpt === '+') ? 'top' : 'bottom',
  43910. vertical: 'middle'
  43911. };
  43912. var rotationMap = {
  43913. horizontal: 0,
  43914. vertical: PI / 2
  43915. };
  43916. // Position
  43917. var mainLength = orient === 'vertical' ? viewRect.height : viewRect.width;
  43918. var controlModel = timelineModel.getModel('controlStyle');
  43919. var showControl = controlModel.get('show');
  43920. var controlSize = showControl ? controlModel.get('itemSize') : 0;
  43921. var controlGap = showControl ? controlModel.get('itemGap') : 0;
  43922. var sizePlusGap = controlSize + controlGap;
  43923. // Special label rotate.
  43924. var labelRotation = timelineModel.get('label.normal.rotate') || 0;
  43925. labelRotation = labelRotation * PI / 180; // To radian.
  43926. var playPosition;
  43927. var prevBtnPosition;
  43928. var nextBtnPosition;
  43929. var axisExtent;
  43930. var controlPosition = controlModel.get('position', true);
  43931. var showControl = controlModel.get('show', true);
  43932. var showPlayBtn = showControl && controlModel.get('showPlayBtn', true);
  43933. var showPrevBtn = showControl && controlModel.get('showPrevBtn', true);
  43934. var showNextBtn = showControl && controlModel.get('showNextBtn', true);
  43935. var xLeft = 0;
  43936. var xRight = mainLength;
  43937. // position[0] means left, position[1] means middle.
  43938. if (controlPosition === 'left' || controlPosition === 'bottom') {
  43939. showPlayBtn && (playPosition = [0, 0], xLeft += sizePlusGap);
  43940. showPrevBtn && (prevBtnPosition = [xLeft, 0], xLeft += sizePlusGap);
  43941. showNextBtn && (nextBtnPosition = [xRight - controlSize, 0], xRight -= sizePlusGap);
  43942. }
  43943. else { // 'top' 'right'
  43944. showPlayBtn && (playPosition = [xRight - controlSize, 0], xRight -= sizePlusGap);
  43945. showPrevBtn && (prevBtnPosition = [0, 0], xLeft += sizePlusGap);
  43946. showNextBtn && (nextBtnPosition = [xRight - controlSize, 0], xRight -= sizePlusGap);
  43947. }
  43948. axisExtent = [xLeft, xRight];
  43949. if (timelineModel.get('inverse')) {
  43950. axisExtent.reverse();
  43951. }
  43952. return {
  43953. viewRect: viewRect,
  43954. mainLength: mainLength,
  43955. orient: orient,
  43956. rotation: rotationMap[orient],
  43957. labelRotation: labelRotation,
  43958. labelPosOpt: labelPosOpt,
  43959. labelAlign: labelAlignMap[orient],
  43960. labelBaseline: labelBaselineMap[orient],
  43961. // Based on mainGroup.
  43962. playPosition: playPosition,
  43963. prevBtnPosition: prevBtnPosition,
  43964. nextBtnPosition: nextBtnPosition,
  43965. axisExtent: axisExtent,
  43966. controlSize: controlSize,
  43967. controlGap: controlGap
  43968. };
  43969. },
  43970. _position: function (layoutInfo, timelineModel) {
  43971. // Position is be called finally, because bounding rect is needed for
  43972. // adapt content to fill viewRect (auto adapt offset).
  43973. // Timeline may be not all in the viewRect when 'offset' is specified
  43974. // as a number, because it is more appropriate that label aligns at
  43975. // 'offset' but not the other edge defined by viewRect.
  43976. var mainGroup = this._mainGroup;
  43977. var labelGroup = this._labelGroup;
  43978. var viewRect = layoutInfo.viewRect;
  43979. if (layoutInfo.orient === 'vertical') {
  43980. // transfrom to horizontal, inverse rotate by left-top point.
  43981. var m = matrix.create();
  43982. var rotateOriginX = viewRect.x;
  43983. var rotateOriginY = viewRect.y + viewRect.height;
  43984. matrix.translate(m, m, [-rotateOriginX, -rotateOriginY]);
  43985. matrix.rotate(m, m, -PI / 2);
  43986. matrix.translate(m, m, [rotateOriginX, rotateOriginY]);
  43987. viewRect = viewRect.clone();
  43988. viewRect.applyTransform(m);
  43989. }
  43990. var viewBound = getBound(viewRect);
  43991. var mainBound = getBound(mainGroup.getBoundingRect());
  43992. var labelBound = getBound(labelGroup.getBoundingRect());
  43993. var mainPosition = mainGroup.position;
  43994. var labelsPosition = labelGroup.position;
  43995. labelsPosition[0] = mainPosition[0] = viewBound[0][0];
  43996. var labelPosOpt = layoutInfo.labelPosOpt;
  43997. if (isNaN(labelPosOpt)) { // '+' or '-'
  43998. var mainBoundIdx = labelPosOpt === '+' ? 0 : 1;
  43999. toBound(mainPosition, mainBound, viewBound, 1, mainBoundIdx);
  44000. toBound(labelsPosition, labelBound, viewBound, 1, 1 - mainBoundIdx);
  44001. }
  44002. else {
  44003. var mainBoundIdx = labelPosOpt >= 0 ? 0 : 1;
  44004. toBound(mainPosition, mainBound, viewBound, 1, mainBoundIdx);
  44005. labelsPosition[1] = mainPosition[1] + labelPosOpt;
  44006. }
  44007. mainGroup.position = mainPosition;
  44008. labelGroup.position = labelsPosition;
  44009. mainGroup.rotation = labelGroup.rotation = layoutInfo.rotation;
  44010. setOrigin(mainGroup);
  44011. setOrigin(labelGroup);
  44012. function setOrigin(targetGroup) {
  44013. var pos = targetGroup.position;
  44014. targetGroup.origin = [
  44015. viewBound[0][0] - pos[0],
  44016. viewBound[1][0] - pos[1]
  44017. ];
  44018. }
  44019. function getBound(rect) {
  44020. // [[xmin, xmax], [ymin, ymax]]
  44021. return [
  44022. [rect.x, rect.x + rect.width],
  44023. [rect.y, rect.y + rect.height]
  44024. ];
  44025. }
  44026. function toBound(fromPos, from, to, dimIdx, boundIdx) {
  44027. fromPos[dimIdx] += to[dimIdx][boundIdx] - from[dimIdx][boundIdx];
  44028. }
  44029. },
  44030. _createAxis: function (layoutInfo, timelineModel) {
  44031. var data = timelineModel.getData();
  44032. var axisType = timelineModel.get('axisType');
  44033. var scale = axisHelper.createScaleByModel(timelineModel, axisType);
  44034. var dataExtent = data.getDataExtent('value');
  44035. scale.setExtent(dataExtent[0], dataExtent[1]);
  44036. this._customizeScale(scale, data);
  44037. scale.niceTicks();
  44038. var axis = new TimelineAxis('value', scale, layoutInfo.axisExtent, axisType);
  44039. axis.model = timelineModel;
  44040. return axis;
  44041. },
  44042. _customizeScale: function (scale, data) {
  44043. scale.getTicks = function () {
  44044. return data.mapArray(['value'], function (value) {
  44045. return value;
  44046. });
  44047. };
  44048. scale.getTicksLabels = function () {
  44049. return zrUtil.map(this.getTicks(), scale.getLabel, scale);
  44050. };
  44051. },
  44052. _createGroup: function (name) {
  44053. var newGroup = this['_' + name] = new graphic.Group();
  44054. this.group.add(newGroup);
  44055. return newGroup;
  44056. },
  44057. _renderAxisLine: function (layoutInfo, group, axis, timelineModel) {
  44058. var axisExtent = axis.getExtent();
  44059. if (!timelineModel.get('lineStyle.show')) {
  44060. return;
  44061. }
  44062. group.add(new graphic.Line({
  44063. shape: {
  44064. x1: axisExtent[0], y1: 0,
  44065. x2: axisExtent[1], y2: 0
  44066. },
  44067. style: zrUtil.extend(
  44068. {lineCap: 'round'},
  44069. timelineModel.getModel('lineStyle').getLineStyle()
  44070. ),
  44071. silent: true,
  44072. z2: 1
  44073. }));
  44074. },
  44075. /**
  44076. * @private
  44077. */
  44078. _renderAxisTick: function (layoutInfo, group, axis, timelineModel) {
  44079. var data = timelineModel.getData();
  44080. var ticks = axis.scale.getTicks();
  44081. each(ticks, function (value, dataIndex) {
  44082. var tickCoord = axis.dataToCoord(value);
  44083. var itemModel = data.getItemModel(dataIndex);
  44084. var itemStyleModel = itemModel.getModel('itemStyle.normal');
  44085. var hoverStyleModel = itemModel.getModel('itemStyle.emphasis');
  44086. var symbolOpt = {
  44087. position: [tickCoord, 0],
  44088. onclick: bind(this._changeTimeline, this, dataIndex)
  44089. };
  44090. var el = giveSymbol(itemModel, itemStyleModel, group, symbolOpt);
  44091. graphic.setHoverStyle(el, hoverStyleModel.getItemStyle());
  44092. if (itemModel.get('tooltip')) {
  44093. el.dataIndex = dataIndex;
  44094. el.dataModel = timelineModel;
  44095. }
  44096. else {
  44097. el.dataIndex = el.dataModel = null;
  44098. }
  44099. }, this);
  44100. },
  44101. /**
  44102. * @private
  44103. */
  44104. _renderAxisLabel: function (layoutInfo, group, axis, timelineModel) {
  44105. var labelModel = timelineModel.getModel('label.normal');
  44106. if (!labelModel.get('show')) {
  44107. return;
  44108. }
  44109. var data = timelineModel.getData();
  44110. var ticks = axis.scale.getTicks();
  44111. var labels = axisHelper.getFormattedLabels(
  44112. axis, labelModel.get('formatter')
  44113. );
  44114. var labelInterval = axis.getLabelInterval();
  44115. each(ticks, function (tick, dataIndex) {
  44116. if (axis.isLabelIgnored(dataIndex, labelInterval)) {
  44117. return;
  44118. }
  44119. var itemModel = data.getItemModel(dataIndex);
  44120. var itemTextStyleModel = itemModel.getModel('label.normal.textStyle');
  44121. var hoverTextStyleModel = itemModel.getModel('label.emphasis.textStyle');
  44122. var tickCoord = axis.dataToCoord(tick);
  44123. var textEl = new graphic.Text({
  44124. style: {
  44125. text: labels[dataIndex],
  44126. textAlign: layoutInfo.labelAlign,
  44127. textVerticalAlign: layoutInfo.labelBaseline,
  44128. textFont: itemTextStyleModel.getFont(),
  44129. fill: itemTextStyleModel.getTextColor()
  44130. },
  44131. position: [tickCoord, 0],
  44132. rotation: layoutInfo.labelRotation - layoutInfo.rotation,
  44133. onclick: bind(this._changeTimeline, this, dataIndex),
  44134. silent: false
  44135. });
  44136. group.add(textEl);
  44137. graphic.setHoverStyle(textEl, hoverTextStyleModel.getItemStyle());
  44138. }, this);
  44139. },
  44140. /**
  44141. * @private
  44142. */
  44143. _renderControl: function (layoutInfo, group, axis, timelineModel) {
  44144. var controlSize = layoutInfo.controlSize;
  44145. var rotation = layoutInfo.rotation;
  44146. var itemStyle = timelineModel.getModel('controlStyle.normal').getItemStyle();
  44147. var hoverStyle = timelineModel.getModel('controlStyle.emphasis').getItemStyle();
  44148. var rect = [0, -controlSize / 2, controlSize, controlSize];
  44149. var playState = timelineModel.getPlayState();
  44150. var inverse = timelineModel.get('inverse', true);
  44151. makeBtn(
  44152. layoutInfo.nextBtnPosition,
  44153. 'controlStyle.nextIcon',
  44154. bind(this._changeTimeline, this, inverse ? '-' : '+')
  44155. );
  44156. makeBtn(
  44157. layoutInfo.prevBtnPosition,
  44158. 'controlStyle.prevIcon',
  44159. bind(this._changeTimeline, this, inverse ? '+' : '-')
  44160. );
  44161. makeBtn(
  44162. layoutInfo.playPosition,
  44163. 'controlStyle.' + (playState ? 'stopIcon' : 'playIcon'),
  44164. bind(this._handlePlayClick, this, !playState),
  44165. true
  44166. );
  44167. function makeBtn(position, iconPath, onclick, willRotate) {
  44168. if (!position) {
  44169. return;
  44170. }
  44171. var opt = {
  44172. position: position,
  44173. origin: [controlSize / 2, 0],
  44174. rotation: willRotate ? -rotation : 0,
  44175. rectHover: true,
  44176. style: itemStyle,
  44177. onclick: onclick
  44178. };
  44179. var btn = makeIcon(timelineModel, iconPath, rect, opt);
  44180. group.add(btn);
  44181. graphic.setHoverStyle(btn, hoverStyle);
  44182. }
  44183. },
  44184. _renderCurrentPointer: function (layoutInfo, group, axis, timelineModel) {
  44185. var data = timelineModel.getData();
  44186. var currentIndex = timelineModel.getCurrentIndex();
  44187. var pointerModel = data.getItemModel(currentIndex).getModel('checkpointStyle');
  44188. var me = this;
  44189. var callback = {
  44190. onCreate: function (pointer) {
  44191. pointer.draggable = true;
  44192. pointer.drift = bind(me._handlePointerDrag, me);
  44193. pointer.ondragend = bind(me._handlePointerDragend, me);
  44194. pointerMoveTo(pointer, currentIndex, axis, timelineModel, true);
  44195. },
  44196. onUpdate: function (pointer) {
  44197. pointerMoveTo(pointer, currentIndex, axis, timelineModel);
  44198. }
  44199. };
  44200. // Reuse when exists, for animation and drag.
  44201. this._currentPointer = giveSymbol(
  44202. pointerModel, pointerModel, this._mainGroup, {}, this._currentPointer, callback
  44203. );
  44204. },
  44205. _handlePlayClick: function (nextState) {
  44206. this._clearTimer();
  44207. this.api.dispatchAction({
  44208. type: 'timelinePlayChange',
  44209. playState: nextState,
  44210. from: this.uid
  44211. });
  44212. },
  44213. _handlePointerDrag: function (dx, dy, e) {
  44214. this._clearTimer();
  44215. this._pointerChangeTimeline([e.offsetX, e.offsetY]);
  44216. },
  44217. _handlePointerDragend: function (e) {
  44218. this._pointerChangeTimeline([e.offsetX, e.offsetY], true);
  44219. },
  44220. _pointerChangeTimeline: function (mousePos, trigger) {
  44221. var toCoord = this._toAxisCoord(mousePos)[0];
  44222. var axis = this._axis;
  44223. var axisExtent = numberUtil.asc(axis.getExtent().slice());
  44224. toCoord > axisExtent[1] && (toCoord = axisExtent[1]);
  44225. toCoord < axisExtent[0] && (toCoord = axisExtent[0]);
  44226. this._currentPointer.position[0] = toCoord;
  44227. this._currentPointer.dirty();
  44228. var targetDataIndex = this._findNearestTick(toCoord);
  44229. var timelineModel = this.model;
  44230. if (trigger || (
  44231. targetDataIndex !== timelineModel.getCurrentIndex()
  44232. && timelineModel.get('realtime')
  44233. )) {
  44234. this._changeTimeline(targetDataIndex);
  44235. }
  44236. },
  44237. _doPlayStop: function () {
  44238. this._clearTimer();
  44239. if (this.model.getPlayState()) {
  44240. this._timer = setTimeout(
  44241. bind(handleFrame, this),
  44242. this.model.get('playInterval')
  44243. );
  44244. }
  44245. function handleFrame() {
  44246. // Do not cache
  44247. var timelineModel = this.model;
  44248. this._changeTimeline(
  44249. timelineModel.getCurrentIndex()
  44250. + (timelineModel.get('rewind', true) ? -1 : 1)
  44251. );
  44252. }
  44253. },
  44254. _toAxisCoord: function (vertex) {
  44255. var trans = this._mainGroup.getLocalTransform();
  44256. return graphic.applyTransform(vertex, trans, true);
  44257. },
  44258. _findNearestTick: function (axisCoord) {
  44259. var data = this.model.getData();
  44260. var dist = Infinity;
  44261. var targetDataIndex;
  44262. var axis = this._axis;
  44263. data.each(['value'], function (value, dataIndex) {
  44264. var coord = axis.dataToCoord(value);
  44265. var d = Math.abs(coord - axisCoord);
  44266. if (d < dist) {
  44267. dist = d;
  44268. targetDataIndex = dataIndex;
  44269. }
  44270. });
  44271. return targetDataIndex;
  44272. },
  44273. _clearTimer: function () {
  44274. if (this._timer) {
  44275. clearTimeout(this._timer);
  44276. this._timer = null;
  44277. }
  44278. },
  44279. _changeTimeline: function (nextIndex) {
  44280. var currentIndex = this.model.getCurrentIndex();
  44281. if (nextIndex === '+') {
  44282. nextIndex = currentIndex + 1;
  44283. }
  44284. else if (nextIndex === '-') {
  44285. nextIndex = currentIndex - 1;
  44286. }
  44287. this.api.dispatchAction({
  44288. type: 'timelineChange',
  44289. currentIndex: nextIndex,
  44290. from: this.uid
  44291. });
  44292. }
  44293. });
  44294. function getViewRect(model, api) {
  44295. return layout.getLayoutRect(
  44296. model.getBoxLayoutParams(),
  44297. {
  44298. width: api.getWidth(),
  44299. height: api.getHeight()
  44300. },
  44301. model.get('padding')
  44302. );
  44303. }
  44304. function makeIcon(timelineModel, objPath, rect, opts) {
  44305. var icon = graphic.makePath(
  44306. timelineModel.get(objPath).replace(/^path:\/\//, ''),
  44307. zrUtil.clone(opts || {}),
  44308. new BoundingRect(rect[0], rect[1], rect[2], rect[3]),
  44309. 'center'
  44310. );
  44311. return icon;
  44312. }
  44313. /**
  44314. * Create symbol or update symbol
  44315. */
  44316. function giveSymbol(hostModel, itemStyleModel, group, opt, symbol, callback) {
  44317. var symbolType = hostModel.get('symbol');
  44318. var color = itemStyleModel.get('color');
  44319. var symbolSize = hostModel.get('symbolSize');
  44320. var halfSymbolSize = symbolSize / 2;
  44321. var itemStyle = itemStyleModel.getItemStyle(['color', 'symbol', 'symbolSize']);
  44322. if (!symbol) {
  44323. symbol = symbolUtil.createSymbol(
  44324. symbolType, -halfSymbolSize, -halfSymbolSize, symbolSize, symbolSize, color
  44325. );
  44326. group.add(symbol);
  44327. callback && callback.onCreate(symbol);
  44328. }
  44329. else {
  44330. symbol.setStyle(itemStyle);
  44331. symbol.setColor(color);
  44332. group.add(symbol); // Group may be new, also need to add.
  44333. callback && callback.onUpdate(symbol);
  44334. }
  44335. opt = zrUtil.merge({
  44336. rectHover: true,
  44337. style: itemStyle,
  44338. z2: 100
  44339. }, opt, true);
  44340. symbol.attr(opt);
  44341. return symbol;
  44342. }
  44343. function pointerMoveTo(pointer, dataIndex, axis, timelineModel, noAnimation) {
  44344. if (pointer.dragging) {
  44345. return;
  44346. }
  44347. var pointerModel = timelineModel.getModel('checkpointStyle');
  44348. var toCoord = axis.dataToCoord(timelineModel.getData().get(['value'], dataIndex));
  44349. if (noAnimation || !pointerModel.get('animation', true)) {
  44350. pointer.attr({position: [toCoord, 0]});
  44351. }
  44352. else {
  44353. pointer.stopAnimation(true);
  44354. pointer.animateTo(
  44355. {position: [toCoord, 0]},
  44356. pointerModel.get('animationDuration', true),
  44357. pointerModel.get('animationEasing', true)
  44358. );
  44359. }
  44360. }
  44361. /***/ },
  44362. /* 333 */
  44363. /***/ function(module, exports, __webpack_require__) {
  44364. /**
  44365. * @file Timeline view
  44366. */
  44367. // var zrUtil = require('zrender/lib/core/util');
  44368. // var graphic = require('../../util/graphic');
  44369. var ComponentView = __webpack_require__(28);
  44370. module.exports = ComponentView.extend({
  44371. type: 'timeline'
  44372. });
  44373. /***/ },
  44374. /* 334 */
  44375. /***/ function(module, exports, __webpack_require__) {
  44376. var zrUtil = __webpack_require__(3);
  44377. var Axis = __webpack_require__(118);
  44378. var axisHelper = __webpack_require__(109);
  44379. /**
  44380. * Extend axis 2d
  44381. * @constructor module:echarts/coord/cartesian/Axis2D
  44382. * @extends {module:echarts/coord/cartesian/Axis}
  44383. * @param {string} dim
  44384. * @param {*} scale
  44385. * @param {Array.<number>} coordExtent
  44386. * @param {string} axisType
  44387. * @param {string} position
  44388. */
  44389. var TimelineAxis = function (dim, scale, coordExtent, axisType) {
  44390. Axis.call(this, dim, scale, coordExtent);
  44391. /**
  44392. * Axis type
  44393. * - 'category'
  44394. * - 'value'
  44395. * - 'time'
  44396. * - 'log'
  44397. * @type {string}
  44398. */
  44399. this.type = axisType || 'value';
  44400. /**
  44401. * @private
  44402. * @type {number}
  44403. */
  44404. this._autoLabelInterval;
  44405. /**
  44406. * Axis model
  44407. * @param {module:echarts/component/TimelineModel}
  44408. */
  44409. this.model = null;
  44410. };
  44411. TimelineAxis.prototype = {
  44412. constructor: TimelineAxis,
  44413. /**
  44414. * @public
  44415. * @return {number}
  44416. */
  44417. getLabelInterval: function () {
  44418. var timelineModel = this.model;
  44419. var labelModel = timelineModel.getModel('label.normal');
  44420. var labelInterval = labelModel.get('interval');
  44421. if (labelInterval != null && labelInterval != 'auto') {
  44422. return labelInterval;
  44423. }
  44424. var labelInterval = this._autoLabelInterval;
  44425. if (!labelInterval) {
  44426. labelInterval = this._autoLabelInterval = axisHelper.getAxisLabelInterval(
  44427. zrUtil.map(this.scale.getTicks(), this.dataToCoord, this),
  44428. axisHelper.getFormattedLabels(this, labelModel.get('formatter')),
  44429. labelModel.getModel('textStyle').getFont(),
  44430. timelineModel.get('orient') === 'horizontal'
  44431. );
  44432. }
  44433. return labelInterval;
  44434. },
  44435. /**
  44436. * If label is ignored.
  44437. * Automatically used when axis is category and label can not be all shown
  44438. * @public
  44439. * @param {number} idx
  44440. * @return {boolean}
  44441. */
  44442. isLabelIgnored: function (idx) {
  44443. if (this.type === 'category') {
  44444. var labelInterval = this.getLabelInterval();
  44445. return ((typeof labelInterval === 'function')
  44446. && !labelInterval(idx, this.scale.getLabel(idx)))
  44447. || idx % (labelInterval + 1);
  44448. }
  44449. }
  44450. };
  44451. zrUtil.inherits(TimelineAxis, Axis);
  44452. module.exports = TimelineAxis;
  44453. /***/ },
  44454. /* 335 */
  44455. /***/ function(module, exports, __webpack_require__) {
  44456. __webpack_require__(336);
  44457. __webpack_require__(338);
  44458. __webpack_require__(340);
  44459. __webpack_require__(341);
  44460. __webpack_require__(342);
  44461. __webpack_require__(343);
  44462. __webpack_require__(348);
  44463. /***/ },
  44464. /* 336 */
  44465. /***/ function(module, exports, __webpack_require__) {
  44466. var featureManager = __webpack_require__(337);
  44467. var zrUtil = __webpack_require__(3);
  44468. var ToolboxModel = __webpack_require__(1).extendComponentModel({
  44469. type: 'toolbox',
  44470. layoutMode: {
  44471. type: 'box',
  44472. ignoreSize: true
  44473. },
  44474. mergeDefaultAndTheme: function (option) {
  44475. ToolboxModel.superApply(this, 'mergeDefaultAndTheme', arguments);
  44476. zrUtil.each(this.option.feature, function (featureOpt, featureName) {
  44477. var Feature = featureManager.get(featureName);
  44478. Feature && zrUtil.merge(featureOpt, Feature.defaultOption);
  44479. });
  44480. },
  44481. defaultOption: {
  44482. show: true,
  44483. z: 6,
  44484. zlevel: 0,
  44485. orient: 'horizontal',
  44486. left: 'right',
  44487. top: 'top',
  44488. // right
  44489. // bottom
  44490. backgroundColor: 'transparent',
  44491. borderColor: '#ccc',
  44492. borderWidth: 0,
  44493. padding: 5,
  44494. itemSize: 15,
  44495. itemGap: 8,
  44496. showTitle: true,
  44497. iconStyle: {
  44498. normal: {
  44499. borderColor: '#666',
  44500. color: 'none'
  44501. },
  44502. emphasis: {
  44503. borderColor: '#3E98C5'
  44504. }
  44505. }
  44506. // textStyle: {},
  44507. // feature
  44508. }
  44509. });
  44510. module.exports = ToolboxModel;
  44511. /***/ },
  44512. /* 337 */
  44513. /***/ function(module, exports) {
  44514. 'use strict';
  44515. var features = {};
  44516. module.exports = {
  44517. register: function (name, ctor) {
  44518. features[name] = ctor;
  44519. },
  44520. get: function (name) {
  44521. return features[name];
  44522. }
  44523. };
  44524. /***/ },
  44525. /* 338 */
  44526. /***/ function(module, exports, __webpack_require__) {
  44527. /* WEBPACK VAR INJECTION */(function(process) {
  44528. var featureManager = __webpack_require__(337);
  44529. var zrUtil = __webpack_require__(3);
  44530. var graphic = __webpack_require__(42);
  44531. var Model = __webpack_require__(8);
  44532. var DataDiffer = __webpack_require__(96);
  44533. var listComponentHelper = __webpack_require__(269);
  44534. var textContain = __webpack_require__(14);
  44535. module.exports = __webpack_require__(1).extendComponentView({
  44536. type: 'toolbox',
  44537. render: function (toolboxModel, ecModel, api) {
  44538. var group = this.group;
  44539. group.removeAll();
  44540. if (!toolboxModel.get('show')) {
  44541. return;
  44542. }
  44543. var itemSize = +toolboxModel.get('itemSize');
  44544. var featureOpts = toolboxModel.get('feature') || {};
  44545. var features = this._features || (this._features = {});
  44546. var featureNames = [];
  44547. zrUtil.each(featureOpts, function (opt, name) {
  44548. featureNames.push(name);
  44549. });
  44550. (new DataDiffer(this._featureNames || [], featureNames))
  44551. .add(process)
  44552. .update(process)
  44553. .remove(zrUtil.curry(process, null))
  44554. .execute();
  44555. // Keep for diff.
  44556. this._featureNames = featureNames;
  44557. function process(newIndex, oldIndex) {
  44558. var featureName = featureNames[newIndex];
  44559. var oldName = featureNames[oldIndex];
  44560. var featureOpt = featureOpts[featureName];
  44561. var featureModel = new Model(featureOpt, toolboxModel, toolboxModel.ecModel);
  44562. var feature;
  44563. if (featureName && !oldName) { // Create
  44564. if (isUserFeatureName(featureName)) {
  44565. feature = {
  44566. model: featureModel,
  44567. onclick: featureModel.option.onclick,
  44568. featureName: featureName
  44569. };
  44570. }
  44571. else {
  44572. var Feature = featureManager.get(featureName);
  44573. if (!Feature) {
  44574. return;
  44575. }
  44576. feature = new Feature(featureModel);
  44577. }
  44578. features[featureName] = feature;
  44579. }
  44580. else {
  44581. feature = features[oldName];
  44582. // If feature does not exsit.
  44583. if (!feature) {
  44584. return;
  44585. }
  44586. feature.model = featureModel;
  44587. }
  44588. if (!featureName && oldName) {
  44589. feature.dispose && feature.dispose(ecModel, api);
  44590. return;
  44591. }
  44592. if (!featureModel.get('show') || feature.unusable) {
  44593. feature.remove && feature.remove(ecModel, api);
  44594. return;
  44595. }
  44596. createIconPaths(featureModel, feature, featureName);
  44597. featureModel.setIconStatus = function (iconName, status) {
  44598. var option = this.option;
  44599. var iconPaths = this.iconPaths;
  44600. option.iconStatus = option.iconStatus || {};
  44601. option.iconStatus[iconName] = status;
  44602. // FIXME
  44603. iconPaths[iconName] && iconPaths[iconName].trigger(status);
  44604. };
  44605. if (feature.render) {
  44606. feature.render(featureModel, ecModel, api);
  44607. }
  44608. }
  44609. function createIconPaths(featureModel, feature, featureName) {
  44610. var iconStyleModel = featureModel.getModel('iconStyle');
  44611. // If one feature has mutiple icon. they are orginaized as
  44612. // {
  44613. // icon: {
  44614. // foo: '',
  44615. // bar: ''
  44616. // },
  44617. // title: {
  44618. // foo: '',
  44619. // bar: ''
  44620. // }
  44621. // }
  44622. var icons = feature.getIcons ? feature.getIcons() : featureModel.get('icon');
  44623. var titles = featureModel.get('title') || {};
  44624. if (typeof icons === 'string') {
  44625. var icon = icons;
  44626. var title = titles;
  44627. icons = {};
  44628. titles = {};
  44629. icons[featureName] = icon;
  44630. titles[featureName] = title;
  44631. }
  44632. var iconPaths = featureModel.iconPaths = {};
  44633. zrUtil.each(icons, function (icon, iconName) {
  44634. var normalStyle = iconStyleModel.getModel('normal').getItemStyle();
  44635. var hoverStyle = iconStyleModel.getModel('emphasis').getItemStyle();
  44636. var style = {
  44637. x: -itemSize / 2,
  44638. y: -itemSize / 2,
  44639. width: itemSize,
  44640. height: itemSize
  44641. };
  44642. var path = icon.indexOf('image://') === 0
  44643. ? (
  44644. style.image = icon.slice(8),
  44645. new graphic.Image({style: style})
  44646. )
  44647. : graphic.makePath(
  44648. icon.replace('path://', ''),
  44649. {
  44650. style: normalStyle,
  44651. hoverStyle: hoverStyle,
  44652. rectHover: true
  44653. },
  44654. style,
  44655. 'center'
  44656. );
  44657. graphic.setHoverStyle(path);
  44658. if (toolboxModel.get('showTitle')) {
  44659. path.__title = titles[iconName];
  44660. path.on('mouseover', function () {
  44661. path.setStyle({
  44662. text: titles[iconName],
  44663. textPosition: hoverStyle.textPosition || 'bottom',
  44664. textFill: hoverStyle.fill || hoverStyle.stroke || '#000',
  44665. textAlign: hoverStyle.textAlign || 'center'
  44666. });
  44667. })
  44668. .on('mouseout', function () {
  44669. path.setStyle({
  44670. textFill: null
  44671. });
  44672. });
  44673. }
  44674. path.trigger(featureModel.get('iconStatus.' + iconName) || 'normal');
  44675. group.add(path);
  44676. path.on('click', zrUtil.bind(
  44677. feature.onclick, feature, ecModel, api, iconName
  44678. ));
  44679. iconPaths[iconName] = path;
  44680. });
  44681. }
  44682. listComponentHelper.layout(group, toolboxModel, api);
  44683. // Render background after group is layout
  44684. // FIXME
  44685. listComponentHelper.addBackground(group, toolboxModel);
  44686. // Adjust icon title positions to avoid them out of screen
  44687. group.eachChild(function (icon) {
  44688. var titleText = icon.__title;
  44689. var hoverStyle = icon.hoverStyle;
  44690. // May be background element
  44691. if (hoverStyle && titleText) {
  44692. var rect = textContain.getBoundingRect(
  44693. titleText, hoverStyle.font
  44694. );
  44695. var offsetX = icon.position[0] + group.position[0];
  44696. var offsetY = icon.position[1] + group.position[1] + itemSize;
  44697. var needPutOnTop = false;
  44698. if (offsetY + rect.height > api.getHeight()) {
  44699. hoverStyle.textPosition = 'top';
  44700. needPutOnTop = true;
  44701. }
  44702. var topOffset = needPutOnTop ? (-5 - rect.height) : (itemSize + 8);
  44703. if (offsetX + rect.width / 2 > api.getWidth()) {
  44704. hoverStyle.textPosition = ['100%', topOffset];
  44705. hoverStyle.textAlign = 'right';
  44706. }
  44707. else if (offsetX - rect.width / 2 < 0) {
  44708. hoverStyle.textPosition = [0, topOffset];
  44709. hoverStyle.textAlign = 'left';
  44710. }
  44711. }
  44712. });
  44713. },
  44714. remove: function (ecModel, api) {
  44715. zrUtil.each(this._features, function (feature) {
  44716. feature.remove && feature.remove(ecModel, api);
  44717. });
  44718. this.group.removeAll();
  44719. },
  44720. dispose: function (ecModel, api) {
  44721. zrUtil.each(this._features, function (feature) {
  44722. feature.dispose && feature.dispose(ecModel, api);
  44723. });
  44724. }
  44725. });
  44726. function isUserFeatureName(featureName) {
  44727. return featureName.indexOf('my') === 0;
  44728. }
  44729. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(339)))
  44730. /***/ },
  44731. /* 339 */
  44732. /***/ function(module, exports) {
  44733. // shim for using process in browser
  44734. var process = module.exports = {};
  44735. var queue = [];
  44736. var draining = false;
  44737. var currentQueue;
  44738. var queueIndex = -1;
  44739. function cleanUpNextTick() {
  44740. draining = false;
  44741. if (currentQueue.length) {
  44742. queue = currentQueue.concat(queue);
  44743. } else {
  44744. queueIndex = -1;
  44745. }
  44746. if (queue.length) {
  44747. drainQueue();
  44748. }
  44749. }
  44750. function drainQueue() {
  44751. if (draining) {
  44752. return;
  44753. }
  44754. var timeout = setTimeout(cleanUpNextTick);
  44755. draining = true;
  44756. var len = queue.length;
  44757. while(len) {
  44758. currentQueue = queue;
  44759. queue = [];
  44760. while (++queueIndex < len) {
  44761. if (currentQueue) {
  44762. currentQueue[queueIndex].run();
  44763. }
  44764. }
  44765. queueIndex = -1;
  44766. len = queue.length;
  44767. }
  44768. currentQueue = null;
  44769. draining = false;
  44770. clearTimeout(timeout);
  44771. }
  44772. process.nextTick = function (fun) {
  44773. var args = new Array(arguments.length - 1);
  44774. if (arguments.length > 1) {
  44775. for (var i = 1; i < arguments.length; i++) {
  44776. args[i - 1] = arguments[i];
  44777. }
  44778. }
  44779. queue.push(new Item(fun, args));
  44780. if (queue.length === 1 && !draining) {
  44781. setTimeout(drainQueue, 0);
  44782. }
  44783. };
  44784. // v8 likes predictible objects
  44785. function Item(fun, array) {
  44786. this.fun = fun;
  44787. this.array = array;
  44788. }
  44789. Item.prototype.run = function () {
  44790. this.fun.apply(null, this.array);
  44791. };
  44792. process.title = 'browser';
  44793. process.browser = true;
  44794. process.env = {};
  44795. process.argv = [];
  44796. process.version = ''; // empty string to avoid regexp issues
  44797. process.versions = {};
  44798. function noop() {}
  44799. process.on = noop;
  44800. process.addListener = noop;
  44801. process.once = noop;
  44802. process.off = noop;
  44803. process.removeListener = noop;
  44804. process.removeAllListeners = noop;
  44805. process.emit = noop;
  44806. process.binding = function (name) {
  44807. throw new Error('process.binding is not supported');
  44808. };
  44809. process.cwd = function () { return '/' };
  44810. process.chdir = function (dir) {
  44811. throw new Error('process.chdir is not supported');
  44812. };
  44813. process.umask = function() { return 0; };
  44814. /***/ },
  44815. /* 340 */
  44816. /***/ function(module, exports, __webpack_require__) {
  44817. var env = __webpack_require__(79);
  44818. function SaveAsImage (model) {
  44819. this.model = model;
  44820. }
  44821. SaveAsImage.defaultOption = {
  44822. show: true,
  44823. 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',
  44824. title: '保存为图片',
  44825. type: 'png',
  44826. // Default use option.backgroundColor
  44827. // backgroundColor: '#fff',
  44828. name: '',
  44829. excludeComponents: ['toolbox'],
  44830. pixelRatio: 1,
  44831. lang: ['右键另存为图片']
  44832. };
  44833. SaveAsImage.prototype.unusable = !env.canvasSupported;
  44834. var proto = SaveAsImage.prototype;
  44835. proto.onclick = function (ecModel, api) {
  44836. var model = this.model;
  44837. var title = model.get('name') || ecModel.get('title.0.text') || 'echarts';
  44838. var $a = document.createElement('a');
  44839. var type = model.get('type', true) || 'png';
  44840. $a.download = title + '.' + type;
  44841. $a.target = '_blank';
  44842. var url = api.getConnectedDataURL({
  44843. type: type,
  44844. backgroundColor: model.get('backgroundColor', true)
  44845. || ecModel.get('backgroundColor') || '#fff',
  44846. excludeComponents: model.get('excludeComponents'),
  44847. pixelRatio: model.get('pixelRatio')
  44848. });
  44849. $a.href = url;
  44850. // Chrome and Firefox
  44851. if (typeof MouseEvent === 'function') {
  44852. var evt = new MouseEvent('click', {
  44853. view: window,
  44854. bubbles: true,
  44855. cancelable: false
  44856. });
  44857. $a.dispatchEvent(evt);
  44858. }
  44859. // IE
  44860. else {
  44861. var lang = model.get('lang');
  44862. var html = ''
  44863. + '<body style="margin:0;">'
  44864. + '<img src="' + url + '" style="max-width:100%;" title="' + ((lang && lang[0]) || '') + '" />'
  44865. + '</body>';
  44866. var tab = window.open();
  44867. tab.document.write(html);
  44868. }
  44869. };
  44870. __webpack_require__(337).register(
  44871. 'saveAsImage', SaveAsImage
  44872. );
  44873. module.exports = SaveAsImage;
  44874. /***/ },
  44875. /* 341 */
  44876. /***/ function(module, exports, __webpack_require__) {
  44877. 'use strict';
  44878. var zrUtil = __webpack_require__(3);
  44879. function MagicType(model) {
  44880. this.model = model;
  44881. }
  44882. MagicType.defaultOption = {
  44883. show: true,
  44884. type: [],
  44885. // Icon group
  44886. icon: {
  44887. line: 'M4.1,28.9h7.1l9.3-22l7.4,38l9.7-19.7l3,12.8h14.9M4.1,58h51.4',
  44888. bar: 'M6.7,22.9h10V48h-10V22.9zM24.9,13h10v35h-10V13zM43.2,2h10v46h-10V2zM3.1,58h53.7',
  44889. 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
  44890. tiled: 'M2.3,2.2h22.8V25H2.3V2.2z M35,2.2h22.8V25H35V2.2zM2.3,35h22.8v22.8H2.3V35z M35,35h22.8v22.8H35V35z'
  44891. },
  44892. title: {
  44893. line: '切换为折线图',
  44894. bar: '切换为柱状图',
  44895. stack: '切换为堆叠',
  44896. tiled: '切换为平铺'
  44897. },
  44898. option: {},
  44899. seriesIndex: {}
  44900. };
  44901. var proto = MagicType.prototype;
  44902. proto.getIcons = function () {
  44903. var model = this.model;
  44904. var availableIcons = model.get('icon');
  44905. var icons = {};
  44906. zrUtil.each(model.get('type'), function (type) {
  44907. if (availableIcons[type]) {
  44908. icons[type] = availableIcons[type];
  44909. }
  44910. });
  44911. return icons;
  44912. };
  44913. var seriesOptGenreator = {
  44914. 'line': function (seriesType, seriesId, seriesModel, model) {
  44915. if (seriesType === 'bar') {
  44916. return zrUtil.merge({
  44917. id: seriesId,
  44918. type: 'line',
  44919. // Preserve data related option
  44920. data: seriesModel.get('data'),
  44921. stack: seriesModel.get('stack'),
  44922. markPoint: seriesModel.get('markPoint'),
  44923. markLine: seriesModel.get('markLine')
  44924. }, model.get('option.line') || {}, true);
  44925. }
  44926. },
  44927. 'bar': function (seriesType, seriesId, seriesModel, model) {
  44928. if (seriesType === 'line') {
  44929. return zrUtil.merge({
  44930. id: seriesId,
  44931. type: 'bar',
  44932. // Preserve data related option
  44933. data: seriesModel.get('data'),
  44934. stack: seriesModel.get('stack'),
  44935. markPoint: seriesModel.get('markPoint'),
  44936. markLine: seriesModel.get('markLine')
  44937. }, model.get('option.bar') || {}, true);
  44938. }
  44939. },
  44940. 'stack': function (seriesType, seriesId, seriesModel, model) {
  44941. if (seriesType === 'line' || seriesType === 'bar') {
  44942. return zrUtil.merge({
  44943. id: seriesId,
  44944. stack: '__ec_magicType_stack__'
  44945. }, model.get('option.stack') || {}, true);
  44946. }
  44947. },
  44948. 'tiled': function (seriesType, seriesId, seriesModel, model) {
  44949. if (seriesType === 'line' || seriesType === 'bar') {
  44950. return zrUtil.merge({
  44951. id: seriesId,
  44952. stack: ''
  44953. }, model.get('option.tiled') || {}, true);
  44954. }
  44955. }
  44956. };
  44957. var radioTypes = [
  44958. ['line', 'bar'],
  44959. ['stack', 'tiled']
  44960. ];
  44961. proto.onclick = function (ecModel, api, type) {
  44962. var model = this.model;
  44963. var seriesIndex = model.get('seriesIndex.' + type);
  44964. // Not supported magicType
  44965. if (!seriesOptGenreator[type]) {
  44966. return;
  44967. }
  44968. var newOption = {
  44969. series: []
  44970. };
  44971. var generateNewSeriesTypes = function (seriesModel) {
  44972. var seriesType = seriesModel.subType;
  44973. var seriesId = seriesModel.id;
  44974. var newSeriesOpt = seriesOptGenreator[type](
  44975. seriesType, seriesId, seriesModel, model
  44976. );
  44977. if (newSeriesOpt) {
  44978. // PENDING If merge original option?
  44979. zrUtil.defaults(newSeriesOpt, seriesModel.option);
  44980. newOption.series.push(newSeriesOpt);
  44981. }
  44982. // Modify boundaryGap
  44983. var coordSys = seriesModel.coordinateSystem;
  44984. if (coordSys && coordSys.type === 'cartesian2d' && (type === 'line' || type === 'bar')) {
  44985. var categoryAxis = coordSys.getAxesByScale('ordinal')[0];
  44986. if (categoryAxis) {
  44987. var axisDim = categoryAxis.dim;
  44988. var axisIndex = seriesModel.get(axisDim + 'AxisIndex');
  44989. var axisKey = axisDim + 'Axis';
  44990. newOption[axisKey] = newOption[axisKey] || [];
  44991. for (var i = 0; i <= axisIndex; i++) {
  44992. newOption[axisKey][axisIndex] = newOption[axisKey][axisIndex] || {};
  44993. }
  44994. newOption[axisKey][axisIndex].boundaryGap = type === 'bar' ? true : false;
  44995. }
  44996. }
  44997. };
  44998. zrUtil.each(radioTypes, function (radio) {
  44999. if (zrUtil.indexOf(radio, type) >= 0) {
  45000. zrUtil.each(radio, function (item) {
  45001. model.setIconStatus(item, 'normal');
  45002. });
  45003. }
  45004. });
  45005. model.setIconStatus(type, 'emphasis');
  45006. ecModel.eachComponent(
  45007. {
  45008. mainType: 'series',
  45009. query: seriesIndex == null ? null : {
  45010. seriesIndex: seriesIndex
  45011. }
  45012. }, generateNewSeriesTypes
  45013. );
  45014. api.dispatchAction({
  45015. type: 'changeMagicType',
  45016. currentType: type,
  45017. newOption: newOption
  45018. });
  45019. };
  45020. var echarts = __webpack_require__(1);
  45021. echarts.registerAction({
  45022. type: 'changeMagicType',
  45023. event: 'magicTypeChanged',
  45024. update: 'prepareAndUpdate'
  45025. }, function (payload, ecModel) {
  45026. ecModel.mergeOption(payload.newOption);
  45027. });
  45028. __webpack_require__(337).register('magicType', MagicType);
  45029. module.exports = MagicType;
  45030. /***/ },
  45031. /* 342 */
  45032. /***/ function(module, exports, __webpack_require__) {
  45033. /**
  45034. * @module echarts/component/toolbox/feature/DataView
  45035. */
  45036. var zrUtil = __webpack_require__(3);
  45037. var eventTool = __webpack_require__(81);
  45038. var BLOCK_SPLITER = new Array(60).join('-');
  45039. var ITEM_SPLITER = '\t';
  45040. /**
  45041. * Group series into two types
  45042. * 1. on category axis, like line, bar
  45043. * 2. others, like scatter, pie
  45044. * @param {module:echarts/model/Global} ecModel
  45045. * @return {Object}
  45046. * @inner
  45047. */
  45048. function groupSeries(ecModel) {
  45049. var seriesGroupByCategoryAxis = {};
  45050. var otherSeries = [];
  45051. var meta = [];
  45052. ecModel.eachRawSeries(function (seriesModel) {
  45053. var coordSys = seriesModel.coordinateSystem;
  45054. if (coordSys && (coordSys.type === 'cartesian2d' || coordSys.type === 'polar')) {
  45055. var baseAxis = coordSys.getBaseAxis();
  45056. if (baseAxis.type === 'category') {
  45057. var key = baseAxis.dim + '_' + baseAxis.index;
  45058. if (!seriesGroupByCategoryAxis[key]) {
  45059. seriesGroupByCategoryAxis[key] = {
  45060. categoryAxis: baseAxis,
  45061. valueAxis: coordSys.getOtherAxis(baseAxis),
  45062. series: []
  45063. };
  45064. meta.push({
  45065. axisDim: baseAxis.dim,
  45066. axisIndex: baseAxis.index
  45067. });
  45068. }
  45069. seriesGroupByCategoryAxis[key].series.push(seriesModel);
  45070. }
  45071. else {
  45072. otherSeries.push(seriesModel);
  45073. }
  45074. }
  45075. else {
  45076. otherSeries.push(seriesModel);
  45077. }
  45078. });
  45079. return {
  45080. seriesGroupByCategoryAxis: seriesGroupByCategoryAxis,
  45081. other: otherSeries,
  45082. meta: meta
  45083. };
  45084. }
  45085. /**
  45086. * Assemble content of series on cateogory axis
  45087. * @param {Array.<module:echarts/model/Series>} series
  45088. * @return {string}
  45089. * @inner
  45090. */
  45091. function assembleSeriesWithCategoryAxis(series) {
  45092. var tables = [];
  45093. zrUtil.each(series, function (group, key) {
  45094. var categoryAxis = group.categoryAxis;
  45095. var valueAxis = group.valueAxis;
  45096. var valueAxisDim = valueAxis.dim;
  45097. var headers = [' '].concat(zrUtil.map(group.series, function (series) {
  45098. return series.name;
  45099. }));
  45100. var columns = [categoryAxis.model.getCategories()];
  45101. zrUtil.each(group.series, function (series) {
  45102. columns.push(series.getRawData().mapArray(valueAxisDim, function (val) {
  45103. return val;
  45104. }));
  45105. });
  45106. // Assemble table content
  45107. var lines = [headers.join(ITEM_SPLITER)];
  45108. for (var i = 0; i < columns[0].length; i++) {
  45109. var items = [];
  45110. for (var j = 0; j < columns.length; j++) {
  45111. items.push(columns[j][i]);
  45112. }
  45113. lines.push(items.join(ITEM_SPLITER));
  45114. }
  45115. tables.push(lines.join('\n'));
  45116. });
  45117. return tables.join('\n\n' + BLOCK_SPLITER + '\n\n');
  45118. }
  45119. /**
  45120. * Assemble content of other series
  45121. * @param {Array.<module:echarts/model/Series>} series
  45122. * @return {string}
  45123. * @inner
  45124. */
  45125. function assembleOtherSeries(series) {
  45126. return zrUtil.map(series, function (series) {
  45127. var data = series.getRawData();
  45128. var lines = [series.name];
  45129. var vals = [];
  45130. data.each(data.dimensions, function () {
  45131. var argLen = arguments.length;
  45132. var dataIndex = arguments[argLen - 1];
  45133. var name = data.getName(dataIndex);
  45134. for (var i = 0; i < argLen - 1; i++) {
  45135. vals[i] = arguments[i];
  45136. }
  45137. lines.push((name ? (name + ITEM_SPLITER) : '') + vals.join(ITEM_SPLITER));
  45138. });
  45139. return lines.join('\n');
  45140. }).join('\n\n' + BLOCK_SPLITER + '\n\n');
  45141. }
  45142. /**
  45143. * @param {module:echarts/model/Global}
  45144. * @return {string}
  45145. * @inner
  45146. */
  45147. function getContentFromModel(ecModel) {
  45148. var result = groupSeries(ecModel);
  45149. return {
  45150. value: zrUtil.filter([
  45151. assembleSeriesWithCategoryAxis(result.seriesGroupByCategoryAxis),
  45152. assembleOtherSeries(result.other)
  45153. ], function (str) {
  45154. return str.replace(/[\n\t\s]/g, '');
  45155. }).join('\n\n' + BLOCK_SPLITER + '\n\n'),
  45156. meta: result.meta
  45157. };
  45158. }
  45159. function trim(str) {
  45160. return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
  45161. }
  45162. /**
  45163. * If a block is tsv format
  45164. */
  45165. function isTSVFormat(block) {
  45166. // Simple method to find out if a block is tsv format
  45167. var firstLine = block.slice(0, block.indexOf('\n'));
  45168. if (firstLine.indexOf(ITEM_SPLITER) >= 0) {
  45169. return true;
  45170. }
  45171. }
  45172. var itemSplitRegex = new RegExp('[' + ITEM_SPLITER + ']+', 'g');
  45173. /**
  45174. * @param {string} tsv
  45175. * @return {Array.<Object>}
  45176. */
  45177. function parseTSVContents(tsv) {
  45178. var tsvLines = tsv.split(/\n+/g);
  45179. var headers = trim(tsvLines.shift()).split(itemSplitRegex);
  45180. var categories = [];
  45181. var series = zrUtil.map(headers, function (header) {
  45182. return {
  45183. name: header,
  45184. data: []
  45185. };
  45186. });
  45187. for (var i = 0; i < tsvLines.length; i++) {
  45188. var items = trim(tsvLines[i]).split(itemSplitRegex);
  45189. categories.push(items.shift());
  45190. for (var j = 0; j < items.length; j++) {
  45191. series[j] && (series[j].data[i] = items[j]);
  45192. }
  45193. }
  45194. return {
  45195. series: series,
  45196. categories: categories
  45197. };
  45198. }
  45199. /**
  45200. * @param {string} str
  45201. * @return {Array.<Object>}
  45202. * @inner
  45203. */
  45204. function parseListContents(str) {
  45205. var lines = str.split(/\n+/g);
  45206. var seriesName = trim(lines.shift());
  45207. var data = [];
  45208. for (var i = 0; i < lines.length; i++) {
  45209. var items = trim(lines[i]).split(itemSplitRegex);
  45210. var name = '';
  45211. var value;
  45212. var hasName = false;
  45213. if (isNaN(items[0])) { // First item is name
  45214. hasName = true;
  45215. name = items[0];
  45216. items = items.slice(1);
  45217. data[i] = {
  45218. name: name,
  45219. value: []
  45220. };
  45221. value = data[i].value;
  45222. }
  45223. else {
  45224. value = data[i] = [];
  45225. }
  45226. for (var j = 0; j < items.length; j++) {
  45227. value.push(+items[j]);
  45228. }
  45229. if (value.length === 1) {
  45230. hasName ? (data[i].value = value[0]) : (data[i] = value[0]);
  45231. }
  45232. }
  45233. return {
  45234. name: seriesName,
  45235. data: data
  45236. };
  45237. }
  45238. /**
  45239. * @param {string} str
  45240. * @param {Array.<Object>} blockMetaList
  45241. * @return {Object}
  45242. * @inner
  45243. */
  45244. function parseContents(str, blockMetaList) {
  45245. var blocks = str.split(new RegExp('\n*' + BLOCK_SPLITER + '\n*', 'g'));
  45246. var newOption = {
  45247. series: []
  45248. };
  45249. zrUtil.each(blocks, function (block, idx) {
  45250. if (isTSVFormat(block)) {
  45251. var result = parseTSVContents(block);
  45252. var blockMeta = blockMetaList[idx];
  45253. var axisKey = blockMeta.axisDim + 'Axis';
  45254. if (blockMeta) {
  45255. newOption[axisKey] = newOption[axisKey] || [];
  45256. newOption[axisKey][blockMeta.axisIndex] = {
  45257. data: result.categories
  45258. };
  45259. newOption.series = newOption.series.concat(result.series);
  45260. }
  45261. }
  45262. else {
  45263. var result = parseListContents(block);
  45264. newOption.series.push(result);
  45265. }
  45266. });
  45267. return newOption;
  45268. }
  45269. /**
  45270. * @alias {module:echarts/component/toolbox/feature/DataView}
  45271. * @constructor
  45272. * @param {module:echarts/model/Model} model
  45273. */
  45274. function DataView(model) {
  45275. this._dom = null;
  45276. this.model = model;
  45277. }
  45278. DataView.defaultOption = {
  45279. show: true,
  45280. readOnly: false,
  45281. optionToContent: null,
  45282. contentToOption: null,
  45283. 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',
  45284. title: '数据视图',
  45285. lang: ['数据视图', '关闭', '刷新'],
  45286. backgroundColor: '#fff',
  45287. textColor: '#000',
  45288. textareaColor: '#fff',
  45289. textareaBorderColor: '#333',
  45290. buttonColor: '#c23531',
  45291. buttonTextColor: '#fff'
  45292. };
  45293. DataView.prototype.onclick = function (ecModel, api) {
  45294. var container = api.getDom();
  45295. var model = this.model;
  45296. if (this._dom) {
  45297. container.removeChild(this._dom);
  45298. }
  45299. var root = document.createElement('div');
  45300. root.style.cssText = 'position:absolute;left:5px;top:5px;bottom:5px;right:5px;';
  45301. root.style.backgroundColor = model.get('backgroundColor') || '#fff';
  45302. // Create elements
  45303. var header = document.createElement('h4');
  45304. var lang = model.get('lang') || [];
  45305. header.innerHTML = lang[0] || model.get('title');
  45306. header.style.cssText = 'margin: 10px 20px;';
  45307. header.style.color = model.get('textColor');
  45308. var viewMain = document.createElement('div');
  45309. var textarea = document.createElement('textarea');
  45310. viewMain.style.cssText = 'display:block;width:100%;overflow:hidden;';
  45311. var optionToContent = model.get('optionToContent');
  45312. var contentToOption = model.get('contentToOption');
  45313. var result = getContentFromModel(ecModel);
  45314. if (typeof optionToContent === 'function') {
  45315. var htmlOrDom = optionToContent(api.getOption());
  45316. if (typeof htmlOrDom === 'string') {
  45317. viewMain.innerHTML = htmlOrDom;
  45318. }
  45319. else if (zrUtil.isDom(htmlOrDom)) {
  45320. viewMain.appendChild(htmlOrDom);
  45321. }
  45322. }
  45323. else {
  45324. // Use default textarea
  45325. viewMain.appendChild(textarea);
  45326. textarea.readOnly = model.get('readOnly');
  45327. textarea.style.cssText = 'width:100%;height:100%;font-family:monospace;font-size:14px;line-height:1.6rem;';
  45328. textarea.style.color = model.get('textColor');
  45329. textarea.style.borderColor = model.get('textareaBorderColor');
  45330. textarea.style.backgroundColor = model.get('textareaColor');
  45331. textarea.value = result.value;
  45332. }
  45333. var blockMetaList = result.meta;
  45334. var buttonContainer = document.createElement('div');
  45335. buttonContainer.style.cssText = 'position:absolute;bottom:0;left:0;right:0;';
  45336. var buttonStyle = 'float:right;margin-right:20px;border:none;'
  45337. + 'cursor:pointer;padding:2px 5px;font-size:12px;border-radius:3px';
  45338. var closeButton = document.createElement('div');
  45339. var refreshButton = document.createElement('div');
  45340. buttonStyle += ';background-color:' + model.get('buttonColor');
  45341. buttonStyle += ';color:' + model.get('buttonTextColor');
  45342. var self = this;
  45343. function close() {
  45344. container.removeChild(root);
  45345. self._dom = null;
  45346. }
  45347. eventTool.addEventListener(closeButton, 'click', close);
  45348. eventTool.addEventListener(refreshButton, 'click', function () {
  45349. var newOption;
  45350. try {
  45351. if (typeof contentToOption === 'function') {
  45352. newOption = contentToOption(viewMain, api.getOption());
  45353. }
  45354. else {
  45355. newOption = parseContents(textarea.value, blockMetaList);
  45356. }
  45357. }
  45358. catch (e) {
  45359. close();
  45360. throw new Error('Data view format error ' + e);
  45361. }
  45362. if (newOption) {
  45363. api.dispatchAction({
  45364. type: 'changeDataView',
  45365. newOption: newOption
  45366. });
  45367. }
  45368. close();
  45369. });
  45370. closeButton.innerHTML = lang[1];
  45371. refreshButton.innerHTML = lang[2];
  45372. refreshButton.style.cssText = buttonStyle;
  45373. closeButton.style.cssText = buttonStyle;
  45374. !model.get('readOnly') && buttonContainer.appendChild(refreshButton);
  45375. buttonContainer.appendChild(closeButton);
  45376. // http://stackoverflow.com/questions/6637341/use-tab-to-indent-in-textarea
  45377. eventTool.addEventListener(textarea, 'keydown', function (e) {
  45378. if ((e.keyCode || e.which) === 9) {
  45379. // get caret position/selection
  45380. var val = this.value;
  45381. var start = this.selectionStart;
  45382. var end = this.selectionEnd;
  45383. // set textarea value to: text before caret + tab + text after caret
  45384. this.value = val.substring(0, start) + ITEM_SPLITER + val.substring(end);
  45385. // put caret at right position again
  45386. this.selectionStart = this.selectionEnd = start + 1;
  45387. // prevent the focus lose
  45388. eventTool.stop(e);
  45389. }
  45390. });
  45391. root.appendChild(header);
  45392. root.appendChild(viewMain);
  45393. root.appendChild(buttonContainer);
  45394. viewMain.style.height = (container.clientHeight - 80) + 'px';
  45395. container.appendChild(root);
  45396. this._dom = root;
  45397. };
  45398. DataView.prototype.remove = function (ecModel, api) {
  45399. this._dom && api.getDom().removeChild(this._dom);
  45400. };
  45401. DataView.prototype.dispose = function (ecModel, api) {
  45402. this.remove(ecModel, api);
  45403. };
  45404. /**
  45405. * @inner
  45406. */
  45407. function tryMergeDataOption(newData, originalData) {
  45408. return zrUtil.map(newData, function (newVal, idx) {
  45409. var original = originalData && originalData[idx];
  45410. if (zrUtil.isObject(original) && !zrUtil.isArray(original)) {
  45411. if (zrUtil.isObject(newVal) && !zrUtil.isArray(newVal)) {
  45412. newVal = newVal.value;
  45413. }
  45414. // Original data has option
  45415. return zrUtil.defaults({
  45416. value: newVal
  45417. }, original);
  45418. }
  45419. else {
  45420. return newVal;
  45421. }
  45422. });
  45423. }
  45424. __webpack_require__(337).register('dataView', DataView);
  45425. __webpack_require__(1).registerAction({
  45426. type: 'changeDataView',
  45427. event: 'dataViewChanged',
  45428. update: 'prepareAndUpdate'
  45429. }, function (payload, ecModel) {
  45430. var newSeriesOptList = [];
  45431. zrUtil.each(payload.newOption.series, function (seriesOpt) {
  45432. var seriesModel = ecModel.getSeriesByName(seriesOpt.name)[0];
  45433. if (!seriesModel) {
  45434. // New created series
  45435. // Geuss the series type
  45436. newSeriesOptList.push(zrUtil.extend({
  45437. // Default is scatter
  45438. type: 'scatter'
  45439. }, seriesOpt));
  45440. }
  45441. else {
  45442. var originalData = seriesModel.get('data');
  45443. newSeriesOptList.push({
  45444. name: seriesOpt.name,
  45445. data: tryMergeDataOption(seriesOpt.data, originalData)
  45446. });
  45447. }
  45448. });
  45449. ecModel.mergeOption(zrUtil.defaults({
  45450. series: newSeriesOptList
  45451. }, payload.newOption));
  45452. });
  45453. module.exports = DataView;
  45454. /***/ },
  45455. /* 343 */
  45456. /***/ function(module, exports, __webpack_require__) {
  45457. 'use strict';
  45458. var zrUtil = __webpack_require__(3);
  45459. var numberUtil = __webpack_require__(7);
  45460. var SelectController = __webpack_require__(228);
  45461. var BoundingRect = __webpack_require__(15);
  45462. var Group = __webpack_require__(29);
  45463. var history = __webpack_require__(344);
  45464. var interactionMutex = __webpack_require__(170);
  45465. var each = zrUtil.each;
  45466. var asc = numberUtil.asc;
  45467. // Use dataZoomSelect
  45468. __webpack_require__(345);
  45469. // Spectial component id start with \0ec\0, see echarts/model/Global.js~hasInnerId
  45470. var DATA_ZOOM_ID_BASE = '\0_ec_\0toolbox-dataZoom_';
  45471. function DataZoom(model) {
  45472. this.model = model;
  45473. /**
  45474. * @private
  45475. * @type {module:zrender/container/Group}
  45476. */
  45477. this._controllerGroup;
  45478. /**
  45479. * @private
  45480. * @type {module:echarts/component/helper/SelectController}
  45481. */
  45482. this._controller;
  45483. /**
  45484. * Is zoom active.
  45485. * @private
  45486. * @type {Object}
  45487. */
  45488. this._isZoomActive;
  45489. }
  45490. DataZoom.defaultOption = {
  45491. show: true,
  45492. // Icon group
  45493. icon: {
  45494. zoom: 'M0,13.5h26.9 M13.5,26.9V0 M32.1,13.5H58V58H13.5 V32.1',
  45495. back: 'M22,1.4L9.9,13.5l12.3,12.3 M10.3,13.5H54.9v44.6 H10.3v-26'
  45496. },
  45497. title: {
  45498. zoom: '区域缩放',
  45499. back: '区域缩放还原'
  45500. }
  45501. };
  45502. var proto = DataZoom.prototype;
  45503. proto.render = function (featureModel, ecModel, api) {
  45504. updateBackBtnStatus(featureModel, ecModel);
  45505. };
  45506. proto.onclick = function (ecModel, api, type) {
  45507. var controllerGroup = this._controllerGroup;
  45508. if (!this._controllerGroup) {
  45509. controllerGroup = this._controllerGroup = new Group();
  45510. api.getZr().add(controllerGroup);
  45511. }
  45512. handlers[type].call(this, controllerGroup, this.model, ecModel, api);
  45513. };
  45514. proto.remove = function (ecModel, api) {
  45515. this._disposeController();
  45516. interactionMutex.release('globalPan', api.getZr());
  45517. };
  45518. proto.dispose = function (ecModel, api) {
  45519. var zr = api.getZr();
  45520. interactionMutex.release('globalPan', zr);
  45521. this._disposeController();
  45522. this._controllerGroup && zr.remove(this._controllerGroup);
  45523. };
  45524. /**
  45525. * @private
  45526. */
  45527. var handlers = {
  45528. zoom: function (controllerGroup, featureModel, ecModel, api) {
  45529. var isZoomActive = this._isZoomActive = !this._isZoomActive;
  45530. var zr = api.getZr();
  45531. interactionMutex[isZoomActive ? 'take' : 'release']('globalPan', zr);
  45532. featureModel.setIconStatus('zoom', isZoomActive ? 'emphasis' : 'normal');
  45533. if (isZoomActive) {
  45534. zr.setDefaultCursorStyle('crosshair');
  45535. this._createController(
  45536. controllerGroup, featureModel, ecModel, api
  45537. );
  45538. }
  45539. else {
  45540. zr.setDefaultCursorStyle('default');
  45541. this._disposeController();
  45542. }
  45543. },
  45544. back: function (controllerGroup, featureModel, ecModel, api) {
  45545. this._dispatchAction(history.pop(ecModel), api);
  45546. }
  45547. };
  45548. /**
  45549. * @private
  45550. */
  45551. proto._createController = function (
  45552. controllerGroup, featureModel, ecModel, api
  45553. ) {
  45554. var controller = this._controller = new SelectController(
  45555. 'rect',
  45556. api.getZr(),
  45557. {
  45558. // FIXME
  45559. lineWidth: 3,
  45560. stroke: '#333',
  45561. fill: 'rgba(0,0,0,0.2)'
  45562. }
  45563. );
  45564. controller.on(
  45565. 'selectEnd',
  45566. zrUtil.bind(
  45567. this._onSelected, this, controller,
  45568. featureModel, ecModel, api
  45569. )
  45570. );
  45571. controller.enable(controllerGroup, false);
  45572. };
  45573. proto._disposeController = function () {
  45574. var controller = this._controller;
  45575. if (controller) {
  45576. controller.off('selected');
  45577. controller.dispose();
  45578. }
  45579. };
  45580. function prepareCoordInfo(grid, ecModel) {
  45581. // Default use the first axis.
  45582. // FIXME
  45583. var coordInfo = [
  45584. {axisModel: grid.getAxis('x').model, axisIndex: 0}, // x
  45585. {axisModel: grid.getAxis('y').model, axisIndex: 0} // y
  45586. ];
  45587. coordInfo.grid = grid;
  45588. ecModel.eachComponent(
  45589. {mainType: 'dataZoom', subType: 'select'},
  45590. function (dzModel, dataZoomIndex) {
  45591. if (isTheAxis('xAxis', coordInfo[0].axisModel, dzModel, ecModel)) {
  45592. coordInfo[0].dataZoomModel = dzModel;
  45593. }
  45594. if (isTheAxis('yAxis', coordInfo[1].axisModel, dzModel, ecModel)) {
  45595. coordInfo[1].dataZoomModel = dzModel;
  45596. }
  45597. }
  45598. );
  45599. return coordInfo;
  45600. }
  45601. function isTheAxis(axisName, axisModel, dataZoomModel, ecModel) {
  45602. var axisIndex = dataZoomModel.get(axisName + 'Index');
  45603. return axisIndex != null
  45604. && ecModel.getComponent(axisName, axisIndex) === axisModel;
  45605. }
  45606. /**
  45607. * @private
  45608. */
  45609. proto._onSelected = function (controller, featureModel, ecModel, api, selRanges) {
  45610. if (!selRanges.length) {
  45611. return;
  45612. }
  45613. var selRange = selRanges[0];
  45614. controller.update(); // remove cover
  45615. var snapshot = {};
  45616. // FIXME
  45617. // polar
  45618. ecModel.eachComponent('grid', function (gridModel, gridIndex) {
  45619. var grid = gridModel.coordinateSystem;
  45620. var coordInfo = prepareCoordInfo(grid, ecModel);
  45621. var selDataRange = pointToDataInCartesian(selRange, coordInfo);
  45622. if (selDataRange) {
  45623. var xBatchItem = scaleCartesianAxis(selDataRange, coordInfo, 0, 'x');
  45624. var yBatchItem = scaleCartesianAxis(selDataRange, coordInfo, 1, 'y');
  45625. xBatchItem && (snapshot[xBatchItem.dataZoomId] = xBatchItem);
  45626. yBatchItem && (snapshot[yBatchItem.dataZoomId] = yBatchItem);
  45627. }
  45628. }, this);
  45629. history.push(ecModel, snapshot);
  45630. this._dispatchAction(snapshot, api);
  45631. };
  45632. function pointToDataInCartesian(selRange, coordInfo) {
  45633. var grid = coordInfo.grid;
  45634. var selRect = new BoundingRect(
  45635. selRange[0][0],
  45636. selRange[1][0],
  45637. selRange[0][1] - selRange[0][0],
  45638. selRange[1][1] - selRange[1][0]
  45639. );
  45640. if (!selRect.intersect(grid.getRect())) {
  45641. return;
  45642. }
  45643. var cartesian = grid.getCartesian(coordInfo[0].axisIndex, coordInfo[1].axisIndex);
  45644. var dataLeftTop = cartesian.pointToData([selRange[0][0], selRange[1][0]], true);
  45645. var dataRightBottom = cartesian.pointToData([selRange[0][1], selRange[1][1]], true);
  45646. return [
  45647. asc([dataLeftTop[0], dataRightBottom[0]]), // x, using asc to handle inverse
  45648. asc([dataLeftTop[1], dataRightBottom[1]]) // y, using asc to handle inverse
  45649. ];
  45650. }
  45651. function scaleCartesianAxis(selDataRange, coordInfo, dimIdx, dimName) {
  45652. var dimCoordInfo = coordInfo[dimIdx];
  45653. var dataZoomModel = dimCoordInfo.dataZoomModel;
  45654. if (dataZoomModel) {
  45655. return {
  45656. dataZoomId: dataZoomModel.id,
  45657. startValue: selDataRange[dimIdx][0],
  45658. endValue: selDataRange[dimIdx][1]
  45659. };
  45660. }
  45661. }
  45662. /**
  45663. * @private
  45664. */
  45665. proto._dispatchAction = function (snapshot, api) {
  45666. var batch = [];
  45667. each(snapshot, function (batchItem) {
  45668. batch.push(batchItem);
  45669. });
  45670. batch.length && api.dispatchAction({
  45671. type: 'dataZoom',
  45672. from: this.uid,
  45673. batch: zrUtil.clone(batch, true)
  45674. });
  45675. };
  45676. function updateBackBtnStatus(featureModel, ecModel) {
  45677. featureModel.setIconStatus(
  45678. 'back',
  45679. history.count(ecModel) > 1 ? 'emphasis' : 'normal'
  45680. );
  45681. }
  45682. __webpack_require__(337).register('dataZoom', DataZoom);
  45683. // Create special dataZoom option for select
  45684. __webpack_require__(1).registerPreprocessor(function (option) {
  45685. if (!option) {
  45686. return;
  45687. }
  45688. var dataZoomOpts = option.dataZoom || (option.dataZoom = []);
  45689. if (!zrUtil.isArray(dataZoomOpts)) {
  45690. option.dataZoom = dataZoomOpts = [dataZoomOpts];
  45691. }
  45692. var toolboxOpt = option.toolbox;
  45693. if (toolboxOpt) {
  45694. // Assume there is only one toolbox
  45695. if (zrUtil.isArray(toolboxOpt)) {
  45696. toolboxOpt = toolboxOpt[0];
  45697. }
  45698. if (toolboxOpt && toolboxOpt.feature) {
  45699. var dataZoomOpt = toolboxOpt.feature.dataZoom;
  45700. addForAxis('xAxis', dataZoomOpt);
  45701. addForAxis('yAxis', dataZoomOpt);
  45702. }
  45703. }
  45704. function addForAxis(axisName, dataZoomOpt) {
  45705. if (!dataZoomOpt) {
  45706. return;
  45707. }
  45708. var axisIndicesName = axisName + 'Index';
  45709. var givenAxisIndices = dataZoomOpt[axisIndicesName];
  45710. if (givenAxisIndices != null && !zrUtil.isArray(givenAxisIndices)) {
  45711. givenAxisIndices = givenAxisIndices === false ? [] : [givenAxisIndices];
  45712. }
  45713. forEachComponent(axisName, function (axisOpt, axisIndex) {
  45714. if (givenAxisIndices != null
  45715. && zrUtil.indexOf(givenAxisIndices, axisIndex) === -1
  45716. ) {
  45717. return;
  45718. }
  45719. var newOpt = {
  45720. type: 'select',
  45721. $fromToolbox: true,
  45722. // Id for merge mapping.
  45723. id: DATA_ZOOM_ID_BASE + axisName + axisIndex
  45724. };
  45725. // FIXME
  45726. // Only support one axis now.
  45727. newOpt[axisIndicesName] = axisIndex;
  45728. dataZoomOpts.push(newOpt);
  45729. });
  45730. }
  45731. function forEachComponent(mainType, cb) {
  45732. var opts = option[mainType];
  45733. if (!zrUtil.isArray(opts)) {
  45734. opts = opts ? [opts] : [];
  45735. }
  45736. each(opts, cb);
  45737. }
  45738. });
  45739. module.exports = DataZoom;
  45740. /***/ },
  45741. /* 344 */
  45742. /***/ function(module, exports, __webpack_require__) {
  45743. /**
  45744. * @file History manager.
  45745. */
  45746. var zrUtil = __webpack_require__(3);
  45747. var each = zrUtil.each;
  45748. var ATTR = '\0_ec_hist_store';
  45749. var history = {
  45750. /**
  45751. * @public
  45752. * @param {module:echarts/model/Global} ecModel
  45753. * @param {Object} newSnapshot {dataZoomId, batch: [payloadInfo, ...]}
  45754. */
  45755. push: function (ecModel, newSnapshot) {
  45756. var store = giveStore(ecModel);
  45757. // If previous dataZoom can not be found,
  45758. // complete an range with current range.
  45759. each(newSnapshot, function (batchItem, dataZoomId) {
  45760. var i = store.length - 1;
  45761. for (; i >= 0; i--) {
  45762. var snapshot = store[i];
  45763. if (snapshot[dataZoomId]) {
  45764. break;
  45765. }
  45766. }
  45767. if (i < 0) {
  45768. // No origin range set, create one by current range.
  45769. var dataZoomModel = ecModel.queryComponents(
  45770. {mainType: 'dataZoom', subType: 'select', id: dataZoomId}
  45771. )[0];
  45772. if (dataZoomModel) {
  45773. var percentRange = dataZoomModel.getPercentRange();
  45774. store[0][dataZoomId] = {
  45775. dataZoomId: dataZoomId,
  45776. start: percentRange[0],
  45777. end: percentRange[1]
  45778. };
  45779. }
  45780. }
  45781. });
  45782. store.push(newSnapshot);
  45783. },
  45784. /**
  45785. * @public
  45786. * @param {module:echarts/model/Global} ecModel
  45787. * @return {Object} snapshot
  45788. */
  45789. pop: function (ecModel) {
  45790. var store = giveStore(ecModel);
  45791. var head = store[store.length - 1];
  45792. store.length > 1 && store.pop();
  45793. // Find top for all dataZoom.
  45794. var snapshot = {};
  45795. each(head, function (batchItem, dataZoomId) {
  45796. for (var i = store.length - 1; i >= 0; i--) {
  45797. var batchItem = store[i][dataZoomId];
  45798. if (batchItem) {
  45799. snapshot[dataZoomId] = batchItem;
  45800. break;
  45801. }
  45802. }
  45803. });
  45804. return snapshot;
  45805. },
  45806. /**
  45807. * @public
  45808. */
  45809. clear: function (ecModel) {
  45810. ecModel[ATTR] = null;
  45811. },
  45812. /**
  45813. * @public
  45814. * @param {module:echarts/model/Global} ecModel
  45815. * @return {number} records. always >= 1.
  45816. */
  45817. count: function (ecModel) {
  45818. return giveStore(ecModel).length;
  45819. }
  45820. };
  45821. /**
  45822. * [{key: dataZoomId, value: {dataZoomId, range}}, ...]
  45823. * History length of each dataZoom may be different.
  45824. * this._history[0] is used to store origin range.
  45825. * @type {Array.<Object>}
  45826. */
  45827. function giveStore(ecModel) {
  45828. var store = ecModel[ATTR];
  45829. if (!store) {
  45830. store = ecModel[ATTR] = [{}];
  45831. }
  45832. return store;
  45833. }
  45834. module.exports = history;
  45835. /***/ },
  45836. /* 345 */
  45837. /***/ function(module, exports, __webpack_require__) {
  45838. /**
  45839. * DataZoom component entry
  45840. */
  45841. __webpack_require__(291);
  45842. __webpack_require__(292);
  45843. __webpack_require__(294);
  45844. __webpack_require__(346);
  45845. __webpack_require__(347);
  45846. __webpack_require__(302);
  45847. __webpack_require__(303);
  45848. /***/ },
  45849. /* 346 */
  45850. /***/ function(module, exports, __webpack_require__) {
  45851. /**
  45852. * @file Data zoom model
  45853. */
  45854. var DataZoomModel = __webpack_require__(292);
  45855. module.exports = DataZoomModel.extend({
  45856. type: 'dataZoom.select'
  45857. });
  45858. /***/ },
  45859. /* 347 */
  45860. /***/ function(module, exports, __webpack_require__) {
  45861. module.exports = __webpack_require__(294).extend({
  45862. type: 'dataZoom.select'
  45863. });
  45864. /***/ },
  45865. /* 348 */
  45866. /***/ function(module, exports, __webpack_require__) {
  45867. 'use strict';
  45868. var history = __webpack_require__(344);
  45869. function Restore(model) {
  45870. this.model = model;
  45871. }
  45872. Restore.defaultOption = {
  45873. show: true,
  45874. 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',
  45875. title: '还原'
  45876. };
  45877. var proto = Restore.prototype;
  45878. proto.onclick = function (ecModel, api, type) {
  45879. history.clear(ecModel);
  45880. api.dispatchAction({
  45881. type: 'restore',
  45882. from: this.uid
  45883. });
  45884. };
  45885. __webpack_require__(337).register('restore', Restore);
  45886. __webpack_require__(1).registerAction(
  45887. {type: 'restore', event: 'restore', update: 'prepareAndUpdate'},
  45888. function (payload, ecModel) {
  45889. ecModel.resetOption('recreate');
  45890. }
  45891. );
  45892. module.exports = Restore;
  45893. /***/ },
  45894. /* 349 */
  45895. /***/ function(module, exports, __webpack_require__) {
  45896. __webpack_require__(350);
  45897. __webpack_require__(78).registerPainter('vml', __webpack_require__(352));
  45898. /***/ },
  45899. /* 350 */
  45900. /***/ function(module, exports, __webpack_require__) {
  45901. // http://www.w3.org/TR/NOTE-VML
  45902. // TODO Use proxy like svg instead of overwrite brush methods
  45903. if (!__webpack_require__(79).canvasSupported) {
  45904. var vec2 = __webpack_require__(16);
  45905. var BoundingRect = __webpack_require__(15);
  45906. var CMD = __webpack_require__(48).CMD;
  45907. var colorTool = __webpack_require__(38);
  45908. var textContain = __webpack_require__(14);
  45909. var RectText = __webpack_require__(47);
  45910. var Displayable = __webpack_require__(45);
  45911. var ZImage = __webpack_require__(59);
  45912. var Text = __webpack_require__(62);
  45913. var Path = __webpack_require__(44);
  45914. var Gradient = __webpack_require__(4);
  45915. var vmlCore = __webpack_require__(351);
  45916. var round = Math.round;
  45917. var sqrt = Math.sqrt;
  45918. var abs = Math.abs;
  45919. var cos = Math.cos;
  45920. var sin = Math.sin;
  45921. var mathMax = Math.max;
  45922. var applyTransform = vec2.applyTransform;
  45923. var comma = ',';
  45924. var imageTransformPrefix = 'progid:DXImageTransform.Microsoft';
  45925. var Z = 21600;
  45926. var Z2 = Z / 2;
  45927. var ZLEVEL_BASE = 100000;
  45928. var Z_BASE = 1000;
  45929. var initRootElStyle = function (el) {
  45930. el.style.cssText = 'position:absolute;left:0;top:0;width:1px;height:1px;';
  45931. el.coordsize = Z + ',' + Z;
  45932. el.coordorigin = '0,0';
  45933. };
  45934. var encodeHtmlAttribute = function (s) {
  45935. return String(s).replace(/&/g, '&amp;').replace(/"/g, '&quot;');
  45936. };
  45937. var rgb2Str = function (r, g, b) {
  45938. return 'rgb(' + [r, g, b].join(',') + ')';
  45939. };
  45940. var append = function (parent, child) {
  45941. if (child && parent && child.parentNode !== parent) {
  45942. parent.appendChild(child);
  45943. }
  45944. };
  45945. var remove = function (parent, child) {
  45946. if (child && parent && child.parentNode === parent) {
  45947. parent.removeChild(child);
  45948. }
  45949. };
  45950. var getZIndex = function (zlevel, z, z2) {
  45951. // z 的取值范围为 [0, 1000]
  45952. return (parseFloat(zlevel) || 0) * ZLEVEL_BASE + (parseFloat(z) || 0) * Z_BASE + z2;
  45953. };
  45954. var parsePercent = function (value, maxValue) {
  45955. if (typeof value === 'string') {
  45956. if (value.lastIndexOf('%') >= 0) {
  45957. return parseFloat(value) / 100 * maxValue;
  45958. }
  45959. return parseFloat(value);
  45960. }
  45961. return value;
  45962. };
  45963. /***************************************************
  45964. * PATH
  45965. **************************************************/
  45966. var setColorAndOpacity = function (el, color, opacity) {
  45967. var colorArr = colorTool.parse(color);
  45968. opacity = +opacity;
  45969. if (isNaN(opacity)) {
  45970. opacity = 1;
  45971. }
  45972. if (colorArr) {
  45973. el.color = rgb2Str(colorArr[0], colorArr[1], colorArr[2]);
  45974. el.opacity = opacity * colorArr[3];
  45975. }
  45976. };
  45977. var getColorAndAlpha = function (color) {
  45978. var colorArr = colorTool.parse(color);
  45979. return [
  45980. rgb2Str(colorArr[0], colorArr[1], colorArr[2]),
  45981. colorArr[3]
  45982. ];
  45983. };
  45984. var updateFillNode = function (el, style, zrEl) {
  45985. // TODO pattern
  45986. var fill = style.fill;
  45987. if (fill != null) {
  45988. // Modified from excanvas
  45989. if (fill instanceof Gradient) {
  45990. var gradientType;
  45991. var angle = 0;
  45992. var focus = [0, 0];
  45993. // additional offset
  45994. var shift = 0;
  45995. // scale factor for offset
  45996. var expansion = 1;
  45997. var rect = zrEl.getBoundingRect();
  45998. var rectWidth = rect.width;
  45999. var rectHeight = rect.height;
  46000. if (fill.type === 'linear') {
  46001. gradientType = 'gradient';
  46002. var transform = zrEl.transform;
  46003. var p0 = [fill.x * rectWidth, fill.y * rectHeight];
  46004. var p1 = [fill.x2 * rectWidth, fill.y2 * rectHeight];
  46005. if (transform) {
  46006. applyTransform(p0, p0, transform);
  46007. applyTransform(p1, p1, transform);
  46008. }
  46009. var dx = p1[0] - p0[0];
  46010. var dy = p1[1] - p0[1];
  46011. angle = Math.atan2(dx, dy) * 180 / Math.PI;
  46012. // The angle should be a non-negative number.
  46013. if (angle < 0) {
  46014. angle += 360;
  46015. }
  46016. // Very small angles produce an unexpected result because they are
  46017. // converted to a scientific notation string.
  46018. if (angle < 1e-6) {
  46019. angle = 0;
  46020. }
  46021. }
  46022. else {
  46023. gradientType = 'gradientradial';
  46024. var p0 = [fill.x * rectWidth, fill.y * rectHeight];
  46025. var transform = zrEl.transform;
  46026. var scale = zrEl.scale;
  46027. var width = rectWidth;
  46028. var height = rectHeight;
  46029. focus = [
  46030. // Percent in bounding rect
  46031. (p0[0] - rect.x) / width,
  46032. (p0[1] - rect.y) / height
  46033. ];
  46034. if (transform) {
  46035. applyTransform(p0, p0, transform);
  46036. }
  46037. width /= scale[0] * Z;
  46038. height /= scale[1] * Z;
  46039. var dimension = mathMax(width, height);
  46040. shift = 2 * 0 / dimension;
  46041. expansion = 2 * fill.r / dimension - shift;
  46042. }
  46043. // We need to sort the color stops in ascending order by offset,
  46044. // otherwise IE won't interpret it correctly.
  46045. var stops = fill.colorStops.slice();
  46046. stops.sort(function(cs1, cs2) {
  46047. return cs1.offset - cs2.offset;
  46048. });
  46049. var length = stops.length;
  46050. // Color and alpha list of first and last stop
  46051. var colorAndAlphaList = [];
  46052. var colors = [];
  46053. for (var i = 0; i < length; i++) {
  46054. var stop = stops[i];
  46055. var colorAndAlpha = getColorAndAlpha(stop.color);
  46056. colors.push(stop.offset * expansion + shift + ' ' + colorAndAlpha[0]);
  46057. if (i === 0 || i === length - 1) {
  46058. colorAndAlphaList.push(colorAndAlpha);
  46059. }
  46060. }
  46061. if (length >= 2) {
  46062. var color1 = colorAndAlphaList[0][0];
  46063. var color2 = colorAndAlphaList[1][0];
  46064. var opacity1 = colorAndAlphaList[0][1] * style.opacity;
  46065. var opacity2 = colorAndAlphaList[1][1] * style.opacity;
  46066. el.type = gradientType;
  46067. el.method = 'none';
  46068. el.focus = '100%';
  46069. el.angle = angle;
  46070. el.color = color1;
  46071. el.color2 = color2;
  46072. el.colors = colors.join(',');
  46073. // When colors attribute is used, the meanings of opacity and o:opacity2
  46074. // are reversed.
  46075. el.opacity = opacity2;
  46076. // FIXME g_o_:opacity ?
  46077. el.opacity2 = opacity1;
  46078. }
  46079. if (gradientType === 'radial') {
  46080. el.focusposition = focus.join(',');
  46081. }
  46082. }
  46083. else {
  46084. // FIXME Change from Gradient fill to color fill
  46085. setColorAndOpacity(el, fill, style.opacity);
  46086. }
  46087. }
  46088. };
  46089. var updateStrokeNode = function (el, style) {
  46090. if (style.lineJoin != null) {
  46091. el.joinstyle = style.lineJoin;
  46092. }
  46093. if (style.miterLimit != null) {
  46094. el.miterlimit = style.miterLimit * Z;
  46095. }
  46096. if (style.lineCap != null) {
  46097. el.endcap = style.lineCap;
  46098. }
  46099. if (style.lineDash != null) {
  46100. el.dashstyle = style.lineDash.join(' ');
  46101. }
  46102. if (style.stroke != null && !(style.stroke instanceof Gradient)) {
  46103. setColorAndOpacity(el, style.stroke, style.opacity);
  46104. }
  46105. };
  46106. var updateFillAndStroke = function (vmlEl, type, style, zrEl) {
  46107. var isFill = type == 'fill';
  46108. var el = vmlEl.getElementsByTagName(type)[0];
  46109. // Stroke must have lineWidth
  46110. if (style[type] != null && style[type] !== 'none' && (isFill || (!isFill && style.lineWidth))) {
  46111. vmlEl[isFill ? 'filled' : 'stroked'] = 'true';
  46112. // FIXME Remove before updating, or set `colors` will throw error
  46113. if (style[type] instanceof Gradient) {
  46114. remove(vmlEl, el);
  46115. }
  46116. if (!el) {
  46117. el = vmlCore.createNode(type);
  46118. }
  46119. isFill ? updateFillNode(el, style, zrEl) : updateStrokeNode(el, style);
  46120. append(vmlEl, el);
  46121. }
  46122. else {
  46123. vmlEl[isFill ? 'filled' : 'stroked'] = 'false';
  46124. remove(vmlEl, el);
  46125. }
  46126. };
  46127. var points = [[], [], []];
  46128. var pathDataToString = function (data, m) {
  46129. var M = CMD.M;
  46130. var C = CMD.C;
  46131. var L = CMD.L;
  46132. var A = CMD.A;
  46133. var Q = CMD.Q;
  46134. var str = [];
  46135. var nPoint;
  46136. var cmdStr;
  46137. var cmd;
  46138. var i;
  46139. var xi;
  46140. var yi;
  46141. for (i = 0; i < data.length;) {
  46142. cmd = data[i++];
  46143. cmdStr = '';
  46144. nPoint = 0;
  46145. switch (cmd) {
  46146. case M:
  46147. cmdStr = ' m ';
  46148. nPoint = 1;
  46149. xi = data[i++];
  46150. yi = data[i++];
  46151. points[0][0] = xi;
  46152. points[0][1] = yi;
  46153. break;
  46154. case L:
  46155. cmdStr = ' l ';
  46156. nPoint = 1;
  46157. xi = data[i++];
  46158. yi = data[i++];
  46159. points[0][0] = xi;
  46160. points[0][1] = yi;
  46161. break;
  46162. case Q:
  46163. case C:
  46164. cmdStr = ' c ';
  46165. nPoint = 3;
  46166. var x1 = data[i++];
  46167. var y1 = data[i++];
  46168. var x2 = data[i++];
  46169. var y2 = data[i++];
  46170. var x3;
  46171. var y3;
  46172. if (cmd === Q) {
  46173. // Convert quadratic to cubic using degree elevation
  46174. x3 = x2;
  46175. y3 = y2;
  46176. x2 = (x2 + 2 * x1) / 3;
  46177. y2 = (y2 + 2 * y1) / 3;
  46178. x1 = (xi + 2 * x1) / 3;
  46179. y1 = (yi + 2 * y1) / 3;
  46180. }
  46181. else {
  46182. x3 = data[i++];
  46183. y3 = data[i++];
  46184. }
  46185. points[0][0] = x1;
  46186. points[0][1] = y1;
  46187. points[1][0] = x2;
  46188. points[1][1] = y2;
  46189. points[2][0] = x3;
  46190. points[2][1] = y3;
  46191. xi = x3;
  46192. yi = y3;
  46193. break;
  46194. case A:
  46195. var x = 0;
  46196. var y = 0;
  46197. var sx = 1;
  46198. var sy = 1;
  46199. var angle = 0;
  46200. if (m) {
  46201. // Extract SRT from matrix
  46202. x = m[4];
  46203. y = m[5];
  46204. sx = sqrt(m[0] * m[0] + m[1] * m[1]);
  46205. sy = sqrt(m[2] * m[2] + m[3] * m[3]);
  46206. angle = Math.atan2(-m[1] / sy, m[0] / sx);
  46207. }
  46208. var cx = data[i++];
  46209. var cy = data[i++];
  46210. var rx = data[i++];
  46211. var ry = data[i++];
  46212. var startAngle = data[i++] + angle;
  46213. var endAngle = data[i++] + startAngle + angle;
  46214. // FIXME
  46215. // var psi = data[i++];
  46216. i++;
  46217. var clockwise = data[i++];
  46218. var x0 = cx + cos(startAngle) * rx;
  46219. var y0 = cy + sin(startAngle) * ry;
  46220. var x1 = cx + cos(endAngle) * rx;
  46221. var y1 = cy + sin(endAngle) * ry;
  46222. var type = clockwise ? ' wa ' : ' at ';
  46223. if (Math.abs(x0 - x1) < 1e-10) {
  46224. // IE won't render arches drawn counter clockwise if x0 == x1.
  46225. if (Math.abs(endAngle - startAngle) > 1e-2) {
  46226. // Offset x0 by 1/80 of a pixel. Use something
  46227. // that can be represented in binary
  46228. if (clockwise) {
  46229. x0 += 270 / Z;
  46230. }
  46231. }
  46232. else {
  46233. // Avoid case draw full circle
  46234. if (Math.abs(y0 - cy) < 1e-10) {
  46235. if ((clockwise && x0 < cx) || (!clockwise && x0 > cx)) {
  46236. y1 -= 270 / Z;
  46237. }
  46238. else {
  46239. y1 += 270 / Z;
  46240. }
  46241. }
  46242. else if ((clockwise && y0 < cy) || (!clockwise && y0 > cy)) {
  46243. x1 += 270 / Z;
  46244. }
  46245. else {
  46246. x1 -= 270 / Z;
  46247. }
  46248. }
  46249. }
  46250. str.push(
  46251. type,
  46252. round(((cx - rx) * sx + x) * Z - Z2), comma,
  46253. round(((cy - ry) * sy + y) * Z - Z2), comma,
  46254. round(((cx + rx) * sx + x) * Z - Z2), comma,
  46255. round(((cy + ry) * sy + y) * Z - Z2), comma,
  46256. round((x0 * sx + x) * Z - Z2), comma,
  46257. round((y0 * sy + y) * Z - Z2), comma,
  46258. round((x1 * sx + x) * Z - Z2), comma,
  46259. round((y1 * sy + y) * Z - Z2)
  46260. );
  46261. xi = x1;
  46262. yi = y1;
  46263. break;
  46264. case CMD.R:
  46265. var p0 = points[0];
  46266. var p1 = points[1];
  46267. // x0, y0
  46268. p0[0] = data[i++];
  46269. p0[1] = data[i++];
  46270. // x1, y1
  46271. p1[0] = p0[0] + data[i++];
  46272. p1[1] = p0[1] + data[i++];
  46273. if (m) {
  46274. applyTransform(p0, p0, m);
  46275. applyTransform(p1, p1, m);
  46276. }
  46277. p0[0] = round(p0[0] * Z - Z2);
  46278. p1[0] = round(p1[0] * Z - Z2);
  46279. p0[1] = round(p0[1] * Z - Z2);
  46280. p1[1] = round(p1[1] * Z - Z2);
  46281. str.push(
  46282. // x0, y0
  46283. ' m ', p0[0], comma, p0[1],
  46284. // x1, y0
  46285. ' l ', p1[0], comma, p0[1],
  46286. // x1, y1
  46287. ' l ', p1[0], comma, p1[1],
  46288. // x0, y1
  46289. ' l ', p0[0], comma, p1[1]
  46290. );
  46291. break;
  46292. case CMD.Z:
  46293. // FIXME Update xi, yi
  46294. str.push(' x ');
  46295. }
  46296. if (nPoint > 0) {
  46297. str.push(cmdStr);
  46298. for (var k = 0; k < nPoint; k++) {
  46299. var p = points[k];
  46300. m && applyTransform(p, p, m);
  46301. // 不 round 会非常慢
  46302. str.push(
  46303. round(p[0] * Z - Z2), comma, round(p[1] * Z - Z2),
  46304. k < nPoint - 1 ? comma : ''
  46305. );
  46306. }
  46307. }
  46308. }
  46309. return str.join('');
  46310. };
  46311. // Rewrite the original path method
  46312. Path.prototype.brushVML = function (vmlRoot) {
  46313. var style = this.style;
  46314. var vmlEl = this._vmlEl;
  46315. if (!vmlEl) {
  46316. vmlEl = vmlCore.createNode('shape');
  46317. initRootElStyle(vmlEl);
  46318. this._vmlEl = vmlEl;
  46319. }
  46320. updateFillAndStroke(vmlEl, 'fill', style, this);
  46321. updateFillAndStroke(vmlEl, 'stroke', style, this);
  46322. var m = this.transform;
  46323. var needTransform = m != null;
  46324. var strokeEl = vmlEl.getElementsByTagName('stroke')[0];
  46325. if (strokeEl) {
  46326. var lineWidth = style.lineWidth;
  46327. // Get the line scale.
  46328. // Determinant of this.m_ means how much the area is enlarged by the
  46329. // transformation. So its square root can be used as a scale factor
  46330. // for width.
  46331. if (needTransform && !style.strokeNoScale) {
  46332. var det = m[0] * m[3] - m[1] * m[2];
  46333. lineWidth *= sqrt(abs(det));
  46334. }
  46335. strokeEl.weight = lineWidth + 'px';
  46336. }
  46337. var path = this.path;
  46338. if (this.__dirtyPath) {
  46339. path.beginPath();
  46340. this.buildPath(path, this.shape);
  46341. path.toStatic();
  46342. this.__dirtyPath = false;
  46343. }
  46344. vmlEl.path = pathDataToString(path.data, this.transform);
  46345. vmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2);
  46346. // Append to root
  46347. append(vmlRoot, vmlEl);
  46348. // Text
  46349. if (style.text) {
  46350. this.drawRectText(vmlRoot, this.getBoundingRect());
  46351. }
  46352. else {
  46353. this.removeRectText(vmlRoot);
  46354. }
  46355. };
  46356. Path.prototype.onRemove = function (vmlRoot) {
  46357. remove(vmlRoot, this._vmlEl);
  46358. this.removeRectText(vmlRoot);
  46359. };
  46360. Path.prototype.onAdd = function (vmlRoot) {
  46361. append(vmlRoot, this._vmlEl);
  46362. this.appendRectText(vmlRoot);
  46363. };
  46364. /***************************************************
  46365. * IMAGE
  46366. **************************************************/
  46367. var isImage = function (img) {
  46368. // FIXME img instanceof Image 如果 img 是一个字符串的时候,IE8 下会报错
  46369. return (typeof img === 'object') && img.tagName && img.tagName.toUpperCase() === 'IMG';
  46370. // return img instanceof Image;
  46371. };
  46372. // Rewrite the original path method
  46373. ZImage.prototype.brushVML = function (vmlRoot) {
  46374. var style = this.style;
  46375. var image = style.image;
  46376. // Image original width, height
  46377. var ow;
  46378. var oh;
  46379. if (isImage(image)) {
  46380. var src = image.src;
  46381. if (src === this._imageSrc) {
  46382. ow = this._imageWidth;
  46383. oh = this._imageHeight;
  46384. }
  46385. else {
  46386. var imageRuntimeStyle = image.runtimeStyle;
  46387. var oldRuntimeWidth = imageRuntimeStyle.width;
  46388. var oldRuntimeHeight = imageRuntimeStyle.height;
  46389. imageRuntimeStyle.width = 'auto';
  46390. imageRuntimeStyle.height = 'auto';
  46391. // get the original size
  46392. ow = image.width;
  46393. oh = image.height;
  46394. // and remove overides
  46395. imageRuntimeStyle.width = oldRuntimeWidth;
  46396. imageRuntimeStyle.height = oldRuntimeHeight;
  46397. // Caching image original width, height and src
  46398. this._imageSrc = src;
  46399. this._imageWidth = ow;
  46400. this._imageHeight = oh;
  46401. }
  46402. image = src;
  46403. }
  46404. else {
  46405. if (image === this._imageSrc) {
  46406. ow = this._imageWidth;
  46407. oh = this._imageHeight;
  46408. }
  46409. }
  46410. if (!image) {
  46411. return;
  46412. }
  46413. var x = style.x || 0;
  46414. var y = style.y || 0;
  46415. var dw = style.width;
  46416. var dh = style.height;
  46417. var sw = style.sWidth;
  46418. var sh = style.sHeight;
  46419. var sx = style.sx || 0;
  46420. var sy = style.sy || 0;
  46421. var hasCrop = sw && sh;
  46422. var vmlEl = this._vmlEl;
  46423. if (!vmlEl) {
  46424. // FIXME 使用 group 在 left, top 都不是 0 的时候就无法显示了。
  46425. // vmlEl = vmlCore.createNode('group');
  46426. vmlEl = vmlCore.doc.createElement('div');
  46427. initRootElStyle(vmlEl);
  46428. this._vmlEl = vmlEl;
  46429. }
  46430. var vmlElStyle = vmlEl.style;
  46431. var hasRotation = false;
  46432. var m;
  46433. var scaleX = 1;
  46434. var scaleY = 1;
  46435. if (this.transform) {
  46436. m = this.transform;
  46437. scaleX = sqrt(m[0] * m[0] + m[1] * m[1]);
  46438. scaleY = sqrt(m[2] * m[2] + m[3] * m[3]);
  46439. hasRotation = m[1] || m[2];
  46440. }
  46441. if (hasRotation) {
  46442. // If filters are necessary (rotation exists), create them
  46443. // filters are bog-slow, so only create them if abbsolutely necessary
  46444. // The following check doesn't account for skews (which don't exist
  46445. // in the canvas spec (yet) anyway.
  46446. // From excanvas
  46447. var p0 = [x, y];
  46448. var p1 = [x + dw, y];
  46449. var p2 = [x, y + dh];
  46450. var p3 = [x + dw, y + dh];
  46451. applyTransform(p0, p0, m);
  46452. applyTransform(p1, p1, m);
  46453. applyTransform(p2, p2, m);
  46454. applyTransform(p3, p3, m);
  46455. var maxX = mathMax(p0[0], p1[0], p2[0], p3[0]);
  46456. var maxY = mathMax(p0[1], p1[1], p2[1], p3[1]);
  46457. var transformFilter = [];
  46458. transformFilter.push('M11=', m[0] / scaleX, comma,
  46459. 'M12=', m[2] / scaleY, comma,
  46460. 'M21=', m[1] / scaleX, comma,
  46461. 'M22=', m[3] / scaleY, comma,
  46462. 'Dx=', round(x * scaleX + m[4]), comma,
  46463. 'Dy=', round(y * scaleY + m[5]));
  46464. vmlElStyle.padding = '0 ' + round(maxX) + 'px ' + round(maxY) + 'px 0';
  46465. // FIXME DXImageTransform 在 IE11 的兼容模式下不起作用
  46466. vmlElStyle.filter = imageTransformPrefix + '.Matrix('
  46467. + transformFilter.join('') + ', SizingMethod=clip)';
  46468. }
  46469. else {
  46470. if (m) {
  46471. x = x * scaleX + m[4];
  46472. y = y * scaleY + m[5];
  46473. }
  46474. vmlElStyle.filter = '';
  46475. vmlElStyle.left = round(x) + 'px';
  46476. vmlElStyle.top = round(y) + 'px';
  46477. }
  46478. var imageEl = this._imageEl;
  46479. var cropEl = this._cropEl;
  46480. if (!imageEl) {
  46481. imageEl = vmlCore.doc.createElement('div');
  46482. this._imageEl = imageEl;
  46483. }
  46484. var imageELStyle = imageEl.style;
  46485. if (hasCrop) {
  46486. // Needs know image original width and height
  46487. if (! (ow && oh)) {
  46488. var tmpImage = new Image();
  46489. var self = this;
  46490. tmpImage.onload = function () {
  46491. tmpImage.onload = null;
  46492. ow = tmpImage.width;
  46493. oh = tmpImage.height;
  46494. // Adjust image width and height to fit the ratio destinationSize / sourceSize
  46495. imageELStyle.width = round(scaleX * ow * dw / sw) + 'px';
  46496. imageELStyle.height = round(scaleY * oh * dh / sh) + 'px';
  46497. // Caching image original width, height and src
  46498. self._imageWidth = ow;
  46499. self._imageHeight = oh;
  46500. self._imageSrc = image;
  46501. };
  46502. tmpImage.src = image;
  46503. }
  46504. else {
  46505. imageELStyle.width = round(scaleX * ow * dw / sw) + 'px';
  46506. imageELStyle.height = round(scaleY * oh * dh / sh) + 'px';
  46507. }
  46508. if (! cropEl) {
  46509. cropEl = vmlCore.doc.createElement('div');
  46510. cropEl.style.overflow = 'hidden';
  46511. this._cropEl = cropEl;
  46512. }
  46513. var cropElStyle = cropEl.style;
  46514. cropElStyle.width = round((dw + sx * dw / sw) * scaleX);
  46515. cropElStyle.height = round((dh + sy * dh / sh) * scaleY);
  46516. cropElStyle.filter = imageTransformPrefix + '.Matrix(Dx='
  46517. + (-sx * dw / sw * scaleX) + ',Dy=' + (-sy * dh / sh * scaleY) + ')';
  46518. if (! cropEl.parentNode) {
  46519. vmlEl.appendChild(cropEl);
  46520. }
  46521. if (imageEl.parentNode != cropEl) {
  46522. cropEl.appendChild(imageEl);
  46523. }
  46524. }
  46525. else {
  46526. imageELStyle.width = round(scaleX * dw) + 'px';
  46527. imageELStyle.height = round(scaleY * dh) + 'px';
  46528. vmlEl.appendChild(imageEl);
  46529. if (cropEl && cropEl.parentNode) {
  46530. vmlEl.removeChild(cropEl);
  46531. this._cropEl = null;
  46532. }
  46533. }
  46534. var filterStr = '';
  46535. var alpha = style.opacity;
  46536. if (alpha < 1) {
  46537. filterStr += '.Alpha(opacity=' + round(alpha * 100) + ') ';
  46538. }
  46539. filterStr += imageTransformPrefix + '.AlphaImageLoader(src=' + image + ', SizingMethod=scale)';
  46540. imageELStyle.filter = filterStr;
  46541. vmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2);
  46542. // Append to root
  46543. append(vmlRoot, vmlEl);
  46544. // Text
  46545. if (style.text) {
  46546. this.drawRectText(vmlRoot, this.getBoundingRect());
  46547. }
  46548. };
  46549. ZImage.prototype.onRemove = function (vmlRoot) {
  46550. remove(vmlRoot, this._vmlEl);
  46551. this._vmlEl = null;
  46552. this._cropEl = null;
  46553. this._imageEl = null;
  46554. this.removeRectText(vmlRoot);
  46555. };
  46556. ZImage.prototype.onAdd = function (vmlRoot) {
  46557. append(vmlRoot, this._vmlEl);
  46558. this.appendRectText(vmlRoot);
  46559. };
  46560. /***************************************************
  46561. * TEXT
  46562. **************************************************/
  46563. var DEFAULT_STYLE_NORMAL = 'normal';
  46564. var fontStyleCache = {};
  46565. var fontStyleCacheCount = 0;
  46566. var MAX_FONT_CACHE_SIZE = 100;
  46567. var fontEl = document.createElement('div');
  46568. var getFontStyle = function (fontString) {
  46569. var fontStyle = fontStyleCache[fontString];
  46570. if (!fontStyle) {
  46571. // Clear cache
  46572. if (fontStyleCacheCount > MAX_FONT_CACHE_SIZE) {
  46573. fontStyleCacheCount = 0;
  46574. fontStyleCache = {};
  46575. }
  46576. var style = fontEl.style;
  46577. var fontFamily;
  46578. try {
  46579. style.font = fontString;
  46580. fontFamily = style.fontFamily.split(',')[0];
  46581. }
  46582. catch (e) {
  46583. }
  46584. fontStyle = {
  46585. style: style.fontStyle || DEFAULT_STYLE_NORMAL,
  46586. variant: style.fontVariant || DEFAULT_STYLE_NORMAL,
  46587. weight: style.fontWeight || DEFAULT_STYLE_NORMAL,
  46588. size: parseFloat(style.fontSize || 12) | 0,
  46589. family: fontFamily || 'Microsoft YaHei'
  46590. };
  46591. fontStyleCache[fontString] = fontStyle;
  46592. fontStyleCacheCount++;
  46593. }
  46594. return fontStyle;
  46595. };
  46596. var textMeasureEl;
  46597. // Overwrite measure text method
  46598. textContain.measureText = function (text, textFont) {
  46599. var doc = vmlCore.doc;
  46600. if (!textMeasureEl) {
  46601. textMeasureEl = doc.createElement('div');
  46602. textMeasureEl.style.cssText = 'position:absolute;top:-20000px;left:0;'
  46603. + 'padding:0;margin:0;border:none;white-space:pre;';
  46604. vmlCore.doc.body.appendChild(textMeasureEl);
  46605. }
  46606. try {
  46607. textMeasureEl.style.font = textFont;
  46608. } catch (ex) {
  46609. // Ignore failures to set to invalid font.
  46610. }
  46611. textMeasureEl.innerHTML = '';
  46612. // Don't use innerHTML or innerText because they allow markup/whitespace.
  46613. textMeasureEl.appendChild(doc.createTextNode(text));
  46614. return {
  46615. width: textMeasureEl.offsetWidth
  46616. };
  46617. };
  46618. var tmpRect = new BoundingRect();
  46619. var drawRectText = function (vmlRoot, rect, textRect, fromTextEl) {
  46620. var style = this.style;
  46621. var text = style.text;
  46622. if (!text) {
  46623. return;
  46624. }
  46625. var x;
  46626. var y;
  46627. var align = style.textAlign;
  46628. var fontStyle = getFontStyle(style.textFont);
  46629. // FIXME encodeHtmlAttribute ?
  46630. var font = fontStyle.style + ' ' + fontStyle.variant + ' ' + fontStyle.weight + ' '
  46631. + fontStyle.size + 'px "' + fontStyle.family + '"';
  46632. var baseline = style.textBaseline;
  46633. var verticalAlign = style.textVerticalAlign;
  46634. textRect = textRect || textContain.getBoundingRect(text, font, align, baseline);
  46635. // Transform rect to view space
  46636. var m = this.transform;
  46637. // Ignore transform for text in other element
  46638. if (m && !fromTextEl) {
  46639. tmpRect.copy(rect);
  46640. tmpRect.applyTransform(m);
  46641. rect = tmpRect;
  46642. }
  46643. if (!fromTextEl) {
  46644. var textPosition = style.textPosition;
  46645. var distance = style.textDistance;
  46646. // Text position represented by coord
  46647. if (textPosition instanceof Array) {
  46648. x = rect.x + parsePercent(textPosition[0], rect.width);
  46649. y = rect.y + parsePercent(textPosition[1], rect.height);
  46650. align = align || 'left';
  46651. baseline = baseline || 'top';
  46652. }
  46653. else {
  46654. var res = textContain.adjustTextPositionOnRect(
  46655. textPosition, rect, textRect, distance
  46656. );
  46657. x = res.x;
  46658. y = res.y;
  46659. // Default align and baseline when has textPosition
  46660. align = align || res.textAlign;
  46661. baseline = baseline || res.textBaseline;
  46662. }
  46663. }
  46664. else {
  46665. x = rect.x;
  46666. y = rect.y;
  46667. }
  46668. if (verticalAlign) {
  46669. switch (verticalAlign) {
  46670. case 'middle':
  46671. y -= textRect.height / 2;
  46672. break;
  46673. case 'bottom':
  46674. y -= textRect.height;
  46675. break;
  46676. // 'top'
  46677. }
  46678. // Ignore baseline
  46679. baseline = 'top';
  46680. }
  46681. var fontSize = fontStyle.size;
  46682. // 1.75 is an arbitrary number, as there is no info about the text baseline
  46683. switch (baseline) {
  46684. case 'hanging':
  46685. case 'top':
  46686. y += fontSize / 1.75;
  46687. break;
  46688. case 'middle':
  46689. break;
  46690. default:
  46691. // case null:
  46692. // case 'alphabetic':
  46693. // case 'ideographic':
  46694. // case 'bottom':
  46695. y -= fontSize / 2.25;
  46696. break;
  46697. }
  46698. switch (align) {
  46699. case 'left':
  46700. break;
  46701. case 'center':
  46702. x -= textRect.width / 2;
  46703. break;
  46704. case 'right':
  46705. x -= textRect.width;
  46706. break;
  46707. // case 'end':
  46708. // align = elementStyle.direction == 'ltr' ? 'right' : 'left';
  46709. // break;
  46710. // case 'start':
  46711. // align = elementStyle.direction == 'rtl' ? 'right' : 'left';
  46712. // break;
  46713. // default:
  46714. // align = 'left';
  46715. }
  46716. var createNode = vmlCore.createNode;
  46717. var textVmlEl = this._textVmlEl;
  46718. var pathEl;
  46719. var textPathEl;
  46720. var skewEl;
  46721. if (!textVmlEl) {
  46722. textVmlEl = createNode('line');
  46723. pathEl = createNode('path');
  46724. textPathEl = createNode('textpath');
  46725. skewEl = createNode('skew');
  46726. // FIXME Why here is not cammel case
  46727. // Align 'center' seems wrong
  46728. textPathEl.style['v-text-align'] = 'left';
  46729. initRootElStyle(textVmlEl);
  46730. pathEl.textpathok = true;
  46731. textPathEl.on = true;
  46732. textVmlEl.from = '0 0';
  46733. textVmlEl.to = '1000 0.05';
  46734. append(textVmlEl, skewEl);
  46735. append(textVmlEl, pathEl);
  46736. append(textVmlEl, textPathEl);
  46737. this._textVmlEl = textVmlEl;
  46738. }
  46739. else {
  46740. // 这里是在前面 appendChild 保证顺序的前提下
  46741. skewEl = textVmlEl.firstChild;
  46742. pathEl = skewEl.nextSibling;
  46743. textPathEl = pathEl.nextSibling;
  46744. }
  46745. var coords = [x, y];
  46746. var textVmlElStyle = textVmlEl.style;
  46747. // Ignore transform for text in other element
  46748. if (m && fromTextEl) {
  46749. applyTransform(coords, coords, m);
  46750. skewEl.on = true;
  46751. skewEl.matrix = m[0].toFixed(3) + comma + m[2].toFixed(3) + comma +
  46752. m[1].toFixed(3) + comma + m[3].toFixed(3) + ',0,0';
  46753. // Text position
  46754. skewEl.offset = (round(coords[0]) || 0) + ',' + (round(coords[1]) || 0);
  46755. // Left top point as origin
  46756. skewEl.origin = '0 0';
  46757. textVmlElStyle.left = '0px';
  46758. textVmlElStyle.top = '0px';
  46759. }
  46760. else {
  46761. skewEl.on = false;
  46762. textVmlElStyle.left = round(x) + 'px';
  46763. textVmlElStyle.top = round(y) + 'px';
  46764. }
  46765. textPathEl.string = encodeHtmlAttribute(text);
  46766. // TODO
  46767. try {
  46768. textPathEl.style.font = font;
  46769. }
  46770. // Error font format
  46771. catch (e) {}
  46772. updateFillAndStroke(textVmlEl, 'fill', {
  46773. fill: fromTextEl ? style.fill : style.textFill,
  46774. opacity: style.opacity
  46775. }, this);
  46776. updateFillAndStroke(textVmlEl, 'stroke', {
  46777. stroke: fromTextEl ? style.stroke : style.textStroke,
  46778. opacity: style.opacity,
  46779. lineDash: style.lineDash
  46780. }, this);
  46781. textVmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2);
  46782. // Attached to root
  46783. append(vmlRoot, textVmlEl);
  46784. };
  46785. var removeRectText = function (vmlRoot) {
  46786. remove(vmlRoot, this._textVmlEl);
  46787. this._textVmlEl = null;
  46788. };
  46789. var appendRectText = function (vmlRoot) {
  46790. append(vmlRoot, this._textVmlEl);
  46791. };
  46792. var list = [RectText, Displayable, ZImage, Path, Text];
  46793. // In case Displayable has been mixed in RectText
  46794. for (var i = 0; i < list.length; i++) {
  46795. var proto = list[i].prototype;
  46796. proto.drawRectText = drawRectText;
  46797. proto.removeRectText = removeRectText;
  46798. proto.appendRectText = appendRectText;
  46799. }
  46800. Text.prototype.brushVML = function (vmlRoot) {
  46801. var style = this.style;
  46802. if (style.text) {
  46803. this.drawRectText(vmlRoot, {
  46804. x: style.x || 0, y: style.y || 0,
  46805. width: 0, height: 0
  46806. }, this.getBoundingRect(), true);
  46807. }
  46808. else {
  46809. this.removeRectText(vmlRoot);
  46810. }
  46811. };
  46812. Text.prototype.onRemove = function (vmlRoot) {
  46813. this.removeRectText(vmlRoot);
  46814. };
  46815. Text.prototype.onAdd = function (vmlRoot) {
  46816. this.appendRectText(vmlRoot);
  46817. };
  46818. }
  46819. /***/ },
  46820. /* 351 */
  46821. /***/ function(module, exports, __webpack_require__) {
  46822. if (!__webpack_require__(79).canvasSupported) {
  46823. var urn = 'urn:schemas-microsoft-com:vml';
  46824. var createNode;
  46825. var win = window;
  46826. var doc = win.document;
  46827. var vmlInited = false;
  46828. try {
  46829. !doc.namespaces.zrvml && doc.namespaces.add('zrvml', urn);
  46830. createNode = function (tagName) {
  46831. return doc.createElement('<zrvml:' + tagName + ' class="zrvml">');
  46832. };
  46833. }
  46834. catch (e) {
  46835. createNode = function (tagName) {
  46836. return doc.createElement('<' + tagName + ' xmlns="' + urn + '" class="zrvml">');
  46837. };
  46838. }
  46839. // From raphael
  46840. var initVML = function () {
  46841. if (vmlInited) {
  46842. return;
  46843. }
  46844. vmlInited = true;
  46845. var styleSheets = doc.styleSheets;
  46846. if (styleSheets.length < 31) {
  46847. doc.createStyleSheet().addRule('.zrvml', 'behavior:url(#default#VML)');
  46848. }
  46849. else {
  46850. // http://msdn.microsoft.com/en-us/library/ms531194%28VS.85%29.aspx
  46851. styleSheets[0].addRule('.zrvml', 'behavior:url(#default#VML)');
  46852. }
  46853. };
  46854. // Not useing return to avoid error when converting to CommonJS module
  46855. module.exports = {
  46856. doc: doc,
  46857. initVML: initVML,
  46858. createNode: createNode
  46859. };
  46860. }
  46861. /***/ },
  46862. /* 352 */
  46863. /***/ function(module, exports, __webpack_require__) {
  46864. /**
  46865. * VML Painter.
  46866. *
  46867. * @module zrender/vml/Painter
  46868. */
  46869. var zrLog = __webpack_require__(39);
  46870. var vmlCore = __webpack_require__(351);
  46871. function parseInt10(val) {
  46872. return parseInt(val, 10);
  46873. }
  46874. /**
  46875. * @alias module:zrender/vml/Painter
  46876. */
  46877. function VMLPainter(root, storage) {
  46878. vmlCore.initVML();
  46879. this.root = root;
  46880. this.storage = storage;
  46881. var vmlViewport = document.createElement('div');
  46882. var vmlRoot = document.createElement('div');
  46883. vmlViewport.style.cssText = 'display:inline-block;overflow:hidden;position:relative;width:300px;height:150px;';
  46884. vmlRoot.style.cssText = 'position:absolute;left:0;top:0;';
  46885. root.appendChild(vmlViewport);
  46886. this._vmlRoot = vmlRoot;
  46887. this._vmlViewport = vmlViewport;
  46888. this.resize();
  46889. // Modify storage
  46890. var oldDelFromMap = storage.delFromMap;
  46891. var oldAddToMap = storage.addToMap;
  46892. storage.delFromMap = function (elId) {
  46893. var el = storage.get(elId);
  46894. oldDelFromMap.call(storage, elId);
  46895. if (el) {
  46896. el.onRemove && el.onRemove(vmlRoot);
  46897. }
  46898. };
  46899. storage.addToMap = function (el) {
  46900. // Displayable already has a vml node
  46901. el.onAdd && el.onAdd(vmlRoot);
  46902. oldAddToMap.call(storage, el);
  46903. };
  46904. this._firstPaint = true;
  46905. }
  46906. VMLPainter.prototype = {
  46907. constructor: VMLPainter,
  46908. /**
  46909. * @return {HTMLDivElement}
  46910. */
  46911. getViewportRoot: function () {
  46912. return this._vmlViewport;
  46913. },
  46914. /**
  46915. * 刷新
  46916. */
  46917. refresh: function () {
  46918. var list = this.storage.getDisplayList(true, true);
  46919. this._paintList(list);
  46920. },
  46921. _paintList: function (list) {
  46922. var vmlRoot = this._vmlRoot;
  46923. for (var i = 0; i < list.length; i++) {
  46924. var el = list[i];
  46925. if (el.invisible || el.ignore) {
  46926. if (!el.__alreadyNotVisible) {
  46927. el.onRemove(vmlRoot);
  46928. }
  46929. // Set as already invisible
  46930. el.__alreadyNotVisible = true;
  46931. }
  46932. else {
  46933. if (el.__alreadyNotVisible) {
  46934. el.onAdd(vmlRoot);
  46935. }
  46936. el.__alreadyNotVisible = false;
  46937. if (el.__dirty) {
  46938. el.beforeBrush && el.beforeBrush();
  46939. (el.brushVML || el.brush).call(el, vmlRoot);
  46940. el.afterBrush && el.afterBrush();
  46941. }
  46942. }
  46943. el.__dirty = false;
  46944. }
  46945. if (this._firstPaint) {
  46946. // Detached from document at first time
  46947. // to avoid page refreshing too many times
  46948. // FIXME 如果每次都先 removeChild 可能会导致一些填充和描边的效果改变
  46949. this._vmlViewport.appendChild(vmlRoot);
  46950. this._firstPaint = false;
  46951. }
  46952. },
  46953. resize: function () {
  46954. var width = this._getWidth();
  46955. var height = this._getHeight();
  46956. if (this._width != width && this._height != height) {
  46957. this._width = width;
  46958. this._height = height;
  46959. var vmlViewportStyle = this._vmlViewport.style;
  46960. vmlViewportStyle.width = width + 'px';
  46961. vmlViewportStyle.height = height + 'px';
  46962. }
  46963. },
  46964. dispose: function () {
  46965. this.root.innerHTML = '';
  46966. this._vmlRoot =
  46967. this._vmlViewport =
  46968. this.storage = null;
  46969. },
  46970. getWidth: function () {
  46971. return this._width;
  46972. },
  46973. getHeight: function () {
  46974. return this._height;
  46975. },
  46976. _getWidth: function () {
  46977. var root = this.root;
  46978. var stl = root.currentStyle;
  46979. return ((root.clientWidth || parseInt10(stl.width))
  46980. - parseInt10(stl.paddingLeft)
  46981. - parseInt10(stl.paddingRight)) | 0;
  46982. },
  46983. _getHeight: function () {
  46984. var root = this.root;
  46985. var stl = root.currentStyle;
  46986. return ((root.clientHeight || parseInt10(stl.height))
  46987. - parseInt10(stl.paddingTop)
  46988. - parseInt10(stl.paddingBottom)) | 0;
  46989. }
  46990. };
  46991. // Not supported methods
  46992. function createMethodNotSupport(method) {
  46993. return function () {
  46994. zrLog('In IE8.0 VML mode painter not support method "' + method + '"');
  46995. };
  46996. }
  46997. var notSupportedMethods = [
  46998. 'getLayer', 'insertLayer', 'eachLayer', 'eachBuildinLayer', 'eachOtherLayer', 'getLayers',
  46999. 'modLayer', 'delLayer', 'clearLayer', 'toDataURL', 'pathToImage'
  47000. ];
  47001. for (var i = 0; i < notSupportedMethods.length; i++) {
  47002. var name = notSupportedMethods[i];
  47003. VMLPainter.prototype[name] = createMethodNotSupport(name);
  47004. }
  47005. module.exports = VMLPainter;
  47006. /***/ }
  47007. /******/ ])
  47008. });
  47009. ;